|
|
@ -91,6 +91,12 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(SysDeptDTO dto) { |
|
|
|
String partyCode = dto.getPartyCode(); |
|
|
|
if (StringUtils.isNotBlank(partyCode)) { |
|
|
|
if (getCodeCount(dto) > 0) { |
|
|
|
throw new RenException("您输入的编码已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
SysDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysDeptEntity.class); |
|
|
|
|
|
|
|
entity.setPids(getPidList(entity.getPid())); |
|
|
@ -100,6 +106,12 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(SysDeptDTO dto) { |
|
|
|
String partyCode = dto.getPartyCode(); |
|
|
|
if (StringUtils.isNotBlank(partyCode)) { |
|
|
|
if (getCodeCount(dto) > 0) { |
|
|
|
throw new RenException("您输入的编码已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
SysDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysDeptEntity.class); |
|
|
|
|
|
|
|
//上级部门不能为自身
|
|
|
@ -217,4 +229,13 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Integer getCodeCount(SysDeptDTO dto) { |
|
|
|
QueryWrapper<SysDeptEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("party_code", dto.getPartyCode()); |
|
|
|
Long id = dto.getId(); |
|
|
|
wrapper.ne(id!=null, "id", dto.getId()); |
|
|
|
return baseDao.selectCount(wrapper); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|