更新删除部门需要判断是否有下级部门
This commit is contained in:
parent
056e8a59ce
commit
94ae833b82
@ -23,4 +23,6 @@ public interface XhpcWorkDeptMapper {
|
||||
int updateByPrimaryKey(XhpcWorkDeptDomain record);
|
||||
|
||||
int updateStatusByPrimaryKey(XhpcWorkDeptDomain record);
|
||||
|
||||
List<XhpcWorkDeptDomain> selectListByParentDeptId(@Param("parentDeptId") Long parentDeptId);
|
||||
}
|
||||
@ -34,7 +34,7 @@ public class WorkDeptServiceImpl implements WorkDeptService {
|
||||
public List<Map<String, Object>> getList(Map<String, Object> params){
|
||||
List<Map<String, Object>> deptList = deptMapper.selectMapListByParams(params);
|
||||
for (Map<String, Object> dept: deptList){
|
||||
params.put("parentDeptId", dept.get("id"));
|
||||
params.put("parentDeptId", dept.get("id").toString().replaceAll("d_", ""));
|
||||
List<Map<String,Object>> childDeptList = deptMapper.selectMapListByParams(params);
|
||||
dept.put("children", childDeptList);
|
||||
}
|
||||
@ -45,13 +45,13 @@ public class WorkDeptServiceImpl implements WorkDeptService {
|
||||
public List<Map<String, Object>> getTree(Map<String, Object> params){
|
||||
List<Map<String, Object>> deptList = deptMapper.selectMapListByParams(params);
|
||||
for (Map<String, Object> dept: deptList){
|
||||
params.put("parentDeptId", dept.get("id"));
|
||||
params.put("parentDeptId", dept.get("id").toString().replaceAll("d_", ""));
|
||||
List<Map<String,Object>> childDeptList = deptMapper.selectMapListByParams(params);
|
||||
if(childDeptList.size() > 0){
|
||||
dept.put("children", childDeptList);
|
||||
}
|
||||
for (Map<String, Object> childMap: childDeptList){
|
||||
params.put("parentDeptId", childMap.get("id"));
|
||||
params.put("parentDeptId", childMap.get("id").toString().replaceAll("d_", ""));
|
||||
List<Map<String,Object>> childDeptList1 = deptMapper.selectMapListByParams(params);
|
||||
if(childDeptList1.size() > 0){
|
||||
childMap.put("children", childDeptList1);
|
||||
@ -97,6 +97,11 @@ public class WorkDeptServiceImpl implements WorkDeptService {
|
||||
|
||||
@Override
|
||||
public Boolean deleteDomain(Long deptId){
|
||||
List<XhpcWorkDeptDomain> domainList = deptMapper.selectListByParentDeptId(deptId);
|
||||
if (domainList.size() > 0){
|
||||
throw new CustomException("存在下级部门");
|
||||
}
|
||||
|
||||
return deptMapper.deleteLogicByPrimaryKey(deptId) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,15 @@
|
||||
</select>
|
||||
|
||||
|
||||
<update id="deleteLogicByPrimaryKey" parameterType="java.lang.Long">
|
||||
<select id="selectListByParentDeptId" resultType="com.xhpc.activity.domain.XhpcWorkDeptDomain">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from xhpc_work_dept
|
||||
where del_flag = 0 and parent_dept_id=#{parentDeptId}
|
||||
</select>
|
||||
|
||||
|
||||
<update id="deleteLogicByPrimaryKey" parameterType="java.lang.Long">
|
||||
update xhpc_work_dept set del_flag=2
|
||||
where work_dept_id = #{workDeptId,jdbcType=BIGINT}
|
||||
</update>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user