Commit 06e56702f5fee01fab46886b247347f3fd7af41b
1 parent
4090b135c2
Exists in
master
and in
1 other branch
bug fix
增加用户类型枚举
Showing 7 changed files with 61 additions and 23 deletions
- platform-common/src/main/java/com/lyms/platform/common/enums/UserTypeEnum.java
- platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/DepartmentsController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RegionController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AutoMatchFacade.java
platform-common/src/main/java/com/lyms/platform/common/enums/UserTypeEnum.java
View file @
06e5670
1 | +package com.lyms.platform.common.enums; | |
2 | + | |
3 | +/** | |
4 | + * Created by Zhang.Rui on 2016/5/10. | |
5 | + * 用户角色类型 | |
6 | + */ | |
7 | +public enum UserTypeEnum { | |
8 | + NORMAL_USER(1, "普通用户"), | |
9 | + PLATFORM_ADMIN(0, "平台管理员"), | |
10 | + SUPPER_ADMIN(2, "超级管理员"); | |
11 | + | |
12 | + private int id; | |
13 | + private String text; | |
14 | + | |
15 | + private UserTypeEnum(int id, String text) { | |
16 | + this.id = id; | |
17 | + this.text = text; | |
18 | + } | |
19 | + | |
20 | + | |
21 | + public Integer getId() { | |
22 | + return id; | |
23 | + } | |
24 | + | |
25 | + public void setId(int id) { | |
26 | + this.id = id; | |
27 | + } | |
28 | + | |
29 | + public String getText() { | |
30 | + return text; | |
31 | + } | |
32 | + | |
33 | + public void setText(String text) { | |
34 | + this.text = text; | |
35 | + } | |
36 | +} |
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java
View file @
06e5670
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | import com.lyms.platform.biz.service.BasicConfigService; |
5 | 5 | import com.lyms.platform.biz.service.PatientsService; |
6 | 6 | import com.lyms.platform.common.enums.PermissionTypeEnums; |
7 | +import com.lyms.platform.common.enums.UserTypeEnum; | |
7 | 8 | import com.lyms.platform.common.enums.VisitStatusEnums; |
8 | 9 | import com.lyms.platform.common.enums.YnEnums; |
9 | 10 | import com.lyms.platform.common.utils.JsonUtil; |
... | ... | @@ -307,7 +308,7 @@ |
307 | 308 | u.setOrgId(o.getId()); |
308 | 309 | u.setDeptId(d.getId()); |
309 | 310 | u.setKsId(d.getId()); |
310 | - u.setType(1); | |
311 | + u.setType(UserTypeEnum.NORMAL_USER.getId()); | |
311 | 312 | u.setOtherAccount(1); |
312 | 313 | u.setLogincenterId(LoginUtil.aouHospitalUser(u.getAccount(), u.getPwd(), typeId, token)); |
313 | 314 | usersQuery.setForeignId(u.getForeignId()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/DepartmentsController.java
View file @
06e5670
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | import com.lyms.platform.common.base.BaseController; |
6 | 6 | import com.lyms.platform.common.base.LoginContext; |
7 | 7 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
8 | +import com.lyms.platform.common.enums.UserTypeEnum; | |
8 | 9 | import com.lyms.platform.common.enums.YnEnums; |
9 | 10 | import com.lyms.platform.common.utils.ResultUtils; |
10 | 11 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
... | ... | @@ -202,7 +203,7 @@ |
202 | 203 | departmentsQuery.setOrgId(orgId); |
203 | 204 | } else if (CollectionUtils.isNotEmpty(orgId1)){ |
204 | 205 | departmentsQuery.setOrgList(orgId1); |
205 | - } else if(!new Integer(2).equals(users.getType())){ //不是超级管理员 | |
206 | + } else if(!UserTypeEnum.SUPPER_ADMIN.getId().equals(users.getType())){ //不是超级管理员 | |
206 | 207 | FrontEndResult frontEndResult = new FrontEndResult(); |
207 | 208 | frontEndResult.setPageInfo(departmentsQuery.getPageInfo()); |
208 | 209 | frontEndResult.setErrorcode(ErrorCodeConstants.SUCCESS); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
View file @
06e5670
... | ... | @@ -7,10 +7,7 @@ |
7 | 7 | import com.lyms.platform.common.base.LoginContext; |
8 | 8 | import com.lyms.platform.common.base.PageInfo; |
9 | 9 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
10 | -import com.lyms.platform.common.enums.OrganizationLevelEnum; | |
11 | -import com.lyms.platform.common.enums.OrganizationTypeEnum; | |
12 | -import com.lyms.platform.common.enums.PermissionTypeEnums; | |
13 | -import com.lyms.platform.common.enums.YnEnums; | |
10 | +import com.lyms.platform.common.enums.*; | |
14 | 11 | import com.lyms.platform.common.utils.ResultUtils; |
15 | 12 | import com.lyms.platform.common.utils.SystemConfig; |
16 | 13 | import com.lyms.platform.operate.web.facade.AccessPermissionFacade; |
... | ... | @@ -286,7 +283,7 @@ |
286 | 283 | organizations = organizationService.queryOrganization(organizationQuery); |
287 | 284 | pageInfo=organizationQuery.getPageInfo(); |
288 | 285 | |
289 | - } else if(null == areaId && users.getType().equals(2)){ | |
286 | + } else if(null == areaId && UserTypeEnum.SUPPER_ADMIN.getId().equals(users.getType())){ | |
290 | 287 | // UserOrganizationMapsQuery userOrganizationMapsQuery = new UserOrganizationMapsQuery(); |
291 | 288 | // userOrganizationMapsQuery.setYn(YnEnums.YES.getId()); |
292 | 289 | // userOrganizationMapsQuery.setUserId(loginState.getId()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RegionController.java
View file @
06e5670
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import com.lyms.platform.common.base.BaseController; |
7 | 7 | import com.lyms.platform.common.base.LoginContext; |
8 | 8 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
9 | +import com.lyms.platform.common.enums.UserTypeEnum; | |
9 | 10 | import com.lyms.platform.common.enums.YnEnums; |
10 | 11 | import com.lyms.platform.common.utils.ResultUtils; |
11 | 12 | import com.lyms.platform.common.utils.SystemConfig; |
... | ... | @@ -57,7 +58,7 @@ |
57 | 58 | BasicConfigQuery query = new BasicConfigQuery(); |
58 | 59 | query.setYn(YnEnums.YES.getId()); |
59 | 60 | |
60 | - if(user.getType().equals(1)) { | |
61 | + if(UserTypeEnum.NORMAL_USER.getId().equals(user.getType())) { | |
61 | 62 | if(null == user.getOrgId()) { |
62 | 63 | ResultUtils.buildResultAndWrite(httpServletResponse, ErrorCodeConstants.SYSTEM_ERROR, "user not defined orgId error!"); |
63 | 64 | return; |
... | ... | @@ -87,7 +88,7 @@ |
87 | 88 | } |
88 | 89 | |
89 | 90 | |
90 | - if ((user.getType().equals(2) || user.getType().equals(0)) && ("0".equals(parentId) || StringUtils.isBlank(parentId))) { | |
91 | + if ((UserTypeEnum.SUPPER_ADMIN.getId().equals(user.getType()) || UserTypeEnum.PLATFORM_ADMIN.getId().equals(user.getType())) && ("0".equals(parentId) || StringUtils.isBlank(parentId))) { | |
91 | 92 | parentId = SystemConfig.CHINA_BASIC_ID; |
92 | 93 | query.setParentId(parentId); |
93 | 94 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
View file @
06e5670
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | import com.lyms.platform.common.base.PageInfo; |
8 | 8 | import com.lyms.platform.common.constants.ConstantInterface; |
9 | 9 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
10 | +import com.lyms.platform.common.enums.UserTypeEnum; | |
10 | 11 | import com.lyms.platform.common.enums.YnEnums; |
11 | 12 | import com.lyms.platform.common.utils.*; |
12 | 13 | import com.lyms.platform.operate.web.facade.AccessPermissionFacade; |
... | ... | @@ -125,7 +126,7 @@ |
125 | 126 | |
126 | 127 | |
127 | 128 | List<Integer> ids = null; |
128 | - if(u.getType().equals(1)) { | |
129 | + if(u.getType().equals(UserTypeEnum.NORMAL_USER.getId())) { | |
129 | 130 | if(null != u.getOrgId()) { |
130 | 131 | orgId = u.getOrgId(); |
131 | 132 | } else { |
... | ... | @@ -134,7 +135,7 @@ |
134 | 135 | frontEndResult.setErrorcode(ErrorCodeConstants.SUCCESS); |
135 | 136 | return frontEndResult; |
136 | 137 | } |
137 | - }else if(u.getType().equals(0)) { | |
138 | + }else if(u.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId())) { | |
138 | 139 | List<Organization> organizations = accessPermissionFacade.findAccessPerminssionByUserId(u.getId()); |
139 | 140 | ids = new ArrayList<>(); |
140 | 141 | if(CollectionUtils.isNotEmpty(organizations)) { |
... | ... | @@ -321,7 +322,7 @@ |
321 | 322 | List<Permissions> permissions = null; |
322 | 323 | List<Roles> roles = new ArrayList<>(); |
323 | 324 | //超级管理员拥有所有角色和权限 |
324 | - if(users.getType().equals(2)) { | |
325 | + if(users.getType().equals(UserTypeEnum.SUPPER_ADMIN.getId())) { | |
325 | 326 | RolesQuery rolesQuery = new RolesQuery(); |
326 | 327 | rolesQuery.setYn(YnEnums.YES.getId()); |
327 | 328 | roles = rolesService.queryRoles(rolesQuery); |
... | ... | @@ -333,7 +334,7 @@ |
333 | 334 | |
334 | 335 | } |
335 | 336 | //其他用户 |
336 | - else if(users.getType().equals(0) || users.getType().equals(1)){ | |
337 | + else if(users.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId()) || users.getType().equals(UserTypeEnum.NORMAL_USER.getId())){ | |
337 | 338 | //获取用户角色信息 |
338 | 339 | UserRoleMapsQuery query = new UserRoleMapsQuery(); |
339 | 340 | query.setUserId(users.getId()); |
340 | 341 | |
341 | 342 | |
... | ... | @@ -378,16 +379,16 @@ |
378 | 379 | |
379 | 380 | |
380 | 381 | List<Organization> organizations = new ArrayList<>(); |
381 | - if(null != users.getOrgId() && new Integer(1).equals(users.getType())) { //普通用户 | |
382 | + if(null != users.getOrgId() && UserTypeEnum.NORMAL_USER.equals(users.getType())) { //普通用户 | |
382 | 383 | organizations.add(organizationService.getOrganization(users.getOrgId())); |
383 | - } else if(new Integer(0).equals(users.getType())) { //管理员 | |
384 | + } else if(UserTypeEnum.PLATFORM_ADMIN.equals(users.getType())) { //管理员 | |
384 | 385 | List<Organization> list2 =accessPermissionFacade.findAccessPerminssionByUserId(users.getId()); |
385 | 386 | if(CollectionUtils.isNotEmpty(list2)){ |
386 | 387 | for(Organization organization:list2){ |
387 | 388 | organizations.add(organization); |
388 | 389 | } |
389 | 390 | } |
390 | - } else if(new Integer(2).equals(users.getType())) {//超级管理员 | |
391 | + } else if(UserTypeEnum.SUPPER_ADMIN.equals(users.getType())) {//超级管理员 | |
391 | 392 | OrganizationQuery organizationQuery = new OrganizationQuery(); |
392 | 393 | organizationQuery.setYn(YnEnums.YES.getId()); |
393 | 394 | organizations = organizationService.queryOrganization(organizationQuery); |
... | ... | @@ -446,7 +447,7 @@ |
446 | 447 | return; |
447 | 448 | } |
448 | 449 | |
449 | - if(!usersList.get(0).getType().equals(0)) { | |
450 | + if(!usersList.get(0).getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId())) { | |
450 | 451 | ResultUtils.buildParameterErrorResultAndWrite(response, "用户错误"); |
451 | 452 | return; |
452 | 453 | } |
... | ... | @@ -540,7 +541,7 @@ |
540 | 541 | |
541 | 542 | //准备添加数据 |
542 | 543 | Users users = new Users(); |
543 | - users.setType(0); | |
544 | + users.setType(UserTypeEnum.PLATFORM_ADMIN.getId()); | |
544 | 545 | users.setName(name); |
545 | 546 | users.setAccount(account); |
546 | 547 | users.setPhone(phone); |
... | ... | @@ -645,7 +646,7 @@ |
645 | 646 | |
646 | 647 | //准备添加数据 |
647 | 648 | Users users = new Users(); |
648 | - users.setType(1); //1普通用户 | |
649 | + users.setType(UserTypeEnum.NORMAL_USER.getId()); //1普通用户 | |
649 | 650 | users.setDeptId(deptId); |
650 | 651 | users.setOrgId(orgId); |
651 | 652 | users.setName(name); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AutoMatchFacade.java
View file @
06e5670
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | import com.lyms.platform.biz.param.CommunityQuery; |
4 | 4 | import com.lyms.platform.biz.service.CommunityConfigService; |
5 | 5 | import com.lyms.platform.biz.service.PatientsService; |
6 | +import com.lyms.platform.common.enums.UserTypeEnum; | |
6 | 7 | import com.lyms.platform.common.enums.YnEnums; |
7 | 8 | import com.lyms.platform.permission.model.*; |
8 | 9 | import com.lyms.platform.permission.service.OrganizationService; |
... | ... | @@ -44,7 +45,7 @@ |
44 | 45 | List<Users> list = usersService.queryUsers(usersQuery); |
45 | 46 | if (CollectionUtils.isNotEmpty(list)) { |
46 | 47 | //用户角色 |
47 | - if (list.get(0).getType() == 1) { | |
48 | + if (UserTypeEnum.NORMAL_USER.equals(list.get(0).getType()) ) { | |
48 | 49 | Organization organization = organizationService.getOrganization(list.get(0).getOrgId()); |
49 | 50 | return organization.getAreaId(); |
50 | 51 | }else { |
51 | 52 | |
... | ... | @@ -63,13 +64,13 @@ |
63 | 64 | List<Integer> data = new ArrayList<>(); |
64 | 65 | if (CollectionUtils.isNotEmpty(list)) { |
65 | 66 | //用户角色 |
66 | - if (list.get(0).getType() == 1) { | |
67 | + if (UserTypeEnum.NORMAL_USER.getId().equals(list.get(0).getType())) { | |
67 | 68 | for(Users users:list){ |
68 | 69 | if(null!=users.getOrgId()){ |
69 | 70 | data.add(users.getOrgId()); |
70 | 71 | } |
71 | 72 | } |
72 | - } else if(list.get(0).getType() == 0){ | |
73 | + } else if(UserTypeEnum.PLATFORM_ADMIN.getId().equals(list.get(0).getType())){ | |
73 | 74 | List<Organization> list2 =accessPermissionFacade.findAccessPerminssionByUserId(list.get(0).getId()); |
74 | 75 | if(CollectionUtils.isNotEmpty(list2)){ |
75 | 76 | for(Organization organization:list2){ |
... | ... | @@ -85,7 +86,7 @@ |
85 | 86 | data.add(userOrganizationMaps.getOrgId()); |
86 | 87 | } |
87 | 88 | }*/ |
88 | - } else if(list.get(0).getType() == 2) { | |
89 | + } else if(UserTypeEnum.SUPPER_ADMIN.getId().equals(list.get(0).getType())) { | |
89 | 90 | return null; |
90 | 91 | } |
91 | 92 | } |