Commit ec7c08c638f6239f44fbe035b4ae91f30252afd9
1 parent
9de70b1c9c
Exists in
master
and in
8 other branches
platform permission
add return pageinfo
Showing 1 changed file with 21 additions and 4 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
View file @
ec7c08c
... | ... | @@ -10,10 +10,7 @@ |
10 | 10 | import com.lyms.platform.common.enums.YnEnums; |
11 | 11 | import com.lyms.platform.common.utils.ResultUtils; |
12 | 12 | import com.lyms.platform.operate.web.result.FrontEndResult; |
13 | -import com.lyms.platform.permission.model.Organization; | |
14 | -import com.lyms.platform.permission.model.OrganizationQuery; | |
15 | -import com.lyms.platform.permission.model.Regions; | |
16 | -import com.lyms.platform.permission.model.Users; | |
13 | +import com.lyms.platform.permission.model.*; | |
17 | 14 | import com.lyms.platform.permission.service.*; |
18 | 15 | import org.apache.commons.lang.StringUtils; |
19 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -38,6 +35,8 @@ |
38 | 35 | private OrganizationService organizationService; |
39 | 36 | @Autowired |
40 | 37 | private RegionsService regionsService; |
38 | + @Autowired | |
39 | + private DepartmentsService departmentsService; | |
41 | 40 | |
42 | 41 | |
43 | 42 | /** |
... | ... | @@ -58,6 +57,24 @@ |
58 | 57 | return; |
59 | 58 | } |
60 | 59 | |
60 | + //机构有使用 不能删除 | |
61 | + UsersQuery usersQuery = new UsersQuery(); | |
62 | + usersQuery.setOrgId(organization.getId()); | |
63 | + usersQuery.setYn(YnEnums.YES.getId()); | |
64 | + if(0 < usersService.queryUsersCount(usersQuery)) { | |
65 | + ResultUtils.buildResultAndWrite(response, ErrorCodeConstants.DONT_DELETE, "机构下有用户信息,不能删除!"); | |
66 | + return; | |
67 | + } | |
68 | + | |
69 | + DepartmentsQuery departmentsQuery = new DepartmentsQuery(); | |
70 | + departmentsQuery.setYn(YnEnums.YES.getId()); | |
71 | + departmentsQuery.setOrgId(organization.getId()); | |
72 | + if(0 < departmentsService.queryDepartmentsCount(departmentsQuery)) { | |
73 | + ResultUtils.buildResultAndWrite(response, ErrorCodeConstants.DONT_DELETE, "机构下有部门信息,不能删除!"); | |
74 | + return; | |
75 | + } | |
76 | + | |
77 | + //删除机构 | |
61 | 78 | organization.setYn(YnEnums.NO.getId()); |
62 | 79 | organization.setModified(new Date()); |
63 | 80 | organizationService.updateOrganization(organization); |