mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +00:00
(improvement)(headless) add TagObject logic (#829)
This commit is contained in:
@@ -4,6 +4,7 @@ public enum TypeEnums {
|
||||
|
||||
METRIC,
|
||||
DIMENSION,
|
||||
TAG_OBJECT,
|
||||
TAG,
|
||||
DOMAIN,
|
||||
ENTITY,
|
||||
|
||||
@@ -38,6 +38,8 @@ public class ModelReq extends SchemaItem {
|
||||
|
||||
private List<String> adminOrgs;
|
||||
|
||||
private Long tagObjectId;
|
||||
|
||||
public List<Dim> getTimeDimension() {
|
||||
if (modelDetail == null) {
|
||||
return Lists.newArrayList();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class TagObjectReq extends SchemaItem {
|
||||
|
||||
@NotNull
|
||||
private Long domainId;
|
||||
private Map<String, Object> ext = new HashMap<>();
|
||||
|
||||
public String getExtJson() {
|
||||
return Objects.nonNull(ext) && ext.size() > 0 ? JSONObject.toJSONString(ext) : "";
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ public class ModelResp extends SchemaItem {
|
||||
|
||||
private Long databaseId;
|
||||
|
||||
private Long tagObjectId;
|
||||
|
||||
private ModelDetail modelDetail;
|
||||
|
||||
private String depends;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.response;
|
||||
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class TagObjectResp extends SchemaItem {
|
||||
|
||||
/**
|
||||
* 关联到某个主题域下
|
||||
*/
|
||||
private Long domainId;
|
||||
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
private Map<String, String> ext;
|
||||
}
|
||||
@@ -16,6 +16,8 @@ public class ModelDO {
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private Long tagObjectId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String bizName;
|
||||
|
||||
@@ -19,12 +19,12 @@ public class TagDO {
|
||||
private Long modelId;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
* 标签名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
* 标签业务名称
|
||||
*/
|
||||
private String bizName;
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.tencent.supersonic.headless.server.persistence.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("s2_tag_object")
|
||||
public class TagObjectDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联到某个主题域下
|
||||
*/
|
||||
private Long domainId;
|
||||
|
||||
/**
|
||||
* 标签对象名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 标签对象业务名称
|
||||
*/
|
||||
private String bizName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态,0正常,1下架,2删除
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 敏感级别
|
||||
*/
|
||||
private Integer sensitiveLevel;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
private String ext;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.tencent.supersonic.headless.server.persistence.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.TagObjectDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface TagObjectMapper extends BaseMapper<TagObjectDO> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.tencent.supersonic.headless.server.persistence.repository;
|
||||
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.TagObjectDO;
|
||||
import com.tencent.supersonic.headless.server.pojo.TagObjectFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TagObjectRepository {
|
||||
|
||||
Integer create(TagObjectDO tagObjectDO);
|
||||
|
||||
Integer update(TagObjectDO tagObjectDO);
|
||||
|
||||
TagObjectDO getTagObjectById(Long id);
|
||||
|
||||
List<TagObjectDO> query(TagObjectFilter filter);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.tencent.supersonic.headless.server.persistence.repository.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.TagObjectDO;
|
||||
import com.tencent.supersonic.headless.server.persistence.mapper.TagObjectMapper;
|
||||
import com.tencent.supersonic.headless.server.persistence.repository.TagObjectRepository;
|
||||
import com.tencent.supersonic.headless.server.pojo.TagObjectFilter;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Repository
|
||||
public class TagObjectRepositoryImpl implements TagObjectRepository {
|
||||
|
||||
private final TagObjectMapper tagObjectMapper;
|
||||
|
||||
public TagObjectRepositoryImpl(TagObjectMapper tagObjectMapper) {
|
||||
this.tagObjectMapper = tagObjectMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer create(TagObjectDO tagObjectDO) {
|
||||
return tagObjectMapper.insert(tagObjectDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer update(TagObjectDO tagObjectDO) {
|
||||
return tagObjectMapper.updateById(tagObjectDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagObjectDO getTagObjectById(Long id) {
|
||||
return tagObjectMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagObjectDO> query(TagObjectFilter filter) {
|
||||
QueryWrapper<TagObjectDO> wrapper = new QueryWrapper<>();
|
||||
if (Objects.nonNull(filter.getDomainIds())) {
|
||||
wrapper.lambda().in(TagObjectDO::getDomainId, filter.getDomainIds());
|
||||
}
|
||||
if (Objects.nonNull(filter.getDomainId())) {
|
||||
wrapper.lambda().eq(TagObjectDO::getDomainId, filter.getDomainId());
|
||||
}
|
||||
if (Objects.nonNull(filter.getIds())) {
|
||||
wrapper.lambda().in(TagObjectDO::getId, filter.getIds());
|
||||
}
|
||||
if (Objects.nonNull(filter.getId())) {
|
||||
wrapper.lambda().eq(TagObjectDO::getId, filter.getId());
|
||||
}
|
||||
if (Objects.nonNull(filter.getBizName())) {
|
||||
wrapper.lambda().eq(TagObjectDO::getBizName, filter.getBizName());
|
||||
}
|
||||
if (Objects.nonNull(filter.getCreatedBy())) {
|
||||
wrapper.lambda().eq(TagObjectDO::getCreatedBy, filter.getCreatedBy());
|
||||
}
|
||||
if (Objects.nonNull(filter.getStatus())) {
|
||||
wrapper.lambda().eq(TagObjectDO::getStatus, filter.getStatus());
|
||||
}
|
||||
return tagObjectMapper.selectList(wrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tencent.supersonic.headless.server.pojo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TagObjectFilter extends MetaFilter {
|
||||
|
||||
private List<Long> domainIds;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.tencent.supersonic.headless.server.rest;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.TagObjectReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.TagObjectResp;
|
||||
import com.tencent.supersonic.headless.server.pojo.TagObjectFilter;
|
||||
import com.tencent.supersonic.headless.server.service.TagObjectService;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/semantic/tagObject")
|
||||
public class TagObjectController {
|
||||
|
||||
private final TagObjectService tagObjectService;
|
||||
|
||||
public TagObjectController(TagObjectService tagObjectService) {
|
||||
this.tagObjectService = tagObjectService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建标签对象
|
||||
*
|
||||
* @param tagObjectReq
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public TagObjectResp create(@RequestBody TagObjectReq tagObjectReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return tagObjectService.create(tagObjectReq, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑标签对象
|
||||
*
|
||||
* @param tagObjectReq
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public TagObjectResp update(@RequestBody TagObjectReq tagObjectReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return tagObjectService.update(tagObjectReq, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标签对象
|
||||
*
|
||||
* @param id
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@DeleteMapping("delete/{id}")
|
||||
public Boolean delete(@PathVariable("id") Long id,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
tagObjectService.delete(id, user);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签对象-查询
|
||||
* @param filter
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/query/tagObject")
|
||||
public List<TagObjectResp> queryTagObject(@RequestBody TagObjectFilter filter,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return tagObjectService.getTagObjects(filter, user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.tencent.supersonic.headless.server.service;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.TagObjectReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.TagObjectResp;
|
||||
import com.tencent.supersonic.headless.server.pojo.TagObjectFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TagObjectService {
|
||||
|
||||
TagObjectResp create(TagObjectReq tagObjectReq, User user) throws Exception;
|
||||
|
||||
TagObjectResp update(TagObjectReq tagObjectReq, User user);
|
||||
|
||||
Boolean delete(Long id, User user) throws Exception;
|
||||
|
||||
TagObjectResp getTagObject(Long id, User user);
|
||||
|
||||
List<TagObjectResp> getTagObjects(TagObjectFilter filter, User user);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.tencent.supersonic.headless.server.service.impl;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.common.util.BeanMapper;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.TagObjectReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.TagObjectResp;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.TagObjectDO;
|
||||
import com.tencent.supersonic.headless.server.persistence.repository.TagObjectRepository;
|
||||
import com.tencent.supersonic.headless.server.pojo.TagObjectFilter;
|
||||
import com.tencent.supersonic.headless.server.service.TagObjectService;
|
||||
import com.tencent.supersonic.headless.server.utils.TagObjectConverter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class TagObjectServiceImpl implements TagObjectService {
|
||||
|
||||
private final TagObjectRepository tagObjectRepository;
|
||||
|
||||
public TagObjectServiceImpl(TagObjectRepository tagObjectRepository) {
|
||||
this.tagObjectRepository = tagObjectRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagObjectResp create(TagObjectReq tagObjectReq, User user) throws Exception {
|
||||
checkParam(tagObjectReq, user);
|
||||
|
||||
TagObjectDO tagObjectDO = TagObjectConverter.convert(tagObjectReq);
|
||||
Date date = new Date();
|
||||
tagObjectDO.setCreatedBy(user.getName());
|
||||
tagObjectDO.setCreatedAt(date);
|
||||
tagObjectDO.setUpdatedBy(user.getName());
|
||||
tagObjectDO.setUpdatedAt(date);
|
||||
tagObjectDO.setStatus(StatusEnum.ONLINE.getCode());
|
||||
|
||||
tagObjectRepository.create(tagObjectDO).longValue();
|
||||
TagObjectDO tagObjectById = tagObjectRepository.getTagObjectById(tagObjectDO.getId());
|
||||
return TagObjectConverter.convert2Resp(tagObjectById);
|
||||
}
|
||||
|
||||
private void checkParam(TagObjectReq tagObjectReq, User user) throws Exception {
|
||||
TagObjectFilter filter = new TagObjectFilter();
|
||||
filter.setDomainId(tagObjectReq.getDomainId());
|
||||
List<TagObjectResp> tagObjectRespList = getTagObjects(filter, user);
|
||||
if (CollectionUtils.isEmpty(tagObjectRespList)) {
|
||||
return;
|
||||
}
|
||||
tagObjectRespList = tagObjectRespList.stream()
|
||||
.filter(tagObjectResp -> StatusEnum.ONLINE.equals(tagObjectResp.getStatus()))
|
||||
.collect(Collectors.toList());
|
||||
for (TagObjectResp tagObject : tagObjectRespList) {
|
||||
if (tagObject.getBizName().equalsIgnoreCase(tagObjectReq.getBizName())) {
|
||||
throw new Exception(String.format("the bizName %s is exit", tagObjectReq.getBizName()));
|
||||
}
|
||||
if (tagObject.getName().equalsIgnoreCase(tagObjectReq.getName())) {
|
||||
throw new Exception(String.format("the bizName %s is exit", tagObjectReq.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagObjectResp update(TagObjectReq tagObjectReq, User user) {
|
||||
TagObjectDO tagObjectDO = tagObjectRepository.getTagObjectById(tagObjectReq.getId());
|
||||
BeanMapper.mapper(tagObjectReq, tagObjectDO);
|
||||
tagObjectDO.setUpdatedAt(new Date());
|
||||
tagObjectDO.setUpdatedBy(user.getName());
|
||||
tagObjectRepository.update(tagObjectDO);
|
||||
TagObjectDO tagObjectById = tagObjectRepository.getTagObjectById(tagObjectReq.getId());
|
||||
return TagObjectConverter.convert2Resp(tagObjectById);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(Long id, User user) throws Exception {
|
||||
TagObjectDO tagObjectDO = tagObjectRepository.getTagObjectById(id);
|
||||
checkDeletePermission(tagObjectDO, user);
|
||||
tagObjectDO.setUpdatedAt(new Date());
|
||||
tagObjectDO.setUpdatedBy(user.getName());
|
||||
tagObjectDO.setStatus(StatusEnum.DELETED.getCode());
|
||||
tagObjectRepository.update(tagObjectDO);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkDeletePermission(TagObjectDO tagObjectDO, User user) throws Exception {
|
||||
if (user.getName().equalsIgnoreCase(tagObjectDO.getCreatedBy()) || user.isSuperAdmin()) {
|
||||
return;
|
||||
}
|
||||
throw new Exception("delete operation is not supported at the moment. Please contact the admin.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagObjectResp getTagObject(Long id, User user) {
|
||||
TagObjectDO tagObjectDO = tagObjectRepository.getTagObjectById(id);
|
||||
return TagObjectConverter.convert2Resp(tagObjectDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagObjectResp> getTagObjects(TagObjectFilter filter, User user) {
|
||||
List<TagObjectDO> tagObjectDOList = tagObjectRepository.query(filter);
|
||||
return TagObjectConverter.convert2RespList(tagObjectDOList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.tencent.supersonic.headless.server.utils;
|
||||
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.TagObjectReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.TagObjectResp;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.TagObjectDO;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TagObjectConverter {
|
||||
|
||||
public static TagObjectDO convert(TagObjectReq tagObjectReq) {
|
||||
TagObjectDO tagObjectDO = new TagObjectDO();
|
||||
BeanUtils.copyProperties(tagObjectReq, tagObjectDO);
|
||||
tagObjectDO.setId(null);
|
||||
tagObjectDO.setExt(tagObjectReq.getExtJson());
|
||||
return tagObjectDO;
|
||||
}
|
||||
|
||||
public static TagObjectResp convert2Resp(TagObjectDO tagObjectDO) {
|
||||
TagObjectResp tagObjectResp = new TagObjectResp();
|
||||
BeanUtils.copyProperties(tagObjectDO, tagObjectResp);
|
||||
if (Strings.isNotEmpty(tagObjectDO.getExt())) {
|
||||
tagObjectResp.setExt(JsonUtil.objectToMapString(tagObjectDO.getExt()));
|
||||
}
|
||||
return tagObjectResp;
|
||||
}
|
||||
|
||||
public static List<TagObjectResp> convert2RespList(List<TagObjectDO> tagObjectDOList) {
|
||||
List<TagObjectResp> tagObjectRespList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(tagObjectDOList)) {
|
||||
tagObjectDOList.stream().forEach(tagObjectDO -> tagObjectRespList.add(convert2Resp(tagObjectDO)));
|
||||
}
|
||||
return tagObjectRespList;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ CREATE TABLE IF NOT EXISTS `s2_model` (
|
||||
`name` varchar(255) DEFAULT NULL , -- domain name
|
||||
`biz_name` varchar(255) DEFAULT NULL , -- internal name
|
||||
`domain_id` INT DEFAULT '0' , -- parent domain ID
|
||||
`tag_object_id` INT DEFAULT '0' ,
|
||||
`alias` varchar(255) DEFAULT NULL , -- internal name
|
||||
`status` INT DEFAULT NULL, -- 0 is off the shelf, 1 is normal
|
||||
`description` varchar(500) DEFAULT NULL ,
|
||||
@@ -283,4 +284,21 @@ CREATE TABLE IF NOT EXISTS `singer` (
|
||||
);
|
||||
COMMENT ON TABLE singer IS 'singer_info';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `s2_tag_object` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`domain_id` INT NOT NULL ,
|
||||
`name` varchar(255) NOT NULL ,
|
||||
`biz_name` varchar(255) NOT NULL ,
|
||||
`description` varchar(500) DEFAULT NULL ,
|
||||
`status` INT NOT NULL ,
|
||||
`sensitive_level` INT NOT NULL ,
|
||||
`created_at` TIMESTAMP NOT NULL ,
|
||||
`created_by` varchar(100) NOT NULL ,
|
||||
`updated_at` TIMESTAMP DEFAULT NULL ,
|
||||
`updated_by` varchar(100) DEFAULT NULL ,
|
||||
`ext` LONGVARCHAR DEFAULT NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_tag IS 'tag object information';
|
||||
|
||||
|
||||
|
||||
@@ -251,4 +251,23 @@ alter table s2_plugin change `view` data_set varchar(200);
|
||||
alter table s2_data_set change view_detail data_set_detail text;
|
||||
|
||||
--20240311
|
||||
alter table s2_data_set add column query_type varchar(100) DEFAULT NULL;
|
||||
alter table s2_data_set add column query_type varchar(100) DEFAULT NULL;
|
||||
|
||||
--20240319
|
||||
CREATE TABLE IF NOT EXISTS `s2_tag_object`
|
||||
(
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`domain_id` bigint(20) DEFAULT NULL,
|
||||
`name` varchar(255) NOT NULL COMMENT '名称',
|
||||
`biz_name` varchar(255) NOT NULL COMMENT '英文名称',
|
||||
`description` varchar(500) DEFAULT NULL COMMENT '描述',
|
||||
`status` int(10) NOT NULL COMMENT '状态',
|
||||
`sensitive_level` int(10) NOT NULL COMMENT '敏感级别',
|
||||
`created_at` datetime NOT NULL COMMENT '创建时间',
|
||||
`created_by` varchar(100) NOT NULL COMMENT '创建人',
|
||||
`updated_at` datetime NULL COMMENT '更新时间',
|
||||
`updated_by` varchar(100) NULL COMMENT '更新人',
|
||||
`ext` text DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8 COMMENT ='标签表对象';
|
||||
@@ -120,6 +120,7 @@ CREATE TABLE IF NOT EXISTS `s2_model` (
|
||||
`name` varchar(255) DEFAULT NULL , -- domain name
|
||||
`biz_name` varchar(255) DEFAULT NULL , -- internal name
|
||||
`domain_id` INT DEFAULT '0' , -- parent domain ID
|
||||
`tag_object_id` INT DEFAULT '0' ,
|
||||
`alias` varchar(255) DEFAULT NULL , -- internal name
|
||||
`status` INT DEFAULT NULL,
|
||||
`description` varchar(500) DEFAULT NULL ,
|
||||
@@ -593,4 +594,21 @@ CREATE TABLE IF NOT EXISTS `s2_tag` (
|
||||
`ext` LONGVARCHAR DEFAULT NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_tag IS 'tag information';
|
||||
COMMENT ON TABLE s2_tag IS 'tag information';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `s2_tag_object` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`domain_id` INT NOT NULL ,
|
||||
`name` varchar(255) NOT NULL ,
|
||||
`biz_name` varchar(255) NOT NULL ,
|
||||
`description` varchar(500) DEFAULT NULL ,
|
||||
`status` INT NOT NULL ,
|
||||
`sensitive_level` INT NOT NULL ,
|
||||
`created_at` TIMESTAMP NOT NULL ,
|
||||
`created_by` varchar(100) NOT NULL ,
|
||||
`updated_at` TIMESTAMP DEFAULT NULL ,
|
||||
`updated_by` varchar(100) DEFAULT NULL ,
|
||||
`ext` LONGVARCHAR DEFAULT NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_tag IS 'tag object information';
|
||||
@@ -517,4 +517,22 @@ CREATE TABLE `s2_tag`
|
||||
`ext` text DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8 COMMENT ='标签表';
|
||||
DEFAULT CHARSET = utf8 COMMENT ='标签表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `s2_tag_object`
|
||||
(
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`domain_id` bigint(20) DEFAULT NULL,
|
||||
`name` varchar(255) NOT NULL COMMENT '名称',
|
||||
`biz_name` varchar(255) NOT NULL COMMENT '英文名称',
|
||||
`description` varchar(500) DEFAULT NULL COMMENT '描述',
|
||||
`status` int(10) NOT NULL COMMENT '状态',
|
||||
`sensitive_level` int(10) NOT NULL COMMENT '敏感级别',
|
||||
`created_at` datetime NOT NULL COMMENT '创建时间',
|
||||
`created_by` varchar(100) NOT NULL COMMENT '创建人',
|
||||
`updated_at` datetime NULL COMMENT '更新时间',
|
||||
`updated_by` varchar(100) NULL COMMENT '更新人',
|
||||
`ext` text DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8 COMMENT ='标签表对象';
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.tencent.supersonic.headless;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.TagObjectReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.TagObjectResp;
|
||||
import com.tencent.supersonic.headless.server.pojo.TagObjectFilter;
|
||||
import com.tencent.supersonic.headless.server.service.TagObjectService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TagObjectTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
private TagObjectService tagObjectService;
|
||||
|
||||
@Test
|
||||
void testCreateTagObject() throws Exception {
|
||||
User user = User.getFakeUser();
|
||||
TagObjectReq tagObjectReq = newTagObjectReq();
|
||||
TagObjectResp tagObjectResp = tagObjectService.create(tagObjectReq, user);
|
||||
tagObjectService.delete(tagObjectResp.getId(), user);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateTagObject() throws Exception {
|
||||
TagObjectReq tagObjectReq = newTagObjectReq();
|
||||
TagObjectResp tagObjectResp = tagObjectService.create(tagObjectReq, User.getFakeUser());
|
||||
TagObjectReq tagObjectReqUpdate = new TagObjectReq();
|
||||
BeanUtils.copyProperties(tagObjectResp, tagObjectReqUpdate);
|
||||
tagObjectReqUpdate.setName("艺人1");
|
||||
tagObjectService.update(tagObjectReqUpdate, User.getFakeUser());
|
||||
TagObjectResp tagObject = tagObjectService.getTagObject(tagObjectReqUpdate.getId(), User.getFakeUser());
|
||||
tagObjectService.delete(tagObject.getId(), User.getFakeUser());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueryTagObject() throws Exception {
|
||||
TagObjectReq tagObjectReq = newTagObjectReq();
|
||||
TagObjectResp tagObjectResp = tagObjectService.create(tagObjectReq, User.getFakeUser());
|
||||
TagObjectFilter filter = new TagObjectFilter();
|
||||
List<TagObjectResp> tagObjects = tagObjectService.getTagObjects(filter, User.getFakeUser());
|
||||
tagObjects.size();
|
||||
tagObjectService.delete(tagObjectResp.getId(), User.getFakeUser());
|
||||
}
|
||||
|
||||
private TagObjectReq newTagObjectReq() {
|
||||
TagObjectReq tagObjectReq = new TagObjectReq();
|
||||
tagObjectReq.setDomainId(2L);
|
||||
tagObjectReq.setName("艺人");
|
||||
tagObjectReq.setBizName("singer");
|
||||
return tagObjectReq;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,6 +120,7 @@ CREATE TABLE IF NOT EXISTS `s2_model` (
|
||||
`name` varchar(255) DEFAULT NULL , -- domain name
|
||||
`biz_name` varchar(255) DEFAULT NULL , -- internal name
|
||||
`domain_id` INT DEFAULT '0' , -- parent domain ID
|
||||
`tag_object_id` INT DEFAULT '0' ,
|
||||
`alias` varchar(255) DEFAULT NULL , -- internal name
|
||||
`status` INT DEFAULT NULL,
|
||||
`description` varchar(500) DEFAULT NULL ,
|
||||
@@ -594,4 +595,22 @@ CREATE TABLE IF NOT EXISTS `s2_tag` (
|
||||
`ext` LONGVARCHAR DEFAULT NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_tag IS 'tag information';
|
||||
COMMENT ON TABLE s2_tag IS 'tag information';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `s2_tag_object` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`domain_id` INT NOT NULL ,
|
||||
`name` varchar(255) NOT NULL ,
|
||||
`biz_name` varchar(255) NOT NULL ,
|
||||
`description` varchar(500) DEFAULT NULL ,
|
||||
`status` INT NOT NULL ,
|
||||
`sensitive_level` INT NOT NULL ,
|
||||
`created_at` TIMESTAMP NOT NULL ,
|
||||
`created_by` varchar(100) NOT NULL ,
|
||||
`updated_at` TIMESTAMP DEFAULT NULL ,
|
||||
`updated_by` varchar(100) DEFAULT NULL ,
|
||||
`ext` LONGVARCHAR DEFAULT NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_tag IS 'tag object information';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user