(feature)(headless) Add tag rest api (#733)

This commit is contained in:
jipeli
2024-02-21 17:45:28 +08:00
committed by GitHub
parent d10801ef38
commit b8831317e9
18 changed files with 699 additions and 3 deletions

View File

@@ -0,0 +1,9 @@
package com.tencent.supersonic.headless.api.pojo;
import lombok.Data;
@Data
public class TagDefineParams {
private String expr;
}

View File

@@ -0,0 +1,8 @@
package com.tencent.supersonic.headless.api.pojo.enums;
public enum TagDefineType {
FIELD,
DIMENSION,
Tag
}

View File

@@ -0,0 +1,27 @@
package com.tencent.supersonic.headless.api.pojo.enums;
import java.util.Objects;
public enum TagType {
ATOMIC,
DERIVED;
public static TagType of(String src) {
for (TagType tagType : TagType.values()) {
if (Objects.nonNull(src) && src.equalsIgnoreCase(tagType.name())) {
return tagType;
}
}
return null;
}
public static Boolean isDerived(String src) {
TagType tagType = of(src);
return Objects.nonNull(tagType) && tagType.equals(DERIVED);
}
public static TagType getType(TagDefineType tagDefineType) {
return Objects.nonNull(tagDefineType) && TagDefineType.Tag.equals(tagDefineType) ? TagType.DERIVED
: TagType.ATOMIC;
}
}

View File

@@ -0,0 +1,33 @@
package com.tencent.supersonic.headless.api.pojo.request;
import com.alibaba.fastjson.JSONObject;
import com.tencent.supersonic.headless.api.pojo.SchemaItem;
import com.tencent.supersonic.headless.api.pojo.TagDefineParams;
import com.tencent.supersonic.headless.api.pojo.enums.TagDefineType;
import com.tencent.supersonic.headless.api.pojo.enums.TagType;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import lombok.Data;
@Data
public class TagReq extends SchemaItem {
private Long modelId;
private Map<String, Object> ext = new HashMap<>();
private TagDefineType tagDefineType;
private TagDefineParams tagDefineParams;
public String getTypeParamsJson() {
return JSONObject.toJSONString(tagDefineParams);
}
public String getExtJson() {
return Objects.nonNull(ext) && ext.size() > 0 ? JSONObject.toJSONString(ext) : "";
}
public TagType getType() {
return TagType.getType(tagDefineType);
}
}

View File

@@ -0,0 +1,29 @@
package com.tencent.supersonic.headless.api.pojo.response;
import com.tencent.supersonic.headless.api.pojo.SchemaItem;
import com.tencent.supersonic.headless.api.pojo.TagDefineParams;
import com.tencent.supersonic.headless.api.pojo.enums.TagDefineType;
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import lombok.ToString;
@Data
@ToString(callSuper = true)
public class TagResp extends SchemaItem {
private Long modelId;
private String type;
private Map<String, Object> ext = new HashMap<>();
private TagDefineType tagDefineType = TagDefineType.FIELD;
private TagDefineParams tagDefineParams;
public String getExpr() {
return tagDefineParams.getExpr();
}
}