mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
删除标签添加约束条件
This commit is contained in:
+1
@@ -189,6 +189,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode LABEL_TEMPLATE_NOT_EXISTS = new ErrorCode(1_002_300_000, "标签模板不存在");
|
||||
ErrorCode LABEL_NOT_EXISTS = new ErrorCode(1_002_300_001, "标签不存在");
|
||||
ErrorCode DEFAULT_LABEL_NOT_EXISTS = new ErrorCode(1_002_300_002, "该类型标签默认模板不存在");
|
||||
ErrorCode MACHINE_USE_LABEL = new ErrorCode(1_002_300_003, "无法删除已有机台使用标签");
|
||||
|
||||
// ========== 系统数据源 1_002_301_000 ==========
|
||||
ErrorCode DATA_SOURCE_NOT_EXISTS = new ErrorCode(1_002_301_000, "系统数据源不存在");
|
||||
|
||||
+13
@@ -1,11 +1,14 @@
|
||||
package com.cf.imes.module.system.service.lable;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.system.controller.admin.label.vo.*;
|
||||
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;
|
||||
import com.cf.imes.module.system.dal.mysql.label.LabelMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.machine.MachineMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -15,6 +18,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.LABEL_NOT_EXISTS;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.MACHINE_USE_LABEL;
|
||||
|
||||
/**
|
||||
* 标签模板 Service 实现类
|
||||
@@ -29,6 +33,8 @@ public class LabelServiceImpl implements LabelService {
|
||||
@Resource
|
||||
private LabelMapper labelMapper;
|
||||
|
||||
@Resource
|
||||
private MachineMapper machineMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -58,6 +64,13 @@ public class LabelServiceImpl implements LabelService {
|
||||
if (LabelDO == null) {
|
||||
throw exception(LABEL_NOT_EXISTS);
|
||||
}
|
||||
List<MachineDO> machineDOS = machineMapper.selectList(new LambdaQueryWrapperX<MachineDO>()
|
||||
.select(MachineDO::getId)
|
||||
.eq(MachineDO::getLabelId, id)
|
||||
);
|
||||
if(CollectionUtil.isNotEmpty(machineDOS)) {
|
||||
throw exception(MACHINE_USE_LABEL);
|
||||
}
|
||||
// 删除标签模板表
|
||||
labelMapper.deleteById(id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user