|
|
@ -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); |
|
|
|
|
|
|
|
//上级部门不能为自身
|
|
|
@ -210,11 +222,20 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit |
|
|
|
public Map<String, String> getIdByCode(String partyCode) { |
|
|
|
QueryWrapper<SysDeptEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.select("id"); |
|
|
|
wrapper.eq("party_code",partyCode); |
|
|
|
wrapper.eq("party_code", partyCode); |
|
|
|
SysDeptEntity sysDeptEntity = baseDao.selectOne(wrapper); |
|
|
|
Map<String, String> map=new HashMap<>(); |
|
|
|
map.put("id",sysDeptEntity.getId().toString()); |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
map.put("id", sysDeptEntity.getId().toString()); |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|