|
@@ -1,5 +1,7 @@
|
|
|
package com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.controller;
|
|
|
|
|
|
+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.entity.RoleInfo;
|
|
@@ -7,24 +9,31 @@ 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.auth.vo.StaffRoleAuthReqVo;
|
|
|
+import com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v1.vo.UserRoleAuthReqVO;
|
|
|
+import com.dragoninfo.dcuc.authweb.util.HeadTokenUtils;
|
|
|
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.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -63,14 +72,14 @@ public class StaffRoleAuthController {
|
|
|
}
|
|
|
//参数校验
|
|
|
Condition appCodeEq = searchable.getSearchFilter("appCode", SearchOperator.eq);
|
|
|
- if(null == appCodeEq) {
|
|
|
+ if (null == appCodeEq) {
|
|
|
return ApiResult.setFailMessage("应用编码不能为空");
|
|
|
}
|
|
|
ApplyInfo appInfo = applyInfoFacade.getAppByCode(appCodeEq.getValue().toString());
|
|
|
- if(null == appInfo) {
|
|
|
+ if (null == appInfo) {
|
|
|
return ApiResult.setFailMessage("应用不存在");
|
|
|
}
|
|
|
- if(BooleanEnum.TRUE.value.equals(appInfo.getApplyStatus())) {
|
|
|
+ if (BooleanEnum.TRUE.value.equals(appInfo.getApplyStatus())) {
|
|
|
return ApiResult.setFailMessage("应用已禁用");
|
|
|
}
|
|
|
|
|
@@ -104,18 +113,47 @@ public class StaffRoleAuthController {
|
|
|
}
|
|
|
//参数校验
|
|
|
Condition appCodeEq = searchable.getSearchFilter("appCode", SearchOperator.eq);
|
|
|
- if(null == appCodeEq) {
|
|
|
+ if (null == appCodeEq) {
|
|
|
return ApiResult.setFailMessage("应用编码不能为空");
|
|
|
}
|
|
|
ApplyInfo appInfo = applyInfoFacade.getAppByCode(appCodeEq.getValue().toString());
|
|
|
- if(null == appInfo) {
|
|
|
+ if (null == appInfo) {
|
|
|
return ApiResult.setFailMessage("应用不存在");
|
|
|
}
|
|
|
- if(BooleanEnum.TRUE.value.equals(appInfo.getApplyStatus())) {
|
|
|
+ if (BooleanEnum.TRUE.value.equals(appInfo.getApplyStatus())) {
|
|
|
return ApiResult.setFailMessage("应用已禁用");
|
|
|
}
|
|
|
searchable.addSearchFilter("appId", SearchOperator.eq, appInfo.getId());
|
|
|
Page<StaffRoleAuthApiVo> page = staffAssignAuthInfoFacade.apiStaffRoleAuthResult(searchable.toSearchDTO());
|
|
|
return ApiResult.setSuccessPage(page.getTotalElements(), page.getContent());
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation("修改人员对应的应用角色")
|
|
|
+ @PutMapping("role/users")
|
|
|
+ public ApiResult userRoleSave(HttpServletRequest request, @Valid @RequestBody UserRoleAuthReqVO userRoleAuthReqVO) {
|
|
|
+ String operateIdcard = HeadTokenUtils.getIdcard(request);
|
|
|
+ String userToken = HeadTokenUtils.getUserToken(request);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(operateIdcard)) {
|
|
|
+ DecodedJWT decode = JWT.decode(userToken);
|
|
|
+ operateIdcard = decode.getClaim("idCard").asString();
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(operateIdcard)) {
|
|
|
+ return ApiResult.setFailMessage("操作人身份证号为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("api role users operateIdcard:{}", operateIdcard);
|
|
|
+
|
|
|
+ StaffRoleAuthReqVo reqVo = new StaffRoleAuthReqVo();
|
|
|
+ BeanUtils.copyProperties(userRoleAuthReqVO, reqVo);
|
|
|
+ reqVo.setOperateIdcard(operateIdcard);
|
|
|
+
|
|
|
+ ResponseStatus status = staffAssignAuthInfoFacade.apiStaffRoleAuth(reqVo);
|
|
|
+ if (ResponseUtil.isSuccess(status)) {
|
|
|
+ return ApiResult.setSuccess();
|
|
|
+ } else {
|
|
|
+ return ApiResult.setFailMessage(status.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|