修改 部门下面还有子部门时无法删除

master
wangwei 2 years ago
parent b30ad9b3a8
commit 43d85a6cdf

@ -291,6 +291,10 @@ public class DeptController extends BaseController {
if (CollUtil.isNotEmpty(deptUserEntities)) { if (CollUtil.isNotEmpty(deptUserEntities)) {
return ResultVOUtils.error(500, "删除失败,请先移除该部门关联用户信息!"); return ResultVOUtils.error(500, "删除失败,请先移除该部门关联用户信息!");
} }
List<DeptEntity> deptEntities = deptService.selectByPcode(deptEntity.getCode());
if(deptEntities.size()>0){
return ResultVOUtils.error(500, "删除失败,请先移除该部门下的子部门!");
}
boolean b = deptService.deleteById(deleteRequest.getId()); boolean b = deptService.deleteById(deleteRequest.getId());

@ -67,4 +67,6 @@ public interface DeptDao {
* @return * @return
*/ */
String selectNameByCode(@Param("code") String code); String selectNameByCode(@Param("code") String code);
List<DeptEntity> selectByPcode(@Param("pcode") String pcode);
} }

@ -75,4 +75,6 @@ public interface DeptService {
List<DeptEntity> getDeptById( List<Integer> ids); List<DeptEntity> getDeptById( List<Integer> ids);
List<DeptEntity> selectByPcode(String pcode);
} }

@ -177,4 +177,11 @@ public class DeptServiceImpl implements DeptService {
public List<DeptEntity> getDeptById(List<Integer> ids) { public List<DeptEntity> getDeptById(List<Integer> ids) {
return deptDao.getDeptById(ids); return deptDao.getDeptById(ids);
} }
@Override
public List<DeptEntity> selectByPcode(String pcode) {
return deptDao.selectByPcode(pcode);
}
} }

@ -308,4 +308,8 @@
<select id="selectNameByCode" resultType="java.lang.String"> <select id="selectNameByCode" resultType="java.lang.String">
select name from auth_dept where code = #{code} select name from auth_dept where code = #{code}
</select> </select>
<select id="selectByPcode" resultType="com.glxp.api.entity.auth.DeptEntity">
select * from auth_dept where pcode = #{pcode}
</select>
</mapper> </mapper>

Loading…
Cancel
Save