Commit 4044f61b03ea963ead2e6b5607203e0fbf339bd9
1 parent
065557a9a1
Exists in
master
and in
6 other branches
COMMIT
Showing 1 changed file with 1264 additions and 1234 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
View file @
4044f61
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.Date; | |
5 | +import java.util.HashMap; | |
6 | +import java.util.List; | |
7 | +import java.util.Map; | |
3 | 8 | |
9 | +import javax.servlet.http.HttpServletRequest; | |
10 | +import javax.servlet.http.HttpServletResponse; | |
11 | + | |
12 | +import org.apache.commons.collections.CollectionUtils; | |
13 | +import org.apache.commons.lang.StringUtils; | |
14 | +import org.apache.commons.lang.math.NumberUtils; | |
15 | +import org.springframework.beans.factory.annotation.Autowired; | |
16 | +import org.springframework.beans.factory.annotation.Value; | |
17 | +import org.springframework.http.MediaType; | |
18 | +import org.springframework.stereotype.Controller; | |
19 | +import org.springframework.web.bind.annotation.PathVariable; | |
20 | +import org.springframework.web.bind.annotation.RequestHeader; | |
21 | +import org.springframework.web.bind.annotation.RequestMapping; | |
22 | +import org.springframework.web.bind.annotation.RequestMethod; | |
23 | +import org.springframework.web.bind.annotation.RequestParam; | |
24 | +import org.springframework.web.bind.annotation.ResponseBody; | |
25 | + | |
4 | 26 | import com.lyms.platform.biz.service.BasicConfigService; |
5 | 27 | import com.lyms.platform.biz.service.OrganizationGroupsService; |
6 | 28 | import com.lyms.platform.common.annotation.TokenRequired; |
7 | 29 | |
8 | 30 | |
9 | 31 | |
10 | 32 | |
11 | 33 | |
12 | 34 | |
13 | 35 | |
14 | 36 | |
15 | 37 | |
16 | 38 | |
17 | 39 | |
18 | 40 | |
19 | 41 | |
20 | 42 | |
21 | 43 | |
22 | 44 | |
23 | 45 | |
24 | 46 | |
25 | 47 | |
26 | 48 | |
27 | 49 | |
... | ... | @@ -9,80 +31,91 @@ |
9 | 31 | import com.lyms.platform.common.base.PageInfo; |
10 | 32 | import com.lyms.platform.common.constants.ConstantInterface; |
11 | 33 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
12 | -import com.lyms.platform.common.enums.*; | |
13 | -import com.lyms.platform.common.utils.*; | |
34 | +import com.lyms.platform.common.enums.GroupEnums; | |
35 | +import com.lyms.platform.common.enums.HospitalStatusEnums; | |
36 | +import com.lyms.platform.common.enums.UserTypeEnum; | |
37 | +import com.lyms.platform.common.enums.YnEnums; | |
38 | +import com.lyms.platform.common.enums.ZhiChenEnums; | |
39 | +import com.lyms.platform.common.utils.CompressEncodeingUtil; | |
40 | +import com.lyms.platform.common.utils.DateUtil; | |
41 | +import com.lyms.platform.common.utils.JsonUtil; | |
42 | +import com.lyms.platform.common.utils.LoginUtil; | |
43 | +import com.lyms.platform.common.utils.MD5Utils; | |
44 | +import com.lyms.platform.common.utils.ResultUtils; | |
14 | 45 | import com.lyms.platform.operate.web.facade.AccessPermissionFacade; |
15 | 46 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
16 | 47 | import com.lyms.platform.operate.web.facade.OrganizationGroupsFacade; |
17 | 48 | import com.lyms.platform.operate.web.result.FrontEndResult; |
18 | 49 | import com.lyms.platform.operate.web.session.SessionProvider; |
19 | -import com.lyms.platform.operate.web.session.strategy.ISessionProvider; | |
20 | -import com.lyms.platform.permission.model.*; | |
21 | -import com.lyms.platform.permission.service.*; | |
50 | +import com.lyms.platform.permission.model.Departments; | |
51 | +import com.lyms.platform.permission.model.Organization; | |
52 | +import com.lyms.platform.permission.model.OrganizationQuery; | |
53 | +import com.lyms.platform.permission.model.Permissions2; | |
54 | +import com.lyms.platform.permission.model.Permissions2Query; | |
55 | +import com.lyms.platform.permission.model.Roles; | |
56 | +import com.lyms.platform.permission.model.RolesQuery; | |
57 | +import com.lyms.platform.permission.model.UserOrganizationMaps; | |
58 | +import com.lyms.platform.permission.model.UserOrganizationMapsQuery; | |
59 | +import com.lyms.platform.permission.model.UserRoleMaps; | |
60 | +import com.lyms.platform.permission.model.UserRoleMapsQuery; | |
61 | +import com.lyms.platform.permission.model.Users; | |
62 | +import com.lyms.platform.permission.model.UsersQuery; | |
63 | +import com.lyms.platform.permission.service.DepartmentsService; | |
64 | +import com.lyms.platform.permission.service.OrganizationService; | |
65 | +import com.lyms.platform.permission.service.Permissions2Service; | |
66 | +import com.lyms.platform.permission.service.RolesService; | |
67 | +import com.lyms.platform.permission.service.UserOrganizationMapsService; | |
68 | +import com.lyms.platform.permission.service.UserRoleMapsService; | |
69 | +import com.lyms.platform.permission.service.UsersService; | |
22 | 70 | import com.lyms.platform.pojo.BasicConfig; |
23 | 71 | import com.lyms.platform.pojo.DataPermissionsModel; |
24 | 72 | import com.lyms.platform.pojo.OrganizationGroups; |
25 | -import org.apache.commons.collections.CollectionUtils; | |
26 | -import org.apache.commons.lang.StringUtils; | |
27 | -import org.apache.commons.lang.math.*; | |
28 | -import org.apache.commons.lang.math.NumberUtils; | |
29 | -import org.springframework.beans.factory.annotation.Autowired; | |
30 | -import org.springframework.beans.factory.annotation.Value; | |
31 | -import org.springframework.http.MediaType; | |
32 | -import org.springframework.stereotype.Controller; | |
33 | -import org.springframework.web.bind.annotation.*; | |
34 | 73 | |
35 | -import javax.management.relation.Role; | |
36 | -import javax.servlet.http.HttpServletRequest; | |
37 | -import javax.servlet.http.HttpServletResponse; | |
38 | -import javax.validation.constraints.Pattern; | |
39 | -import java.util.*; | |
40 | - | |
41 | 74 | /** |
42 | 75 | * Created by Administrator on 2015/9/25 0025. |
43 | 76 | */ |
44 | 77 | @Controller |
45 | 78 | public class UsersController extends BaseController { |
46 | 79 | @Autowired |
47 | - private DepartmentsService departmentsService; | |
80 | + private DepartmentsService departmentsService; | |
48 | 81 | |
49 | 82 | @Autowired |
50 | - private UsersService usersService; | |
83 | + private UsersService usersService; | |
51 | 84 | @Autowired |
52 | - private OrganizationGroupsFacade groupsFacade; | |
85 | + private OrganizationGroupsFacade groupsFacade; | |
53 | 86 | @Autowired |
54 | - private UserRoleMapsService userRoleMapsService; | |
87 | + private UserRoleMapsService userRoleMapsService; | |
55 | 88 | @Autowired |
56 | - private RolesService rolesService; | |
89 | + private RolesService rolesService; | |
57 | 90 | @Autowired |
58 | - UserOrganizationMapsService userOrganizationMapsService; | |
91 | + UserOrganizationMapsService userOrganizationMapsService; | |
59 | 92 | @Autowired |
60 | - OrganizationService organizationService; | |
93 | + OrganizationService organizationService; | |
61 | 94 | @Value("#{configProperties['login.token']}") |
62 | - private String token; | |
95 | + private String token; | |
63 | 96 | @Value("#{configProperties['login.typeId']}") |
64 | - private String typeId; | |
97 | + private String typeId; | |
65 | 98 | @Value("#{configProperties['login.defaultPwd']}") |
66 | - private String defaultPwd; | |
99 | + private String defaultPwd; | |
67 | 100 | @Value("#{configProperties['defaultAdminOrgId']}") |
68 | - private String defaultAdminOrgId; | |
101 | + private String defaultAdminOrgId; | |
69 | 102 | @Autowired |
70 | 103 | private OrganizationGroupsService groupsService; |
71 | 104 | @Autowired |
72 | - private Permissions2Service permissions2Service; | |
105 | + private Permissions2Service permissions2Service; | |
73 | 106 | @Autowired |
74 | - private AccessPermissionFacade accessPermissionFacade; | |
107 | + private AccessPermissionFacade accessPermissionFacade; | |
75 | 108 | @Autowired |
76 | - private SessionProvider iSessionProvider; | |
109 | + private SessionProvider iSessionProvider; | |
77 | 110 | @Autowired |
78 | - private AutoMatchFacade autoMatchFacade; | |
111 | + private AutoMatchFacade autoMatchFacade; | |
79 | 112 | @Autowired |
80 | - private BasicConfigService basicConfigService; | |
113 | + private BasicConfigService basicConfigService; | |
81 | 114 | |
82 | - private static final String LYMS = "龙源美生"; | |
115 | + private static final String LYMS = "龙源美生"; | |
83 | 116 | |
84 | - private static final String ADMIN = "管理员"; | |
85 | - private static final String replacePwd = "[$#&/]-+"; | |
117 | + private static final String ADMIN = "管理员"; | |
118 | + private static final String replacePwd = "[$#&/]-+"; | |
86 | 119 | |
87 | 120 | @RequestMapping(value = "/rebuildUserRoles", method = RequestMethod.GET) |
88 | 121 | @ResponseBody |
... | ... | @@ -122,7 +155,8 @@ |
122 | 155 | dbmaps.setUserId(users.getId()); |
123 | 156 | userRoleMapsService.addUserRoleMaps(dbmaps); |
124 | 157 | userRoleMapsService.deleteUserRoleMaps(maps.getId()); |
125 | - sb.append("<br>success userid:" + users.getId() + " -- " + JsonUtil.obj2JsonString(dbmaps) + " -- " + JsonUtil.obj2JsonString(maps)); | |
158 | + sb.append("<br>success userid:" + users.getId() + " -- " + JsonUtil.obj2JsonString(dbmaps) | |
159 | + + " -- " + JsonUtil.obj2JsonString(maps)); | |
126 | 160 | } |
127 | 161 | } |
128 | 162 | } |
... | ... | @@ -163,7 +197,8 @@ |
163 | 197 | for (Users user : users) { |
164 | 198 | user.setRoles(this.getUserRoles(user.getId())); |
165 | 199 | user.setDepartmentses(departmentsService.getDepartments(user.getDeptId())); |
166 | - List<DataPermissionsModel> permissionsModelList = accessPermissionFacade.findAccessPerminssionByUserId(user.getId()); | |
200 | + List<DataPermissionsModel> permissionsModelList = accessPermissionFacade.findAccessPerminssionByUserId(user | |
201 | + .getId()); | |
167 | 202 | user.setOrganizations(accessPermissionFacade.getOrganization(permissionsModelList)); |
168 | 203 | if (permissionsModelList != null && permissionsModelList.size() > 0) { |
169 | 204 | user.setAreaPermission(permissionsModelList.get(0).getAreaPermission()); |
... | ... | @@ -193,8 +228,7 @@ |
193 | 228 | @RequestMapping(value = "/users", method = RequestMethod.GET) |
194 | 229 | @TokenRequired |
195 | 230 | @ResponseBody |
196 | - public FrontEndResult getPermissions(HttpServletResponse response, | |
197 | - HttpServletRequest request, | |
231 | + public FrontEndResult getPermissions(HttpServletResponse response, HttpServletRequest request, | |
198 | 232 | @RequestParam(value = "keyword", required = false) String keyword, |
199 | 233 | @RequestParam(value = "rolesId", required = false) Integer rolesId, |
200 | 234 | @RequestParam(value = "page", required = false) Integer page, |
201 | 235 | |
... | ... | @@ -204,11 +238,23 @@ |
204 | 238 | LoginContext loginContext = (LoginContext) request.getAttribute("loginContext"); |
205 | 239 | Users u = usersService.getUsers(loginContext.getId()); |
206 | 240 | |
207 | - | |
208 | 241 | List<Integer> ids = null; |
209 | 242 | if (u.getType().equals(UserTypeEnum.NORMAL_USER.getId())) { |
210 | - if (null != u.getOrgId()) { | |
211 | - orgId = u.getOrgId(); | |
243 | + /* if (null != u.getOrgId()) { | |
244 | + orgId = u.getOrgId(); | |
245 | + } else { | |
246 | + FrontEndResult frontEndResult = new FrontEndResult(); | |
247 | + frontEndResult.setPageInfo(new PageInfo(0, 0, 0, 10)); | |
248 | + frontEndResult.setErrorcode(ErrorCodeConstants.SUCCESS); | |
249 | + return frontEndResult; | |
250 | + }*/ | |
251 | + List<Organization> organizations = accessPermissionFacade.getOrganization(accessPermissionFacade | |
252 | + .findAccessPerminssionByUserId(u.getId())); | |
253 | + ids = new ArrayList<>(); | |
254 | + if (CollectionUtils.isNotEmpty(organizations)) { | |
255 | + for (Organization organization : organizations) { | |
256 | + ids.add(organization.getId()); | |
257 | + } | |
212 | 258 | } else { |
213 | 259 | FrontEndResult frontEndResult = new FrontEndResult(); |
214 | 260 | frontEndResult.setPageInfo(new PageInfo(0, 0, 0, 10)); |
... | ... | @@ -216,7 +262,8 @@ |
216 | 262 | return frontEndResult; |
217 | 263 | } |
218 | 264 | } else if (u.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId())) { |
219 | - List<Organization> organizations = accessPermissionFacade.getOrganization(accessPermissionFacade.findAccessPerminssionByUserId(u.getId())); | |
265 | + List<Organization> organizations = accessPermissionFacade.getOrganization(accessPermissionFacade | |
266 | + .findAccessPerminssionByUserId(u.getId())); | |
220 | 267 | ids = new ArrayList<>(); |
221 | 268 | if (CollectionUtils.isNotEmpty(organizations)) { |
222 | 269 | for (Organization organization : organizations) { |
... | ... | @@ -250,7 +297,6 @@ |
250 | 297 | usersQuery.setLimit(limit); |
251 | 298 | usersQuery.setRoleId(rolesId); |
252 | 299 | |
253 | - | |
254 | 300 | List<Users> users = usersService.queryUsers2(usersQuery); |
255 | 301 | List<Organization> organizations = null; |
256 | 302 | //设置用户角色信息 |
257 | 303 | |
... | ... | @@ -266,12 +312,13 @@ |
266 | 312 | if (null != user.getZhiChenId()) { |
267 | 313 | user.setZhiChen(ZhiChenEnums.getById(user.getZhiChenId())); |
268 | 314 | } |
269 | - List<DataPermissionsModel> permissionsModelList = accessPermissionFacade.findAccessPerminssionByUserId(user.getId()); | |
315 | + List<DataPermissionsModel> permissionsModelList = accessPermissionFacade.findAccessPerminssionByUserId(user | |
316 | + .getId()); | |
270 | 317 | user.setOrganizations(accessPermissionFacade.getOrganization(permissionsModelList)); |
271 | 318 | if (permissionsModelList != null && permissionsModelList.size() > 0) { |
272 | 319 | user.setAreaPermission(permissionsModelList.get(0).getAreaPermission()); |
273 | 320 | } |
274 | -// user.setPwd(StringUtils.isEmpty(user.getPwd())?user.getPwd():user.getPwd().replaceAll(".","*")); | |
321 | + // user.setPwd(StringUtils.isEmpty(user.getPwd())?user.getPwd():user.getPwd().replaceAll(".","*")); | |
275 | 322 | user.setPwd(replacePwd); |
276 | 323 | } |
277 | 324 | |
... | ... | @@ -281,7 +328,7 @@ |
281 | 328 | frontEndResult.setErrorcode(ErrorCodeConstants.SUCCESS); |
282 | 329 | |
283 | 330 | return frontEndResult; |
284 | -// ResultUtils.buildSuccessResultAndWrite(response, frontEndResult); | |
331 | + // ResultUtils.buildSuccessResultAndWrite(response, frontEndResult); | |
285 | 332 | } |
286 | 333 | |
287 | 334 | //获取用户角色信息 |
... | ... | @@ -297,7 +344,6 @@ |
297 | 344 | return roles; |
298 | 345 | } |
299 | 346 | |
300 | - | |
301 | 347 | /** |
302 | 348 | * AMS 用户请求登录,获取token |
303 | 349 | */ |
304 | 350 | |
... | ... | @@ -345,16 +391,15 @@ |
345 | 391 | } |
346 | 392 | } |
347 | 393 | |
348 | - | |
349 | 394 | LoginContext loginContext = new LoginContext(); |
350 | 395 | loginContext.setErrormsg("服务器内部错误!"); |
351 | 396 | loginContext = iSessionProvider.login(account, password, code); |
352 | - /* if(null != code) { | |
353 | - loginContext =LoginUtil.loginByPhone(account, code, typeId, token); | |
354 | - } | |
355 | - if(null != password) { | |
356 | - loginContext = LoginUtil.loginByAccount(account, password, typeId, token); | |
357 | - }*/ | |
397 | + /* if(null != code) { | |
398 | + loginContext =LoginUtil.loginByPhone(account, code, typeId, token); | |
399 | + } | |
400 | + if(null != password) { | |
401 | + loginContext = LoginUtil.loginByAccount(account, password, typeId, token); | |
402 | + }*/ | |
358 | 403 | |
359 | 404 | if (null != loginContext && loginContext.getErrorcode().equals(0)) { |
360 | 405 | if (u.getLastLoginTime() != null) { |
... | ... | @@ -377,9 +422,9 @@ |
377 | 422 | * |
378 | 423 | * @param phone |
379 | 424 | */ |
380 | - @RequestMapping(value = "/vercode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8") | |
381 | - public void sendVerCode(@RequestParam("phone") String phone, | |
382 | - HttpServletResponse httpServletResponse) { | |
425 | + @RequestMapping(value = "/vercode", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE | |
426 | + + ";charset=utf-8") | |
427 | + public void sendVerCode(@RequestParam("phone") String phone, HttpServletResponse httpServletResponse) { | |
383 | 428 | |
384 | 429 | if (StringUtils.isEmpty(phone)) { |
385 | 430 | ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse); |
386 | 431 | |
... | ... | @@ -406,14 +451,14 @@ |
406 | 451 | |
407 | 452 | LoginContext loginContext = LoginUtil.sendVerCode(phone, typeId, token); |
408 | 453 | if (null != loginContext) { |
409 | - ResultUtils.buildResultAndWrite(httpServletResponse, loginContext.getErrorcode(), loginContext.getErrormsg()); | |
454 | + ResultUtils.buildResultAndWrite(httpServletResponse, loginContext.getErrorcode(), | |
455 | + loginContext.getErrormsg()); | |
410 | 456 | return; |
411 | 457 | } |
412 | 458 | ResultUtils.buildResultAndWrite(httpServletResponse, ErrorCodeConstants.SYSTEM_ERROR, "服务器内部错误"); |
413 | 459 | |
414 | 460 | } |
415 | 461 | |
416 | - | |
417 | 462 | /** |
418 | 463 | * 获取 登录用户信息(用户、最后登录时间) |
419 | 464 | */ |
420 | 465 | |
... | ... | @@ -438,10 +483,10 @@ |
438 | 483 | permissionsQuery.setYn(YnEnums.YES.getId()); |
439 | 484 | permissions = permissions2Service.queryPermissions2(permissionsQuery); |
440 | 485 | |
441 | - | |
442 | 486 | } |
443 | 487 | //其他用户 |
444 | - else if (users.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId()) || users.getType().equals(UserTypeEnum.NORMAL_USER.getId())) { | |
488 | + else if (users.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId()) | |
489 | + || users.getType().equals(UserTypeEnum.NORMAL_USER.getId())) { | |
445 | 490 | //获取用户角色信息 |
446 | 491 | UserRoleMapsQuery query = new UserRoleMapsQuery(); |
447 | 492 | query.setUserId(users.getId()); |
... | ... | @@ -472,7 +517,8 @@ |
472 | 517 | } |
473 | 518 | } |
474 | 519 | |
475 | - List<DataPermissionsModel> permissionsModelList = accessPermissionFacade.findAccessPerminssionByUserId(users.getId()); | |
520 | + List<DataPermissionsModel> permissionsModelList = accessPermissionFacade.findAccessPerminssionByUserId(users | |
521 | + .getId()); | |
476 | 522 | if (permissionsModelList != null && permissionsModelList.size() > 0) { |
477 | 523 | users.setAreaPermission(permissionsModelList.get(0).getAreaPermission()); |
478 | 524 | } |
479 | 525 | |
480 | 526 | |
... | ... | @@ -483,32 +529,32 @@ |
483 | 529 | organizations = organizationService.queryOrganization(organizationQuery); |
484 | 530 | } else { |
485 | 531 | Organization organization = organizationService.getOrganization(users.getOrgId()); |
486 | - if(null!=organization&&StringUtils.isNotEmpty(organization.getCityId())){ | |
487 | - BasicConfig bg= basicConfigService.getOneBasicConfigById(organization.getCityId()); | |
488 | - Map<String,String> map = new HashMap<>(); | |
489 | - map.put("id",organization.getCityId()); | |
490 | - if(null!=bg){ | |
491 | - map.put("name",bg.getName()); | |
532 | + if (null != organization && StringUtils.isNotEmpty(organization.getCityId())) { | |
533 | + BasicConfig bg = basicConfigService.getOneBasicConfigById(organization.getCityId()); | |
534 | + Map<String, String> map = new HashMap<>(); | |
535 | + map.put("id", organization.getCityId()); | |
536 | + if (null != bg) { | |
537 | + map.put("name", bg.getName()); | |
492 | 538 | } |
493 | 539 | organization.setCity(map); |
494 | 540 | } |
495 | 541 | |
496 | - if(null!=organization&&StringUtils.isNotEmpty(organization.getProvinceId())){ | |
497 | - BasicConfig bg= basicConfigService.getOneBasicConfigById(organization.getProvinceId()); | |
498 | - Map<String,String> map = new HashMap<>(); | |
499 | - map.put("id",organization.getProvinceId()); | |
500 | - if(null!=bg){ | |
501 | - map.put("name",bg.getName()); | |
542 | + if (null != organization && StringUtils.isNotEmpty(organization.getProvinceId())) { | |
543 | + BasicConfig bg = basicConfigService.getOneBasicConfigById(organization.getProvinceId()); | |
544 | + Map<String, String> map = new HashMap<>(); | |
545 | + map.put("id", organization.getProvinceId()); | |
546 | + if (null != bg) { | |
547 | + map.put("name", bg.getName()); | |
502 | 548 | } |
503 | 549 | organization.setProvince(map); |
504 | 550 | } |
505 | 551 | |
506 | - if(null!=organization&&StringUtils.isNotEmpty(organization.getAreaId())){ | |
507 | - BasicConfig bg= basicConfigService.getOneBasicConfigById(organization.getAreaId()); | |
508 | - Map<String,String> map = new HashMap<>(); | |
509 | - map.put("id",organization.getAreaId()); | |
510 | - if(null!=bg){ | |
511 | - map.put("name",bg.getName()); | |
552 | + if (null != organization && StringUtils.isNotEmpty(organization.getAreaId())) { | |
553 | + BasicConfig bg = basicConfigService.getOneBasicConfigById(organization.getAreaId()); | |
554 | + Map<String, String> map = new HashMap<>(); | |
555 | + map.put("id", organization.getAreaId()); | |
556 | + if (null != bg) { | |
557 | + map.put("name", bg.getName()); | |
512 | 558 | } |
513 | 559 | organization.setArea(map); |
514 | 560 | } |
... | ... | @@ -552,7 +598,8 @@ |
552 | 598 | */ |
553 | 599 | @RequestMapping(value = "/users/userRole/{id}", method = RequestMethod.GET) |
554 | 600 | @TokenRequired |
555 | - public void userRole(HttpServletResponse response, HttpServletRequest request, @PathVariable(value = "id") Integer id) { | |
601 | + public void userRole(HttpServletResponse response, HttpServletRequest request, | |
602 | + @PathVariable(value = "id") Integer id) { | |
556 | 603 | UserRoleMapsQuery query = new UserRoleMapsQuery(); |
557 | 604 | query.setUserId(id); |
558 | 605 | query.setYn(YnEnums.YES.getId()); |
559 | 606 | |
... | ... | @@ -565,13 +612,13 @@ |
565 | 612 | ResultUtils.buildSuccessResultAndWrite(response, roles); |
566 | 613 | } |
567 | 614 | |
568 | - | |
569 | 615 | /** |
570 | 616 | * 管理员权限设置 |
571 | 617 | */ |
572 | 618 | @RequestMapping(value = "/adminPermissions", method = RequestMethod.POST) |
573 | 619 | @TokenRequired |
574 | - public void adminPermissions(HttpServletResponse response, @RequestParam(value = "userId") Integer userId, @RequestParam(value = "ids") String ids) { | |
620 | + public void adminPermissions(HttpServletResponse response, @RequestParam(value = "userId") Integer userId, | |
621 | + @RequestParam(value = "ids") String ids) { | |
575 | 622 | |
576 | 623 | if (ids == null) { |
577 | 624 | ResultUtils.buildParameterErrorResultAndWrite(response); |
... | ... | @@ -598,7 +645,8 @@ |
598 | 645 | //将已有映射设为失效 |
599 | 646 | UserOrganizationMapsQuery userOrganizationMapsQuery = new UserOrganizationMapsQuery(); |
600 | 647 | userOrganizationMapsQuery.setUserId(userId); |
601 | - List<UserOrganizationMaps> userOrganizationMapsList = userOrganizationMapsService.queryUserOrganizationMaps(userOrganizationMapsQuery); | |
648 | + List<UserOrganizationMaps> userOrganizationMapsList = userOrganizationMapsService | |
649 | + .queryUserOrganizationMaps(userOrganizationMapsQuery); | |
602 | 650 | if (0 < userOrganizationMapsList.size()) { |
603 | 651 | for (UserOrganizationMaps userOrganizationMaps : userOrganizationMapsList) { |
604 | 652 | userOrganizationMaps.setYn(YnEnums.NO.getId()); |
... | ... | @@ -622,7 +670,6 @@ |
622 | 670 | } |
623 | 671 | } |
624 | 672 | |
625 | - | |
626 | 673 | //修改user相关字段 |
627 | 674 | user.setModified(new Date()); |
628 | 675 | usersService.updateUsers(user); |
... | ... | @@ -630,7 +677,6 @@ |
630 | 677 | ResultUtils.buildSuccessResultAndWrite(response); |
631 | 678 | } |
632 | 679 | |
633 | - | |
634 | 680 | private Boolean isPhone(String phone) { |
635 | 681 | return phone.matches("^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\\d{8})$"); |
636 | 682 | } |
... | ... | @@ -640,8 +686,7 @@ |
640 | 686 | */ |
641 | 687 | @RequestMapping(value = "/admins", method = RequestMethod.POST) |
642 | 688 | @TokenRequired |
643 | - public void addAdmin(HttpServletResponse response, | |
644 | - HttpServletRequest request, | |
689 | + public void addAdmin(HttpServletResponse response, HttpServletRequest request, | |
645 | 690 | @RequestParam(value = "name", required = false) String name, |
646 | 691 | @RequestParam(value = "account", required = false) String account, |
647 | 692 | @RequestParam(value = "phone") String phone, |
648 | 693 | |
... | ... | @@ -649,14 +694,11 @@ |
649 | 694 | @RequestParam(value = "remarks", required = false) String remarks, |
650 | 695 | @RequestParam(value = "roleIds") String roleIds) { |
651 | 696 | |
652 | - | |
653 | 697 | //获取登录用户 |
654 | 698 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
655 | 699 | Users user = usersService.getUsers(loginState.getId()); |
656 | 700 | |
657 | - | |
658 | - if (StringUtils.isBlank(roleIds) || | |
659 | - StringUtils.isBlank(name) || StringUtils.isBlank(phone) || null == user) { | |
701 | + if (StringUtils.isBlank(roleIds) || StringUtils.isBlank(name) || StringUtils.isBlank(phone) || null == user) { | |
660 | 702 | ResultUtils.buildParameterErrorResultAndWrite(response); |
661 | 703 | return; |
662 | 704 | } |
... | ... | @@ -666,15 +708,15 @@ |
666 | 708 | return; |
667 | 709 | } |
668 | 710 | |
669 | - /* //根据当前登录的用户判断是否 有管理员的权限 | |
670 | - List<String> list = userRoleMapsService.queryUserRoleName(loginState.getId()); | |
671 | - if(CollectionUtils.isEmpty(list) ||!list.contains(ADMIN)){ | |
672 | - Map<String, Object> map = new HashMap<>(); | |
673 | - map.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR); | |
674 | - map.put(ResultUtils.ERROR_MSG, "你没有足够的权限."); | |
675 | - writeJson(response, JsonUtil.obj2JsonString(map)); | |
676 | - return; | |
677 | - }*/ | |
711 | + /* //根据当前登录的用户判断是否 有管理员的权限 | |
712 | + List<String> list = userRoleMapsService.queryUserRoleName(loginState.getId()); | |
713 | + if(CollectionUtils.isEmpty(list) ||!list.contains(ADMIN)){ | |
714 | + Map<String, Object> map = new HashMap<>(); | |
715 | + map.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR); | |
716 | + map.put(ResultUtils.ERROR_MSG, "你没有足够的权限."); | |
717 | + writeJson(response, JsonUtil.obj2JsonString(map)); | |
718 | + return; | |
719 | + }*/ | |
678 | 720 | if (user != null) { |
679 | 721 | |
680 | 722 | //检查注册账户是否存在 |
681 | 723 | |
682 | 724 | |
683 | 725 | |
... | ... | @@ -704,22 +746,20 @@ |
704 | 746 | users.setYn(YnEnums.YES.getId()); |
705 | 747 | users.setModified(new Date()); |
706 | 748 | users.setCreated(new Date()); |
707 | -// users.setLastLoginTime(new Date()); | |
708 | -// users.setPwd(LoginUtil.md5(NumberUtils.getRandomString(6))); | |
749 | + // users.setLastLoginTime(new Date()); | |
750 | + // users.setPwd(LoginUtil.md5(NumberUtils.getRandomString(6))); | |
709 | 751 | |
710 | 752 | //关联登录中心ID |
711 | 753 | LoginContext loginContext = null; |
712 | -// loginContext = LoginUtil.register(null, phone, null, null, token, typeId); | |
754 | + // loginContext = LoginUtil.register(null, phone, null, null, token, typeId); | |
713 | 755 | loginContext = iSessionProvider.register(null, phone, null, null); |
714 | 756 | //0 成功 4009 已注册 |
715 | 757 | if (loginContext.getErrorcode().equals(0) || loginContext.getErrorcode().equals(4009)) { |
716 | 758 | users.setLogincenterId(loginContext.getId()); |
717 | 759 | usersService.addUsers(users); |
718 | 760 | |
719 | - | |
720 | 761 | //如有角色,则对用户角色中间表新增 |
721 | 762 | |
722 | - | |
723 | 763 | String[] roleArrayIds = roleIds.split(","); |
724 | 764 | List<Users> user1 = usersService.queryUsers(usersQuery); |
725 | 765 | for (String id : roleArrayIds) { |
726 | 766 | |
... | ... | @@ -745,14 +785,12 @@ |
745 | 785 | } |
746 | 786 | } |
747 | 787 | |
748 | - | |
749 | 788 | /** |
750 | 789 | * 添加用户信息 |
751 | 790 | */ |
752 | 791 | @RequestMapping(value = "/users", method = RequestMethod.POST) |
753 | 792 | @TokenRequired |
754 | - public void addUsers(HttpServletResponse response, | |
755 | - HttpServletRequest request, | |
793 | + public void addUsers(HttpServletResponse response, HttpServletRequest request, | |
756 | 794 | @RequestParam(value = "orgId") Integer orgId, |
757 | 795 | @RequestParam(value = "deptId", required = false) Integer deptId, |
758 | 796 | @RequestParam(value = "ksId", required = false) Integer ksId, |
759 | 797 | |
760 | 798 | |
... | ... | @@ -762,16 +800,14 @@ |
762 | 800 | @RequestParam(value = "phone", required = false) String phone, |
763 | 801 | @RequestParam(value = "enable", required = false) Integer enable, |
764 | 802 | @RequestParam(value = "remarks", required = false) String remarks, |
765 | - @RequestParam(value = "roleIds") String roleIds, | |
766 | - @RequestParam(value = "zhiCId") Integer zhiCId) { | |
803 | + @RequestParam(value = "roleIds") String roleIds, @RequestParam(value = "zhiCId") Integer zhiCId) { | |
767 | 804 | |
768 | - | |
769 | 805 | //获取登录用户 |
770 | 806 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
771 | 807 | Users user = usersService.getUsers(loginState.getId()); |
772 | 808 | |
773 | - | |
774 | - if (StringUtils.isBlank(roleIds) || null == user || (StringUtils.isBlank(account) && StringUtils.isBlank(phone))) { | |
809 | + if (StringUtils.isBlank(roleIds) || null == user | |
810 | + || (StringUtils.isBlank(account) && StringUtils.isBlank(phone))) { | |
775 | 811 | ResultUtils.buildParameterErrorResultAndWrite(response); |
776 | 812 | return; |
777 | 813 | } |
... | ... | @@ -788,14 +824,14 @@ |
788 | 824 | return; |
789 | 825 | } |
790 | 826 | //根据当前登录的用户判断是否 有管理员的权限 |
791 | - /* List<String> list = userRoleMapsService.queryUserRoleName(loginState.getId()); | |
792 | - if(CollectionUtils.isEmpty(list) ||!list.contains(ADMIN)){ | |
793 | - Map<String, Object> map = new HashMap<>(); | |
794 | - map.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR); | |
795 | - map.put(ResultUtils.ERROR_MSG, "你没有足够的权限."); | |
796 | - writeJson(response, JsonUtil.obj2JsonString(map)); | |
797 | - return; | |
798 | - }*/ | |
827 | + /* List<String> list = userRoleMapsService.queryUserRoleName(loginState.getId()); | |
828 | + if(CollectionUtils.isEmpty(list) ||!list.contains(ADMIN)){ | |
829 | + Map<String, Object> map = new HashMap<>(); | |
830 | + map.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR); | |
831 | + map.put(ResultUtils.ERROR_MSG, "你没有足够的权限."); | |
832 | + writeJson(response, JsonUtil.obj2JsonString(map)); | |
833 | + return; | |
834 | + }*/ | |
799 | 835 | if (user != null) { |
800 | 836 | UsersQuery usersQuery = new UsersQuery(); |
801 | 837 | if (StringUtils.isNotBlank(phone)) { |
... | ... | @@ -827,7 +863,7 @@ |
827 | 863 | |
828 | 864 | //准备添加数据 |
829 | 865 | Users users = new Users(); |
830 | - users.setType(UserTypeEnum.NORMAL_USER.getId()); //1普通用户 | |
866 | + users.setType(UserTypeEnum.NORMAL_USER.getId()); //1普通用户 | |
831 | 867 | users.setDeptId(deptId); |
832 | 868 | users.setOrgId(orgId); |
833 | 869 | users.setName(name); |
834 | 870 | |
835 | 871 | |
... | ... | @@ -844,20 +880,20 @@ |
844 | 880 | users.setModified(new Date()); |
845 | 881 | users.setCreated(new Date()); |
846 | 882 | users.setZhiChen(ZhiChenEnums.getById(zhiCId)); |
847 | -// users.setLastLoginTime(new Date()); | |
848 | -// users.setPwd(LoginUtil.md5(NumberUtils.getRandomString(6))); | |
883 | + // users.setLastLoginTime(new Date()); | |
884 | + // users.setPwd(LoginUtil.md5(NumberUtils.getRandomString(6))); | |
849 | 885 | |
850 | 886 | LoginContext loginContext = new LoginContext(); |
851 | 887 | loginContext.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); |
852 | 888 | loginContext.setErrormsg("系统错误"); |
853 | 889 | //关联登录中心ID |
854 | 890 | if (StringUtils.isNotBlank(phone) || StringUtils.isNotBlank(account)) { |
855 | - /**/ | |
891 | + /**/ | |
856 | 892 | String pwd = null; |
857 | 893 | if (StringUtils.isNotBlank(password)) { |
858 | 894 | pwd = MD5Utils.md5(password).toUpperCase(); |
859 | 895 | } |
860 | -// loginContext = LoginUtil.register(null, phone,account, pwd, token, typeId); | |
896 | + // loginContext = LoginUtil.register(null, phone,account, pwd, token, typeId); | |
861 | 897 | loginContext = iSessionProvider.register(null, phone, account, pwd); |
862 | 898 | } |
863 | 899 | |
864 | 900 | |
... | ... | @@ -891,14 +927,12 @@ |
891 | 927 | } |
892 | 928 | } |
893 | 929 | |
894 | - | |
895 | 930 | /** |
896 | 931 | * 用户修改 |
897 | 932 | */ |
898 | 933 | @RequestMapping(value = "/users/{id}", method = RequestMethod.PUT) |
899 | 934 | @TokenRequired |
900 | - public void updateUsers(HttpServletResponse response, | |
901 | - HttpServletRequest request, | |
935 | + public void updateUsers(HttpServletResponse response, HttpServletRequest request, | |
902 | 936 | @PathVariable(value = "id") Integer id, |
903 | 937 | @RequestParam(value = "name", required = false) String name, |
904 | 938 | @RequestParam(value = "account", required = false) String account, |
... | ... | @@ -940,14 +974,14 @@ |
940 | 974 | } |
941 | 975 | |
942 | 976 | //根据当前登录的用户判断是否 有管理员的权限 |
943 | - /* List<String> list = userRoleMapsService.queryUserRoleName(loginState.getId()); | |
944 | - if(CollectionUtils.isEmpty(list) ||!list.contains(ADMIN)){ | |
945 | - Map<String, Object> map = new HashMap<>(); | |
946 | - map.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR); | |
947 | - map.put(ResultUtils.ERROR_MSG, "你没有足够的权限."); | |
948 | - writeJson(response, JsonUtil.obj2JsonString(map)); | |
949 | - return; | |
950 | - }*/ | |
977 | + /* List<String> list = userRoleMapsService.queryUserRoleName(loginState.getId()); | |
978 | + if(CollectionUtils.isEmpty(list) ||!list.contains(ADMIN)){ | |
979 | + Map<String, Object> map = new HashMap<>(); | |
980 | + map.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR); | |
981 | + map.put(ResultUtils.ERROR_MSG, "你没有足够的权限."); | |
982 | + writeJson(response, JsonUtil.obj2JsonString(map)); | |
983 | + return; | |
984 | + }*/ | |
951 | 985 | if (null == users) { |
952 | 986 | Map<String, Object> map = new HashMap<>(); |
953 | 987 | map.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR); |
954 | 988 | |
... | ... | @@ -956,10 +990,11 @@ |
956 | 990 | return; |
957 | 991 | } |
958 | 992 | |
959 | - | |
960 | 993 | //修改了手机号, 帐号 密码 |
961 | 994 | if (!new Integer(1).equals(users.getOtherAccount())) { |
962 | - if ((StringUtils.isNotBlank(account) && !account.equals(users.getAccount())) || (StringUtils.isNotBlank(phone) && !phone.equals(users.getPhone())) || (StringUtils.isNotBlank(password) && !password.equals(users.getPwd()))) { | |
995 | + if ((StringUtils.isNotBlank(account) && !account.equals(users.getAccount())) | |
996 | + || (StringUtils.isNotBlank(phone) && !phone.equals(users.getPhone())) | |
997 | + || (StringUtils.isNotBlank(password) && !password.equals(users.getPwd()))) { | |
963 | 998 | UsersQuery usersQuery = new UsersQuery(); |
964 | 999 | List<Users> usersList; |
965 | 1000 | if (StringUtils.isNotBlank(phone) && !phone.equals(users.getPhone())) { |
... | ... | @@ -991,9 +1026,9 @@ |
991 | 1026 | } |
992 | 1027 | } |
993 | 1028 | |
994 | - | |
995 | -// LoginContext loginContext = LoginUtil.register(users.getLogincenterId().toString(), phone, account, MD5Utils.md5(password).toUpperCase(), token, typeId); | |
996 | - LoginContext loginContext = iSessionProvider.register(users.getLogincenterId(), phone, account, StringUtils.isNotBlank(password) ? MD5Utils.md5(password).toUpperCase() : null); | |
1029 | + // LoginContext loginContext = LoginUtil.register(users.getLogincenterId().toString(), phone, account, MD5Utils.md5(password).toUpperCase(), token, typeId); | |
1030 | + LoginContext loginContext = iSessionProvider.register(users.getLogincenterId(), phone, account, | |
1031 | + StringUtils.isNotBlank(password) ? MD5Utils.md5(password).toUpperCase() : null); | |
997 | 1032 | //0 成功 4009 已注册 |
998 | 1033 | if (loginContext.getErrorcode().equals(0) || loginContext.getErrorcode().equals(4009)) { |
999 | 1034 | users.setPhone(phone); |
1000 | 1035 | |
... | ... | @@ -1001,13 +1036,13 @@ |
1001 | 1036 | users.setLogincenterId(loginContext.getId()); |
1002 | 1037 | users.setPwd(StringUtils.isNotBlank(password) ? MD5Utils.md5(password).toUpperCase() : null); |
1003 | 1038 | } else { |
1004 | - ResultUtils.buildResultAndWrite(response, ErrorCodeConstants.SYSTEM_ERROR, loginContext.getErrormsg()); | |
1039 | + ResultUtils.buildResultAndWrite(response, ErrorCodeConstants.SYSTEM_ERROR, | |
1040 | + loginContext.getErrormsg()); | |
1005 | 1041 | return; |
1006 | 1042 | } |
1007 | 1043 | } |
1008 | 1044 | } |
1009 | 1045 | |
1010 | - | |
1011 | 1046 | users.setName(name); |
1012 | 1047 | users.setEnable(enable); |
1013 | 1048 | users.setRemarks(remarks); |
1014 | 1049 | |
... | ... | @@ -1015,10 +1050,9 @@ |
1015 | 1050 | users.setDeptId(deptId); |
1016 | 1051 | users.setOrgId(orgId); |
1017 | 1052 | users.setZhiChenId(zhiCId); |
1018 | -// users.setPwd(LoginUtil.md5(NumberUtils.getRandomString(6))); | |
1053 | + // users.setPwd(LoginUtil.md5(NumberUtils.getRandomString(6))); | |
1019 | 1054 | usersService.updateUsers(users); |
1020 | 1055 | |
1021 | - | |
1022 | 1056 | //如有角色,则对用户角色中间表先删除后新增 |
1023 | 1057 | if (StringUtils.isNotBlank(roleIds)) { |
1024 | 1058 | |
... | ... | @@ -1027,7 +1061,6 @@ |
1027 | 1061 | userRoleMapsQuery.setYn(YnEnums.YES.getId()); |
1028 | 1062 | List<UserRoleMaps> userRoleMapses = userRoleMapsService.queryUserRoleMaps(userRoleMapsQuery); |
1029 | 1063 | |
1030 | - | |
1031 | 1064 | String[] roleArrayIds = roleIds.split(","); |
1032 | 1065 | //判断角色是否有更新 |
1033 | 1066 | Boolean flag = false; |
... | ... | @@ -1058,7 +1091,6 @@ |
1058 | 1091 | userRoleMapsService.updateUserRoleMaps(userRoleMaps); |
1059 | 1092 | } |
1060 | 1093 | |
1061 | - | |
1062 | 1094 | for (String tmp : roleArrayIds) { |
1063 | 1095 | if (StringUtils.isEmpty(tmp)) { |
1064 | 1096 | continue; |
... | ... | @@ -1089,7 +1121,6 @@ |
1089 | 1121 | @TokenRequired |
1090 | 1122 | public void enableUsers(HttpServletResponse response, @RequestParam Integer id, @RequestParam Integer flag) { |
1091 | 1123 | |
1092 | - | |
1093 | 1124 | //检查账户是否存在 |
1094 | 1125 | UsersQuery usersQuery = new UsersQuery(); |
1095 | 1126 | usersQuery.setId(id); |
... | ... | @@ -1117,7 +1148,6 @@ |
1117 | 1148 | ResultUtils.buildSuccessResultAndWrite(response); |
1118 | 1149 | } |
1119 | 1150 | |
1120 | - | |
1121 | 1151 | /** |
1122 | 1152 | * 用户删除 |
1123 | 1153 | */ |
... | ... | @@ -1143,7 +1173,6 @@ |
1143 | 1173 | users.setModified(new Date()); |
1144 | 1174 | usersService.updateUsers(users); |
1145 | 1175 | |
1146 | - | |
1147 | 1176 | //中间表数据的删除 |
1148 | 1177 | UserRoleMapsQuery userRoleMapsQuery = new UserRoleMapsQuery(); |
1149 | 1178 | userRoleMapsQuery.setUserId(userId); |
... | ... | @@ -1155,7 +1184,8 @@ |
1155 | 1184 | |
1156 | 1185 | UserOrganizationMapsQuery userOrganizationMapsQuery = new UserOrganizationMapsQuery(); |
1157 | 1186 | userOrganizationMapsQuery.setUserId(userId); |
1158 | - List<UserOrganizationMaps> userOrganizationMapsList = userOrganizationMapsService.queryUserOrganizationMaps(userOrganizationMapsQuery); | |
1187 | + List<UserOrganizationMaps> userOrganizationMapsList = userOrganizationMapsService | |
1188 | + .queryUserOrganizationMaps(userOrganizationMapsQuery); | |
1159 | 1189 | for (UserOrganizationMaps userOrganizationMaps : userOrganizationMapsList) { |
1160 | 1190 | userOrganizationMaps.setYn(YnEnums.NO.getId()); |
1161 | 1191 | userOrganizationMapsService.updateUserOrganizationMaps(userOrganizationMaps);//把状态设置成无效 |
... | ... | @@ -1164,7 +1194,6 @@ |
1164 | 1194 | ResultUtils.buildSuccessResultAndWrite(response); |
1165 | 1195 | } |
1166 | 1196 | |
1167 | - | |
1168 | 1197 | /** |
1169 | 1198 | * 重置用户密码 |
1170 | 1199 | */ |
... | ... | @@ -1189,7 +1218,8 @@ |
1189 | 1218 | users.setModified(new Date()); |
1190 | 1219 | users.setLastLoginTime(users.getModified()); |
1191 | 1220 | usersService.updateUsers(users); |
1192 | - LoginContext loginContext = iSessionProvider.register(users.getLogincenterId(), users.getPhone(), users.getAccount(), users.getPwd().toUpperCase()); | |
1221 | + LoginContext loginContext = iSessionProvider.register(users.getLogincenterId(), users.getPhone(), | |
1222 | + users.getAccount(), users.getPwd().toUpperCase()); | |
1193 | 1223 | if (loginContext.getErrorcode().equals(0)) { |
1194 | 1224 | ResultUtils.buildSuccessResultAndWrite(response); |
1195 | 1225 | } else { |