优化新增用户接口
This commit is contained in:
@@ -127,16 +127,6 @@ public class UserController {
|
|||||||
token = token + "_" + user.getTenantId();
|
token = token + "_" + user.getTenantId();
|
||||||
}
|
}
|
||||||
redisService.storageObjectBySession(token,"userId",user.getId());
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -197,6 +187,8 @@ public class UserController {
|
|||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
try {
|
try {
|
||||||
redisService.deleteObjectBySession(request,"userId");
|
redisService.deleteObjectBySession(request,"userId");
|
||||||
|
redisService.deleteObjectBySession(request,"roleType");
|
||||||
|
redisService.deleteObjectBySession(request,"clientIp");
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
res.code = 500;
|
res.code = 500;
|
||||||
@@ -319,15 +311,18 @@ public class UserController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object addUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{
|
public Object addUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{
|
||||||
JSONObject result = ExceptionConstants.standardSuccess();
|
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);
|
Long count = userService.countUser(null,null);
|
||||||
if(count>= userNumLimit) {
|
if(tenant!=null) {
|
||||||
|
if(count>= tenant.getUserNumLimit()) {
|
||||||
throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE,
|
throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE,
|
||||||
ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG);
|
ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG);
|
||||||
} else {
|
} else {
|
||||||
UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class);
|
UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class);
|
||||||
userService.addUserAndOrgUserRel(ue, request);
|
userService.addUserAndOrgUserRel(ue, request);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user