opt checkTagObject info (#847)

This commit is contained in:
daikon
2024-03-21 00:54:44 +08:00
committed by GitHub
parent 01bfb57149
commit 449ad8b117
4 changed files with 45 additions and 34 deletions

View File

@@ -15,5 +15,7 @@ public interface TagCustomMapper {
Boolean deleteById(Long id);
void deleteBatch(List<Long> itemIds, List<Long> ids, String type);
void deleteBatchByIds(List<Long> ids);
void deleteBatchByType(List<Long> itemIds, String type);
}

View File

@@ -7,8 +7,12 @@ import com.tencent.supersonic.headless.server.persistence.mapper.TagCustomMapper
import com.tencent.supersonic.headless.server.persistence.mapper.TagMapper;
import com.tencent.supersonic.headless.server.persistence.repository.TagRepository;
import com.tencent.supersonic.headless.server.pojo.TagFilter;
import java.util.List;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Repository;
@Slf4j
@@ -18,7 +22,7 @@ public class TagRepositoryImpl implements TagRepository {
private final TagCustomMapper tagCustomMapper;
public TagRepositoryImpl(TagMapper mapper,
TagCustomMapper tagCustomMapper) {
TagCustomMapper tagCustomMapper) {
this.mapper = mapper;
this.tagCustomMapper = tagCustomMapper;
}
@@ -56,7 +60,11 @@ public class TagRepositoryImpl implements TagRepository {
@Override
public void deleteBatch(TagDeleteReq tagDeleteReq) {
tagCustomMapper.deleteBatch(tagDeleteReq.getItemIds(), tagDeleteReq.getIds(),
tagDeleteReq.getTagDefineType().name());
if (CollectionUtils.isNotEmpty(tagDeleteReq.getIds())) {
tagCustomMapper.deleteBatchByIds(tagDeleteReq.getIds());
}
if (Objects.nonNull(tagDeleteReq.getTagDefineType()) && CollectionUtils.isNotEmpty(tagDeleteReq.getItemIds())) {
tagCustomMapper.deleteBatchByType(tagDeleteReq.getItemIds(), tagDeleteReq.getTagDefineType().name());
}
}
}

View File

@@ -339,7 +339,7 @@ public class TagMetaServiceImpl implements TagMetaService {
DimensionResp dimension = dimensionService.getDimension(tagReq.getItemId());
ModelResp model = modelService.getModel(dimension.getModelId());
if (Objects.isNull(model.getTagObjectId())) {
throw new RuntimeException(String.format("this dimension:%s is not supported to create tag",
throw new RuntimeException(String.format("this dimension:%s is not supported to create tag, no related tag object",
tagReq.getItemId()));
}
}
@@ -347,7 +347,7 @@ public class TagMetaServiceImpl implements TagMetaService {
MetricResp metric = metricService.getMetric(tagReq.getItemId());
ModelResp model = modelService.getModel(metric.getModelId());
if (Objects.isNull(model.getTagObjectId())) {
throw new RuntimeException(String.format("this metric:%s is not supported to create tag",
throw new RuntimeException(String.format("this metric:%s is not supported to create tag, no related tag object",
tagReq.getItemId()));
}
}

View File

@@ -3,28 +3,28 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.headless.server.persistence.mapper.TagCustomMapper">
<resultMap id="BaseTagDO" type="com.tencent.supersonic.headless.server.persistence.dataobject.TagDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="item_id" jdbcType="BIGINT" property="itemId" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="item_id" jdbcType="BIGINT" property="itemId"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy"/>
</resultMap>
<resultMap id="TagResp" type="com.tencent.supersonic.headless.api.pojo.response.TagResp">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="domain_id" jdbcType="BIGINT" property="domainId" />
<result column="domain_name" jdbcType="VARCHAR" property="domainName" />
<result column="model_id" jdbcType="BIGINT" property="modelId" />
<result column="model_name" jdbcType="VARCHAR" property="modelName" />
<result column="tag_object_id" jdbcType="BIGINT" property="tagObjectId" />
<result column="tag_object_name" jdbcType="VARCHAR" property="tagObjectName" />
<result column="type" jdbcType="VARCHAR" property="tagDefineType" />
<result column="item_id" jdbcType="VARCHAR" property="itemId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
<result column="description" jdbcType="VARCHAR" property="description" />
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="domain_id" jdbcType="BIGINT" property="domainId"/>
<result column="domain_name" jdbcType="VARCHAR" property="domainName"/>
<result column="model_id" jdbcType="BIGINT" property="modelId"/>
<result column="model_name" jdbcType="VARCHAR" property="modelName"/>
<result column="tag_object_id" jdbcType="BIGINT" property="tagObjectId"/>
<result column="tag_object_name" jdbcType="VARCHAR" property="tagObjectName"/>
<result column="type" jdbcType="VARCHAR" property="tagDefineType"/>
<result column="item_id" jdbcType="VARCHAR" property="itemId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="biz_name" jdbcType="VARCHAR" property="bizName"/>
<result column="description" jdbcType="VARCHAR" property="description"/>
</resultMap>
<select id="getTagDOList" resultMap="BaseTagDO">
@@ -116,7 +116,16 @@
delete from s2_tag where id = #{id}
</delete>
<delete id="deleteBatch">
<delete id="deleteBatchByIds">
delete from s2_tag
where id in
<foreach collection="ids" index="index" item="tagId" open="(" close=")"
separator=",">
#{tagId}
</foreach>
</delete>
<delete id="deleteBatchByType">
delete from s2_tag
where type = #{type}
<if test="itemIds != null and itemIds.size >0">
@@ -126,14 +135,6 @@
#{itemId}
</foreach>
</if>
<if test="ids != null and ids.size >0">
and id in
<foreach collection="ids" index="index" item="tagId" open="(" close=")"
separator=",">
#{tagId}
</foreach>
</if>
</delete>
</mapper>