From a543e4437aca0059dfe3f78374f22d05940d498e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Fri, 24 Mar 2023 23:02:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=B0=E5=A2=9E=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsh/erp/controller/UserController.java | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/UserController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/UserController.java index 3cab91cd..81c1d857 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/UserController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/UserController.java @@ -127,16 +127,6 @@ public class UserController { token = token + "_" + user.getTenantId(); } redisService.storageObjectBySession(token,"userId",user.getId()); - if(user.getTenantId()!=null) { - Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId()); - if(tenant!=null) { - Long tenantId = tenant.getTenantId(); - Integer userNumLimit = tenant.getUserNumLimit(); - if(tenantId!=null) { - redisService.storageObjectBySession(token,"userNumLimit",userNumLimit); //用户限制数 - } - } - } break; default: break; @@ -197,6 +187,8 @@ public class UserController { BaseResponseInfo res = new BaseResponseInfo(); try { redisService.deleteObjectBySession(request,"userId"); + redisService.deleteObjectBySession(request,"roleType"); + redisService.deleteObjectBySession(request,"clientIp"); } catch(Exception e){ e.printStackTrace(); res.code = 500; @@ -319,14 +311,17 @@ public class UserController { @ResponseBody public Object addUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{ JSONObject result = ExceptionConstants.standardSuccess(); - Long userNumLimit = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userNumLimit").toString()); + User userInfo = userService.getCurrentUser(); + Tenant tenant = tenantService.getTenantByTenantId(userInfo.getTenantId()); Long count = userService.countUser(null,null); - if(count>= userNumLimit) { - throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE, - ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG); - } else { - UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class); - userService.addUserAndOrgUserRel(ue, request); + if(tenant!=null) { + if(count>= tenant.getUserNumLimit()) { + throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE, + ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG); + } else { + UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class); + userService.addUserAndOrgUserRel(ue, request); + } } return result; }