对外报告模块-修改文件夹权限问题

This commit is contained in:
gaosong
2022-07-27 17:54:40 +08:00
parent 35000d2dbc
commit 42b1243419
9 changed files with 315 additions and 265 deletions
@@ -9,6 +9,7 @@ import com.jero.common.system.base.controller.JeroController;
import com.jero.common.system.query.QueryGenerator;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.extRepo.entity.ExtRepoData;
import com.jero.modules.extRepo.entity.ExtRepoDataPage;
import com.jero.modules.extRepo.service.IExtRepoDataService;
import com.jero.modules.extRepo.service.IExtRepoFolderService;
import io.swagger.annotations.Api;
@@ -78,7 +79,8 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
log.info("查询当前页数量:" + pageList.getSize());
log.info("查询结果数量:" + pageList.getRecords().size());
log.info("数据总数:" + pageList.getTotal());
return Result.OK(pageList);
ExtRepoDataPage res = new ExtRepoDataPage(extRepoFolderService.haveManageAuth(extRepoData.getSupFolder()), pageList);
return Result.OK(res);
}
/**
@@ -122,7 +124,9 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
@ApiOperation(value = "对外报告数据表-编辑", notes = "对外报告数据表-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody ExtRepoData extRepoData) {
if (extRepoFolderService.haveManageAuth(extRepoData.getSupFolder())) {
ExtRepoData erd = extRepoDataService.queryById(extRepoData.getId());
if (extRepoFolderService.haveManageAuth(erd.getSupFolder())) {
extRepoData.setSupFolder(erd.getSupFolder());
extRepoDataService.editById(extRepoData);
return Result.OK("编辑成功!");
} else {
@@ -142,7 +146,7 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
ExtRepoData erd = extRepoDataService.queryById(id);
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (extRepoFolderService.haveManageAuth(erd.getSupFolder()) && erd.getCreateBy().equals(sysUser.getUsername())) {
if (erd.getCreateBy().equals(sysUser.getUsername())) {
extRepoDataService.deleteById(id);
return Result.OK("删除成功!");
} else {
@@ -160,7 +164,15 @@ public class ExtRepoDataController extends JeroController<ExtRepoData, IExtRepoD
@ApiOperation(value = "对外报告数据表-批量删除", notes = "对外报告数据表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.extRepoDataService.deleteByIds(Arrays.asList(ids.split(",")));
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<String> idsList = Arrays.asList(ids.split(","));
for (String id : idsList) {
ExtRepoData erd = extRepoDataService.queryById(id);
if (null != erd && !erd.getCreateBy().equals(sysUser.getUsername())) {
return Result.OK("没有权限!");
}
}
this.extRepoDataService.deleteByIds(idsList);
return Result.OK("批量删除成功!");
}
@@ -1,12 +1,8 @@
package com.jero.modules.extRepo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.system.base.controller.JeroController;
import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.extRepo.entity.ERFTreeData;
import com.jero.modules.extRepo.entity.ExtRepoFolder;
import com.jero.modules.extRepo.service.IExtRepoFolderService;
@@ -16,157 +12,93 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
/**
/**
* @Description: 对外报告文件夹表
* @Author: jero-boot
* @Date: 2022-07-25
* @Date: 2022-07-25
* @Version: V1.0
*/
@Api(tags="对外报告文件夹表")
@Api(tags = "对外报告文件夹表")
@RestController
@RequestMapping("/extRepo/extRepoFolder")
@Slf4j
public class ExtRepoFolderController extends JeroController<ExtRepoFolder, IExtRepoFolderService> {
@Autowired
private IExtRepoFolderService extRepoFolderService;
/**
* 分页列表查询
*
* @param extRepoFolder
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "对外报告文件夹表-分页列表查询")
@ApiOperation(value="对外报告文件夹表-分页列表查询", notes="对外报告文件夹表-分页列表查询")
@GetMapping(value = "/page")
public Result<?> queryPageList(ExtRepoFolder extRepoFolder,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<ExtRepoFolder> queryWrapper = QueryGenerator.initQueryWrapper(extRepoFolder, req.getParameterMap());
Page<ExtRepoFolder> page = new Page<ExtRepoFolder>(pageNo, pageSize);
IPage<ExtRepoFolder> pageList = extRepoFolderService.page(page, queryWrapper);
return Result.OK(pageList);
}
@Autowired
private IExtRepoFolderService extRepoFolderService;
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "对外报告文件夹表-列表查询")
@ApiOperation(value="对外报告文件夹表-列表查询", notes="对外报告文件夹表-列表查询")
@GetMapping(value = "/list")
public Result<List<ERFTreeData>> queryList() {
* 列表查询
*
* @return
*/
@AutoLog(value = "对外报告文件夹表-列表查询")
@ApiOperation(value = "对外报告文件夹表-列表查询", notes = "对外报告文件夹表-列表查询")
@GetMapping(value = "/list")
public Result<List<ERFTreeData>> queryList() {
List<ERFTreeData> list = extRepoFolderService.queryTreeList();
return Result.OK(list);
}
/**
* 添加
*
* @param extRepoFolder
* @return
*/
@AutoLog(value = "对外报告文件夹表-添加")
@ApiOperation(value="对外报告文件夹表-添加", notes="对外报告文件夹表-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody ExtRepoFolder extRepoFolder) {
extRepoFolderService.add(extRepoFolder);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param extRepoFolder
* @return
*/
@AutoLog(value = "对外报告文件夹表-编辑")
@ApiOperation(value="对外报告文件夹表-编辑", notes="对外报告文件夹表-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody ExtRepoFolder extRepoFolder) {
extRepoFolderService.editById(extRepoFolder);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "对外报告文件夹表-通过id删除")
@ApiOperation(value="对外报告文件夹表-通过id删除", notes="对外报告文件夹表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
extRepoFolderService.deleteById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "对外报告文件夹表-批量删除")
@ApiOperation(value="对外报告文件夹表-批量删除", notes="对外报告文件夹表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.extRepoFolderService.deleteByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "对外报告文件夹表-通过id查询")
@ApiOperation(value="对外报告文件夹表-通过id查询", notes="对外报告文件夹表-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
ExtRepoFolder extRepoFolder = extRepoFolderService.queryById(id);
if(extRepoFolder==null) {
return Result.error("未找到对应数据");
}
return Result.OK(extRepoFolder);
}
/**
* 导出excel
*
* @param request
* @param extRepoFolder
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, ExtRepoFolder extRepoFolder) {
return super.exportXls(request, extRepoFolder, ExtRepoFolder.class, "对外报告文件夹表");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, ExtRepoFolder.class);
* 添加
*
* @param extRepoFolder
* @return
*/
@AutoLog(value = "对外报告文件夹表-添加")
@ApiOperation(value = "对外报告文件夹表-添加", notes = "对外报告文件夹表-添加")
@PostMapping(value = "/add")
public Result<?> add(@Validated @RequestBody ExtRepoFolder extRepoFolder) {
extRepoFolderService.add(extRepoFolder);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param extRepoFolder
* @return
*/
@AutoLog(value = "对外报告文件夹表-编辑")
@ApiOperation(value = "对外报告文件夹表-编辑", notes = "对外报告文件夹表-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@Validated @RequestBody ExtRepoFolder extRepoFolder) {
extRepoFolderService.editById(extRepoFolder);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "对外报告文件夹表-通过id删除")
@ApiOperation(value = "对外报告文件夹表-通过id删除", notes = "对外报告文件夹表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
extRepoFolderService.deleteById(id);
return Result.OK("删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "对外报告文件夹表-通过id查询")
@ApiOperation(value = "对外报告文件夹表-通过id查询", notes = "对外报告文件夹表-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
ExtRepoFolder extRepoFolder = extRepoFolderService.queryById(id);
if (extRepoFolder == null) {
return Result.error("未找到对应数据");
}
return Result.OK(extRepoFolder);
}
}
@@ -18,6 +18,8 @@ public class ERFTreeData implements Comparable<ERFTreeData> {
*/
private String title;
private String folderName;
/**
* 文件夹ID 对应 id
*/
@@ -40,6 +42,27 @@ public class ERFTreeData implements Comparable<ERFTreeData> {
*/
private boolean display = false;
/**
* 查看权限人员
*/
private String authView = "";
/**
* 管理权限人员
*/
private String authManage = "";
/**
* 查看权限人员id
*/
private String authViewIds = "";
/**
* 管理权限人员id
*/
private String authManageIds = "";
/**
* 子文件夹
*/
@@ -48,8 +71,9 @@ public class ERFTreeData implements Comparable<ERFTreeData> {
public ERFTreeData() {
}
public ERFTreeData(String title, String key, int level,int orderId) {
public ERFTreeData(String title, String key, int level, int orderId) {
this.title = title;
this.folderName = title;
this.key = key;
this.level = level;
this.orderId = orderId;
@@ -103,23 +127,50 @@ public class ERFTreeData implements Comparable<ERFTreeData> {
this.display = display;
}
@Override
public String toString() {
return "ERFTreeData{" +
"title='" + title + '\'' +
", key='" + key + '\'' +
", level=" + level +
", orderId=" + orderId +
", display=" + display +
", children=" + children +
'}';
public String getFolderName() {
return folderName;
}
public void setFolderName(String folderName) {
this.folderName = folderName;
}
public String getAuthView() {
return authView;
}
public void setAuthView(String authView) {
this.authView = authView;
}
public String getAuthManage() {
return authManage;
}
public void setAuthManage(String authManage) {
this.authManage = authManage;
}
public String getAuthViewIds() {
return authViewIds;
}
public void setAuthViewIds(String authViewIds) {
this.authViewIds = authViewIds;
}
public String getAuthManageIds() {
return authManageIds;
}
public void setAuthManageIds(String authManageIds) {
this.authManageIds = authManageIds;
}
public void sortChildren() {
Collections.sort(children);
}
@Override
public int compareTo(@NotNull ERFTreeData o) {
return this.orderId - o.orderId;
@@ -0,0 +1,40 @@
package com.jero.modules.extRepo.entity;
import com.baomidou.mybatisplus.core.metadata.IPage;
public class ExtRepoDataPage {
/**
* 此页面是否有管理权限
*/
private boolean auth_manage;
/**
* 数据列表
*/
private IPage<ExtRepoData> pageList;
public ExtRepoDataPage() {
}
public ExtRepoDataPage(boolean auth_manage, IPage<ExtRepoData> pageList) {
this.auth_manage = auth_manage;
this.pageList = pageList;
}
public boolean isAuth_manage() {
return auth_manage;
}
public void setAuth_manage(boolean auth_manage) {
this.auth_manage = auth_manage;
}
public IPage<ExtRepoData> getPageList() {
return pageList;
}
public void setPageList(IPage<ExtRepoData> pageList) {
this.pageList = pageList;
}
}
@@ -13,14 +13,12 @@ import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
/**
* @Description: 对外报告文件夹表
* @Author: jero-boot
* @Date: 2022-07-25
* @Date: 2022-07-27
* @Version: V1.0
*/
@Data
@@ -34,11 +32,11 @@ public class ExtRepoFolder implements Serializable {
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private java.lang.String id;
private String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@@ -48,7 +46,7 @@ public class ExtRepoFolder implements Serializable {
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@@ -58,39 +56,40 @@ public class ExtRepoFolder implements Serializable {
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode;
private String sysOrgCode;
/**文件夹名称*/
@Excel(name = "文件夹名称", width = 15)
@ApiModelProperty(value = "文件夹名称")
private java.lang.String folderName;
private String folderName;
/**文件夹排序*/
@Excel(name = "文件夹排序", width = 15)
@ApiModelProperty(value = "文件夹排序")
private java.lang.Integer orderId;
private Integer orderId;
/**所属文件夹*/
@Excel(name = "所属文件夹", width = 15)
@ApiModelProperty(value = "所属文件夹")
private java.lang.String supFolder;
private String supFolder;
/**查看权限人员*/
@Excel(name = "查看权限人员", width = 15)
@ApiModelProperty(value = "查看权限人员")
private java.lang.String authView;
private String authView;
/**管理权限人员*/
@Excel(name = "管理权限人员", width = 15)
@ApiModelProperty(value = "管理权限人员")
private java.lang.String authManage;
private String authManage;
public List<String> getAuthManageList(){
return Arrays.asList(authManage.split(","));
}
public List<String> getAuthViewList(){
return Arrays.asList(authView.split(","));
}
/**查看权限人员id*/
@Excel(name = "查看权限人员id", width = 15)
@ApiModelProperty(value = "查看权限人员id")
private String authViewIds;
/**管理权限人员id*/
@Excel(name = "管理权限人员id", width = 15)
@ApiModelProperty(value = "管理权限人员id")
private String authManageIds;
}
@@ -13,5 +13,7 @@
<result column="sup_folder" property="supFolder" />
<result column="auth_view" property="authView" />
<result column="auth_manage" property="authManage" />
<result column="auth_view_ids" property="authViewIds" />
<result column="auth_manage_ids" property="authManageIds" />
</resultMap>
</mapper>
@@ -9,69 +9,63 @@ import java.util.List;
/**
* @Description: 对外报告文件夹表
* @Author: jero-boot
* @Date: 2022-07-25
* @Date: 2022-07-25
* @Version: V1.0
*/
public interface IExtRepoFolderService extends IService<ExtRepoFolder> {
/**
* 保存
*
* @param extRepoFolder
* @return
*/
/**
* 保存
*
* @param extRepoFolder
* @return
*/
void add(ExtRepoFolder extRepoFolder);
/**
* 更新
*
* @param extRepoFolder
* @return
*/
/**
* 更新
*
* @param extRepoFolder
* @return
*/
void editById(ExtRepoFolder extRepoFolder);
/**
* 通过id删除
*
* @param id
* @return
*/
/**
* 通过id删除
*
* @param id
* @return
*/
void deleteById(String id);
/**
* 批量删除
*
* @param ids
* @return
*/
void deleteByIds(List<String> ids);
/**
* 通过id查询
*
* @param id
* @return
*/
/**
* 通过id查询
*
* @param id
* @return
*/
ExtRepoFolder queryById(String id);
/**
* 列表查询
*
* @return
*/
* 列表查询
*
* @return
*/
List<ExtRepoFolder> queryList();
/**
* 查询返回树结构
* @return
*/
List<ERFTreeData> queryTreeList();
/**
* 查询返回树结构
*
* @return
*/
List<ERFTreeData> queryTreeList();
/**
* 是否有管理权限
* @param folderId
* @return
*/
boolean haveManageAuth(String folderId);
/**
* 是否有管理权限
*
* @param folderId
* @return
*/
boolean haveManageAuth(String folderId);
}
@@ -1,9 +1,11 @@
package com.jero.modules.extRepo.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.extRepo.entity.ExtRepoData;
import com.jero.modules.extRepo.mapper.ExtRepoDataMapper;
import com.jero.modules.extRepo.service.IExtRepoDataService;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Service;
import java.util.Date;
@@ -29,6 +31,8 @@ public class ExtRepoDataServiceImpl extends ServiceImpl<ExtRepoDataMapper, ExtRe
Date now = new Date();
extRepoData.setCreateTime(now);
extRepoData.setUpdateTime(now);
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
extRepoData.setUpdateBy(sysUser.getUsername());
save(extRepoData);
}
@@ -38,9 +38,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
@Override
public void add(ExtRepoFolder extRepoFolder) {
try {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//创建文件夹的时候把创建人加入管理权限
extRepoFolder.setAuthManage(extRepoFolder.getAuthManage() + "," + sysUser.getUsername());
if (StringUtils.isEmpty(extRepoFolder.getSupFolder())) {
//一级文件夹的supFolder统一存root,方便以后查找
extRepoFolder.setSupFolder(superFolder);
@@ -71,7 +68,7 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
}
}
private List<ExtRepoFolder> getListBySupFolder(String supFolder){
private List<ExtRepoFolder> getListBySupFolder(String supFolder) {
ExtRepoFolder erf = new ExtRepoFolder();
erf.setSupFolder(supFolder);
QueryWrapper<ExtRepoFolder> queryWrapper = QueryGenerator.initQueryWrapper(erf, new HashMap<>());
@@ -104,53 +101,57 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
* 修改所有关联文件夹的权限
*/
private void editAuth(ExtRepoFolder erf_orig, ExtRepoFolder erf_new) throws Exception {
List<String> authManage_orig = erf_orig.getAuthManageList();
List<String> authManage_new = erf_new.getAuthManageList();
//管理权限
Map<String, String> authManage_orig = getAuthMap(erf_orig.getAuthManage(), erf_orig.getAuthManageIds());
Map<String, String> authManage_new = getAuthMap(erf_new.getAuthManage(), erf_new.getAuthManageIds());
//增加管理权限的人
List<String> addManageRole = getDefList(authManage_new, authManage_orig);
Map<String, String> addManageRole = getDefMap(authManage_new, authManage_orig);
//删除管理权限的人
List<String> delManageRole = getDefList(authManage_orig, authManage_new);
Map<String, String> delManageRole = getDefMap(authManage_orig, authManage_new);
List<String> authView_orig = erf_orig.getAuthViewList();
List<String> authView_new = erf_new.getAuthViewList();
//查看权限
Map<String, String> authView_orig = getAuthMap(erf_orig.getAuthView(), erf_orig.getAuthViewIds());
Map<String, String> authView_new = getAuthMap(erf_new.getAuthView(), erf_new.getAuthViewIds());
//增加查看权限的人
List<String> addViewRole = getDefList(authView_new, authView_orig);
Map<String, String> addViewRole = getDefMap(authView_new, authView_orig);
//删除查看权限的人
List<String> delViewRole = getDefList(authView_orig, authView_new);
Map<String, String> delViewRole = getDefMap(authView_orig, authView_new);
List<ExtRepoFolder> allSubFolder = getAllSubFolder(erf_orig.getId());
//存储变化的对象
List<ExtRepoFolder> updateFolder = new ArrayList<ExtRepoFolder>();
for (ExtRepoFolder erf : allSubFolder) {
boolean isChange = false;
List<String> authManage_erf = erf.getAuthManageList();
List<String> authView_erf = erf.getAuthViewList();
for (String add : addManageRole) {
if (!authManage_erf.contains(add)) {
authManage_erf.add(add);
Map<String, String> authManage_erf = getAuthMap(erf.getAuthManage(), erf.getAuthManageIds());
Map<String, String> authView_erf = getAuthMap(erf.getAuthView(), erf.getAuthViewIds());
for (String add : addManageRole.keySet()) {
if (!authManage_erf.keySet().contains(add)) {
authManage_erf.put(add, addManageRole.get(add));
isChange = true;
}
}
for (String del : delManageRole) {
if (authManage_erf.contains(del)) {
for (String del : delManageRole.keySet()) {
if (authManage_erf.keySet().contains(del)) {
authManage_erf.remove(del);
isChange = true;
}
}
for (String add : addViewRole) {
if (!authView_erf.contains(add)) {
authView_erf.add(add);
for (String add : addViewRole.keySet()) {
if (!authView_erf.keySet().contains(add)) {
authView_erf.put(add, addViewRole.get(add));
isChange = true;
}
}
for (String del : delViewRole) {
if (authView_erf.contains(del)) {
for (String del : delViewRole.keySet()) {
if (authView_erf.keySet().contains(del)) {
authView_erf.remove(del);
isChange = true;
}
}
erf.setAuthManage(StringUtils.join(authManage_erf, ","));
erf.setAuthView(StringUtils.join(authView_erf, ","));
erf.setAuthManage(StringUtils.join(authManage_erf.keySet(), ","));
erf.setAuthManageIds(StringUtils.join(authManage_erf.values(), ","));
erf.setAuthView(StringUtils.join(authView_erf.keySet(), ","));
erf.setAuthViewIds(StringUtils.join(authView_erf.values(), ","));
if (isChange) {
updateFolder.add(erf);
}
@@ -163,15 +164,15 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
/**
* 得到列表新增元素集合
*
* @param listA
* @param listB
* @param mapA
* @param mapB
* @return
*/
private List<String> getDefList(List<String> listA, List<String> listB) {
List<String> res = new ArrayList<String>();
for (String s : listA) {
if (StringUtils.isNotBlank(s) && !listB.contains(s)) {
res.add(s);
private Map<String, String> getDefMap(Map<String, String> mapA, Map<String, String> mapB) {
Map<String, String> res = new HashMap<String, String>();
for (String s : mapA.keySet()) {
if (StringUtils.isNotBlank(s) && !mapB.keySet().contains(s)) {
res.put(s, mapA.get(s));
}
}
return res;
@@ -206,17 +207,6 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
}
}
/**
* 批量删除
*
* @param ids
* @return
*/
@Override
public void deleteByIds(List<String> ids) {
removeByIds(ids);
}
/**
* 通过id查询
*
@@ -272,8 +262,12 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
if (supId.equals(erf.getSupFolder())) {
ERFTreeData date = new ERFTreeData(erf.getFolderName(), erf.getId(), level, erf.getOrderId());
//检查有没有权限查看
date.setDisplay(erf.getAuthManageList().contains(sysUser.getUsername()) || erf.getAuthViewList().contains(sysUser.getUsername()));
date.setDisplay(erf.getCreateBy().equals(sysUser.getUsername()) || getStringList(erf.getAuthManage()).contains(sysUser.getUsername()) || getStringList(erf.getAuthView()).contains(sysUser.getUsername()));
int childLevel = date.getLevel() + 1;
date.setAuthManage(erf.getAuthManage());
date.setAuthManageIds(erf.getAuthManageIds());
date.setAuthView(erf.getAuthManage());
date.setAuthViewIds(erf.getAuthViewIds());
date.setChildren(getSubFolder(erf.getId(), list, childLevel));
date.sortChildren();
resList.add(date);
@@ -284,6 +278,7 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
/**
* 是否有管理权限
*
* @param folderId
* @return
*/
@@ -291,8 +286,29 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl<ExtRepoFolderMapper, E
public boolean haveManageAuth(String folderId) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
ExtRepoFolder erf = queryById(folderId);
return erf.getAuthManageList().contains(sysUser.getUsername());
//如果是创建人 则默认有权限
if (null != erf) {
return getStringList(erf.getAuthManage()).contains(sysUser.getUsername()) || erf.getCreateBy().equals(sysUser.getUsername());
}
return false;
}
private List<String> getStringList(String listStr) {
List<String> res = new ArrayList<String>();
if (null != listStr) {
res = Arrays.asList(listStr.split(","));
}
return res;
}
private Map<String, String> getAuthMap(String strKey, String strValue) {
Map<String, String> resMap = new HashMap<String, String>();
List<String> keyList = getStringList(strKey);
List<String> valueList = getStringList(strValue);
for (int i = 0; i < keyList.size(); i++) {
resMap.put(keyList.get(i), valueList.get(i));
}
return resMap;
}
}