|
@@ -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
|