mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
(feature)(headless) Add tag rest api (#733)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TagDefineParams {
|
||||
|
||||
private String expr;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.enums;
|
||||
|
||||
public enum TagDefineType {
|
||||
|
||||
FIELD,
|
||||
DIMENSION,
|
||||
Tag
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user