|
|
@@ -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); |