فهرست منبع

feature(红白名单功能开发): 红白名单功能开发

红白名单功能开发
mazq 3 سال پیش
والد
کامیت
1d37b6c566

+ 28 - 21
pom.xml

@@ -5,14 +5,14 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.dragoninfo</groupId>
     <artifactId>dcuc-auth-back</artifactId>
-    <version>2.3.2-tjdsj-SNAPSHOT</version>
+    <version>2.3.3-tjdsj-SNAPSHOT</version>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
         <!--revisions需写死,用于标识打包的版本号,不可删除-->
-        <revision>2.3.2-tjdsj-SNAPSHOT</revision>
+        <revision>2.3.3-tjdsj-SNAPSHOT</revision>
         <duceap.version>2.1.0-SNAPSHOT</duceap.version>
         <lombok.version>1.18.2</lombok.version>
         <jwt.version>3.10.3</jwt.version>
@@ -91,11 +91,17 @@
         </dependency>
         <!--配置 duceap 结束-->
 
-        <!--配置 dcuc 开始-->
+        <!--许可-->
         <dependency>
-            <groupId>com.dragoninfo</groupId>
-            <artifactId>dcuc-common</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <groupId>com.dragonsoft</groupId>
+            <artifactId>duceap-support-license</artifactId>
+        </dependency>
+        <!--许可依赖包 结束-->
+
+        <!--redis缓存-->
+        <dependency>
+            <groupId>com.dragonsoft</groupId>
+            <artifactId>duceap-boot-starter-cache-redis</artifactId>
             <exclusions>
                 <exclusion>
                     <artifactId>spring-jdbc</artifactId>
@@ -103,22 +109,12 @@
                 </exclusion>
             </exclusions>
         </dependency>
-        <!--许可-->
-        <dependency>
-            <groupId>com.dragonsoft</groupId>
-            <artifactId>duceap-support-license</artifactId>
-        </dependency>
 
-        <!--许可依赖包 结束-->
+        <!--配置 dcuc 开始-->
         <dependency>
             <groupId>com.dragoninfo</groupId>
-            <artifactId>dcuc-auth-api</artifactId>
-            <version>2.3.2-tjdsj-SNAPSHOT</version>
-        </dependency>
-        <!--redis缓存-->
-        <dependency>
-            <groupId>com.dragonsoft</groupId>
-            <artifactId>duceap-boot-starter-cache-redis</artifactId>
+            <artifactId>dcuc-common</artifactId>
+            <version>2.0.0-SNAPSHOT</version>
             <exclusions>
                 <exclusion>
                     <artifactId>spring-jdbc</artifactId>
@@ -126,11 +122,22 @@
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>com.dragoninfo</groupId>
+            <artifactId>dcuc-auth-api</artifactId>
+            <version>2.3.3-tjdsj-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.dragoninfo</groupId>
+            <artifactId>dcuc-list-api</artifactId>
+            <version>2.0.0-tjdsj-SNAPSHOT</version>
+        </dependency>
 
         <dependency>
             <groupId>com.dragoninfo</groupId>
             <artifactId>dcuc-app-api</artifactId>
-            <version>2.2.0-tjdsj-SNAPSHOT</version>
+            <version>2.2.2-tjdsj-SNAPSHOT</version>
         </dependency>
 
         <dependency>
@@ -161,8 +168,8 @@
             <artifactId>java-jwt</artifactId>
             <version>${jwt.version}</version>
         </dependency>
-
         <!--配置 dcuc 结束-->
+
         <dependency>
             <groupId>net.unicon.cas</groupId>
             <artifactId>cas-client-autoconfig-support</artifactId>

+ 19 - 6
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/AppFunInfoController.java

@@ -1,15 +1,14 @@
 
 package com.dragoninfo.dcuc.authweb.restcontroller.auth;
 
-import cn.hutool.core.bean.BeanUtil;
-import com.dragoninfo.dcuc.app.entity.ApplyInfo;
+import com.dragoninfo.dcuc.auth.auth.dto.AppFunTreeDTO;
 import com.dragoninfo.dcuc.auth.auth.entity.AppFunInfo;
 import com.dragoninfo.dcuc.auth.auth.vo.AppFunInfoVo;
 import com.dragoninfo.dcuc.auth.auth.vo.EventInfoVO;
 import com.dragoninfo.dcuc.auth.auth.vo.TreeInfoVO;
 import com.dragoninfo.dcuc.auth.power.facade.IAppFunInfoFacade;
 import com.dragoninfo.dcuc.auth.power.facade.IFunEventFacade;
-import com.dragoninfo.dcuc.authweb.restcontroller.app.vo.AppVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.auth.vo.AppFunTreeVo;
 import com.dragoninfo.duceap.core.response.Result;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
@@ -35,6 +34,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 菜单功能信息
@@ -145,7 +145,7 @@ public class AppFunInfoController {
         AppFunInfo appFunInfo = new AppFunInfo();
         BeanUtils.copyProperties(appFunInfoVo, appFunInfo);
         ResponseStatus responseStatus = iAppFunInfoFacade.save(appFunInfo);
-        if (!responseStatus.getStatusCode().equals("200")){
+        if (!responseStatus.getStatusCode().equals(ResponseStatus.SUCCESS_CODE)){
             return Result.fail(responseStatus.getStatusCode(), responseStatus.getMessage());
         }
         return Result.success();
@@ -156,7 +156,7 @@ public class AppFunInfoController {
     @PutMapping(value = "/update")
     public Result updateAppFunInfo(@Validated @RequestBody  AppFunInfoVo appFunInfoVo) {
         ResponseStatus responseStatus = iAppFunInfoFacade.updateAppFunInfo(appFunInfoVo);
-        if (!responseStatus.getStatusCode().equals("200")){
+        if (!responseStatus.getStatusCode().equals(ResponseStatus.SUCCESS_CODE)){
             return Result.fail(responseStatus.getStatusCode(), responseStatus.getMessage());
         }
         return Result.success();
@@ -167,12 +167,25 @@ public class AppFunInfoController {
     @DeleteMapping(value = "/{id}")
     public Result deleteAppFunInfo(@PathVariable("id") String id) {
         ResponseStatus responseStatus = iAppFunInfoFacade.deleteById(id);
-        if (!responseStatus.getStatusCode().equals("200")){
+        if (!responseStatus.getStatusCode().equals(ResponseStatus.SUCCESS_CODE)){
             return Result.fail(responseStatus.getStatusCode(), responseStatus.getMessage());
         }
         return Result.success();
     }
 
+    @ApiOperation(value = "全量应用功能树")
+    @GetMapping(value = "/allMenuTree")
+    public Result allMenuTree() {
+        List<AppFunTreeDTO> treeDTOS = iAppFunInfoFacade.allMenuTree();
+        List<AppFunTreeVo> list = treeDTOS.stream().map(item -> {
+            AppFunTreeVo treeVo = new AppFunTreeVo();
+            BeanUtils.copyProperties(item, treeVo);
+            return treeVo;
+        }).collect(Collectors.toList());
+        return Result.success(list);
+    }
+
+
     public List<TreeInfoVO> getChildTreeObjects(List<TreeInfoVO> list,
                                                 String parentCode) {
         List<TreeInfoVO> returnList = new ArrayList<TreeInfoVO>();

+ 39 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/auth/vo/AppFunTreeVo.java

@@ -0,0 +1,39 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.auth.vo;
+
+import com.dragoninfo.dcuc.auth.auth.dto.AppFunTreeDTO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2021/7/13
+ */
+@ApiModel(value = "应用功能全量树Vo")
+@Data
+public class AppFunTreeVo {
+
+    @ApiModelProperty(value = "主键id")
+    private String id;
+
+    @ApiModelProperty(value = "父节点id")
+    private String pid;
+
+    @ApiModelProperty(value = "节点名称")
+    private String label;
+
+    @ApiModelProperty(value = "资源code")
+    private String code;
+
+    @ApiModelProperty(value = "是否是树节点")
+    private Boolean isTreeNode;
+
+    @ApiModelProperty(value = "节点类型")
+    private String type;
+
+    @ApiModelProperty(value = "子节点集合")
+    private List<AppFunTreeDTO> child;
+
+}

+ 92 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/list/controller/RedListController.java

@@ -0,0 +1,92 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.list.controller;
+
+import com.dragoninfo.dcuc.authweb.restcontroller.list.vo.AppFunRedListAddVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.list.vo.FunRedListTreeVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.list.vo.RedListOperateVo;
+import com.dragoninfo.dcuc.list.dto.redwhitelist.AppFunRedListAddDTO;
+import com.dragoninfo.dcuc.list.dto.redwhitelist.FunRedListTreeDTO;
+import com.dragoninfo.dcuc.list.dto.redwhitelist.RedListOperateDTO;
+import com.dragoninfo.dcuc.list.facade.IRedListFacade;
+import com.dragoninfo.duceap.core.response.Result;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
+import com.dragonsoft.duceap.core.search.Searchable;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author mazq
+ * @date 2021/7/12
+ */
+@Api(tags = "权限红名单接口")
+@RestController
+@RequestMapping(value = "/authsvr/v2/redlist")
+public class RedListController {
+
+    @Autowired
+    IRedListFacade redListFacade;
+
+    @ApiOperation(value = "功能红名单列表查询")
+    @ApiImplicitParam(name = "searchable", value = "查询条件 level:= ; appName:like ; appCode:like")
+    @PostMapping(value = "funRedListPage")
+    public Result<List<FunRedListTreeVo>> funRedListPage(Searchable searchable) {
+        Page<FunRedListTreeDTO> treeDTOPage = redListFacade.funRedListPage(searchable.toSearchDTO());
+        List<FunRedListTreeDTO> content = treeDTOPage.getContent();
+        List<FunRedListTreeVo> collect = content.stream().map(item -> {
+            FunRedListTreeVo vo = new FunRedListTreeVo();
+            BeanUtils.copyProperties(item, vo);
+            return vo;
+        }).collect(Collectors.toList());
+        return Result.success(treeDTOPage.getTotalElements(), collect);
+    }
+
+    @ApiOperation(value = "功能红名单添加")
+    @PostMapping("userWhiteListAdd")
+    public Result userWhiteListAdd(@RequestBody List<AppFunRedListAddVo> addVoList) {
+        if(CollectionUtils.isEmpty(addVoList)) {
+            return Result.fail();
+        }
+        List<AppFunRedListAddDTO> collect = addVoList.stream().map(item -> {
+            AppFunRedListAddDTO addDTO = new AppFunRedListAddDTO();
+            BeanUtils.copyProperties(item, addDTO);
+            return addDTO;
+        }).collect(Collectors.toList());
+        redListFacade.funRedListAdd(collect);
+        return Result.success();
+    }
+
+    @ApiOperation(value = "红名单批量修改等级")
+    @PostMapping("redListUpdateLevel")
+    public Result redListUpdateLevel(@RequestBody RedListOperateVo vo) {
+        RedListOperateDTO dto = new RedListOperateDTO();
+        BeanUtils.copyProperties(vo, dto);
+        redListFacade.funRedListUpdateLevel(dto);
+        return Result.success();
+    }
+
+    @ApiOperation(value = "应用功能红名单批量移除")
+    @PostMapping("funRedListBatchDel")
+    public Result funRedListBatchDel(@RequestBody RedListOperateVo vo) {
+        RedListOperateDTO dto = new RedListOperateDTO();
+        BeanUtils.copyProperties(vo, dto);
+        redListFacade.funRedListBatchDel(dto);
+        return Result.success();
+    }
+
+    @ApiOperation(value = "应用功能红名单单条记录移除")
+    @DeleteMapping(value = "funRedListDel")
+    public Result funRedListDel(@RequestParam("resourceType") String resourceType,
+                                @RequestParam("resourceId") String resourceId,
+                                @RequestParam("isTreeNode") Boolean isTreeNode) {
+        redListFacade.funRedListDel(resourceType, resourceId, isTreeNode);
+        return Result.success();
+    }
+
+}

+ 80 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/list/controller/WhiteListController.java

@@ -0,0 +1,80 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.list.controller;
+
+import com.dragoninfo.dcuc.auth.sub.enumresource.SubObjTypeEnum;
+import com.dragoninfo.dcuc.authweb.restcontroller.list.vo.WhiteListOperateVo;
+import com.dragoninfo.dcuc.authweb.restcontroller.list.vo.WhiteListUserVo;
+import com.dragoninfo.dcuc.list.dto.redwhitelist.WhiteListOperateDTO;
+import com.dragoninfo.dcuc.list.dto.redwhitelist.WhiteListUserDTO;
+import com.dragoninfo.dcuc.list.facade.IWhiteListFacade;
+import com.dragoninfo.duceap.core.response.Result;
+import com.dragonsoft.duceap.core.search.Searchable;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+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.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author mazq
+ * @date 2021/7/9
+ */
+@Api(tags = "权限白名单接口")
+@RestController
+@RequestMapping(value = "/authsvr/v2/whitelist")
+public class WhiteListController {
+
+    @Autowired
+    IWhiteListFacade whiteListFacade;
+
+    @ApiImplicitParam(name = "searchable", value = "查询条件 level:= ; name:like ; idcard:like ; org_name:like")
+    @ApiOperation(value = "用户白名单列表查询")
+    @PostMapping("userWhiteListPage")
+    public Page<WhiteListUserVo> whiteListUserPage(Searchable searchable) {
+        Page<WhiteListUserDTO> userPage = whiteListFacade.whiteListUserPage(searchable.toSearchDTO());
+        List<WhiteListUserDTO> content = userPage.getContent();
+        List<WhiteListUserVo> collect = content.stream().map(item -> {
+            WhiteListUserVo userVo = new WhiteListUserVo();
+            BeanUtils.copyProperties(item, userVo);
+            return userVo;
+        }).collect(Collectors.toList());
+        return new PageImpl<>(collect, userPage.getPageable(), userPage.getTotalElements());
+    }
+
+    @ApiOperation(value = "用户白名单添加")
+    @PostMapping("userWhiteListAdd")
+    public Result userWhiteListAdd(@RequestBody WhiteListOperateVo vo) {
+        WhiteListOperateDTO dto = new WhiteListOperateDTO();
+        vo.setSubType(SubObjTypeEnum.SUB_USER.getCode());
+        BeanUtils.copyProperties(vo, dto);
+        whiteListFacade.whiteListAdd(dto);
+        return Result.success();
+    }
+
+    @ApiOperation(value = "白名单批量删除")
+    @PostMapping("whiteListDel")
+    public Result whiteListDel(@RequestBody WhiteListOperateVo vo) {
+        WhiteListOperateDTO dto = new WhiteListOperateDTO();
+        BeanUtils.copyProperties(vo, dto);
+        whiteListFacade.whiteListDel(dto);
+        return Result.success();
+    }
+
+    @ApiOperation(value = "白名单批量修改等级")
+    @PostMapping("whiteListUpdateLevel")
+    public Result whiteListUpdateLevel(@RequestBody WhiteListOperateVo vo) {
+        WhiteListOperateDTO dto = new WhiteListOperateDTO();
+        BeanUtils.copyProperties(vo, dto);
+        whiteListFacade.whiteListUpdateLevel(dto);
+        return Result.success();
+    }
+
+}

+ 26 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/list/vo/AppFunRedListAddVo.java

@@ -0,0 +1,26 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.list.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2021/7/12
+ */
+@ApiModel(value = "功能红名单添加Vo")
+@Data
+public class AppFunRedListAddVo {
+
+    @ApiModelProperty(value = "红名单等级")
+    private String level;
+
+    @ApiModelProperty(value = "应用id")
+    private String appId;
+
+    @ApiModelProperty(value = "功能ids")
+    private List<String> funIds;
+
+}

+ 41 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/list/vo/FunRedListTreeVo.java

@@ -0,0 +1,41 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.list.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2021/7/13
+ */
+@ApiModel(value = "功能红名单列表树Vo")
+@Data
+public class FunRedListTreeVo {
+
+    @ApiModelProperty(value = "主键id")
+    private String id;
+
+    @ApiModelProperty(value = "父节点id")
+    private String pid;
+
+    @ApiModelProperty(value = "节点名称")
+    private String label;
+
+    @ApiModelProperty(value = "资源code")
+    private String code;
+
+    @ApiModelProperty(value = "是否是树节点")
+    private Boolean isTreeNode;
+
+    @ApiModelProperty(value = "红名单记录id")
+    private String listId;
+
+    @ApiModelProperty(value = "节点类型")
+    private String type;
+
+    @ApiModelProperty(value = "子节点集合")
+    private List<FunRedListTreeVo> child;
+
+}

+ 28 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/list/vo/RedListOperateVo.java

@@ -0,0 +1,28 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.list.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2021/7/9
+ */
+@ApiModel(value = "红名单操作Vo")
+@Data
+public class RedListOperateVo {
+
+    @ApiModelProperty(value = "红名单等级")
+    private String level;
+
+    @ApiModelProperty(value = "客体类型")
+    private String objType;
+
+    @ApiModelProperty(value = "客体id集合")
+    private List<String> objIds;
+
+    @ApiModelProperty(value = "红名单记录id")
+    private List<String> listIds;
+}

+ 28 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/list/vo/WhiteListOperateVo.java

@@ -0,0 +1,28 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.list.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author mazq
+ * @date 2021/7/9
+ */
+@ApiModel(value = "白名单操作Vo")
+@Data
+public class WhiteListOperateVo {
+
+    @ApiModelProperty(value = "白名单等级")
+    private String level;
+
+    @ApiModelProperty(value = "主体类型")
+    private String subType;
+
+    @ApiModelProperty(value = "主体id集合")
+    private List<String> subIds;
+
+    @ApiModelProperty(value = "白名单记录id")
+    private List<String> listIds;
+}

+ 29 - 0
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/list/vo/WhiteListUserVo.java

@@ -0,0 +1,29 @@
+package com.dragoninfo.dcuc.authweb.restcontroller.list.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author mazq
+ * @date 2021/7/9
+ */
+@ApiModel(value = "人员白名单Vo")
+@Data
+public class WhiteListUserVo {
+
+    @ApiModelProperty(value = "人员id")
+    private String userId;
+    @ApiModelProperty(value = "人员姓名")
+    private String userName;
+    @ApiModelProperty(value = "人员所属机构id")
+    private String orgId;
+    @ApiModelProperty(value = "人员所属机构名称")
+    private String orgName;
+    @ApiModelProperty(value = "人员身份证号")
+    private String idcard;
+    @ApiModelProperty(value = "白名单权限级别")
+    private String listLevel;
+    @ApiModelProperty(value = "白名单记录id")
+    private String listId;
+}

+ 2 - 2
src/main/java/com/dragoninfo/dcuc/authweb/restcontroller/sub/AttrController.java

@@ -6,8 +6,8 @@ import com.dragoninfo.dcuc.app.entity.ApplyInfo;
 import com.dragoninfo.dcuc.auth.sub.dto.AttrInfoTreeDTO;
 import com.dragoninfo.dcuc.auth.sub.dto.AttrRelAcceptDTO;
 import com.dragoninfo.dcuc.auth.sub.dto.RelSearchDTO;
-import com.dragoninfo.dcuc.auth.auth.enumresources.sub.AttrBelongTypeEnum;
-import com.dragoninfo.dcuc.auth.auth.enumresources.sub.AttrTypeEnum;
+import com.dragoninfo.dcuc.auth.sub.enumresource.AttrBelongTypeEnum;
+import com.dragoninfo.dcuc.auth.sub.enumresource.AttrTypeEnum;
 import com.dragoninfo.dcuc.auth.sub.facade.IAttrFacade;
 import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.attr.AttrInfoTreeVo;
 import com.dragoninfo.dcuc.authweb.restcontroller.sub.vo.attr.AttrRelAcceptVo;