Commit 06acc82ec38209de8b746ea50847f283918fc7f9
1 parent
1cdde2f1a6
Exists in
master
and in
1 other branch
增加权限
Showing 6 changed files with 126 additions and 121 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/PermissionsMapper.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/PermissionsService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/PermissionsServiceImpl.java
- platform-biz-service/src/main/resources/mainOrm/Permissions.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RolesController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/PermissionsMapper.java
View file @
06acc82
... | ... | @@ -18,7 +18,9 @@ |
18 | 18 | |
19 | 19 | public List<Permissions> queryPermissions(PermissionsQuery query); |
20 | 20 | |
21 | - List<Permissions> queryPermissionByRoleIds(Integer roleIds); | |
21 | + List<Permissions> queryPermissionByRoleIds(List<Integer> statusList); | |
22 | + | |
23 | + List<Permissions> queryPermissionByRoleIds1(Integer roleIds); | |
22 | 24 | |
23 | 25 | } |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/PermissionsService.java
View file @
06acc82
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | public int queryPermissionsCount(PermissionsQuery query); |
18 | 18 | |
19 | 19 | public List<Permissions> queryPermissions(PermissionsQuery query); |
20 | - List<Permissions> queryPermissionByRoleIds(Integer roleIds); | |
20 | + List<Permissions> queryPermissionByRoleIds(List<Integer> roleIds); | |
21 | + List<Permissions> queryPermissionByRoleIds1(Integer roleIds); | |
21 | 22 | } |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/PermissionsServiceImpl.java
View file @
06acc82
... | ... | @@ -48,8 +48,11 @@ |
48 | 48 | return permissionsMapper.queryPermissions(query); |
49 | 49 | } |
50 | 50 | |
51 | - public List<Permissions> queryPermissionByRoleIds(Integer roleIds) { | |
51 | + public List<Permissions> queryPermissionByRoleIds(List<Integer> roleIds) { | |
52 | 52 | return permissionsMapper.queryPermissionByRoleIds(roleIds); |
53 | + } | |
54 | + public List<Permissions> queryPermissionByRoleIds1(Integer roleIds){ | |
55 | + return permissionsMapper.queryPermissionByRoleIds1(roleIds); | |
53 | 56 | } |
54 | 57 | } |
platform-biz-service/src/main/resources/mainOrm/Permissions.xml
View file @
06acc82
... | ... | @@ -180,10 +180,17 @@ |
180 | 180 | <include refid="PermissionsCondition" /> |
181 | 181 | </select> |
182 | 182 | |
183 | -<select id="queryPermissionByRoleIds" parameterType="java.lang.Integer" resultMap="PermissionsResultMap"> | |
184 | - select b.* from role_permission_maps a, permissions b where a.yn=1 and b.yn=1 and a.role_id = | |
185 | - #{weight,jdbcType=INTEGER} | |
183 | +<select id="queryPermissionByRoleIds" parameterType="java.util.List" resultMap="PermissionsResultMap"> | |
184 | + select b.* from role_permission_maps a, permissions b where a.yn=1 and b.yn=1 and a.role_id | |
185 | + in | |
186 | + <foreach collection="statusList" index="index" item="item" open="(" separator="," close=")"> | |
187 | + #{item} | |
188 | + </foreach> | |
186 | 189 | and a.permission_id=b.id ORDER BY weight |
187 | 190 | </select> |
191 | + <select id="queryPermissionByRoleIds1" parameterType="int" resultMap="PermissionsResultMap"> | |
192 | + select b.* from role_permission_maps a, permissions b where a.yn=1 and b.yn=1 and a.role_id= | |
193 | + #{weight,jdbcType=INTEGER} | |
194 | + </select> | |
188 | 195 | </mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RolesController.java
View file @
06acc82
... | ... | @@ -391,7 +391,7 @@ |
391 | 391 | |
392 | 392 | List<Permissions> permissionses; |
393 | 393 | for (Roles roles1 : roles) { |
394 | - permissionses = permissionsService.queryPermissionByRoleIds(roles1.getId()); | |
394 | + permissionses = permissionsService.queryPermissionByRoleIds1(roles1.getId()); | |
395 | 395 | |
396 | 396 | /* RolePermissionMapsQuery rolePermissionMapsQuery = new RolePermissionMapsQuery(); |
397 | 397 | rolePermissionMapsQuery.setYn(YnEnums.YES.getId()); |
... | ... | @@ -460,7 +460,7 @@ |
460 | 460 | if (permissions.getYn().equals(YnEnums.NO.getId())) continue; |
461 | 461 | permissionses.add(permissions); |
462 | 462 | }*/ |
463 | - permissionses= permissionsService.queryPermissionByRoleIds(roles1.getId()); | |
463 | + permissionses= permissionsService.queryPermissionByRoleIds1(roles1.getId()); | |
464 | 464 | |
465 | 465 | roles1.setPermissions(permissionses); |
466 | 466 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
View file @
06acc82
... | ... | @@ -9,7 +9,9 @@ |
9 | 9 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
10 | 10 | import com.lyms.platform.common.enums.UserTypeEnum; |
11 | 11 | import com.lyms.platform.common.enums.YnEnums; |
12 | -import com.lyms.platform.common.utils.*; | |
12 | +import com.lyms.platform.common.utils.JsonUtil; | |
13 | +import com.lyms.platform.common.utils.LoginUtil; | |
14 | +import com.lyms.platform.common.utils.ResultUtils; | |
13 | 15 | import com.lyms.platform.operate.web.facade.AccessPermissionFacade; |
14 | 16 | import com.lyms.platform.operate.web.result.FrontEndResult; |
15 | 17 | import com.lyms.platform.permission.model.*; |
16 | 18 | |
... | ... | @@ -22,10 +24,8 @@ |
22 | 24 | import org.springframework.stereotype.Controller; |
23 | 25 | import org.springframework.web.bind.annotation.*; |
24 | 26 | |
25 | -import javax.management.relation.Role; | |
26 | 27 | import javax.servlet.http.HttpServletRequest; |
27 | 28 | import javax.servlet.http.HttpServletResponse; |
28 | -import javax.validation.constraints.Pattern; | |
29 | 29 | import java.util.*; |
30 | 30 | |
31 | 31 | /** |
32 | 32 | |
... | ... | @@ -61,10 +61,9 @@ |
61 | 61 | |
62 | 62 | private static final String LYMS = "龙源美生"; |
63 | 63 | |
64 | - private static final String ADMIN="管理员"; | |
64 | + private static final String ADMIN = "管理员"; | |
65 | 65 | |
66 | 66 | |
67 | - | |
68 | 67 | /** |
69 | 68 | * 获取管理员列表 |
70 | 69 | */ |
... | ... | @@ -72,10 +71,10 @@ |
72 | 71 | @ResponseBody |
73 | 72 | @TokenRequired |
74 | 73 | public FrontEndResult getAdminList(HttpServletResponse response, |
75 | - @RequestParam(value = "keyword", required = false) String keyword, | |
76 | - @RequestParam(value = "rolesId", required = false) Integer rolesId, | |
77 | - @RequestParam(value = "page", required = false) Integer page, | |
78 | - @RequestParam(value = "limit", required = false) Integer limit) { | |
74 | + @RequestParam(value = "keyword", required = false) String keyword, | |
75 | + @RequestParam(value = "rolesId", required = false) Integer rolesId, | |
76 | + @RequestParam(value = "page", required = false) Integer page, | |
77 | + @RequestParam(value = "limit", required = false) Integer limit) { | |
79 | 78 | |
80 | 79 | limit = limit == null ? 10 : limit; |
81 | 80 | page = page == null ? 1 : page; |
... | ... | @@ -92,7 +91,7 @@ |
92 | 91 | |
93 | 92 | List<Users> users = usersService.queryUsers2(usersQuery); |
94 | 93 | //设置用户角色信息 |
95 | - for(Users user : users) { | |
94 | + for (Users user : users) { | |
96 | 95 | user.setRoles(this.getUserRoles(user.getId())); |
97 | 96 | |
98 | 97 | user.setDepartmentses(departmentsService.getDepartments(user.getDeptId())); |
... | ... | @@ -108,7 +107,6 @@ |
108 | 107 | } |
109 | 108 | |
110 | 109 | |
111 | - | |
112 | 110 | /** |
113 | 111 | * 获取用户列表 |
114 | 112 | */ |
115 | 113 | |
116 | 114 | |
117 | 115 | |
118 | 116 | |
119 | 117 | |
120 | 118 | |
121 | 119 | |
122 | 120 | |
... | ... | @@ -117,42 +115,42 @@ |
117 | 115 | @ResponseBody |
118 | 116 | public FrontEndResult getPermissions(HttpServletResponse response, |
119 | 117 | HttpServletRequest request, |
120 | - @RequestParam(value = "keyword", required = false) String keyword, | |
121 | - @RequestParam(value = "rolesId", required = false) Integer rolesId, | |
122 | - @RequestParam(value = "page", required = false) Integer page, | |
123 | - @RequestParam(value = "limit", required = false) Integer limit, | |
124 | - @RequestParam(value = "orgId", required = false) Integer orgId, | |
125 | - @RequestParam(value = "deptId", required = false) Integer deptId) { | |
118 | + @RequestParam(value = "keyword", required = false) String keyword, | |
119 | + @RequestParam(value = "rolesId", required = false) Integer rolesId, | |
120 | + @RequestParam(value = "page", required = false) Integer page, | |
121 | + @RequestParam(value = "limit", required = false) Integer limit, | |
122 | + @RequestParam(value = "orgId", required = false) Integer orgId, | |
123 | + @RequestParam(value = "deptId", required = false) Integer deptId) { | |
126 | 124 | LoginContext loginContext = (LoginContext) request.getAttribute("loginContext"); |
127 | 125 | Users u = usersService.getUsers(loginContext.getId()); |
128 | 126 | |
129 | 127 | |
130 | 128 | List<Integer> ids = null; |
131 | - if(u.getType().equals(UserTypeEnum.NORMAL_USER.getId())) { | |
132 | - if(null != u.getOrgId()) { | |
129 | + if (u.getType().equals(UserTypeEnum.NORMAL_USER.getId())) { | |
130 | + if (null != u.getOrgId()) { | |
133 | 131 | orgId = u.getOrgId(); |
134 | 132 | } else { |
135 | 133 | FrontEndResult frontEndResult = new FrontEndResult(); |
136 | - frontEndResult.setPageInfo(new PageInfo(0,0,0,10)); | |
134 | + frontEndResult.setPageInfo(new PageInfo(0, 0, 0, 10)); | |
137 | 135 | frontEndResult.setErrorcode(ErrorCodeConstants.SUCCESS); |
138 | - return frontEndResult; | |
136 | + return frontEndResult; | |
139 | 137 | } |
140 | - }else if(u.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId())) { | |
138 | + } else if (u.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId())) { | |
141 | 139 | List<Organization> organizations = accessPermissionFacade.findAccessPerminssionByUserId(u.getId()); |
142 | 140 | ids = new ArrayList<>(); |
143 | - if(CollectionUtils.isNotEmpty(organizations)) { | |
144 | - for(Organization organization : organizations) { | |
141 | + if (CollectionUtils.isNotEmpty(organizations)) { | |
142 | + for (Organization organization : organizations) { | |
145 | 143 | ids.add(organization.getId()); |
146 | 144 | } |
147 | 145 | } else { |
148 | 146 | FrontEndResult frontEndResult = new FrontEndResult(); |
149 | - frontEndResult.setPageInfo(new PageInfo(0,0,0,10)); | |
147 | + frontEndResult.setPageInfo(new PageInfo(0, 0, 0, 10)); | |
150 | 148 | frontEndResult.setErrorcode(ErrorCodeConstants.SUCCESS); |
151 | - return frontEndResult; | |
149 | + return frontEndResult; | |
152 | 150 | } |
153 | 151 | } |
154 | 152 | |
155 | - if(null != orgId) { | |
153 | + if (null != orgId) { | |
156 | 154 | ids = new ArrayList<>(); |
157 | 155 | ids.add(orgId); |
158 | 156 | } |
... | ... | @@ -176,7 +174,7 @@ |
176 | 174 | List<Users> users = usersService.queryUsers2(usersQuery); |
177 | 175 | List<Organization> organizations = null; |
178 | 176 | //设置用户角色信息 |
179 | - for(Users user : users) { | |
177 | + for (Users user : users) { | |
180 | 178 | organizations = new ArrayList<>(); |
181 | 179 | Organization organization = organizationService.getOrganization(user.getOrgId()); |
182 | 180 | user.setOrganization(organization); |
183 | 181 | |
... | ... | @@ -199,13 +197,13 @@ |
199 | 197 | } |
200 | 198 | |
201 | 199 | //获取用户角色信息 |
202 | - private List<Roles> getUserRoles(Integer userId) { | |
200 | + private List<Roles> getUserRoles(Integer userId) { | |
203 | 201 | UserRoleMapsQuery query = new UserRoleMapsQuery(); |
204 | 202 | query.setUserId(userId); |
205 | 203 | query.setYn(YnEnums.YES.getId()); |
206 | 204 | List<UserRoleMaps> userRoleMapses = userRoleMapsService.queryUserRoleMaps(query); |
207 | 205 | List<Roles> roles = new ArrayList<>(); |
208 | - for(UserRoleMaps roleMaps : userRoleMapses) { | |
206 | + for (UserRoleMaps roleMaps : userRoleMapses) { | |
209 | 207 | roles.add(rolesService.getRoles(roleMaps.getRoleId())); |
210 | 208 | } |
211 | 209 | return roles; |
212 | 210 | |
213 | 211 | |
214 | 212 | |
215 | 213 | |
216 | 214 | |
217 | 215 | |
... | ... | @@ -232,33 +230,33 @@ |
232 | 230 | //code 不为空使用手机登录, password不为空时使用帐号登录 |
233 | 231 | UsersQuery usersQuery = new UsersQuery(); |
234 | 232 | usersQuery.setYn(YnEnums.YES.getId()); |
235 | - if(null != code) { | |
233 | + if (null != code) { | |
236 | 234 | usersQuery.setPhone(account); |
237 | 235 | } |
238 | - if(null != password) { | |
236 | + if (null != password) { | |
239 | 237 | usersQuery.setAccount(account); |
240 | 238 | } |
241 | 239 | List<Users> users = usersService.queryUsers(usersQuery); |
242 | - if(0 == users.size()) { | |
240 | + if (0 == users.size()) { | |
243 | 241 | ResultUtils.buildParameterErrorResultAndWrite(response, "该账户不存在"); |
244 | 242 | return; |
245 | 243 | } |
246 | 244 | |
247 | - if(!users.get(0).getEnable().equals(1)) { | |
245 | + if (!users.get(0).getEnable().equals(1)) { | |
248 | 246 | ResultUtils.buildParameterErrorResultAndWrite(response, "该账户已被禁用"); |
249 | 247 | return; |
250 | 248 | } |
251 | 249 | |
252 | 250 | LoginContext loginContext = new LoginContext(); |
253 | 251 | loginContext.setErrormsg("服务器内部错误!"); |
254 | - if(null != code) { | |
255 | - loginContext =LoginUtil.login(account, code, typeId, token); | |
252 | + if (null != code) { | |
253 | + loginContext = LoginUtil.login(account, code, typeId, token); | |
256 | 254 | } |
257 | - if(null != password) { | |
255 | + if (null != password) { | |
258 | 256 | loginContext = LoginUtil.loginHospitalUser(account, password, typeId, token); |
259 | 257 | } |
260 | 258 | |
261 | - if(null != loginContext && loginContext.getErrorcode().equals(0)) { | |
259 | + if (null != loginContext && loginContext.getErrorcode().equals(0)) { | |
262 | 260 | Users users1 = new Users(); |
263 | 261 | users1.setId(users.get(0).getId()); |
264 | 262 | users1.setLastLoginTime(new Date()); |
... | ... | @@ -267,7 +265,7 @@ |
267 | 265 | Map<String, Object> result = new HashMap<>(); |
268 | 266 | result.put("token", loginContext.getToken()); |
269 | 267 | ResultUtils.buildSuccessResultAndWrite(response, result); |
270 | - }else { | |
268 | + } else { | |
271 | 269 | ResultUtils.buildResultAndWrite(response, ErrorCodeConstants.PARAMETER_ERROR, loginContext.getErrormsg()); |
272 | 270 | } |
273 | 271 | } |
... | ... | @@ -285,7 +283,7 @@ |
285 | 283 | ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse); |
286 | 284 | return; |
287 | 285 | } |
288 | - if(!phone.matches("^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$")) { | |
286 | + if (!phone.matches("^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$")) { | |
289 | 287 | ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse, "手机号不正确!"); |
290 | 288 | return; |
291 | 289 | } |
292 | 290 | |
293 | 291 | |
... | ... | @@ -294,18 +292,18 @@ |
294 | 292 | usersQuery.setPhone(phone); |
295 | 293 | usersQuery.setYn(YnEnums.YES.getId()); |
296 | 294 | List<Users> list = usersService.queryUsers(usersQuery); |
297 | - if(null == list || 0 == list.size()) { | |
295 | + if (null == list || 0 == list.size()) { | |
298 | 296 | ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse, "该账户不存在"); |
299 | 297 | return; |
300 | 298 | } |
301 | 299 | |
302 | - if(!list.get(0).getEnable().equals(1)) { | |
300 | + if (!list.get(0).getEnable().equals(1)) { | |
303 | 301 | ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse, "该账户已被禁用"); |
304 | 302 | return; |
305 | 303 | } |
306 | 304 | |
307 | 305 | LoginContext loginContext = LoginUtil.sendVerCode(phone, typeId, token); |
308 | - if(null != loginContext) { | |
306 | + if (null != loginContext) { | |
309 | 307 | ResultUtils.buildResultAndWrite(httpServletResponse, loginContext.getErrorcode(), loginContext.getErrormsg()); |
310 | 308 | return; |
311 | 309 | } |
312 | 310 | |
... | ... | @@ -322,14 +320,14 @@ |
322 | 320 | public void usersLoginMsg(HttpServletResponse response, HttpServletRequest request) { |
323 | 321 | LoginContext loginContext = (LoginContext) request.getAttribute("loginContext"); |
324 | 322 | Users users = null; |
325 | - if(null != loginContext) { | |
323 | + if (null != loginContext) { | |
326 | 324 | users = usersService.getUsers(loginContext.getId()); |
327 | 325 | } |
328 | 326 | |
329 | 327 | List<Permissions> permissions = null; |
330 | 328 | List<Roles> roles = new ArrayList<>(); |
331 | 329 | //超级管理员拥有所有角色和权限 |
332 | - if(users.getType().equals(UserTypeEnum.SUPPER_ADMIN.getId())) { | |
330 | + if (users.getType().equals(UserTypeEnum.SUPPER_ADMIN.getId())) { | |
333 | 331 | RolesQuery rolesQuery = new RolesQuery(); |
334 | 332 | rolesQuery.setYn(YnEnums.YES.getId()); |
335 | 333 | roles = rolesService.queryRoles(rolesQuery); |
336 | 334 | |
337 | 335 | |
... | ... | @@ -341,16 +339,16 @@ |
341 | 339 | |
342 | 340 | } |
343 | 341 | //其他用户 |
344 | - else if(users.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId()) || users.getType().equals(UserTypeEnum.NORMAL_USER.getId())){ | |
342 | + else if (users.getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId()) || users.getType().equals(UserTypeEnum.NORMAL_USER.getId())) { | |
345 | 343 | //获取用户角色信息 |
346 | 344 | UserRoleMapsQuery query = new UserRoleMapsQuery(); |
347 | 345 | query.setUserId(users.getId()); |
348 | 346 | query.setYn(YnEnums.YES.getId()); |
349 | 347 | List<Integer> userRoleMapses = userRoleMapsService.queryUserRoleList(query); |
350 | - RolePermissionMapsQuery rolePermissionMapsQuery ; | |
348 | + RolePermissionMapsQuery rolePermissionMapsQuery; | |
351 | 349 | List<Integer> permissionIds = new ArrayList<>(); |
352 | - permissions = new ArrayList<>(); | |
353 | - for(Integer roleMaps : userRoleMapses) { | |
350 | + permissions = new ArrayList<>(); | |
351 | + for (Integer roleMaps : userRoleMapses) { | |
354 | 352 | roles.add(rolesService.getRoles(roleMaps)); |
355 | 353 | |
356 | 354 | //获取角色权限信息 |
... | ... | @@ -371,14 +369,13 @@ |
371 | 369 | } |
372 | 370 | } |
373 | 371 | }*/ |
374 | - | |
375 | - List<Permissions> local = permissionsService.queryPermissionByRoleIds(roleMaps); | |
376 | - if(CollectionUtils.isNotEmpty(local)){ | |
377 | - for(Permissions permissions1:local){ | |
378 | - if(!permissionIds.contains(permissions1.getId())) { | |
379 | - permissionIds.add(permissions1.getId()); | |
380 | - permissions.add(permissions1); | |
381 | - } | |
372 | + } | |
373 | + List<Permissions> local = permissionsService.queryPermissionByRoleIds(userRoleMapses); | |
374 | + if (CollectionUtils.isNotEmpty(local)) { | |
375 | + for (Permissions permissions1 : local) { | |
376 | + if (!permissionIds.contains(permissions1.getId())) { | |
377 | + permissionIds.add(permissions1.getId()); | |
378 | + permissions.add(permissions1); | |
382 | 379 | } |
383 | 380 | } |
384 | 381 | } |
385 | 382 | |
... | ... | @@ -386,14 +383,14 @@ |
386 | 383 | |
387 | 384 | |
388 | 385 | List<Organization> organizations = new ArrayList<>(); |
389 | - if(null != users.getOrgId() && UserTypeEnum.NORMAL_USER.getId().equals(users.getType())) { //普通用户 | |
386 | + if (null != users.getOrgId() && UserTypeEnum.NORMAL_USER.getId().equals(users.getType())) { //普通用户 | |
390 | 387 | Organization organization = organizationService.getOrganization(users.getOrgId()); |
391 | 388 | organizations.add(organization); |
392 | 389 | users.setOrganization(organization); |
393 | 390 | } else if (UserTypeEnum.PLATFORM_ADMIN.getId().equals(users.getType())) { //管理员 |
394 | - List<Organization> list2 =accessPermissionFacade.findAccessPerminssionByUserId(users.getId()); | |
395 | - if(CollectionUtils.isNotEmpty(list2)){ | |
396 | - for(Organization organization:list2){ | |
391 | + List<Organization> list2 = accessPermissionFacade.findAccessPerminssionByUserId(users.getId()); | |
392 | + if (CollectionUtils.isNotEmpty(list2)) { | |
393 | + for (Organization organization : list2) { | |
397 | 394 | organizations.add(organization); |
398 | 395 | } |
399 | 396 | } |
400 | 397 | |
... | ... | @@ -418,12 +415,12 @@ |
418 | 415 | @RequestMapping(value = "/users/userRole/{id}", method = RequestMethod.GET) |
419 | 416 | @TokenRequired |
420 | 417 | public void userRole(HttpServletResponse response, HttpServletRequest request, @PathVariable(value = "id") Integer id) { |
421 | - UserRoleMapsQuery query = new UserRoleMapsQuery(); | |
418 | + UserRoleMapsQuery query = new UserRoleMapsQuery(); | |
422 | 419 | query.setUserId(id); |
423 | 420 | query.setYn(YnEnums.YES.getId()); |
424 | 421 | List<UserRoleMaps> userRoleMapses = userRoleMapsService.queryUserRoleMaps(query); |
425 | 422 | List<Roles> roles = new ArrayList<>(); |
426 | - for(UserRoleMaps roleMaps : userRoleMapses) { | |
423 | + for (UserRoleMaps roleMaps : userRoleMapses) { | |
427 | 424 | roles.add(rolesService.getRoles(roleMaps.getRoleId())); |
428 | 425 | } |
429 | 426 | |
430 | 427 | |
... | ... | @@ -431,13 +428,12 @@ |
431 | 428 | } |
432 | 429 | |
433 | 430 | |
434 | - | |
435 | 431 | /** |
436 | 432 | * 管理员权限设置 |
437 | 433 | */ |
438 | 434 | @RequestMapping(value = "/adminPermissions", method = RequestMethod.POST) |
439 | 435 | @TokenRequired |
440 | - public void adminPermissions(HttpServletResponse response,@RequestParam(value = "userId") Integer userId, @RequestParam(value = "ids") String ids){ | |
436 | + public void adminPermissions(HttpServletResponse response, @RequestParam(value = "userId") Integer userId, @RequestParam(value = "ids") String ids) { | |
441 | 437 | |
442 | 438 | if (ids == null) { |
443 | 439 | ResultUtils.buildParameterErrorResultAndWrite(response); |
... | ... | @@ -456,7 +452,7 @@ |
456 | 452 | return; |
457 | 453 | } |
458 | 454 | |
459 | - if(!usersList.get(0).getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId())) { | |
455 | + if (!usersList.get(0).getType().equals(UserTypeEnum.PLATFORM_ADMIN.getId())) { | |
460 | 456 | ResultUtils.buildParameterErrorResultAndWrite(response, "用户错误"); |
461 | 457 | return; |
462 | 458 | } |
... | ... | @@ -465,8 +461,8 @@ |
465 | 461 | UserOrganizationMapsQuery userOrganizationMapsQuery = new UserOrganizationMapsQuery(); |
466 | 462 | userOrganizationMapsQuery.setUserId(userId); |
467 | 463 | List<UserOrganizationMaps> userOrganizationMapsList = userOrganizationMapsService.queryUserOrganizationMaps(userOrganizationMapsQuery); |
468 | - if(0 < userOrganizationMapsList.size()) { | |
469 | - for(UserOrganizationMaps userOrganizationMaps : userOrganizationMapsList) { | |
464 | + if (0 < userOrganizationMapsList.size()) { | |
465 | + for (UserOrganizationMaps userOrganizationMaps : userOrganizationMapsList) { | |
470 | 466 | userOrganizationMaps.setYn(YnEnums.NO.getId()); |
471 | 467 | userOrganizationMapsService.updateUserOrganizationMaps(userOrganizationMaps); |
472 | 468 | } |
473 | 469 | |
... | ... | @@ -474,12 +470,12 @@ |
474 | 470 | |
475 | 471 | //添加最新权限映射 |
476 | 472 | String[] roleArrayIds = ids.split(","); |
477 | - Users user = usersList.get(0); | |
473 | + Users user = usersList.get(0); | |
478 | 474 | UserOrganizationMaps userOrganizationMaps = null; |
479 | 475 | Organization organization = null; |
480 | 476 | for (String id : roleArrayIds) { |
481 | 477 | organization = organizationService.getOrganization(Integer.valueOf(id)); |
482 | - if(null != organization) { | |
478 | + if (null != organization) { | |
483 | 479 | userOrganizationMaps = new UserOrganizationMaps(); |
484 | 480 | userOrganizationMaps.setUserId(user.getId()); |
485 | 481 | userOrganizationMaps.setOrgId(Integer.valueOf(id)); |
... | ... | @@ -498,7 +494,7 @@ |
498 | 494 | |
499 | 495 | |
500 | 496 | private Boolean isPhone(String phone) { |
501 | - return phone.matches("^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$"); | |
497 | + return phone.matches("^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$"); | |
502 | 498 | } |
503 | 499 | |
504 | 500 | /** |
... | ... | @@ -509,7 +505,7 @@ |
509 | 505 | public void addAdmin(HttpServletResponse response, |
510 | 506 | HttpServletRequest request, |
511 | 507 | @RequestParam(value = "name", required = false) String name, |
512 | - @RequestParam(value = "account", required = false)String account, | |
508 | + @RequestParam(value = "account", required = false) String account, | |
513 | 509 | @RequestParam(value = "phone") String phone, |
514 | 510 | @RequestParam(value = "enable", required = false) Integer enable, |
515 | 511 | @RequestParam(value = "remarks", required = false) String remarks, |
... | ... | @@ -522,7 +518,7 @@ |
522 | 518 | |
523 | 519 | |
524 | 520 | if (StringUtils.isBlank(roleIds) || |
525 | - StringUtils.isBlank(name) || StringUtils.isBlank(phone) || null == user ) { | |
521 | + StringUtils.isBlank(name) || StringUtils.isBlank(phone) || null == user) { | |
526 | 522 | ResultUtils.buildParameterErrorResultAndWrite(response); |
527 | 523 | return; |
528 | 524 | } |
... | ... | @@ -575,7 +571,7 @@ |
575 | 571 | //关联登录中心ID |
576 | 572 | LoginContext loginContext = LoginUtil.register(phone, token, typeId); |
577 | 573 | //0 成功 4009 已注册 |
578 | - if(loginContext.getErrorcode().equals(0) || loginContext.getErrorcode().equals(4009)) { | |
574 | + if (loginContext.getErrorcode().equals(0) || loginContext.getErrorcode().equals(4009)) { | |
579 | 575 | users.setLogincenterId(loginContext.getId()); |
580 | 576 | usersService.addUsers(users); |
581 | 577 | |
... | ... | @@ -584,7 +580,7 @@ |
584 | 580 | UserRoleMaps userRoleMaps = new UserRoleMaps(); |
585 | 581 | |
586 | 582 | String[] roleArrayIds = roleIds.split(","); |
587 | - List<Users> user1 = usersService.queryUsers(usersQuery); | |
583 | + List<Users> user1 = usersService.queryUsers(usersQuery); | |
588 | 584 | for (String id : roleArrayIds) { |
589 | 585 | Roles roles = rolesService.getRoles(Integer.valueOf(id)); |
590 | 586 | if (roles == null || roles.getYn() == YnEnums.NO.getId()) { |
... | ... | @@ -619,7 +615,7 @@ |
619 | 615 | @RequestParam(value = "deptId", required = false) Integer deptId, |
620 | 616 | @RequestParam(value = "ksId", required = false) Integer ksId, |
621 | 617 | @RequestParam(value = "name", required = false) String name, |
622 | - @RequestParam(value = "account", required = false)String account, | |
618 | + @RequestParam(value = "account", required = false) String account, | |
623 | 619 | @RequestParam(value = "phone") String phone, |
624 | 620 | @RequestParam(value = "enable", required = false) Integer enable, |
625 | 621 | @RequestParam(value = "remarks", required = false) String remarks, |
... | ... | @@ -631,7 +627,7 @@ |
631 | 627 | Users user = usersService.getUsers(loginState.getId()); |
632 | 628 | |
633 | 629 | |
634 | - if ( StringUtils.isBlank(roleIds) || StringUtils.isBlank(phone) || null == user ) { | |
630 | + if (StringUtils.isBlank(roleIds) || StringUtils.isBlank(phone) || null == user) { | |
635 | 631 | ResultUtils.buildParameterErrorResultAndWrite(response); |
636 | 632 | return; |
637 | 633 | } |
... | ... | @@ -641,7 +637,7 @@ |
641 | 637 | return; |
642 | 638 | } |
643 | 639 | |
644 | - if(deptId == null && ksId == null) { | |
640 | + if (deptId == null && ksId == null) { | |
645 | 641 | ResultUtils.buildParameterErrorResultAndWrite(response, "deptId or ksId required"); |
646 | 642 | return; |
647 | 643 | } |
... | ... | @@ -691,7 +687,7 @@ |
691 | 687 | //关联登录中心ID |
692 | 688 | LoginContext loginContext = LoginUtil.register(phone, token, typeId); |
693 | 689 | //0 成功 4009 已注册 |
694 | - if(loginContext.getErrorcode().equals(0) || loginContext.getErrorcode().equals(4009)) { | |
690 | + if (loginContext.getErrorcode().equals(0) || loginContext.getErrorcode().equals(4009)) { | |
695 | 691 | users.setLogincenterId(loginContext.getId()); |
696 | 692 | usersService.addUsers(users); |
697 | 693 | |
... | ... | @@ -699,7 +695,7 @@ |
699 | 695 | UserRoleMaps userRoleMaps = new UserRoleMaps(); |
700 | 696 | |
701 | 697 | String[] roleArrayIds = roleIds.split(","); |
702 | - List<Users> user1 = usersService.queryUsers(usersQuery); | |
698 | + List<Users> user1 = usersService.queryUsers(usersQuery); | |
703 | 699 | for (String id : roleArrayIds) { |
704 | 700 | Roles roles = rolesService.getRoles(Integer.valueOf(id)); |
705 | 701 | if (roles == null || roles.getYn() == YnEnums.NO.getId()) { |
... | ... | @@ -722,7 +718,6 @@ |
722 | 718 | } |
723 | 719 | |
724 | 720 | |
725 | - | |
726 | 721 | // /** |
727 | 722 | // * 添加用户信息 |
728 | 723 | // */ |
729 | 724 | |
730 | 725 | |
... | ... | @@ -827,21 +822,21 @@ |
827 | 822 | public void updateUsers(HttpServletResponse response, |
828 | 823 | HttpServletRequest request, |
829 | 824 | @PathVariable(value = "id") Integer id, |
830 | - @RequestParam(value = "name",required = false) String name, | |
831 | - @RequestParam(value = "account",required = false)String account, | |
832 | - @RequestParam(value = "phone",required = false) String phone, | |
833 | - @RequestParam(value = "enable",required = false) Integer enable, | |
834 | - @RequestParam(value = "remarks",required = false) String remarks, | |
835 | - @RequestParam(value = "roleIds",required = false) String roleIds, | |
836 | - @RequestParam(value = "orgId",required = false) Integer orgId, | |
837 | - @RequestParam(value = "deptId",required = false) Integer deptId) { | |
825 | + @RequestParam(value = "name", required = false) String name, | |
826 | + @RequestParam(value = "account", required = false) String account, | |
827 | + @RequestParam(value = "phone", required = false) String phone, | |
828 | + @RequestParam(value = "enable", required = false) Integer enable, | |
829 | + @RequestParam(value = "remarks", required = false) String remarks, | |
830 | + @RequestParam(value = "roleIds", required = false) String roleIds, | |
831 | + @RequestParam(value = "orgId", required = false) Integer orgId, | |
832 | + @RequestParam(value = "deptId", required = false) Integer deptId) { | |
838 | 833 | |
839 | - if(null == roleIds) { | |
834 | + if (null == roleIds) { | |
840 | 835 | ResultUtils.buildParameterErrorResultAndWrite(response, "roleIds不能为空"); |
841 | 836 | return; |
842 | 837 | } |
843 | 838 | |
844 | - if(!(null != enable && (1 == enable || 2 == enable))) { | |
839 | + if (!(null != enable && (1 == enable || 2 == enable))) { | |
845 | 840 | ResultUtils.buildParameterErrorResultAndWrite(response, "enable参数错误"); |
846 | 841 | return; |
847 | 842 | } |
... | ... | @@ -852,7 +847,7 @@ |
852 | 847 | if (user != null) { |
853 | 848 | |
854 | 849 | Users users = usersService.getUsers(id); |
855 | - if(null!=users.getOtherAccount()&&"1".equals(user.getOtherAccount()+"")){ | |
850 | + if (null != users.getOtherAccount() && "1".equals(user.getOtherAccount() + "")) { | |
856 | 851 | return; |
857 | 852 | } |
858 | 853 | //根据当前登录的用户判断是否 有管理员的权限 |
... | ... | @@ -864,7 +859,7 @@ |
864 | 859 | writeJson(response, JsonUtil.obj2JsonString(map)); |
865 | 860 | return; |
866 | 861 | }*/ |
867 | - if(null == users) { | |
862 | + if (null == users) { | |
868 | 863 | Map<String, Object> map = new HashMap<>(); |
869 | 864 | map.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR); |
870 | 865 | map.put(ResultUtils.ERROR_MSG, "用户不存在"); |
... | ... | @@ -874,7 +869,7 @@ |
874 | 869 | |
875 | 870 | |
876 | 871 | //修改了手机号,不能修改已存在的手机号 |
877 | - if(!new Integer(1).equals(users.getOtherAccount()) && !phone.equals(users.getPhone())) { | |
872 | + if (!new Integer(1).equals(users.getOtherAccount()) && !phone.equals(users.getPhone())) { | |
878 | 873 | //检查账户是否存在 |
879 | 874 | UsersQuery usersQuery = new UsersQuery(); |
880 | 875 | usersQuery.setPhone(phone); |
... | ... | @@ -891,7 +886,7 @@ |
891 | 886 | |
892 | 887 | LoginContext loginContext = LoginUtil.register(phone, token, typeId); |
893 | 888 | //0 成功 4009 已注册 |
894 | - if(loginContext.getErrorcode().equals(0) || loginContext.getErrorcode().equals(4009)) { | |
889 | + if (loginContext.getErrorcode().equals(0) || loginContext.getErrorcode().equals(4009)) { | |
895 | 890 | users.setPhone(phone); |
896 | 891 | users.setLogincenterId(loginContext.getId()); |
897 | 892 | } else { |
898 | 893 | |
899 | 894 | |
900 | 895 | |
901 | 896 | |
... | ... | @@ -912,22 +907,22 @@ |
912 | 907 | |
913 | 908 | |
914 | 909 | //如有角色,则对用户角色中间表先删除后新增 |
915 | - if(null != roleIds) { | |
910 | + if (null != roleIds) { | |
916 | 911 | String[] roleArrayIds = roleIds.split(","); |
917 | 912 | //判断角色是否有更新 |
918 | 913 | Boolean flag = false; |
919 | - if(null == users.getRoles()) flag = true; | |
920 | - if(!flag) { | |
914 | + if (null == users.getRoles()) flag = true; | |
915 | + if (!flag) { | |
921 | 916 | for (String s : roleArrayIds) { |
922 | - for(Roles role : users.getRoles()) { | |
923 | - if(s.equals(role.getId().toString())) continue; | |
917 | + for (Roles role : users.getRoles()) { | |
918 | + if (s.equals(role.getId().toString())) continue; | |
924 | 919 | flag = true; |
925 | 920 | } |
926 | - if(flag) break; | |
921 | + if (flag) break; | |
927 | 922 | } |
928 | 923 | } |
929 | 924 | |
930 | - if(flag) { | |
925 | + if (flag) { | |
931 | 926 | Integer _userId = users.getId(); |
932 | 927 | UserRoleMapsQuery userRoleMapsQuery = new UserRoleMapsQuery(); |
933 | 928 | userRoleMapsQuery.setUserId(_userId); |
... | ... | @@ -940,7 +935,7 @@ |
940 | 935 | |
941 | 936 | UserRoleMaps userRoleMaps = new UserRoleMaps(); |
942 | 937 | for (String tmp : roleArrayIds) { |
943 | - if(StringUtils.isEmpty(tmp)){ | |
938 | + if (StringUtils.isEmpty(tmp)) { | |
944 | 939 | continue; |
945 | 940 | } |
946 | 941 | Roles roles = rolesService.getRoles(Integer.valueOf(tmp)); |
... | ... | @@ -966,7 +961,7 @@ |
966 | 961 | */ |
967 | 962 | @RequestMapping(value = "/users/enable", method = RequestMethod.POST) |
968 | 963 | @TokenRequired |
969 | - public void enableUsers(HttpServletResponse response,@RequestParam Integer id, @RequestParam Integer flag) { | |
964 | + public void enableUsers(HttpServletResponse response, @RequestParam Integer id, @RequestParam Integer flag) { | |
970 | 965 | |
971 | 966 | |
972 | 967 | //检查账户是否存在 |
... | ... | @@ -980,10 +975,10 @@ |
980 | 975 | writeJson(response, JsonUtil.obj2JsonString(map)); |
981 | 976 | return; |
982 | 977 | } |
983 | - Users users =null; | |
984 | - if(CollectionUtils.isNotEmpty(usersList)){ | |
985 | - users =usersList.get(0); | |
986 | - if(null!=users.getOtherAccount()&&"1".equals(users.getOtherAccount()+"")){ | |
978 | + Users users = null; | |
979 | + if (CollectionUtils.isNotEmpty(usersList)) { | |
980 | + users = usersList.get(0); | |
981 | + if (null != users.getOtherAccount() && "1".equals(users.getOtherAccount() + "")) { | |
987 | 982 | return; |
988 | 983 | } |
989 | 984 | } |
990 | 985 | |
... | ... | @@ -997,14 +992,12 @@ |
997 | 992 | } |
998 | 993 | |
999 | 994 | |
1000 | - | |
1001 | - | |
1002 | 995 | /** |
1003 | 996 | * 用户删除 |
1004 | 997 | */ |
1005 | 998 | @RequestMapping(value = "/users/{id}", method = RequestMethod.DELETE) |
1006 | 999 | @TokenRequired |
1007 | - public void deleteUsers(HttpServletResponse response,@PathVariable Integer id) { | |
1000 | + public void deleteUsers(HttpServletResponse response, @PathVariable Integer id) { | |
1008 | 1001 | if (null == id) { |
1009 | 1002 | ResultUtils.buildIdIsNull(response); |
1010 | 1003 | return; |
... | ... | @@ -1044,7 +1037,6 @@ |
1044 | 1037 | |
1045 | 1038 | ResultUtils.buildSuccessResultAndWrite(response); |
1046 | 1039 | } |
1047 | - | |
1048 | 1040 | |
1049 | 1041 | |
1050 | 1042 | /** |