|
@@ -0,0 +1,81 @@
|
|
|
+package com.dragoninfo.dcuc.authweb.restcontroller.api.authservice.v2.controller;
|
|
|
+
|
|
|
+import com.dragoninfo.dcuc.app.entity.ApplyInfo;
|
|
|
+import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.facade.IRoleFacade;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.facade.IStaffAssignAuthInfoFacade;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.vo.StaffRoleAuthApiV2Vo;
|
|
|
+import com.dragoninfo.dcuc.authweb.util.VersionUtils;
|
|
|
+import com.dragoninfo.dcuc.common.entity.ApiResult;
|
|
|
+import com.dragoninfo.dcuc.common.entity.ApiSearchReq;
|
|
|
+import com.dragoninfo.dcuc.common.utils.SearchableUtil;
|
|
|
+import com.dragonsoft.duceap.base.enums.BooleanEnum;
|
|
|
+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.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 java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author mazq
|
|
|
+ * @date 2022/2/17
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@Api(tags = {"人员-角色授权查询接口"})
|
|
|
+@RequestMapping(value = "/api/auth-service/" + VersionUtils.VERSION_UID + "/staff-role-auth")
|
|
|
+public class StaffRoleAuthV2Controller {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRoleFacade roleFacade;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IApplyInfoFacade applyInfoFacade;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IStaffAssignAuthInfoFacade staffAssignAuthInfoFacade;
|
|
|
+
|
|
|
+ @ApiOperation("应用下的角色授权列表")
|
|
|
+ @PostMapping("role/staff-auth")
|
|
|
+ public ApiResult staffRoleAuthResult(@RequestBody ApiSearchReq apiSearchReq) {
|
|
|
+ Map<String, SearchOperator[]> requestMap = new HashMap<>();
|
|
|
+ requestMap.put("appCode", new SearchOperator[]{SearchOperator.eq});
|
|
|
+ requestMap.put("roleCode", new SearchOperator[]{SearchOperator.eq, SearchOperator.in});
|
|
|
+ requestMap.put("orgCode", new SearchOperator[]{SearchOperator.eq, SearchOperator.like});
|
|
|
+ requestMap.put("userName", new SearchOperator[]{SearchOperator.like});
|
|
|
+ requestMap.put("postStatus", new SearchOperator[]{SearchOperator.eq, SearchOperator.in});
|
|
|
+ Searchable searchable;
|
|
|
+ try {
|
|
|
+ searchable = SearchableUtil.parseApiSearchReqToSearchable(apiSearchReq, requestMap, 1000);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ String message = e.getMessage();
|
|
|
+ return ApiResult.setFailMessage(message);
|
|
|
+ }
|
|
|
+ //参数校验
|
|
|
+ Condition appCodeEq = searchable.getSearchFilter("appCode", SearchOperator.eq);
|
|
|
+ if (null == appCodeEq) {
|
|
|
+ return ApiResult.setFailMessage("应用编码不能为空");
|
|
|
+ }
|
|
|
+ ApplyInfo appInfo = applyInfoFacade.getAppByCode(appCodeEq.getValue().toString());
|
|
|
+ if (null == appInfo) {
|
|
|
+ return ApiResult.setFailMessage("应用不存在");
|
|
|
+ }
|
|
|
+ if (BooleanEnum.TRUE.value.equals(appInfo.getApplyStatus())) {
|
|
|
+ return ApiResult.setFailMessage("应用已禁用");
|
|
|
+ }
|
|
|
+ searchable.addSearchFilter("appId", SearchOperator.eq, appInfo.getId());
|
|
|
+ Page<StaffRoleAuthApiV2Vo> page = staffAssignAuthInfoFacade.apiStaffRoleAuthV2Result(searchable.toSearchDTO());
|
|
|
+ return ApiResult.setSuccessPage(page.getTotalElements(), page.getContent());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|