Browse Source

Merge branch 'merge-mazq-bujz-211015' into 'develop'

fix(用户中心机构删除问题修改): 用户中心机构删除问题修改

See merge request dcuc-tjdsj/auth-back!114
马志强 3 years ago
parent
commit
3135a8bd13

+ 1 - 1
README.md

@@ -32,4 +32,4 @@
   - 主客体分离机构数据独立
   - 机构树查询接口修改
   - 内存机构树功能新增
-  - 修改调用app-service facade后applyInfo.orgId()改为applyInfo.orgCode()
+  - 修改调用app-service facade后applyInfo.orgId()改为applyInfo.orgCode() 

+ 1 - 67
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/app/AppController.java

@@ -51,8 +51,6 @@ public class AppController {
     @Autowired
     private IDuceapUploadFacade uploadFacade;
 
-    @Autowired
-    private IApplicationInfoFacade applicationInfoFacade;
 
     @ApiOperation(value = "查询所有应用列表")
     @ApiImplicitParam(name = "applyStatus", value = "applyStatus:应用在用标识(0:启用 1:禁用)")
@@ -63,7 +61,7 @@ public class AppController {
     }
 
     @ApiOperation(value = "查询应用列表")
-    @ApiImplicitParam(name = "searchable", value = "查询条件(applyName:应用名称,like;managerOrgCode:应用系统事权单位代码,like;applyStatus:应用在用标识(0:启用 1:禁用);=;)")
+    @ApiImplicitParam(name = "searchable", value = "查询条件(applyName:应用名称,like;orgCode:应用系统事权单位代码,like;applyStatus:应用在用标识(0:启用 1:禁用);=;)")
     @PostMapping(value = "apps")
     public Result<List<ApplyInfo>> applyPage(Searchable searchable) {
         SearchDTO searchDTO = searchable.toSearchDTO();
@@ -160,68 +158,4 @@ public class AppController {
         return Result.success(message);
     }
 
-
-    @ApiOperation(value = "根据厂商ID,获取厂商所有的应用")
-    @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "厂商ID", required = true
-            , example = "40288a8b699fc2500169a33b20540000")})
-    @GetMapping(value = "app/manufacturer/{mfrId}")
-    public Result<List<Map<String, String>>> getAppByMfr(@PathVariable String mfrId) {
-        if (StrUtil.isBlank(mfrId)) {
-            return Result.success(Collections.emptyList());
-        }
-
-        List<ApplyInfo> appList = applyInfoFacade.getAppListByManufacturerId(mfrId);
-        List<Map<String, String>> list = new ArrayList<>(appList.size());
-        for (ApplyInfo app : appList) {
-            Map<String, String> appmap = new HashMap<>();
-            appmap.put("code", app.getId());
-            appmap.put("value", app.getApplyName());
-            appmap.put("managerName", app.getManagerName());
-            appmap.put("managerPhone", app.getManagerPhone());
-            list.add(appmap);
-        }
-        return Result.success(list);
-    }
-
-
-    /**
-     * 根据机构Id获取应用信息列表
-     **/
-    @ApiOperation(value = "查询应用列表")
-    @ApiImplicitParam(name = "searchable", value = "查询条件")
-    @PostMapping(value = "apps/role/_serach")
-    public Result getAppList(Searchable searchable) {
-//        AuthUserDTO userInfo = authUserInfoFacade.get(ContextUtils.getUserInfo().getId());
-        //TODO
-        //权限中心同步的应用厂商非必填
-        //外部人员只能配置自己所属厂商下的应用
-//        if (UserTypeEnum.EXTERNAL.getValue().equals(userInfo.getUserType())) {
-//            searchable.addSearchParam("manufacturerId", userInfo.getCompany());
-//        }
-        SearchDTO searchDTO = searchable.toSearchDTO();
-        Page<ApplyInfo> applyInfos = applyInfoFacade.applyInfoPage(searchDTO);
-        if (CollectionUtils.isEmpty(applyInfos.getContent())) {
-            return Result.success(0L, "");
-        }
-        //填充统计数据
-        List<ApplicationInfoVO> apps = applicationInfoFacade.addCountInfo(objectConvert(applyInfos));
-        return Result.success(applyInfos.getTotalElements(), apps);
-    }
-
-    private List<ApplicationInfoVO> objectConvert(Page<ApplyInfo> applyInfos) {
-        List<ApplicationInfoVO> apps = new ArrayList<>();
-        for (ApplyInfo applyInfo : applyInfos) {
-            ApplicationInfoVO applicationInfoVO = new ApplicationInfoVO();
-            applicationInfoVO.setId(applyInfo.getId());
-            applicationInfoVO.setCode(applyInfo.getApplyCode());
-            applicationInfoVO.setName(applyInfo.getApplyName());
-            applicationInfoVO.setMenus(0L);
-            applicationInfoVO.setRoles(0L);
-            applicationInfoVO.setInitquotas(0L);
-            applicationInfoVO.setQuotaed(0L);
-            applicationInfoVO.setLeavequotas(0L);
-            apps.add(applicationInfoVO);
-        }
-        return apps;
-    }
 }

+ 3 - 11
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/ApplicationController.java

@@ -52,8 +52,8 @@ public class ApplicationController {
      * @return
      */
     @ApiOperation(value = "根据机构code获取应用信息列表")
-    @ApiImplicitParam(name = "searchable", value = "查询条件,orgCode不能为空")
-    @PostMapping(value = "/appList/_search", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    @ApiImplicitParam(name = "searchable", value = "查询条件,orgCode")
+    @PostMapping(value = "/appList/_search")
     public Result<List<ApplicationInfoVo>> getAppList(SearchDTO searchDTO) {
         List<ApplicationInfoVo> resultList = new ArrayList<>();
         Searchable searchable = Searchable.toSearchable(searchDTO);
@@ -98,7 +98,7 @@ public class ApplicationController {
      * @return
      */
     @ApiOperation(value = "根据机构Id获取应用信息列表")
-    @ApiImplicitParam(name = "searchable", value = "查询条件,orgId机构id不能为空")
+    @ApiImplicitParam(name = "searchable", value = "查询条件,orgCode机构")
     @PostMapping(value = "/appQutoList/_search")
     public Result<List<ApplicationInfoVo>> getAppQutoList(SearchDTO searchDTO) {
         List<ApplicationInfoVo> resultList = new ArrayList<>();
@@ -162,14 +162,6 @@ public class ApplicationController {
      * @return
      */
     private Page<ApplyInfo> getApplyInfos(Searchable searchable) {
-        String userId = ContextUtils.getUserInfo().getId();
-        AuthUserDTO userInfo = authUserInfoFacade.get(userId);
-        String userBusiness = userInfo.getPoliceBusiness();             //获取当前用户业务域
-        if (userBusiness == null) {
-            userBusiness = "";
-        }
-        searchable.addSearchFilter("userBusiness", SearchOperator.eq, userBusiness);
-       // searchable.addSearchFilter("zaPolicectegory", SearchOperator.eq, dcucWebConfig.getZaPolicectegory());
         Page<ApplyInfo> retainList = applyInfoFacade.findApplyList(searchable.toSearchDTO());
         return retainList;
     }

+ 9 - 8
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/RoleAuthInfoController.java

@@ -73,7 +73,6 @@ public class RoleAuthInfoController {
     @ApiImplicitParam(name = "searchDTO", value = "角色视图 人员列表 查询条件 orgId eq 必填, roleId eq 必填")
     @PostMapping(value = "/roleStaffList/_search")
     public Result<List<AuthUserDTO>> roleStaffList(SearchDTO searchDTO) {
-        //只查询民警和辅警
         //职位状态只查询在职、挂职、借调
         Searchable searchable = getUserQuerySearchable(searchDTO);
         Page<AuthUserDTO> page = authUserInfoFacade.roleAuthRoleViewPage(searchable.toSearchDTO());
@@ -88,8 +87,6 @@ public class RoleAuthInfoController {
 
     private Searchable getUserQuerySearchable(SearchDTO searchDTO) {
         Searchable searchable = Searchable.toSearchable(searchDTO);
-        String[] userTypes = new String[]{UserTypeEnum.POLICE.getValue(), UserTypeEnum.HELPER.getValue()};
-        searchable.addSearchFilter("userType", SearchOperator.in, userTypes);
         searchable.addSearchFilter("id", SearchOperator.ne, authUserInfoFacade.getRootUserId());
         String[] jobTypes = new String[]{JobTypeEnum.ZZ.getValue(), JobTypeEnum.GZ.getValue(), JobTypeEnum.JD.getValue()};
         searchable.addSearchFilter("relStatus", SearchOperator.in, jobTypes);
@@ -149,7 +146,6 @@ public class RoleAuthInfoController {
         if (null == manageInfo) {
             return Result.success(0L,null);
         }
-        //只查询民警和辅警
         //职位状态只查询在职、挂职、借调
         Searchable searchable = getUserQuerySearchable(searchDTO);
         Page<AuthUserDTO> page = authUserInfoFacade.roleAuthUserViewPage(searchable.toSearchDTO());
@@ -209,11 +205,14 @@ public class RoleAuthInfoController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "roleName", value = "角色名称"),
             @ApiImplicitParam(name = "userId", value = "用户id",required = true),
-            @ApiImplicitParam(name = "appName", value = "应用名称")
+            @ApiImplicitParam(name = "appName", value = "应用名称"),
+            @ApiImplicitParam(name = "orgId", value = "机构id",required = true)
     })
     @GetMapping(value = "/staffRoleList")
-    public Result<List<RoleInfoVO>> staffRoleList(@RequestParam(value = "roleName",required = false) String roleName,@RequestParam("userId") String userId,
-                                @RequestParam(value = "appName",required = false) String appName) {
+    public Result<List<RoleInfoVO>> staffRoleList(@RequestParam(value = "roleName",required = false) String roleName,
+                                                  @RequestParam("userId") String userId,
+                                @RequestParam(value = "appName",required = false) String appName,
+                                @RequestParam(value = "orgId",required = false) String orgId) {
         if (StringUtils.isBlank(userId)) {
             return Result.success(new ArrayList<RoleInfoVO>());
         }
@@ -225,6 +224,7 @@ public class RoleAuthInfoController {
         if (StringUtils.isNotEmpty(appName)) {
             roleSearchable.addSearchFilter("appName",SearchOperator.like,appName);
         }
+        roleSearchable.addSearchFilter("orgId", SearchOperator.eq, orgId);
         //TODO
         //DTO待设计
         List<RoleInfoVO> roleInfoVOList = roleInfoFacade.staffRoleList(roleSearchable.toSearchDTO());
@@ -309,9 +309,10 @@ public class RoleAuthInfoController {
     @PostMapping (value = "/staff")
     public Result saveStaff(@RequestBody StaffOperateVo staffOperateVo) {
         String userId = staffOperateVo.getUserId();
+        String orgId = staffOperateVo.getOrgId();
         String saveIds = JSON.toJSONString(staffOperateVo.getSaveIds());
         String deleteIds = JSON.toJSONString(staffOperateVo.getDeleteIds());
-        StaffAssignDTO staffAssignDTO=new StaffAssignDTO(userId, saveIds, deleteIds);
+        StaffAssignDTO staffAssignDTO=new StaffAssignDTO(userId, orgId, saveIds, deleteIds);
         ResponseStatus responseStatus = staffAssignAuthInfoFacade.saveStaff(staffAssignDTO);
         Result result = new Result(responseStatus.getStatusCode(),responseStatus.getMessage(),null,null);
         return result;

+ 2 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/vo/StaffOperateVo.java

@@ -12,6 +12,8 @@ import java.util.List;
 public class StaffOperateVo {
     @ApiModelProperty(value = "人员id")
     private String userId;
+    @ApiModelProperty(value = "机构id")
+    private String orgId;
     @ApiModelProperty(value = "需要保存的角色信息")
     private List<RoleInfoVo> saveIds;
     @ApiModelProperty(value = "需要删除的角色信息")

+ 56 - 8
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/sub/AuthOrgInfoController.java

@@ -18,11 +18,13 @@ import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
 import com.dragonsoft.duceap.base.entity.security.SecurityUser;
 import com.dragonsoft.duceap.base.utils.UserContextUtils;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
 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.ListUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -32,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -225,7 +228,10 @@ public class AuthOrgInfoController {
             String[] orgIdStatus = orgIdStr.split(StrUtil.COLON);
             orgIds.add(orgIdStatus[0]);
         }
-        List<OrgTreeNodeDTO> orgInfosList = authOrgInfoFacade.getOrgTreeNodeByIds(orgIds);
+        List<OrgTreeNodeDTO> orgInfosList = authOrgInfoFacade.getSelfAndChildByIds(orgIds);
+        //组成树结构只返回顶部节点
+        //重新设置权限过滤后的子节点集合和isParent字段
+        orgInfosList = convertFilterTree(orgInfosList, mtAuthIds, true);
         List<OrgTreeNodeVo> collect = orgInfosList.stream().map(e -> {
             e.setChildIds(null);
             OrgTreeNodeVo vo = new OrgTreeNodeVo();
@@ -244,13 +250,8 @@ public class AuthOrgInfoController {
      */
     public List<OrgTreeNodeVo> getChildTreeNode(String id, String mtAuthIds) {
         //子级机构
-        List<OrgTreeNodeDTO> childList = authOrgInfoFacade.getChildById(id);
-        if (StringUtils.isNotEmpty(mtAuthIds)) {
-           childList = childList
-                   .stream()
-                   .filter(e-> OrgInfoUtil.isHaveAuth(e.getId(), e.getPath(), mtAuthIds))
-                   .collect(Collectors.toList());
-        }
+        List<OrgTreeNodeDTO> childList = authOrgInfoFacade.getChildById(id, 2);
+        childList = convertFilterTree(childList, mtAuthIds, true);
         return childList.stream().map(e->{
             OrgTreeNodeVo nodeVo = new OrgTreeNodeVo();
             BeanUtils.copyProperties(e, nodeVo);
@@ -258,4 +259,51 @@ public class AuthOrgInfoController {
         }).collect(Collectors.toList());
     }
 
+    /**
+     * 组成树结构后只返回顶部节点集合
+     * 组成树结构后重新设置权限过滤后的顶节点isParent字段和child字段
+     * @param treeNodeList
+     * @param mtAuthIds
+     * @param needTree 是否需要组装成树结构
+     * @return
+     */
+    private List<OrgTreeNodeDTO> convertFilterTree(List<OrgTreeNodeDTO> treeNodeList, String mtAuthIds, boolean needTree) {
+        List<OrgTreeNodeDTO> collect = new ArrayList<>();
+        if(StringUtils.isEmpty(mtAuthIds)) {
+            return collect;
+        }
+        //筛选有权限的节点
+        collect = treeNodeList
+                .stream()
+                .filter(e -> OrgInfoUtil.isHaveAuth(e.getId(), e.getPath(), mtAuthIds))
+                .collect(Collectors.toList());
+        if(!needTree) {
+            return collect;
+        } else {
+            //重新设置权限过滤后的顶节点isParent字段和child字段
+            //只返回顶部节点集合
+            Map<String, OrgTreeNodeDTO> idMap = collect
+                    .stream()
+                    .collect(Collectors.toMap(OrgTreeNodeDTO::getId, e -> e, (old, last)->last));
+            Set<String> keySet = idMap.keySet();
+            //筛选父节点
+            List<OrgTreeNodeDTO> allTopNodes = collect.stream().filter(e->{
+                String pid = e.getPid();
+                if(StringUtils.isBlank(pid)) {
+                    return true;
+                }
+                if(!keySet.contains(pid)) {
+                    return true;
+                }
+                return false;
+            }).collect(Collectors.toList());
+            //重新设置父节点isParent字段
+            allTopNodes.forEach(e->{
+                List<String> childIds = e.getChildIds();
+                e.setIsParent(childIds.stream().anyMatch(keySet::contains));
+                e.setChildIds(null);
+            });
+            return allTopNodes;
+        }
+    }
 }

+ 6 - 1
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/sub/AuthUserInfoController.java

@@ -29,11 +29,16 @@ public class AuthUserInfoController {
     @Autowired
     private IAuthUserInfoFacade userInfoFacade;
 
+    /**
+     * 同角色授权-人员视图列表
+     * @param searchable
+     * @return
+     */
     @RequestMapping("/page")
     @ApiImplicitParam(name = "searchable", value = "查询条件")
     @ApiOperation(value = "分页查询用户信息")
     public Page<AuthUserDTO> page(Searchable searchable) {
-        return userInfoFacade.page(searchable.toSearchDTO());
+        return userInfoFacade.roleAuthUserViewPage(searchable.toSearchDTO());
     }
 
     @ApiOperation(value = "用户信息详情")