|
@@ -20,14 +20,10 @@ import com.qmth.themis.business.enums.MqTagEnum;
|
|
|
import com.qmth.themis.business.enums.SystemOperationEnum;
|
|
|
import com.qmth.themis.business.service.*;
|
|
|
import com.qmth.themis.business.util.*;
|
|
|
-import com.qmth.themis.common.contanst.Constants;
|
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.themis.common.enums.Platform;
|
|
|
import com.qmth.themis.common.enums.Source;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
-import com.qmth.themis.common.signature.SignatureInfo;
|
|
|
-import com.qmth.themis.common.signature.SignatureType;
|
|
|
-import com.qmth.themis.common.util.Base64Util;
|
|
|
import com.qmth.themis.common.util.Result;
|
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.*;
|
|
@@ -154,7 +150,7 @@ public class TBUserController {
|
|
|
}
|
|
|
return userLoginCommon(user);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@ApiOperation(value = "短信验证码登陆接口")
|
|
|
@RequestMapping(value = "/login/verifyCode", method = RequestMethod.POST)
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = TBUser.class)})
|
|
@@ -615,19 +611,29 @@ public class TBUserController {
|
|
|
if (Objects.isNull(mapParameter.get("orgId"))) {
|
|
|
throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
|
|
|
}
|
|
|
- TBUser loginUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
+ boolean cacheClean = false;
|
|
|
+ TBUser loginUser = null;
|
|
|
+ AuthDto authDto = null;
|
|
|
+ if (Objects.nonNull(mapParameter.get("id"))) {
|
|
|
+ loginUser = tbUserService.getById(Long.parseLong(String.valueOf(mapParameter.get("id"))));
|
|
|
+ authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + loginUser.getId());
|
|
|
+ }
|
|
|
+ Gson gson = new Gson();
|
|
|
+ TBUser tbUser = gson.fromJson(gson.toJson(mapParameter), TBUser.class);
|
|
|
+ List<String> roleList = (List<String>) mapParameter.get("roleCode");
|
|
|
+ if (Objects.isNull(roleList) || roleList.size() == 0) {
|
|
|
+ throw new BusinessException("请选择角色");
|
|
|
+ }
|
|
|
+ Set<String> roleSet = new HashSet<>(roleList);
|
|
|
+ if (roleSet.size() > 1) {
|
|
|
+ throw new BusinessException("暂不支持多个角色");
|
|
|
+ }
|
|
|
+ if ((Objects.nonNull(tbUser) && Objects.nonNull(loginUser) && !tbUser.equals(loginUser))
|
|
|
+ || (Objects.nonNull(authDto) && !roleSet.equals(authDto.getRoleCodes()))) {
|
|
|
+ cacheClean = true;
|
|
|
+ }
|
|
|
Long orgId = Long.parseLong(String.valueOf(mapParameter.get("orgId")));
|
|
|
try {
|
|
|
- Gson gson = new Gson();
|
|
|
- TBUser tbUser = gson.fromJson(gson.toJson(mapParameter), TBUser.class);
|
|
|
- List<String> roleList = (List<String>) mapParameter.get("roleCode");
|
|
|
- if (Objects.isNull(roleList) || roleList.size() == 0) {
|
|
|
- throw new BusinessException("请选择角色");
|
|
|
- }
|
|
|
- Set<String> roleSet = new HashSet<>(roleList);
|
|
|
- if (roleSet.size() > 1) {
|
|
|
- throw new BusinessException("暂不支持多个角色");
|
|
|
- }
|
|
|
if (Objects.isNull(tbUser.getId())) {
|
|
|
tbUser.setId(uidUtil.getId());
|
|
|
tbUser.setOrgId(orgId);
|
|
@@ -654,15 +660,12 @@ public class TBUserController {
|
|
|
}
|
|
|
tbUserService.saveOrUpdate(tbUser);
|
|
|
//清除用户缓存
|
|
|
- if (Objects.nonNull(roleSet) && roleSet.size() > 0) {
|
|
|
- AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + tbUser.getId());
|
|
|
- if (Objects.nonNull(authDto)) {
|
|
|
- for (Source s : Source.values()) {
|
|
|
- String sessionId = SessionUtil
|
|
|
- .digest(tbUser.getId(), Math.abs(authDto.getRoleCodes().toString().hashCode()),
|
|
|
- s.name());
|
|
|
- redisUtil.deleteUserSession(sessionId);
|
|
|
- }
|
|
|
+ if (cacheClean) {
|
|
|
+ for (Source s : Source.values()) {
|
|
|
+ String sessionId = SessionUtil
|
|
|
+ .digest(tbUser.getId(), Math.abs(authDto.getRoleCodes().toString().hashCode()),
|
|
|
+ s.name());
|
|
|
+ redisUtil.deleteUserSession(sessionId);
|
|
|
}
|
|
|
redisUtil.deleteUser(tbUser.getId());
|
|
|
cacheService.removeAccountCache(tbUser.getId());
|
|
@@ -717,7 +720,7 @@ public class TBUserController {
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
public Result enableUser(@ApiJsonObject(name = "enableUser", value = {
|
|
|
@ApiJsonProperty(key = "id", type = "long", example = "1", description = "用户id"),
|
|
|
- @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "停用/启用")}) @ApiParam(value = "用户信息", required = true) @RequestBody Map<String, Object> user) {
|
|
|
+ @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "停用/启用")}) @ApiParam(value = "用户信息", required = true) @RequestBody Map<String, Object> user) throws NoSuchAlgorithmException {
|
|
|
if (Objects.isNull(user.get("id")) || Objects.equals(user.get("id"), "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.USER_ID_IS_NULL);
|
|
|
}
|
|
@@ -733,7 +736,21 @@ public class TBUserController {
|
|
|
//保存用户
|
|
|
tbUser.setEnable(enable);
|
|
|
tbUserService.updateById(tbUser);
|
|
|
- redisUtil.setUser(tbUser.getId(), tbUser);
|
|
|
+ if (enable == 0) {
|
|
|
+ AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + tbUser.getId());
|
|
|
+ if (Objects.nonNull(authDto)) {
|
|
|
+ for (Source s : Source.values()) {
|
|
|
+ String sessionId = SessionUtil
|
|
|
+ .digest(tbUser.getId(), Math.abs(authDto.getRoleCodes().toString().hashCode()),
|
|
|
+ s.name());
|
|
|
+ redisUtil.deleteUserSession(sessionId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ redisUtil.deleteUser(tbUser.getId());
|
|
|
+ cacheService.removeAccountCache(tbUser.getId());
|
|
|
+ } else {
|
|
|
+ redisUtil.setUser(tbUser.getId(), tbUser);
|
|
|
+ }
|
|
|
return ResultUtil.ok(true);
|
|
|
}
|
|
|
|