|
|
@@ -123,14 +123,7 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
public String saveTag(AitagTagInfoEntity aitagTagInfo){
|
|
|
aitagTagInfo.setId(StringUtils.getUUID());
|
|
|
String parentId = aitagTagInfo.getParentId();
|
|
|
-
|
|
|
- LambdaQueryWrapper<AitagTagInfoEntity> queryTagInfo = new LambdaQueryWrapper<>();
|
|
|
- queryTagInfo.eq(AitagTagInfoEntity::getTagCode,aitagTagInfo.getTagCode());
|
|
|
- queryTagInfo.eq(AitagTagInfoEntity::getIsDelete,TAG_UNDELETED);
|
|
|
- if(this.baseMapper.selectCount(queryTagInfo) > 0){
|
|
|
- throw BizException.of("E010");
|
|
|
- }
|
|
|
-
|
|
|
+ checkTagCodeDuplicate(aitagTagInfo.getTagCode());
|
|
|
if(!StringUtils.isBlank(parentId)){
|
|
|
LambdaQueryWrapper<AitagTagInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(AitagTagInfoEntity::getParentId,parentId);
|
|
|
@@ -190,21 +183,20 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateTag(AitagTagInfoEntity aitagTagInfoEntity) {
|
|
|
- AitagTagInfoEntity tagInfo = this.baseMapper.selectById(aitagTagInfoEntity.getId());
|
|
|
+ AitagTagInfoEntity oldTagInfo = this.baseMapper.selectById(aitagTagInfoEntity.getId());
|
|
|
+ if(oldTagInfo.valueEqualsValue(aitagTagInfoEntity)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
String newTagCode = aitagTagInfoEntity.getTagCode();
|
|
|
- String oldTagCode = tagInfo.getTagCode();
|
|
|
+ String oldTagCode = oldTagInfo.getTagCode();
|
|
|
if(!StringUtils.isEmpty(newTagCode) && !StringUtils.equals(oldTagCode,newTagCode)){
|
|
|
- LambdaQueryWrapper<AitagTagInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(AitagTagInfoEntity::getTagCode,newTagCode);
|
|
|
- if(this.baseMapper.selectCount(queryWrapper) > 0 ){
|
|
|
- throw BizException.of("E010");
|
|
|
- }
|
|
|
+ checkTagCodeDuplicate(newTagCode);
|
|
|
}
|
|
|
- AitagTagInfoVersionEntity aitagTagInfoVersionEntity = JSON.parseObject(JSON.toJSONString(tagInfo), AitagTagInfoVersionEntity.class);
|
|
|
+ AitagTagInfoVersionEntity aitagTagInfoVersionEntity = JSON.parseObject(JSON.toJSONString(oldTagInfo), AitagTagInfoVersionEntity.class);
|
|
|
aitagTagInfoVersionEntity.setId(StringUtils.getUUID());
|
|
|
this.aitagTagInfoVersionDao.insert(aitagTagInfoVersionEntity);
|
|
|
aitagTagInfoEntity.setRevisionTime(DateUtils.getCurrDateTimeStr());
|
|
|
- aitagTagInfoEntity.setTagVersion(Integer.parseInt(tagInfo.getTagVersion())+1+"");
|
|
|
+ aitagTagInfoEntity.setTagVersion(Integer.parseInt(oldTagInfo.getTagVersion())+1+"");
|
|
|
if(!StringUtils.isBlank(aitagTagInfoEntity.getParentId())){
|
|
|
AitagTagInfoEntity parentTagInfo = this.baseMapper.selectById(aitagTagInfoEntity.getParentId());
|
|
|
if(parentTagInfo !=null){
|
|
|
@@ -351,6 +343,8 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
throw BizException.of("E018");
|
|
|
}
|
|
|
for (TagImportDto tagImportDto: tagImportDtos){
|
|
|
+
|
|
|
+ checkTagCodeDuplicate(tagImportDto.getTagCode());
|
|
|
AitagTagInfoEntity aitagTagInfo = JSONObject.parseObject(JSONObject.toJSONString(tagImportDto),
|
|
|
AitagTagInfoEntity.class);
|
|
|
String tagPath = tagImportDto.getTagPath();
|
|
|
@@ -371,6 +365,15 @@ public class AitagTagInfoServiceImpl extends ServiceImpl<AitagTagInfoDao, AitagT
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void checkTagCodeDuplicate(String tagCode) {
|
|
|
+ LambdaQueryWrapper<AitagTagInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getTagCode, tagCode);
|
|
|
+ queryWrapper.eq(AitagTagInfoEntity::getIsDelete,TAG_UNDELETED);
|
|
|
+ if (this.baseMapper.selectCount(queryWrapper) > 0) {
|
|
|
+ throw BizException.of("E010");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 校验父标签存在性并将赋值parentId
|
|
|
* @param nameToDtoMap
|