فهرست منبع

Merge branch 'develop' into 'master'

Develop

See merge request dcuc-tjdsj/auth-back!148
马志强 2 سال پیش
والد
کامیت
16394dfbb9

+ 0 - 5
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/api/authservice/v1/controller/StaffRoleAuthController.java

@@ -132,12 +132,7 @@ public class StaffRoleAuthController {
     @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("操作人身份证号为空");
         }

+ 4 - 6
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/api/authservice/v1/controller/WorkFlowApiController.java

@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * @author mazq
@@ -54,17 +55,14 @@ public class WorkFlowApiController {
     @ResponseBody
     public ApiResult serviceAuthFlowSave(@RequestBody @Validated ServiceAuthFlowAcceptVo serviceAuthFlowVo, HttpServletRequest request) {
         String idcard = HeadTokenUtils.getIdcard(request);
-        String userToken = HeadTokenUtils.getUserToken(request);
         String applyAppCode = HeadTokenUtils.getAppCode(request);
-        String user = idcard;
-        if (StringUtils.isBlank(user)) {
-            DecodedJWT decode = JWT.decode(userToken);
-            user = decode.getClaim("idCard").asString();
+        if (StringUtils.isBlank(idcard)) {
+            return ApiResult.setFailMessage("用户凭据为空");
         }
         ServiceAuthFlowDTO dto = new ServiceAuthFlowDTO();
         setAppServiceInfo(dto, serviceAuthFlowVo);
         BeanUtils.copyProperties(serviceAuthFlowVo, dto, "serviceCodes", "serviceNames");
-        dto.setUser(user);
+        dto.setUser(idcard);
         dto.setApplyAppCode(applyAppCode);
         ResponseDTO responseDTO = serviceAuthFlowFacade.serviceAuthFlowSave(dto);
         String statusCode = responseDTO.getStatusCode();

+ 53 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/AuthRoleOrgController.java

@@ -0,0 +1,53 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.auth;
+
+import com.dragoninfo.dcuc.auth.auth.facade.IAuthRoleOrgRelFacade;
+import com.dragoninfo.dcuc.auth.auth.vo.roleorgauth.RoleOrgAuthSaveVo;
+import com.dragoninfo.dcuc.auth.auth.vo.roleorgauth.RoleOrgAuthVo;
+import com.dragoninfo.duceap.core.response.Result;
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
+import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+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.List;
+
+/**
+ * @author mazq
+ * @date 2023/6/6
+ */
+@Api(tags = "机构角色授权管理")
+@RestController
+@RequestMapping("authsvr/v2/role-org-auth")
+public class AuthRoleOrgController {
+
+    @Autowired
+    private IAuthRoleOrgRelFacade authRoleOrgRelFacade;
+
+    @ApiOperation(value = "机构角色授权分页查询")
+    @ApiImplicitParam(name = "searchable", value = "[orgId eq] [appId eq] [roleName like]")
+    @PostMapping("page")
+    public Result<List<RoleOrgAuthVo>> roleAuthPage(SearchDTO searchDTO) {
+        Page<RoleOrgAuthVo> page = authRoleOrgRelFacade.roleAuthPage(searchDTO);
+        return Result.success(page.getTotalElements(), page.getContent());
+    }
+
+    @ApiOperation(value = "机构角色授权保存")
+    @PostMapping("save")
+    public Result<Object> roleAuthSave(@Valid @RequestBody RoleOrgAuthSaveVo saveVo) {
+        ResponseStatus responseStatus = authRoleOrgRelFacade.roleAuthSave(saveVo);
+        return new Result<>(responseStatus.getStatusCode(), responseStatus.getMessage(), null, null);
+    }
+
+    @ApiOperation(value = "获取已授权的角色id")
+    @GetMapping("auth-role-ids")
+    public Result<List<String>> getAuthRoleIds(@RequestParam("orgId") String orgId) {
+        List<String> authRoleIds = authRoleOrgRelFacade.getAuthRoleIds(orgId);
+        return Result.success(authRoleIds);
+    }
+
+}

+ 0 - 49
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/statisics/ManageStatisicsController.java

@@ -1,49 +0,0 @@
-//package com.dragoninfo.dcuc.authweb.restcontroller.statisics;
-//
-//import com.dragoninfo.dcuc.auth.admin.facade.IManageInfoFacade;
-//import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
-//import com.dragonsoft.duceap.web.controller.BaseController;
-//import io.swagger.annotations.Api;
-//import io.swagger.annotations.ApiImplicitParam;
-//import io.swagger.annotations.ApiImplicitParams;
-//import io.swagger.annotations.ApiOperation;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.web.bind.annotation.GetMapping;
-//import org.springframework.web.bind.annotation.PathVariable;
-//import org.springframework.web.bind.annotation.RequestMapping;
-//import org.springframework.web.bind.annotation.RestController;
-//
-//import java.util.List;
-//import java.util.Map;
-//
-///**
-// * Created by liws on 2018/9/21.
-// */
-//@Api(tags = {"管理员统计"})
-//@RestController
-//@RequestMapping(value = "managesvr")
-//public class ManageStatisicsController extends BaseController {
-//    @Autowired
-//    private IOrgInfoFacade iOrgInfoFacade;
-//    @Autowired
-//    private IManageInfoFacade iManageInfoFacade;
-//
-//    /**
-//     * 获取管理员分布详情信息列表
-//     *
-//     * @param id
-//     * @return
-//     */
-//
-//    @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true
-//            , example = "40288a8b699fc2500169a33b20540000")})
-//    @ApiOperation(value = "获取警员管理员统计列表")
-//    @GetMapping(value = "statisics/{id}")
-//    public List<Map<String, String>> getMgeSpreadDtlList(@PathVariable String id) {
-//        if (id.equals("null")) {
-//            id = "";
-//        }
-//        List<Map<String, String>> list = iManageInfoFacade.mgeSpreadDtlListForGD(id);
-//        return list;
-//    }
-//}

+ 0 - 158
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/statisics/UserStatisicsController.java

@@ -1,158 +0,0 @@
-//package com.dragoninfo.dcuc.authweb.restcontroller.statisics;
-//
-//import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.org.OrgTreeNodeVo;
-//import com.dragoninfo.dcuc.duceap.enums.UserTypeEnum;
-//import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
-//import com.dragoninfo.dcuc.org.vo.OrgTreeNode;
-//import com.dragonsoft.duceap.commons.util.string.StringUtils;
-//import com.dragonsoft.duceap.web.controller.BaseController;
-//import io.swagger.annotations.Api;
-//import io.swagger.annotations.ApiImplicitParam;
-//import io.swagger.annotations.ApiImplicitParams;
-//import io.swagger.annotations.ApiOperation;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.web.bind.annotation.GetMapping;
-//import org.springframework.web.bind.annotation.PathVariable;
-//import org.springframework.web.bind.annotation.RequestMapping;
-//import org.springframework.web.bind.annotation.RestController;
-//
-//import java.util.ArrayList;
-//import java.util.List;
-//
-///**
-// * Created by liws on 2018/9/21.
-// */
-//@Api(tags = {"用户统计"})
-//@RestController
-//@RequestMapping(value = "usersvr")
-//public class UserStatisicsController extends BaseController {
-//    @Autowired
-//    private IUserInfoFacade iUserInfoFacade;
-//    @Autowired
-//    private IOrgInfoFacade iOrgInfoFacade;
-//
-//    /**
-//     * 完整树
-//     *
-//     * @param id 节点机构id
-//     * @return
-//     */
-//    @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "机构ID", required = true
-//            , example = "40288a8b699fc2500169a33b20540000")})
-//    @ApiOperation(value = "获取完整树下各用户数量")
-//    @GetMapping(value = "statisics/{id}")
-//    public List<OrgTreeNodeVo> treeGrid(@PathVariable String id) {
-//        if (StringUtils.isEmpty(id) || id.equals("null")) {
-//            id = iOrgInfoFacade.getRootOrgId();
-//            OrgTreeNode orgTreeNode = iOrgInfoFacade.getOrgTreeNode(id);
-//            int orgCount = iOrgInfoFacade.allOrgNum();
-//            int userCount = iUserInfoFacade.allUserNum();
-//            orgTreeNode.setCount(orgCount);
-//            int policeNum = iUserInfoFacade.allUserTypeNum(UserTypeEnum.POLICE.getValue());
-//            orgTreeNode.setPoliceNum(policeNum);
-//            int helperNum = iUserInfoFacade.allUserTypeNum(UserTypeEnum.HELPER.getValue());
-//            orgTreeNode.setAuxiliaryNum(helperNum);
-//            int externalNum = iUserInfoFacade.allUserTypeNum(UserTypeEnum.EXTERNAL.getValue());
-//            orgTreeNode.setExternalNum(externalNum);
-//            orgTreeNode.setUserNum(userCount);
-//            List<OrgTreeNode> resultList = new ArrayList<OrgTreeNode>();
-//            resultList.add(orgTreeNode);
-//            List<OrgTreeNodeVo> orgTreeNodeVos = this.treeNodeToVo(resultList);
-//            return orgTreeNodeVos;
-//        } else {
-//            List<OrgTreeNode> resultList = iOrgInfoFacade.countChildOrgTreeNode(id);
-//            List<OrgTreeNodeVo> orgTreeNodeVos = this.treeNodeToVo(resultList);
-//            return orgTreeNodeVos;
-//        }
-//    }
-//
-////
-////    @RequestMapping(value = "provinces")
-////    @ResponseBody
-////    public List provinces() {
-////        Searchable searchable = Searchable.newSearchable();
-////        searchable.addSearchFilter("ranged",SearchOperator.eq,dcucWebConfig.getStatisticsRange());
-////        SearchDTO searchDTO = searchable.toSearchDTO();
-////        searchDTO.setSize("100");
-////        searchDTO.setPage("1");
-////        List<Map<String, String>> result = new ArrayList<Map<String, String>>();
-////        Page<AreaInfo> page = iOrgInfoFacade.areaMap(searchDTO);
-////        List<AreaInfo> areas = page.getContent();
-////        for (AreaInfo area : areas) {
-////            Map<String, String> countMap = null;
-////            if (dcucWebConfig.getStatisticsRange().equals(UserAreaEnum.HZ_AREA.getValue())) {
-////                String areacode = area.getCode().substring(0, 2);
-////                countMap = iUserInfoFacade.countUserByArea(areacode, false, true);
-////            } else if (dcucWebConfig.getStatisticsRange().equals(UserAreaEnum.GD_AREA.getValue())) {
-////                String areacode = area.getCode().substring(0, 4);
-////                countMap = iUserInfoFacade.countUserByArea(areacode, false, false);
-////            }
-////            countMap.put("area", area.getName());
-////            result.add(countMap);
-////        }
-////        return result;
-////    }
-////
-////    /**
-////     * 导出列表
-////     *
-////     * @param searchDTO
-////     * @param request
-////     */
-////    @RequestMapping(value = "excel")
-////    public void listExport(Searchable searchable, HttpServletRequest request, HttpServletResponse response) {
-////        try {
-////            searchable.addSearchFilter("ranged",SearchOperator.eq,dcucWebConfig.getStatisticsRange());
-////            SearchDTO searchDTO = searchable.toSearchDTO();
-////            searchDTO.setSize(searchDTO.getTotal());
-////            searchDTO.setPage("1");
-////            List<Map<String, String>> result = new ArrayList<Map<String, String>>();
-////            Page<AreaInfo> page = iOrgInfoFacade.areaMap(searchDTO);
-////            List<AreaInfo> areas = page.getContent();
-////            for (AreaInfo area : areas) {
-////                String areacode = area.getCode().substring(0, 2);
-////                Map<String, String> countMap = iUserInfoFacade.countUserByArea(areacode, true, true);
-////                countMap.put("area", area.getName());
-////                result.add(countMap);
-////            }
-////            Map<String, String> countMap = iUserInfoFacade.countUserByArea(null, true, true);
-////            countMap.put("area", "总计");
-////            result.add(countMap);
-////            exportExcel("全国治安用户建设情况", result, Searchable.toSearchable(searchDTO).getMetaData(), request, response);
-////        } catch (IOException e) {
-////            logger.error(e.getMessage(), e);
-////            throw new ApplicationException(300, "导出失败", e);
-////        }
-////    }
-//
-//
-//
-//    /**
-//     * 组装树节点
-//     *
-//     * @param nodeList
-//     * @return
-//     */
-//    private List<OrgTreeNodeVo> treeNodeToVo(List<OrgTreeNode> nodeList) {
-//        List<OrgTreeNodeVo> result = new ArrayList<>();
-//        for (OrgTreeNode orgTreeNode : nodeList) {
-//            OrgTreeNodeVo orgTreeNodeVo = new OrgTreeNodeVo();
-//            orgTreeNodeVo.setId(orgTreeNode.getValue());
-//            orgTreeNodeVo.setCode( orgTreeNode.getCode());
-//            orgTreeNodeVo.setName(orgTreeNode.getLabel());
-//            orgTreeNodeVo.setPid(orgTreeNode.getPid());
-//            orgTreeNodeVo.setOrgNum(orgTreeNode.getCount());
-//            orgTreeNodeVo.setUserNum(orgTreeNode.getUserNum());
-//            orgTreeNodeVo.setPoliceUserCount(orgTreeNode.getPoliceNum());
-//            orgTreeNodeVo.setAuxiliUserCount(orgTreeNode.getAuxiliaryNum());
-//            orgTreeNodeVo.setExtcerUserCount(orgTreeNode.getExternalNum());
-//            if (orgTreeNode.getChildIds() != null && orgTreeNode.getChildIds().size() > 0) {
-//                orgTreeNodeVo.setIsParent(true);
-//            } else {
-//                orgTreeNodeVo.setIsParent(false);
-//            }
-//            result.add(orgTreeNodeVo);
-//        }
-//        return result;
-//    }
-//}

+ 39 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/statistics/StatisticsController.java

@@ -0,0 +1,39 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.statistics;
+
+import com.dragoninfo.dcuc.auth.statistics.IStatisticsFacade;
+import com.dragoninfo.dcuc.auth.statistics.ObjStatisticsVo;
+import com.dragoninfo.dcuc.auth.statistics.StatisticsReqVo;
+import com.dragoninfo.dcuc.auth.statistics.SubStatisticsVo;
+import com.dragoninfo.duceap.core.response.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author mazq
+ * @date 2023/6/7
+ */
+@Api(tags = "主客体统计")
+@RestController
+@RequestMapping("/statistics/v2/")
+public class StatisticsController {
+
+    @Autowired
+    private IStatisticsFacade statisticsFacade;
+
+    @ApiOperation(value = "主体统计")
+    @PostMapping("sub-statistics")
+    public Result<SubStatisticsVo> subStatistics(@RequestBody StatisticsReqVo reqVo) {
+        SubStatisticsVo subStatisticsVo = statisticsFacade.subStatistics(reqVo);
+        return Result.success(subStatisticsVo);
+    }
+
+    @ApiOperation(value = "客体统计")
+    @PostMapping("obj-statistics")
+    public Result<ObjStatisticsVo> objStatistics(@RequestBody StatisticsReqVo reqVo) {
+        ObjStatisticsVo objStatisticsVo = statisticsFacade.objStatistics(reqVo);
+        return Result.success(objStatisticsVo);
+    }
+
+}

+ 18 - 1
src/main/java/com/dragoninfo/dcuc/authweb/util/HeadTokenUtils.java

@@ -1,7 +1,10 @@
 package com.dragoninfo.dcuc.authweb.util;
 
 import cn.hutool.core.util.StrUtil;
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.interfaces.DecodedJWT;
 import com.dragoninfo.dcuc.common.Constants;
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -12,11 +15,20 @@ import javax.servlet.http.HttpServletRequest;
 public class HeadTokenUtils {
 
     public static String getIdcard(HttpServletRequest request) {
+        // 获取基础凭据
         String idcard = request.getHeader(Constants.IDCARD);
+        // 获取总线的IDCARD
         if (StrUtil.isBlank(idcard)) {
-            // 获取总线的IDCARD
             idcard = request.getHeader(Constants.BUS_SRE_IDCARD);
         }
+        // 获取令牌中的身份证号
+        if (StringUtils.isBlank(idcard)) {
+            String userToken = getUserToken(request);
+            if (StringUtils.isNotBlank(userToken)) {
+                DecodedJWT decode = JWT.decode(userToken);
+                idcard = decode.getClaim("idCard").asString();
+            }
+        }
         return idcard;
     }
 
@@ -26,6 +38,11 @@ public class HeadTokenUtils {
             // 获取总线的应用代码
             appCode = request.getHeader(Constants.BUS_SRA_ID);
         }
+        if (StringUtils.isBlank(appCode)) {
+            String appToken = getAppToken(request);
+            DecodedJWT decode = JWT.decode(appToken);
+            appCode = decode.getClaim("appCode").asString();
+        }
         return appCode;
     }