修改对外报告-修改文件夹权限显示问题
This commit is contained in:
+6
-4
@@ -4,7 +4,7 @@ import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import com.jero.modules.extRepo.entity.ERFTreeData;
|
||||
import com.jero.modules.extRepo.entity.ERFTreeDataVO;
|
||||
import com.jero.modules.extRepo.entity.ExtRepoData;
|
||||
import com.jero.modules.extRepo.entity.ExtRepoFolder;
|
||||
import com.jero.modules.extRepo.service.IExtRepoDataService;
|
||||
@@ -44,9 +44,11 @@ public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtR
|
||||
@AutoLog(value = "对外报告文件夹表-列表查询")
|
||||
@ApiOperation(value = "对外报告文件夹表-列表查询", notes = "对外报告文件夹表-列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<ERFTreeData>> queryList() {
|
||||
List<ERFTreeData> list = extRepoFolderService.queryTreeList();
|
||||
return Result.OK(list);
|
||||
public Result<ERFTreeDataVO> queryList() {
|
||||
ERFTreeDataVO dataVO = new ERFTreeDataVO();
|
||||
dataVO.setManager(extRepoFolderService.isManager());
|
||||
dataVO.setList(extRepoFolderService.queryTreeList());
|
||||
return Result.OK(dataVO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
-15
@@ -36,13 +36,6 @@ public class ERFTreeData implements Comparable<ERFTreeData> {
|
||||
*/
|
||||
private int orderId;
|
||||
|
||||
|
||||
/**
|
||||
* 是否显示
|
||||
*/
|
||||
private boolean display = false;
|
||||
|
||||
|
||||
/**
|
||||
* 查看权限人员
|
||||
*/
|
||||
@@ -119,14 +112,6 @@ public class ERFTreeData implements Comparable<ERFTreeData> {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(boolean display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getFolderName() {
|
||||
return folderName;
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.jero.modules.extRepo.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ERFTreeDataVO {
|
||||
boolean isManager;
|
||||
List<ERFTreeData> list;
|
||||
|
||||
public ERFTreeDataVO() {
|
||||
}
|
||||
|
||||
public boolean isManager() {
|
||||
return isManager;
|
||||
}
|
||||
|
||||
public void setManager(boolean manager) {
|
||||
isManager = manager;
|
||||
}
|
||||
|
||||
public List<ERFTreeData> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<ERFTreeData> list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
+33
-72
@@ -22,10 +22,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 对外报告文件夹表
|
||||
* @Author: jero-boot
|
||||
* @Date: 2022-07-25
|
||||
* @Version: V1.0
|
||||
* 对外报告文件夹表
|
||||
*/
|
||||
@Service
|
||||
public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, ExtRepoFolder> implements IExtRepoFolderService {
|
||||
@@ -38,9 +35,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param extRepoFolder
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void add(ExtRepoFolder extRepoFolder) {
|
||||
@@ -52,9 +46,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
Date now = new Date();
|
||||
extRepoFolder.setCreateTime(now);
|
||||
extRepoFolder.setUpdateTime(now);
|
||||
// LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// extRepoFolder.setAuthManageName(extRepoFolder.getAuthManageName() + "," + sysUser.getUsername());
|
||||
// extRepoFolder.setAuthManageIds(extRepoFolder.getAuthManageIds() + "," + sysUser.getId());
|
||||
extRepoFolder.setAuthManageIdsName(extRepoFolder.getAuthManageIdsName());
|
||||
extRepoFolder.setAuthManageIds(extRepoFolder.getAuthManageIds());
|
||||
save(extRepoFolder);
|
||||
@@ -67,10 +58,8 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 同级文件夹,修改顺序号
|
||||
*
|
||||
* @param extRepoFolder
|
||||
*/
|
||||
private void editOrderId(ExtRepoFolder extRepoFolder) throws Exception {
|
||||
private void editOrderId(ExtRepoFolder extRepoFolder) {
|
||||
List<ExtRepoFolder> list = getListBySupFolder(extRepoFolder.getSupFolder());
|
||||
for (ExtRepoFolder erf : list) {
|
||||
if (erf.getOrderId() >= extRepoFolder.getOrderId() && !erf.getId().equals(extRepoFolder.getId())) {
|
||||
@@ -90,9 +79,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param extRepoFolder
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void editById(ExtRepoFolder extRepoFolder) {
|
||||
@@ -113,7 +99,7 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
/**
|
||||
* 修改所有关联文件夹的权限
|
||||
*/
|
||||
private void editAuth(ExtRepoFolder erf_orig, ExtRepoFolder erf_new) throws Exception {
|
||||
private void editAuth(ExtRepoFolder erf_orig, ExtRepoFolder erf_new) {
|
||||
//管理权限
|
||||
Map<String, String> authManage_orig = getAuthMap(erf_orig.getAuthManageIdsName(), erf_orig.getAuthManageIds());
|
||||
Map<String, String> authManage_new = getAuthMap(erf_new.getAuthManageIdsName(), erf_new.getAuthManageIds());
|
||||
@@ -132,20 +118,20 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
List<ExtRepoFolder> allSubFolder = getAllSubFolder(erf_orig.getId());
|
||||
//存储变化的对象
|
||||
List<ExtRepoFolder> updateFolder = new ArrayList<ExtRepoFolder>();
|
||||
List<ExtRepoFolder> updateFolder = new ArrayList<>();
|
||||
for (ExtRepoFolder erf : allSubFolder) {
|
||||
boolean isChange = false;
|
||||
Map<String, String> authManage_erf = getAuthMap(erf.getAuthManageIdsName(), erf.getAuthManageIds());
|
||||
Map<String, String> authView_erf = getAuthMap(erf.getAuthViewIdsName(), erf.getAuthViewIds());
|
||||
for (String add : addManageRole.keySet()) {
|
||||
if (!authManage_erf.keySet().contains(add)) {
|
||||
if (!authManage_erf.containsKey(add)) {
|
||||
authManage_erf.put(add, addManageRole.get(add));
|
||||
isChange = true;
|
||||
}
|
||||
}
|
||||
for (String del : delManageRole.keySet()) {
|
||||
//如果是创建人 不能删除管理权限
|
||||
if (authManage_erf.keySet().contains(del)) {
|
||||
if (authManage_erf.containsKey(del)) {
|
||||
if (!del.equals(erf_orig.getCreateBy())) {
|
||||
authManage_erf.remove(del);
|
||||
isChange = true;
|
||||
@@ -153,13 +139,13 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
}
|
||||
}
|
||||
for (String add : addViewRole.keySet()) {
|
||||
if (!authView_erf.keySet().contains(add)) {
|
||||
if (!authView_erf.containsKey(add)) {
|
||||
authView_erf.put(add, addViewRole.get(add));
|
||||
isChange = true;
|
||||
}
|
||||
}
|
||||
for (String del : delViewRole.keySet()) {
|
||||
if (authView_erf.keySet().contains(del)) {
|
||||
if (authView_erf.containsKey(del)) {
|
||||
authView_erf.remove(del);
|
||||
isChange = true;
|
||||
}
|
||||
@@ -179,15 +165,11 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 得到列表新增元素集合
|
||||
*
|
||||
* @param mapA
|
||||
* @param mapB
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> getDefMap(Map<String, String> mapA, Map<String, String> mapB) {
|
||||
Map<String, String> res = new HashMap<String, String>();
|
||||
Map<String, String> res = new HashMap<>();
|
||||
for (String s : mapA.keySet()) {
|
||||
if (StringUtils.isNotBlank(s) && !mapB.keySet().contains(s)) {
|
||||
if (StringUtils.isNotBlank(s) && !mapB.containsKey(s)) {
|
||||
res.put(s, mapA.get(s));
|
||||
}
|
||||
}
|
||||
@@ -196,7 +178,7 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
private List<ExtRepoFolder> getAllSubFolder(String folderId) {
|
||||
List<ExtRepoFolder> resList = getListBySupFolder(folderId);
|
||||
List<ExtRepoFolder> subList = new ArrayList<ExtRepoFolder>();
|
||||
List<ExtRepoFolder> subList = new ArrayList<>();
|
||||
for (ExtRepoFolder erf : resList) {
|
||||
subList.addAll(getAllSubFolder(erf.getId()));
|
||||
}
|
||||
@@ -206,9 +188,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
@@ -222,9 +201,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ExtRepoFolder queryById(String id) {
|
||||
@@ -233,8 +209,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ExtRepoFolder> queryList() {
|
||||
@@ -243,14 +217,12 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ERFTreeData> queryTreeList() {
|
||||
try {
|
||||
List<ExtRepoFolder> list = queryList();
|
||||
List<ERFTreeData> res = getSubFolder(superFolder, list, 1);
|
||||
List<ERFTreeData> res = getSubFolder(superFolder, list, 1, true);
|
||||
Collections.sort(res);
|
||||
return res;
|
||||
} catch (Exception ex) {
|
||||
@@ -262,34 +234,31 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 查找子文件夹,生成树结构
|
||||
*
|
||||
* @param supId
|
||||
* @param list
|
||||
* @param level 前端需要知道当前文件夹在哪一层
|
||||
* @return
|
||||
*/
|
||||
private List<ERFTreeData> getSubFolder(String supId, List<ExtRepoFolder> list, int level) throws Exception {
|
||||
List<ERFTreeData> resList = new ArrayList<ERFTreeData>();
|
||||
private List<ERFTreeData> getSubFolder(String supId, List<ExtRepoFolder> list, int level, boolean needAuth) {
|
||||
List<ERFTreeData> resList = new ArrayList<>();
|
||||
for (ExtRepoFolder erf : list) {
|
||||
if (supId.equals(erf.getSupFolder())) {
|
||||
ERFTreeData date = new ERFTreeData(erf.getFolderName(), erf.getId(), level, erf.getOrderId());
|
||||
//检查有没有权限查看
|
||||
date.setDisplay(haveViewAuth(erf.getSupFolder()));
|
||||
int childLevel = date.getLevel() + 1;
|
||||
date.setAuthManageIdsName(erf.getAuthManageIdsName());
|
||||
date.setAuthManageIds(erf.getAuthManageIds());
|
||||
date.setAuthViewIdsName(erf.getAuthViewIdsName());
|
||||
date.setAuthViewIds(erf.getAuthViewIds());
|
||||
date.setChildren(getSubFolder(erf.getId(), list, childLevel));
|
||||
date.sortChildren();
|
||||
resList.add(date);
|
||||
int childLevel = level + 1;
|
||||
if (!needAuth || haveViewAuth(erf.getId())) {
|
||||
ERFTreeData date = new ERFTreeData(erf.getFolderName(), erf.getId(), level, erf.getOrderId());
|
||||
date.setAuthManageIdsName(erf.getAuthManageIdsName());
|
||||
date.setAuthManageIds(erf.getAuthManageIds());
|
||||
date.setAuthViewIdsName(erf.getAuthViewIdsName());
|
||||
date.setAuthViewIds(erf.getAuthViewIds());
|
||||
date.setChildren(getSubFolder(erf.getId(), list, childLevel, false));
|
||||
date.sortChildren();
|
||||
resList.add(date);
|
||||
} else {
|
||||
resList.addAll(getSubFolder(erf.getId(), list, childLevel, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
private List<String> getStringList(String listStr) {
|
||||
List<String> res = new ArrayList<String>();
|
||||
List<String> res = new ArrayList<>();
|
||||
if (null != listStr) {
|
||||
res = Arrays.asList(listStr.split(","));
|
||||
}
|
||||
@@ -297,7 +266,7 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
}
|
||||
|
||||
private Map<String, String> getAuthMap(String strKey, String strValue) {
|
||||
Map<String, String> resMap = new HashMap<String, String>();
|
||||
Map<String, String> resMap = new HashMap<>();
|
||||
List<String> keyList = getStringList(strKey);
|
||||
List<String> valueList = getStringList(strValue);
|
||||
for (int i = 0; i < keyList.size(); i++) {
|
||||
@@ -308,19 +277,17 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 判断是否是文件夹管理员角色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isManager() {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // 获取当前登录用户
|
||||
// 查询当前登录用户角色
|
||||
List<SysUserRole> userRoles = sysUserRoleService.list(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, loginUser.getId())); // 查询用户所有角色
|
||||
List<String> userRoleIds = new ArrayList<>(); // 用户管理员/对外报告管理员
|
||||
List<String> userRoleIds; // 用户管理员/对外报告管理员
|
||||
if (CollectionUtil.isNotEmpty(userRoles)) {
|
||||
List<String> roleIdList = ExtRepoMamagerRoleIdEnum.getIdList();
|
||||
List<String> userRoleIdList = userRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
|
||||
userRoleIds = roleIdList.stream().filter(e -> userRoleIdList.contains(e)).collect(Collectors.toList());
|
||||
userRoleIds = roleIdList.stream().filter(userRoleIdList::contains).collect(Collectors.toList());
|
||||
return !CollectionUtil.isEmpty(userRoleIds);
|
||||
}
|
||||
return false;
|
||||
@@ -328,13 +295,10 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 是否有管理权限
|
||||
*
|
||||
* @param folderId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean haveManageAuth(String folderId) {
|
||||
boolean res = false;
|
||||
boolean res;
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
res = isManager();
|
||||
ExtRepoFolder erf = queryById(folderId);
|
||||
@@ -346,12 +310,9 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
|
||||
|
||||
/**
|
||||
* 是否有查看权限
|
||||
*
|
||||
* @param folderId
|
||||
* @return
|
||||
*/
|
||||
public boolean haveViewAuth(String folderId) {
|
||||
boolean res = false;
|
||||
boolean res;
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
res = isManager();
|
||||
ExtRepoFolder erf = queryById(folderId);
|
||||
|
||||
Reference in New Issue
Block a user