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
@@ -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

@@ -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>