|
@@ -1,78 +1,178 @@
|
|
|
package com.dragoninfo.dcuc.authweb.restcontroller.auth;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.dto.DataClassifyDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.dto.SubDataAuthDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.dto.SubDataAuthQueryDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.dto.SubDataDTO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.enumresources.SubDataAuthTypeEnum;
|
|
|
import com.dragoninfo.dcuc.auth.auth.facade.IDataAuthFacade;
|
|
|
-import com.dragoninfo.dcuc.authweb.restcontroller.auth.vo.LabelDataAuthAcceptVo;
|
|
|
-import com.dragoninfo.dcuc.authweb.restcontroller.auth.vo.OrgDataAuthAcceptVo;
|
|
|
-import com.dragoninfo.dcuc.authweb.restcontroller.auth.vo.UserDataAuthAcceptVo;
|
|
|
+import com.dragoninfo.dcuc.authweb.restcontroller.auth.vo.data.*;
|
|
|
+import com.dragoninfo.dcuc.authweb.util.VersionUtils;
|
|
|
import com.dragoninfo.duceap.core.response.Result;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @author mazq
|
|
|
* @date 2021/4/6
|
|
|
*/
|
|
|
-@Api("数据授权相关接口")
|
|
|
+@Api(tags ="数据授权API")
|
|
|
@RestController
|
|
|
-@RequestMapping("authsvr/v2/dataauth")
|
|
|
+@RequestMapping("authsvr/"+ VersionUtils.VERSION_UID +"/dataauth")
|
|
|
public class DataAuthController {
|
|
|
|
|
|
+ Logger logger = LoggerFactory.getLogger(DataAuthController.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
IDataAuthFacade dataAuthFacade;
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取属性列表,树形结构:警种1-业务域N")
|
|
|
- @GetMapping(value = "attrTreeList", produces = "application/json;charset=UTF-8")
|
|
|
- public Result<?> getAttrTreeList(){
|
|
|
+ @ApiImplicitParam(name = "name", value = "查询条件")
|
|
|
+ @GetMapping(value = "businessTreeList", produces = "application/json;charset=UTF-8")
|
|
|
+ public Result<List<PropertyTreeVo>> businessTreeList(@RequestParam(value = "name",required = false) String name){
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-// @ApiOperation(value = "获取所有数据资源")
|
|
|
-
|
|
|
+ @ApiOperation(value = "获取所有数据资源,返回返回树结构")
|
|
|
+ @ApiImplicitParam(name = "attrType",value = "数据属性类型 TABLE:表 COLUMN:列")
|
|
|
+ @GetMapping(value = "allDataTree", produces = "application/json;charset=UTF-8")
|
|
|
+ public Result<List<DataClassifyVo>> getAllDataResource(@RequestParam("attrType") String attrType){
|
|
|
+ logger.info("allDataTree>>attrType:{}", attrType);
|
|
|
+ List<DataClassifyDTO> dtos = dataAuthFacade.getAllDataResourceTree(attrType);
|
|
|
+ List<DataClassifyVo> vos = dtos.stream().map(item -> {
|
|
|
+ DataClassifyVo vo = new DataClassifyVo();
|
|
|
+ BeanUtils.copyProperties(item, vo);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return Result.success(vos);
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation(value = "人员数据授权接口")
|
|
|
@PostMapping(value = "userDataAuth", produces = "application/json;charset=UTF-8")
|
|
|
- public Result userDataAuth(@RequestBody UserDataAuthAcceptVo userDataAuthAcceptVo){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return Result.success();
|
|
|
+ public Result<Boolean> userDataAuth(@RequestBody UserDataAuthAcceptVo vo){
|
|
|
+ List<DataAuthAcceptVo> authVoList = vo.getAuthVoList();
|
|
|
+ if(CollectionUtils.isEmpty(authVoList)) {
|
|
|
+ return Result.failMessage("权限集合为空");
|
|
|
+ }
|
|
|
+ logger.info("userDataAuth>>userDataAuthAcceptVo",JSON.toJSONString(vo));
|
|
|
+ SubDataAuthDTO subDataAuthDTO = convertToSubAuthDTO(vo.getUserId(), SubDataAuthTypeEnum.SUB_DATA_AUTH_USER.getValue(), vo.getAuthType(), authVoList);
|
|
|
+ dataAuthFacade.subDataAuthAdd(subDataAuthDTO);
|
|
|
+ return Result.success(true);
|
|
|
}
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "机构数据授权接口")
|
|
|
@PostMapping(value = "orgDataAuth", produces = "application/json;charset=UTF-8")
|
|
|
- public Result orgDataAuth(@RequestBody OrgDataAuthAcceptVo orgDataAuthAcceptVo){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return Result.success();
|
|
|
+ public Result<Boolean> orgDataAuth(@RequestBody OrgDataAuthAcceptVo vo){
|
|
|
+ List<DataAuthAcceptVo> authVoList = vo.getAuthVoList();
|
|
|
+ if(CollectionUtils.isEmpty(authVoList)){
|
|
|
+ return Result.failMessage("权限集合为空");
|
|
|
+ }
|
|
|
+ logger.info("orgDataAuth>>orgDataAuthAcceptVo",JSON.toJSONString(vo));
|
|
|
+ SubDataAuthDTO subDataAuthDTO = convertToSubAuthDTO(vo.getOrgId(), SubDataAuthTypeEnum.SUB_DATA_AUTH_ORG.getValue(), vo.getAuthType(), authVoList);
|
|
|
+ dataAuthFacade.subDataAuthAdd(subDataAuthDTO);
|
|
|
+ return Result.success(true);
|
|
|
}
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "业务域标签数据授权接口")
|
|
|
@PostMapping(value = "labelDataAuth", produces = "application/json;charset=UTF-8")
|
|
|
- public Result labelDataAuth(@RequestBody LabelDataAuthAcceptVo labelDataAuthAcceptVo){
|
|
|
+ public Result<Boolean> labelDataAuth(@RequestBody LabelDataAuthAcceptVo vo){
|
|
|
+ List<DataAuthAcceptVo> authVoList = vo.getAuthVoList();
|
|
|
+ if(CollectionUtils.isEmpty(authVoList)){
|
|
|
+ return Result.failMessage("权限集合为空");
|
|
|
+ }
|
|
|
+ logger.info("labelDataAuth>>labelDataAuthAcceptVo",JSON.toJSONString(vo));
|
|
|
+ SubDataAuthDTO subDataAuthDTO = convertToSubAuthDTO(vo.getCode(), SubDataAuthTypeEnum.SUB_DATA_AUTH_BUSINESS.getValue(), vo.getAuthType(), authVoList);
|
|
|
+ dataAuthFacade.subDataAuthAdd(subDataAuthDTO);
|
|
|
+ return Result.success(true);
|
|
|
+ }
|
|
|
|
|
|
+ @ApiOperation(value = "查询多个主体相关数据权限")
|
|
|
+ @PostMapping(value = "subListDataAuth", produces = "application/json;charset=UTF-8")
|
|
|
+ public Result subDataAuthList(@RequestBody List<SubDataAuthQueryVo> queryVoList) {
|
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "人员视角数据权限查询")
|
|
|
- @ApiImplicitParam(name = "userId",value = "人员id")
|
|
|
- @GetMapping(value = "userDataAuthInfo")
|
|
|
- public Result userDataAuthInfo(@RequestParam("userId") String userId){
|
|
|
+ @ApiOperation(value = "查询单个主体数据权限")
|
|
|
+ @PostMapping(value = "getSubDataAuth" , produces = "application/json;charset=UTF-8")
|
|
|
+ public Result<List<DataClassifyVo>> getSubDataAuth(@RequestBody SubDataAuthQueryVo queryVo){
|
|
|
+ logger.info("getSubDataAuth >> vo:{}",JSON.toJSONString(queryVo));
|
|
|
+ SubDataAuthQueryDTO queryDTO = new SubDataAuthQueryDTO();
|
|
|
+ BeanUtils.copyProperties(queryVo,queryDTO);
|
|
|
+ List<DataClassifyDTO> dtos = dataAuthFacade.getSubDataAuth(queryDTO);
|
|
|
+ List<DataClassifyVo> vos = dtos.stream().map(item -> {
|
|
|
+ DataClassifyVo vo = new DataClassifyVo();
|
|
|
+ BeanUtils.copyProperties(item, vo);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return Result.success(vos);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- return Result.success();
|
|
|
+ @ApiOperation(value = "人员视角数据权限查询-根据人员id查询")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(name = "userId",value = "人员id"),
|
|
|
+ @ApiImplicitParam(name = "authType",value = "数据属性授权类型 TABLE:表授权 COLUMN:列授权")
|
|
|
+ })
|
|
|
+ @GetMapping(value = "dataAuthInfoByUserId" , produces = "application/json;charset=UTF-8")
|
|
|
+ public Result<List<DataClassifyVo>> userDataAuthInfoById(@RequestParam("userId") String userId,
|
|
|
+ @RequestParam(value = "authType") String authType){
|
|
|
+ logger.info("dataAuthInfoByUserId >> userId:{},authType:{}", userId, authType);
|
|
|
+ List<DataClassifyDTO> dtos = dataAuthFacade.userDataAuthInfoByUserId(userId, authType);
|
|
|
+ List<DataClassifyVo> vos = dtos.stream().map(item -> {
|
|
|
+ DataClassifyVo vo = new DataClassifyVo();
|
|
|
+ BeanUtils.copyProperties(item, vo);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return Result.success(vos);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "人员视角数据权限查询-根据人员身份证号查询")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(name = "idcard",value = "身份证号"),
|
|
|
+ @ApiImplicitParam(name = "authType",value = "数据属性授权类型 TABLE:表授权 COLUMN:列授权")
|
|
|
+ })
|
|
|
+ @GetMapping(value = "dataAuthInfoByIdcard" , produces = "application/json;charset=UTF-8")
|
|
|
+ public Result<List<DataClassifyVo>> userDataAuthInfoByIdcard(@RequestParam("idcard") String idcard,
|
|
|
+ @RequestParam(value = "authType") String authType){
|
|
|
+ List<DataClassifyDTO> dtos = dataAuthFacade.userDataAuthInfoByIdcard(idcard, authType);
|
|
|
+ List<DataClassifyVo> vos = dtos.stream().map(item -> {
|
|
|
+ DataClassifyVo vo = new DataClassifyVo();
|
|
|
+ BeanUtils.copyProperties(item, vo);
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return Result.success(vos);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ private SubDataAuthDTO convertToSubAuthDTO(String subId, String subType, String authType,List<DataAuthAcceptVo> authVoList) {
|
|
|
+ SubDataAuthDTO subDataAuthDTO = new SubDataAuthDTO(subId,subType,authType);
|
|
|
+ List<SubDataDTO> dataDTOList = new ArrayList<>();
|
|
|
+ for (DataAuthAcceptVo vo : authVoList) {
|
|
|
+ SubDataDTO subDataDTO = new SubDataDTO();
|
|
|
+ subDataDTO.setDataType(vo.getDataType());
|
|
|
+ subDataDTO.setDataCode(vo.getDataCode());
|
|
|
+ dataDTOList.add(subDataDTO);
|
|
|
+ }
|
|
|
+ subDataAuthDTO.setDataAuthList(dataDTOList);
|
|
|
+ return subDataAuthDTO;
|
|
|
+ }
|
|
|
|
|
|
}
|