[301]
设备编码 没做唯一性校验,可以新增相同编码的设备
This commit is contained in:
parent
0faf0601ff
commit
1087f539af
@ -65,7 +65,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||||
// 判断设备编码是否存在
|
// 判断设备编码是否存在
|
||||||
if (sysEquipmentMapper.queryEquipmentByCode(sysEquipment.getCode()) > 0) {
|
if (sysEquipmentMapper.queryEquipmentByCode(sysEquipment.getCode()) > 0) {
|
||||||
throw new ServiceException("设备编码已存在");
|
throw new RuntimeException("设备编码已存在");
|
||||||
}
|
}
|
||||||
sysEquipment.setCreatedTime(new Date());
|
sysEquipment.setCreatedTime(new Date());
|
||||||
sysEquipment.setUpdatedTime(new Date());
|
sysEquipment.setUpdatedTime(new Date());
|
||||||
@ -83,6 +83,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
SysEquipment sysEquipment = new SysEquipment();
|
SysEquipment sysEquipment = new SysEquipment();
|
||||||
BeanCopyUtils.copy(sysEquipmentDto, sysEquipment);
|
BeanCopyUtils.copy(sysEquipmentDto, sysEquipment);
|
||||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||||
|
// 判断设备编码是否存在
|
||||||
|
if (sysEquipmentMapper.queryEquipmentByCode(sysEquipment.getCode()) > 0) {
|
||||||
|
throw new RuntimeException("设备编码已存在");
|
||||||
|
}
|
||||||
sysEquipment.setUpdatedTime(new Date());
|
sysEquipment.setUpdatedTime(new Date());
|
||||||
sysEquipment.setUpdatedBy(sysUserVo.getAccount());
|
sysEquipment.setUpdatedBy(sysUserVo.getAccount());
|
||||||
sysEquipmentMapper.updateById(sysEquipment);
|
sysEquipmentMapper.updateById(sysEquipment);
|
||||||
@ -95,7 +99,7 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
public void deleteSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
public void deleteSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||||
// 设备下面有子设备则不能删除
|
// 设备下面有子设备则不能删除
|
||||||
if (sysEquipmentMapper.queryChildEquipmentCount(sysEquipmentDto.getId()) > 0) {
|
if (sysEquipmentMapper.queryChildEquipmentCount(sysEquipmentDto.getId()) > 0) {
|
||||||
throw new ServiceException("该设备下有子设备,不能删除");
|
throw new RuntimeException("该设备下有子设备,不能删除");
|
||||||
}
|
}
|
||||||
sysEquipmentMapper.deleteById(sysEquipmentDto.getId());
|
sysEquipmentMapper.deleteById(sysEquipmentDto.getId());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user