|
@@ -1,38 +1,40 @@
|
|
|
package com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.controller;
|
|
|
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.auth0.jwt.JWT;
|
|
|
+import com.auth0.jwt.interfaces.DecodedJWT;
|
|
|
import com.dragoninfo.dcuc.app.entity.ApplyInfo;
|
|
|
import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
|
|
|
-import com.dragoninfo.dcuc.auth.auth.dto.StaffAssignDTO;
|
|
|
import com.dragoninfo.dcuc.auth.auth.entity.RoleInfo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.facade.IRoleFacade;
|
|
|
import com.dragoninfo.dcuc.auth.auth.facade.IStaffAssignAuthInfoFacade;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.RoleInfoApiVo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.StaffRoleAuthApiVo;
|
|
|
-import com.dragoninfo.dcuc.auth.sub.dto.AuthUserDTO;
|
|
|
-import com.dragoninfo.dcuc.auth.sub.facade.IAuthUserInfoFacade;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.vo.StaffRoleAuthReqVo;
|
|
|
import com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.vo.UserRoleAuthReqVO;
|
|
|
import com.dragoninfo.dcuc.authweb.util.VersionUtils;
|
|
|
+import com.dragoninfo.dcuc.common.Constants;
|
|
|
import com.dragoninfo.dcuc.common.entity.ApiResult;
|
|
|
import com.dragoninfo.dcuc.common.entity.ApiSearchReq;
|
|
|
import com.dragoninfo.dcuc.common.utils.ResponseUtil;
|
|
|
import com.dragoninfo.dcuc.common.utils.SearchableUtil;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
import com.dragonsoft.duceap.base.enums.BooleanEnum;
|
|
|
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
|
|
|
import com.dragonsoft.duceap.core.search.Searchable;
|
|
|
import com.dragonsoft.duceap.core.search.enums.SearchOperator;
|
|
|
import com.dragonsoft.duceap.core.search.filter.Condition;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
-import java.util.*;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -54,9 +56,6 @@ public class StaffRoleAuthController {
|
|
|
@Autowired
|
|
|
private IStaffAssignAuthInfoFacade staffAssignAuthInfoFacade;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IAuthUserInfoFacade userInfoFacad;
|
|
|
-
|
|
|
@ApiOperation("应用下的角色列表查询(不分页)")
|
|
|
@PostMapping("role/search")
|
|
|
public ApiResult roleInfoList(@RequestBody ApiSearchReq apiSearchReq) {
|
|
@@ -129,65 +128,24 @@ public class StaffRoleAuthController {
|
|
|
|
|
|
@ApiOperation("修改人员对应的应用角色")
|
|
|
@PutMapping("role/users")
|
|
|
- public ApiResult userRoleSave(@Valid @RequestBody UserRoleAuthReqVO userRoleAuthReqVO) {
|
|
|
- List<String> roleCodeList = Optional
|
|
|
- .ofNullable(userRoleAuthReqVO.getRoleCodeList())
|
|
|
- .orElse(Collections.emptyList());
|
|
|
- String idcard = userRoleAuthReqVO.getIdcard();
|
|
|
- String appCode = userRoleAuthReqVO.getAppCode();
|
|
|
-
|
|
|
- // 查询人员信息
|
|
|
- AuthUserDTO userDTO = userInfoFacad.findByIdcard(idcard);
|
|
|
- if (null == userDTO) {
|
|
|
- return ApiResult.setFailMessage("人员不存在");
|
|
|
+ public ApiResult userRoleSave(@RequestHeader(value = Constants.DCUC_USER_TOKEN, required = false) String userToken,
|
|
|
+ @RequestHeader(value = Constants.IDCARD, required = false) String operateIdcard,
|
|
|
+ @Valid @RequestBody UserRoleAuthReqVO userRoleAuthReqVO) {
|
|
|
+ if (StringUtils.isBlank(operateIdcard)) {
|
|
|
+ DecodedJWT decode = JWT.decode(userToken);
|
|
|
+ operateIdcard = decode.getClaim("idCard").asString();
|
|
|
}
|
|
|
-
|
|
|
- ApplyInfo appInfo = applyInfoFacade.getAppByCode(appCode);
|
|
|
- if (null == appInfo) {
|
|
|
- return ApiResult.setFailMessage("应用资源不存在");
|
|
|
+ if (StringUtils.isBlank(operateIdcard)) {
|
|
|
+ return ApiResult.setFailMessage("操作人身份证号为空");
|
|
|
}
|
|
|
|
|
|
- // 查询应用角色信息
|
|
|
- List<RoleInfo> roleInfos = roleFacade.getRolesByAppId(appInfo.getId());
|
|
|
-
|
|
|
- // 过滤角色信息
|
|
|
- List<String> roleIds = roleInfos.stream()
|
|
|
- .filter(e -> roleCodeList.contains(e.getCode()))
|
|
|
- .map(RoleInfo::getId)
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- // 删除应用下的角色信息
|
|
|
- StaffAssignDTO dto = new StaffAssignDTO();
|
|
|
- dto.setUserId(userDTO.getId());
|
|
|
- dto.setOrgId(userDTO.getOrgId());
|
|
|
-
|
|
|
- List<JSONObject> collect = roleIds.stream()
|
|
|
- .map(e -> {
|
|
|
- JSONObject json = new JSONObject();
|
|
|
- json.put("id", e);
|
|
|
- json.put("appId", appInfo.getId());
|
|
|
- return json;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- String arrs = JSON.toJSONString(collect);
|
|
|
- String empStr = JSON.toJSONString(Collections.emptyList());
|
|
|
-
|
|
|
-
|
|
|
- if (CollUtil.isNotEmpty(roleCodeList)) {
|
|
|
- dto.setDeleteIds(arrs);
|
|
|
- dto.setSaveIds(empStr);
|
|
|
- ResponseStatus status = staffAssignAuthInfoFacade.saveStaff(dto);
|
|
|
- if (ResponseUtil.isSuccess(status)) {
|
|
|
- return ApiResult.setSuccess();
|
|
|
- } else {
|
|
|
- return ApiResult.setFailMessage(status.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
+ log.info("api role users operateIdcard:{}", operateIdcard);
|
|
|
|
|
|
- dto.setDeleteIds(empStr);
|
|
|
- dto.setSaveIds(arrs);
|
|
|
+ StaffRoleAuthReqVo reqVo = new StaffRoleAuthReqVo();
|
|
|
+ BeanUtils.copyProperties(userRoleAuthReqVO, reqVo);
|
|
|
+ reqVo.setOperateIdcard(operateIdcard);
|
|
|
|
|
|
- ResponseStatus status = staffAssignAuthInfoFacade.saveStaff(dto);
|
|
|
+ ResponseStatus status = staffAssignAuthInfoFacade.apiStaffRoleAuth(reqVo);
|
|
|
if (ResponseUtil.isSuccess(status)) {
|
|
|
return ApiResult.setSuccess();
|
|
|
} else {
|