فهرست منبع

角色表单权限相关

liuyc 3 سال پیش
والد
کامیت
41f2e7a427

+ 14 - 11
blade-service-api/blade-system-api/src/main/java/org/springblade/system/vo/GrantVO.java

@@ -29,21 +29,24 @@ import java.util.List;
  */
 @Data
 public class GrantVO implements Serializable {
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	@ApiModelProperty(value = "roleIds集合")
-	private List<Long> roleIds;
+    @ApiModelProperty(value = "roleIds集合")
+    private List<Long> roleIds;
 
-	@ApiModelProperty(value = "menuIds集合")
-	private List<Long> menuIds;
+    @ApiModelProperty(value = "menuIds集合")
+    private List<Long> menuIds;
 
-	@ApiModelProperty(value = "topMenuIds集合")
-	private List<Long> topMenuIds;
+    @ApiModelProperty(value = "topMenuIds集合")
+    private List<Long> topMenuIds;
 
-	@ApiModelProperty(value = "dataScopeIds集合")
-	private List<Long> dataScopeIds;
+    @ApiModelProperty(value = "dataScopeIds集合")
+    private List<Long> dataScopeIds;
 
-	@ApiModelProperty(value = "apiScopeIds集合")
-	private List<Long> apiScopeIds;
+    @ApiModelProperty(value = "apiScopeIds集合")
+    private List<Long> apiScopeIds;
+
+    @ApiModelProperty(value = "tableOwners集合")
+    private List<Long> tableOwners;
 
 }

+ 4 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -589,8 +589,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
 
     //采用批量 默认排序
     private boolean importExcel2(ArrayList<Map<String, String>> result, WbsTree wbsTreeFu, WbsTree wbsTree1) {
-        WbsTree wbsTreeFu1 = new WbsTree();
-        BeanUtils.copyProperties(wbsTreeFu, wbsTreeFu1);
         List<WbsTree> allNodeData = new ArrayList<>();
         //解析list-map
         for (Map<String, String> map : result) {
@@ -603,7 +601,9 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                     wbsTreeZi.setDeptName(maps.getValue());
                     wbsTreeZi.setDeptCategory(Integer.valueOf(maps.getKey()));
                     wbsTreeZi.setWbsId(wbsTreeFu.getWbsId());
+
                     wbsTreeZi.setParentId(wbsTreeFu.getParentId());
+
                     wbsTreeZi.setAncestors(wbsTreeFu.getAncestors());
                     wbsTreeZi.setProjectNodeId(wbsTree1.getProjectNodeId());
 
@@ -646,8 +646,8 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
             if (tree.getDeptName().equals(wbsTreeZi.getDeptName())
                     && tree.getDeptCategory().equals(wbsTreeZi.getDeptCategory())
                     && tree.getProjectNodeId().equals(wbsTreeZi.getProjectNodeId())
-                    && !tree.getAncestors().equals(wbsTreeZi.getAncestors())) {
-
+                    && !tree.getAncestors().equals(wbsTreeZi.getAncestors())
+            ) {
                 //判断上级节点不同,当前节点名相同的tree选择问题,例如:第X跨的上级有上部构造现场浇筑、上部构造预制和安装,导致下方新增重复节点判断时找到的是前一个
                 wbsTrees.add(tree);
                 break;

+ 2 - 18
blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java

@@ -186,7 +186,7 @@ public class RoleController extends BladeController {
     public R grant(@RequestBody GrantVO grantVO) {
         CacheUtil.clear(SYS_CACHE);
         CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
-        boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds());
+        boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds(),grantVO.getTableOwners());
         return R.status(temp);
     }
 
@@ -207,27 +207,11 @@ public class RoleController extends BladeController {
     }
 
 
-    /**
-     * 保存角色绑定表单所属方关系
-     */
-    @PostMapping("/submitRoleAndTableOwner")
-    @ApiOperationSupport(order = 9)
-    @ApiOperation(value = "保存角色绑定表单所属方关系", notes = "传入角色id,tableOwners")
-    @PreAuth(AuthConstant.PERMIT_ALL)
-    @ApiImplicitParams(value = {
-            @ApiImplicitParam(value = "roleId", name = "角色id"),
-            @ApiImplicitParam(value = "tableOwners", name = "表单所属方value值=字符串拼接以 ',' 分割 "),
-            @ApiImplicitParam(value = "ids", name = "表单所属方value值的ids ',' 分割,用于删除时")
-    })
-    public R submitRoleAndTableOwner(String roleId, String tableOwners, String ids) {
-        return R.status(roleService.submitRoleAndTableOwner(roleId, tableOwners, ids));
-    }
-
     /**
      * 获取角色绑定的表单所属方关系List
      */
     @GetMapping("/searchRoleAndTableOwnerList")
-    @ApiOperationSupport(order = 10)
+    @ApiOperationSupport(order = 9)
     @ApiOperation(value = "获取角色绑定的表单所属方关系List", notes = "传入角色id")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(value = "roleId", name = "角色id")

+ 2 - 2
blade-service/blade-system/src/main/java/org/springblade/system/mapper/RoleMapper.java

@@ -71,11 +71,11 @@ public interface RoleMapper extends BaseMapper<Role> {
 
     Integer deleteRoleAndPostByRid(@Param("rId") String ids);
 
-    Integer insertRoleAndTableOwner(Long id, String roleId, String tableOwner);
+    Integer insertRoleAndTableOwner(Long id, Long roleId, String tableOwner);
 
     Integer deleteRoleAndTableOwner(List<String> ids);
 
-    List<WbsTableOwnerRole> selectRoleAndTableOwnerListByRoleId(String roleId);
+    List<WbsTableOwnerRole> selectRoleAndTableOwnerListByRoleId(Long roleId);
 
     List<WbsTableOwnerRole> selectRoleAndTableOwnerList(String roleId);
 

+ 1 - 3
blade-service/blade-system/src/main/java/org/springblade/system/service/IRoleService.java

@@ -60,7 +60,7 @@ public interface IRoleService extends IService<Role> {
      * @param apiScopeIds  接口权限id集合
      * @return 是否成功
      */
-    boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds);
+    boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds, List<Long> tableOwners);
 
     /**
      * 获取角色ID
@@ -116,8 +116,6 @@ public interface IRoleService extends IService<Role> {
 
     List<Role> selectParentRole();
 
-    Boolean submitRoleAndTableOwner(String roleId, String tableOwners,String tableOwnerIds);
-
     List<WbsTableOwnerRole> searchRoleAndTableOwnerList(String roleId);
 
 }

+ 33 - 36
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RoleServiceImpl.java

@@ -85,8 +85,10 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds) {
-        return grantRoleMenu(roleIds, menuIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds);
+    public boolean grant(@NotEmpty List<Long> roleIds, List<Long> menuIds, List<Long> dataScopeIds, List<Long> apiScopeIds, List<Long> tableOwners) {
+
+
+        return grantRoleMenu(roleIds, menuIds) && grantDataScope(roleIds, dataScopeIds) && grantApiScope(roleIds, apiScopeIds) && submitRoleAndTableOwner(roleIds, tableOwners);
     }
 
     private boolean grantRoleMenu(List<Long> roleIds, List<Long> menuIds) {
@@ -260,53 +262,48 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
         return false;
     }
 
-    @Override
-    public Boolean submitRoleAndTableOwner(String roleId, String tableOwners, String tableOwnerIds) {
-        List<WbsTableOwnerRole> list = baseMapper.selectRoleAndTableOwnerListByRoleId(roleId);
 
-        List<String> tableOwnerValuesIn = list.stream().map(WbsTableOwnerRole::getTableOwnerNumber).collect(Collectors.toList());
+    public Boolean submitRoleAndTableOwner(List<Long> roleIds, List<Long> tableOwners) {
+        for (Long role : roleIds) {
+            List<WbsTableOwnerRole> list = baseMapper.selectRoleAndTableOwnerListByRoleId(role);
 
-        List<String> tableOwnerValuesOut = Func.toStrList(tableOwners);
+            List<String> tableOwnerValuesIn = list.stream().map(WbsTableOwnerRole::getTableOwnerNumber).collect(Collectors.toList());
 
-        List<String> diffRent = getDiffRent(tableOwnerValuesOut, tableOwnerValuesIn);
+            List<String> tableOwnerValuesOut = tableOwners.stream().map(String::valueOf).collect(Collectors.toList());
 
-        System.out.println("list: " + list);
-        System.out.println("tableOwnerValuesIn: " + tableOwnerValuesIn);
-        System.out.println("tableOwnerValuesOut: " + tableOwnerValuesOut);
-        System.out.println("diffRent: " + diffRent);
+            List<String> diffRent = getDiffRent(tableOwnerValuesOut, tableOwnerValuesIn);
 
-        List<String> ids = new ArrayList<>();
+            List<String> ids = new ArrayList<>();
 
-        //获取ids
-        for (WbsTableOwnerRole wbsTableOwnerRole : list) {
-            for (String diff : diffRent) {
-                if (wbsTableOwnerRole.getTableOwnerNumber().equals(diff)) {
-                    ids.add(String.valueOf(wbsTableOwnerRole.getId()));
+            //获取ids
+            for (WbsTableOwnerRole wbsTableOwnerRole : list) {
+                for (String diff : diffRent) {
+                    if (wbsTableOwnerRole.getTableOwnerNumber().equals(diff)) {
+                        ids.add(String.valueOf(wbsTableOwnerRole.getId()));
+                    }
                 }
             }
-        }
 
-        System.out.println("ids: " + ids);
-
-        if (diffRent.size() == 0) {
-            throw new ServiceException("未进行任何操作");
-        } else {
-            if (tableOwnerValuesOut.size() > tableOwnerValuesIn.size()) {
-                //新增
-                for (String tableOwner : diffRent) {
-                    Long id = SnowFlakeUtil.getId();
-                    baseMapper.insertRoleAndTableOwner(id, roleId, tableOwner);
+            if (diffRent.size() == 0) {
+                throw new ServiceException("角色表单权限未进行任何操作");
+            } else {
+                if (tableOwnerValuesOut.size() > tableOwnerValuesIn.size()) {
+                    //新增
+                    for (String tableOwner : diffRent) {
+                        Long id = SnowFlakeUtil.getId();
+                        baseMapper.insertRoleAndTableOwner(id, role, tableOwner);
+                    }
+                    return true;
+
+                } else if (tableOwnerValuesOut.size() < tableOwnerValuesIn.size()) {
+                    //删除
+                    Integer row = baseMapper.deleteRoleAndTableOwner(ids);
+                    return row > 0;
                 }
-                return true;
-
-            } else if (tableOwnerValuesOut.size() < tableOwnerValuesIn.size()) {
-                //删除
-                Integer row = baseMapper.deleteRoleAndTableOwner(ids);
-                return row > 0;
             }
+            return false;
         }
         return false;
-
     }
 
     @Override