Browse Source

编辑、删除组织架构时校验

master
牧羊人 4 years ago
parent
commit
b64cf339a2
1 changed files with 17 additions and 0 deletions
  1. +17
    -0
      src/main/java/com/taauav/admin/service/impl/LsCityServiceImpl.java

+ 17
- 0
src/main/java/com/taauav/admin/service/impl/LsCityServiceImpl.java View File

@@ -183,6 +183,15 @@ public class LsCityServiceImpl extends ServiceImpl<SysCityMapper, SysCity> imple
if (entity == null || entity.getId() == null) {
return response.failure("实体对象不能为空");
}
// 同名不给添加
QueryWrapper<SysCity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("name", entity.getName());
queryWrapper.eq("level", entity.getLevel());
queryWrapper.eq("mark", 1);
SysCity cityInfo = sysCityMapper.selectOne(queryWrapper);
if (cityInfo != null) {
return response.failure("同级已存在该组织名称");
}
entity.setUpdateUser(ShiroUtils.getAdminId());
entity.setUpdateTime(DateUtil.now());
boolean result = this.updateById(entity);
@@ -207,6 +216,14 @@ public class LsCityServiceImpl extends ServiceImpl<SysCityMapper, SysCity> imple
if (entity == null) {
return response.failure("机构信息不存在");
}
// 校验是否存在子级
QueryWrapper<SysCity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pid", entity.getId());
queryWrapper.eq("mark", 1);
Integer count = sysCityMapper.selectCount(queryWrapper);
if (count > 0) {
return response.failure("存在子级,无法删除");
}
entity.setUpdateUser(ShiroUtils.getAdminId());
entity.setUpdateTime(DateUtil.now());
entity.setMark(0);

Loading…
Cancel
Save