修复标签循环引用Bug

This commit is contained in:
2023-04-21 10:42:41 +08:00
parent ed9adf2a93
commit 59c2d6f833
@@ -3,6 +3,8 @@ package com.adc.da.report.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import com.adc.da.report.constant.TreeLabelConstants;
import com.adc.da.report.dao.mysql.ReportLabelDao;
import com.adc.da.report.eo.ReportLabelEntity;
import com.adc.da.report.vo.TreeLabelVo;
import com.adc.da.util.exception.AdcDaBaseException;
import com.adc.da.util.utils.StringUtils;
@@ -14,6 +16,7 @@ import com.adc.da.report.eo.TreeLabelEntity;
import com.adc.da.report.service.ITreeLabelService;
import com.adc.da.report.dao.mysql.TreeLabelDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
@@ -34,6 +37,9 @@ public class ITreeLabelServiceImpl extends ServiceImpl<TreeLabelDao, TreeLabelEn
@Resource
private TreeLabelDao treeLabelDao;
@Resource
private ReportLabelDao reportLabelDao;
@Override
public List<TreeLabelVo> getTreeLabellist(String like) {
@@ -109,6 +115,10 @@ public class ITreeLabelServiceImpl extends ServiceImpl<TreeLabelDao, TreeLabelEn
treeLabelDao.insert(entity);
} else {
//编辑标签
//不能设置上级标签为自己
if (entity.getParentId().equals(entity.getId())) {
throw new AdcDaBaseException("不能设置上级标签为自身");
}
TreeLabelEntity treeLabelEntity = treeLabelDao.selectById(entity.getId());
if (Objects.nonNull(treeLabelEntity)) {
treeLabelDao.updateById(entity);