|
@@ -0,0 +1,358 @@
|
|
|
+package com.dragoninfo.dcuc.auth.business.impl.zerotrust;
|
|
|
+
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
|
|
|
+import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
|
|
|
+import com.dragoninfo.dcuc.auth.api.enums.zerotrust.AuthApplyRespEnum;
|
|
|
+import com.dragoninfo.dcuc.auth.api.enums.zerotrust.ZeroTrustBusinessRespEnum;
|
|
|
+import com.dragoninfo.dcuc.auth.api.vo.zerotrust.ZeroTrustDataRespVO;
|
|
|
+import com.dragoninfo.dcuc.auth.api.vo.zerotrust.authapply.ApiRoleAuthContentVo;
|
|
|
+import com.dragoninfo.dcuc.auth.api.vo.zerotrust.authapply.ApiRoleAuthReqVo;
|
|
|
+import com.dragoninfo.dcuc.auth.api.vo.zerotrust.authapply.AuthApplyRespVo;
|
|
|
+import com.dragoninfo.dcuc.auth.api.vo.zerotrust.role.ApiAppRoleRespVo;
|
|
|
+import com.dragoninfo.dcuc.auth.api.vo.zerotrust.role.ApiRoleRespVo;
|
|
|
+import com.dragoninfo.dcuc.auth.api.vo.zerotrust.role.ApiRolesReqVo;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.dto.RoleAuthApplyDto;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.entity.RoleInfo;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.service.IRoleInfoService;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.service.zerotrust.IRoleAuthApplyService;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.vo.zerotrust.roleauthapply.ApplyRoleInVo;
|
|
|
+import com.dragoninfo.dcuc.auth.business.zerotrust.IAuthTokenBusiness;
|
|
|
+import com.dragoninfo.dcuc.auth.business.zerotrust.IZeroTrustAuthApplyBusiness;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.entity.AuthUserInfo;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.service.IAuthUserInfoService;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.vo.ApplyInfoVo;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.vo.AuthUserVo;
|
|
|
+import com.dragoninfo.dcuc.auth.token.vo.AppTokenDetailRespVo;
|
|
|
+import com.dragoninfo.dcuc.auth.token.vo.AppTokenInfoRespVO;
|
|
|
+import com.dragoninfo.dcuc.auth.token.vo.UserTokenInfoRespVO;
|
|
|
+import com.dragoninfo.dcuc.common.enums.UserExtInfoEnum;
|
|
|
+import com.dragoninfo.dcuc.common.utils.DcucBeanUtil;
|
|
|
+import com.dragoninfo.dcuc.common.utils.ResponseUtil;
|
|
|
+import com.dragoninfo.duceap.core.enums.ResultEnum;
|
|
|
+import com.dragoninfo.duceap.core.response.Result;
|
|
|
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
+import com.dragonsoft.duceap.base.entity.security.SecurityUser;
|
|
|
+import com.dragonsoft.duceap.base.enums.BooleanEnum;
|
|
|
+import com.dragonsoft.duceap.base.utils.UserContextUtils;
|
|
|
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
|
|
|
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author mazq
|
|
|
+ * @date 2023/11/23
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class ZeroTrustAuthApplyBusinessImpl implements IZeroTrustAuthApplyBusiness {
|
|
|
+
|
|
|
+ private IRoleAuthApplyService roleAuthApplyService;
|
|
|
+
|
|
|
+ private IApplyInfoFacade applyInfoFacade;
|
|
|
+
|
|
|
+ private IRoleInfoService roleInfoService;
|
|
|
+
|
|
|
+ private IAuthUserInfoService userInfoService;
|
|
|
+
|
|
|
+ private IAuthTokenBusiness authTokenBusiness;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setUserInfoService(IAuthUserInfoService userInfoService) {
|
|
|
+ this.userInfoService = userInfoService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setAuthTokenBusiness(IAuthTokenBusiness authTokenBusiness) {
|
|
|
+ this.authTokenBusiness = authTokenBusiness;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setRoleAuthApplyService(IRoleAuthApplyService roleAuthApplyService) {
|
|
|
+ this.roleAuthApplyService = roleAuthApplyService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setApplyInfoFacade(IApplyInfoFacade applyInfoFacade) {
|
|
|
+ this.applyInfoFacade = applyInfoFacade;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public void setRoleInfoService(IRoleInfoService roleInfoService) {
|
|
|
+ this.roleInfoService = roleInfoService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ZeroTrustDataRespVO<List<ApiAppRoleRespVo>> appRoleInfos(ApiRolesReqVo reqVo) {
|
|
|
+ log.info("角色授权申请,应用令牌:{}, 申请内容:{}", reqVo.getAppTokenId(), JSONUtil.toJsonStr(reqVo));
|
|
|
+
|
|
|
+ // 校验应用令牌
|
|
|
+ AppTokenDetailRespVo appTokenDetail = authTokenBusiness.getByAppTokenId(reqVo.getAppTokenId(), false, true);
|
|
|
+ if (appTokenDetail.isEmpty()) {
|
|
|
+ return ZeroTrustDataRespVO.resultEnumMessage(ZeroTrustBusinessRespEnum.TOKEN_FAIL);
|
|
|
+ }
|
|
|
+
|
|
|
+ ApplyInfoVo tokenAppInfo = appTokenDetail.getApplyInfo();
|
|
|
+ List<String> appCodes = reqVo.getAppCodes();
|
|
|
+ if (CollectionUtils.isEmpty(appCodes)) {
|
|
|
+ appCodes = new ArrayList<>();
|
|
|
+ appCodes.add(tokenAppInfo.getApplyCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询应用下的角色
|
|
|
+ List<ApplyInfo> appInfos = applyInfoFacade.getListByCodes(appCodes);
|
|
|
+ if (CollectionUtils.isEmpty(appInfos)) {
|
|
|
+ ZeroTrustDataRespVO.success(Collections.emptyList());
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, ApplyInfo> appMap = appInfos.stream().collect(Collectors.toMap(ApplyInfo::getId, e -> e));
|
|
|
+ List<RoleInfo> roles = roleInfoService.getRolesByAppIds(appMap.keySet());
|
|
|
+ Map<String, List<RoleInfo>> roleGroup = roles.stream().collect(Collectors.groupingBy(RoleInfo::getAppId));
|
|
|
+ List<ApiAppRoleRespVo> respVos = roleGroup.entrySet().stream().map(e -> {
|
|
|
+ ApiAppRoleRespVo vo = new ApiAppRoleRespVo();
|
|
|
+ ApplyInfo applyInfo = appMap.get(e.getKey());
|
|
|
+ vo.setAppCode(applyInfo.getApplyCode());
|
|
|
+ vo.setAppName(applyInfo.getApplyName());
|
|
|
+ List<RoleInfo> value = e.getValue();
|
|
|
+ List<ApiRoleRespVo> collect = value.stream().map(r -> {
|
|
|
+ ApiRoleRespVo roleRespVo = new ApiRoleRespVo();
|
|
|
+ roleRespVo.setRoleCode(r.getCode());
|
|
|
+ roleRespVo.setRoleName(r.getName());
|
|
|
+ return roleRespVo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ vo.setRoleInfos(collect);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return ZeroTrustDataRespVO.success(respVos);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ZeroTrustDataRespVO<AuthApplyRespVo> roleAuthApply(ApiRoleAuthReqVo reqVo) {
|
|
|
+ log.info("角色授权申请,应用令牌:{}, 申请内容:{}", reqVo.getAppTokenId(), JSONUtil.toJsonStr(reqVo));
|
|
|
+
|
|
|
+ // 校验应用令牌
|
|
|
+ AppTokenDetailRespVo appTokenDetail = authTokenBusiness.getByAppTokenId(reqVo.getAppTokenId(), true, true);
|
|
|
+ if (appTokenDetail.isEmpty()) {
|
|
|
+ return ZeroTrustDataRespVO.resultEnumMessage(ZeroTrustBusinessRespEnum.TOKEN_FAIL);
|
|
|
+ }
|
|
|
+ AuthUserVo tokenUserInfo = appTokenDetail.getUserInfo();
|
|
|
+ ApplyInfoVo tokenAppInfo = appTokenDetail.getApplyInfo();
|
|
|
+
|
|
|
+ // 校验申请人
|
|
|
+ Result<List<AuthUserVo>> userResult = getApplyUserInfo(reqVo, tokenUserInfo);
|
|
|
+ List<AuthUserVo> users = userResult.getContent();
|
|
|
+ if (userResult.isFail()) {
|
|
|
+ return getErrorApplyResp(AuthApplyRespEnum.USER_NOT_EXIST, users);
|
|
|
+ }
|
|
|
+ // 校验申请的应用
|
|
|
+ Result<List<ApplyInfoVo>> appResult = getAppInfos(reqVo, tokenAppInfo);
|
|
|
+ List<ApplyInfoVo> applyInfoVos = appResult.getContent();
|
|
|
+ if (appResult.isFail()) {
|
|
|
+ return getErrorApplyResp(AuthApplyRespEnum.APP_NOT_EXIST, applyInfoVos);
|
|
|
+ }
|
|
|
+ // 校验申请的角色
|
|
|
+ Result<List<RoleInfo>> roleResult = getApplyRoles(reqVo, applyInfoVos);
|
|
|
+ List<RoleInfo> roles = roleResult.getContent();
|
|
|
+ if (roleResult.isFail()) {
|
|
|
+ return getErrorApplyResp(AuthApplyRespEnum.ROLE_NOT_EXIST, roles);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, List<RoleInfo>> roleMap = roles.stream().collect(Collectors.groupingBy(RoleInfo::getAppId));
|
|
|
+ Map<String, AuthUserVo> userVoMap = users.stream().collect(Collectors.toMap(AuthUserVo::getIdcard, e -> e));
|
|
|
+ Map<String, ApplyInfoVo> appVoMap = applyInfoVos.stream().collect(Collectors.toMap(ApplyInfoVo::getApplyCode, e -> e));
|
|
|
+ // 设置为当前登录人
|
|
|
+ setSecurityUser(appTokenDetail);
|
|
|
+
|
|
|
+ // 组装批量申请dto
|
|
|
+ List<RoleAuthApplyDto> applyDtos = getApplyDtos(reqVo, tokenUserInfo.getIdcard(), tokenAppInfo.getApplyCode(), userVoMap, appVoMap, roleMap);
|
|
|
+
|
|
|
+ ResponseStatus status = roleAuthApplyService.applyAndPushToApproval(applyDtos, null);
|
|
|
+ if (ResponseUtil.isFail(status)) {
|
|
|
+ return getErrorApplyResp(AuthApplyRespEnum.OTHER, status.getMessage());
|
|
|
+ }
|
|
|
+ return ZeroTrustDataRespVO.success(AuthApplyRespVo.success());
|
|
|
+ }
|
|
|
+
|
|
|
+ private ZeroTrustDataRespVO<AuthApplyRespVo> getErrorApplyResp(AuthApplyRespEnum authApplyRespEnum, Object content) {
|
|
|
+ AuthApplyRespVo vo = new AuthApplyRespVo();
|
|
|
+ vo.setRespCode(authApplyRespEnum.getValue());
|
|
|
+ vo.setRespMsg(authApplyRespEnum.getLabel());
|
|
|
+ switch (authApplyRespEnum) {
|
|
|
+ case APP_NOT_EXIST:
|
|
|
+ List<ApplyInfoVo> apps = (List<ApplyInfoVo>) content;
|
|
|
+ List<String> appCodes = apps.stream().map(ApplyInfoVo::getApplyCode).collect(Collectors.toList());
|
|
|
+ vo.setRespContent(appCodes);
|
|
|
+ break;
|
|
|
+ case USER_NOT_EXIST:
|
|
|
+ List<AuthUserVo> userVos = (List<AuthUserVo>) content;
|
|
|
+ List<String> idcards = userVos.stream().map(AuthUserVo::getIdcard).collect(Collectors.toList());
|
|
|
+ vo.setRespContent(idcards);
|
|
|
+ break;
|
|
|
+ case ROLE_NOT_EXIST:
|
|
|
+ List<RoleInfo> roleInfos = (List<RoleInfo>) content;
|
|
|
+ Map<String, List<String>> roleAppMap = roleInfos.stream()
|
|
|
+ .collect(Collectors.groupingBy(RoleInfo::getAppId, Collectors.mapping(RoleInfo::getCode, Collectors.toList())));
|
|
|
+ List<String> collect = roleAppMap.entrySet().stream().map(e -> {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("appCode", e.getKey());
|
|
|
+ jsonObject.put("roleCodes", e.getValue());
|
|
|
+ return jsonObject.toString();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ vo.setRespContent(collect);
|
|
|
+ break;
|
|
|
+ case SERVICE_NOT_EXIST:
|
|
|
+ // TODO
|
|
|
+ break;
|
|
|
+ case OTHER:
|
|
|
+ default:
|
|
|
+ vo.setRespContent(Collections.emptyList());
|
|
|
+ vo.setRespMsg(content.toString());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return ZeroTrustDataRespVO.resultEnumMessage(ZeroTrustBusinessRespEnum.OPERATE_FAIL, vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<RoleAuthApplyDto> getApplyDtos(ApiRoleAuthReqVo reqVo, String defaultIdcard, String defaultAppCode,
|
|
|
+ Map<String, AuthUserVo> userVoMap, Map<String, ApplyInfoVo> appVoMap, Map<String, List<RoleInfo>> roleMap) {
|
|
|
+ List<ApiRoleAuthContentVo> contents = reqVo.getContents();
|
|
|
+ return contents.stream().map(e -> {
|
|
|
+ String applyUserIdcard = Optional.ofNullable(e.getApplyUserIdcard()).orElse(defaultIdcard);
|
|
|
+ String appCode = Optional.ofNullable(e.getAppCode()).orElse(defaultAppCode);
|
|
|
+
|
|
|
+ RoleAuthApplyDto applyDto = new RoleAuthApplyDto();
|
|
|
+ applyDto.setUserInfo(userVoMap.get(applyUserIdcard));
|
|
|
+
|
|
|
+ ApplyInfoVo applyInfoVo = appVoMap.get(appCode);
|
|
|
+ List<RoleInfo> roleList = roleMap.get(applyInfoVo.getId());
|
|
|
+ List<ApplyRoleInVo> collect = roleList.stream().map(r -> {
|
|
|
+ ApplyRoleInVo applyVo = new ApplyRoleInVo();
|
|
|
+ applyVo.setApply(BooleanEnum.FALSE.value);
|
|
|
+ applyVo.setRoleCode(r.getCode());
|
|
|
+ applyVo.setRoleName(r.getName());
|
|
|
+ applyVo.setAppId(applyInfoVo.getId());
|
|
|
+ applyVo.setAppName(applyInfoVo.getApplyName());
|
|
|
+ return applyVo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ applyDto.setApplyRoleIns(collect);
|
|
|
+ return applyDto;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private Result<List<RoleInfo>> getApplyRoles(ApiRoleAuthReqVo reqVo, List<ApplyInfoVo> applyInfoVos) {
|
|
|
+ Map<String, ApplyInfoVo> appMap = applyInfoVos.stream().collect(Collectors.toMap(ApplyInfoVo::getApplyCode, e -> e));
|
|
|
+ List<ApiRoleAuthContentVo> contents = reqVo.getContents();
|
|
|
+ List<String> roleCodes = contents.stream()
|
|
|
+ .map(ApiRoleAuthContentVo::getRoleCodes)
|
|
|
+ .flatMap(List::stream)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<RoleInfo> roleInfos = roleInfoService.getByCodes(roleCodes);
|
|
|
+ Map<String, List<RoleInfo>> roleMap = roleInfos.stream().collect(Collectors.groupingBy(RoleInfo::getAppId));
|
|
|
+ for (ApiRoleAuthContentVo authVo : contents) {
|
|
|
+ String appCode = authVo.getAppCode();
|
|
|
+ List<String> appRoleCodes = authVo.getRoleCodes();
|
|
|
+ ApplyInfoVo applyInfoVo = appMap.get(appCode);
|
|
|
+ List<RoleInfo> roles = roleMap.get(applyInfoVo.getId());
|
|
|
+ if (CollectionUtils.isEmpty(roles)) {
|
|
|
+ List<RoleInfo> notExistRoles = mapNotExistRoles(appRoleCodes, applyInfoVo);
|
|
|
+ return Result.fail(ResultEnum.FAIL.getValue(), "角色不存在", notExistRoles);
|
|
|
+ }
|
|
|
+ Set<String> exist = roles.stream().map(RoleInfo::getCode).collect(Collectors.toSet());
|
|
|
+ List<String> notExist = appRoleCodes.stream().filter(e -> !exist.contains(e)).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(notExist)) {
|
|
|
+ List<RoleInfo> notExistRoles = mapNotExistRoles(notExist, applyInfoVo);
|
|
|
+ return Result.fail(ResultEnum.FAIL.getValue(), "角色不存在", notExistRoles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.success(roleInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static List<RoleInfo> mapNotExistRoles(List<String> appRoleCodes, ApplyInfoVo applyInfoVo) {
|
|
|
+ return appRoleCodes.stream().map(e -> {
|
|
|
+ RoleInfo roleInfo = new RoleInfo();
|
|
|
+ roleInfo.setAppId(applyInfoVo.getApplyCode());
|
|
|
+ roleInfo.setCode(e);
|
|
|
+ return roleInfo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private Result<List<ApplyInfoVo>> getAppInfos(ApiRoleAuthReqVo reqVo, ApplyInfoVo defaultApp) {
|
|
|
+ List<ApiRoleAuthContentVo> contents = reqVo.getContents();
|
|
|
+ List<String> appCodes = contents.stream().map(ApiRoleAuthContentVo::getAppCode)
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<ApplyInfoVo> appInfoVos = new ArrayList<>();
|
|
|
+ appInfoVos.add(defaultApp);
|
|
|
+ if (CollectionUtils.isNotEmpty(appCodes)) {
|
|
|
+ List<ApplyInfo> appInfos = applyInfoFacade.getListByCodes(appCodes);
|
|
|
+ Set<String> exist = appInfos.stream().map(ApplyInfo::getApplyCode).collect(Collectors.toSet());
|
|
|
+ List<String> collect = appCodes.stream().filter(e -> !exist.contains(e)).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
+ List<ApplyInfoVo> notExistApps = collect.stream().map(e -> {
|
|
|
+ ApplyInfoVo vo = new ApplyInfoVo();
|
|
|
+ vo.setApplyCode(e);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return Result.fail(ResultEnum.FAIL.getValue(), "应用资源不存在", notExistApps);
|
|
|
+ }
|
|
|
+ List<ApplyInfoVo> list = DcucBeanUtil.createCopyToObjectList(appInfos, ApplyInfoVo.class);
|
|
|
+ appInfoVos.addAll(list);
|
|
|
+ }
|
|
|
+ return Result.success(appInfoVos);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Result<List<AuthUserVo>> getApplyUserInfo(ApiRoleAuthReqVo reqVo, AuthUserVo defaultUserVo) {
|
|
|
+ List<String> applyUserIdcards = reqVo.getContents()
|
|
|
+ .stream()
|
|
|
+ .map(ApiRoleAuthContentVo::getApplyUserIdcard)
|
|
|
+ .distinct()
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<AuthUserVo> list = new ArrayList<>();
|
|
|
+ list.add(defaultUserVo);
|
|
|
+ if (CollectionUtils.isNotEmpty(applyUserIdcards)) {
|
|
|
+ List<AuthUserInfo> userInfos = userInfoService.findByIdcards(applyUserIdcards);
|
|
|
+ // 判断人员是否都存在
|
|
|
+ Set<String> exist = userInfos.stream().map(AuthUserInfo::getIdcard).collect(Collectors.toSet());
|
|
|
+ List<String> collect = applyUserIdcards.stream().filter(e -> !exist.contains(e)).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
+ List<AuthUserVo> notExistUsers = collect.stream().map(e -> {
|
|
|
+ AuthUserVo vo = new AuthUserVo();
|
|
|
+ vo.setIdcard(e);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return Result.fail(ResultEnum.FAIL.getValue(), "申请授权人员不存在", notExistUsers);
|
|
|
+ }
|
|
|
+ List<AuthUserVo> userVos = DcucBeanUtil.createCopyToObjectList(userInfos, AuthUserVo.class);
|
|
|
+ list.addAll(userVos);
|
|
|
+ }
|
|
|
+ return Result.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setSecurityUser(AppTokenDetailRespVo appTokenDetail) {
|
|
|
+ UserTokenInfoRespVO userToken = appTokenDetail.getUserToken();
|
|
|
+ AppTokenInfoRespVO appToken = appTokenDetail.getAppToken();
|
|
|
+ AuthUserVo userInfo = appTokenDetail.getUserInfo();
|
|
|
+ SecurityUser securityUser = new SecurityUser();
|
|
|
+ securityUser.setId(userInfo.getId());
|
|
|
+ securityUser.setIdcard(userInfo.getIdcard());
|
|
|
+ securityUser.setManId(userInfo.getId());
|
|
|
+ securityUser.setSecurityOrg(userInfo.getOrgCode());
|
|
|
+ securityUser.setDeptId(userInfo.getOrgId());
|
|
|
+ Map<String, Object> ext = new HashMap<>();
|
|
|
+ ext.put(UserExtInfoEnum.APP_TOKEN_ID.getValue(), appToken.getAppTokenId());
|
|
|
+ ext.put(UserExtInfoEnum.USER_TOKEN_ID.getValue(), userToken.getUserTokenId());
|
|
|
+ ext.put(UserExtInfoEnum.OPEN_ID.getValue(), userToken.getPid());
|
|
|
+ securityUser.setExtendtions(ext);
|
|
|
+ UserContextUtils.setCurrentUser(securityUser);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|