From 42b1243419be40e9b63a14170a8a281a6d86b2a6 Mon Sep 17 00:00:00 2001 From: gaosong Date: Wed, 27 Jul 2022 17:54:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E5=A4=96=E6=8A=A5=E5=91=8A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97-=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ExtRepoDataController.java | 20 +- .../controller/ExtRepoFolderController.java | 204 ++++++------------ .../modules/extRepo/entity/ERFTreeData.java | 75 +++++-- .../extRepo/entity/ExtRepoDataPage.java | 40 ++++ .../modules/extRepo/entity/ExtRepoFolder.java | 37 ++-- .../mapper/xml/ExtRepoFolderMapper.xml | 2 + .../service/IExtRepoFolderService.java | 90 ++++---- .../service/impl/ExtRepoDataServiceImpl.java | 4 + .../impl/ExtRepoFolderServiceImpl.java | 108 ++++++---- 9 files changed, 315 insertions(+), 265 deletions(-) create mode 100644 jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoDataPage.java diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoDataController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoDataController.java index 167f4e812..9798e3269 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoDataController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoDataController.java @@ -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 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 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 deleteBatch(@RequestParam(name = "ids", required = true) String ids) { - this.extRepoDataService.deleteByIds(Arrays.asList(ids.split(","))); + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + List 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("批量删除成功!"); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java index d4b2107d4..67bc95ced 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/controller/ExtRepoFolderController.java @@ -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 { - @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 queryWrapper = QueryGenerator.initQueryWrapper(extRepoFolder, req.getParameterMap()); - Page page = new Page(pageNo, pageSize); - IPage pageList = extRepoFolderService.page(page, queryWrapper); - return Result.OK(pageList); - } + @Autowired + private IExtRepoFolderService extRepoFolderService; /** - * 列表查询 - * - * @return - */ - @AutoLog(value = "对外报告文件夹表-列表查询") - @ApiOperation(value="对外报告文件夹表-列表查询", notes="对外报告文件夹表-列表查询") - @GetMapping(value = "/list") - public Result> queryList() { + * 列表查询 + * + * @return + */ + @AutoLog(value = "对外报告文件夹表-列表查询") + @ApiOperation(value = "对外报告文件夹表-列表查询", notes = "对外报告文件夹表-列表查询") + @GetMapping(value = "/list") + public Result> queryList() { List 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); + } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ERFTreeData.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ERFTreeData.java index 4c6553b2d..a03327422 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ERFTreeData.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ERFTreeData.java @@ -18,6 +18,8 @@ public class ERFTreeData implements Comparable { */ private String title; + private String folderName; + /** * 文件夹ID 对应 id */ @@ -40,6 +42,27 @@ public class ERFTreeData implements Comparable { */ 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 { 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 { 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; diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoDataPage.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoDataPage.java new file mode 100644 index 000000000..fd6598f35 --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoDataPage.java @@ -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 pageList; + + public ExtRepoDataPage() { + } + + public ExtRepoDataPage(boolean auth_manage, IPage 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 getPageList() { + return pageList; + } + + public void setPageList(IPage pageList) { + this.pageList = pageList; + } +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java index 44c91e902..b6915fc50 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/entity/ExtRepoFolder.java @@ -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 getAuthManageList(){ - return Arrays.asList(authManage.split(",")); - } - - public List 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; } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/mapper/xml/ExtRepoFolderMapper.xml b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/mapper/xml/ExtRepoFolderMapper.xml index 57568b5fd..a742f17b9 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/mapper/xml/ExtRepoFolderMapper.xml +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/mapper/xml/ExtRepoFolderMapper.xml @@ -13,5 +13,7 @@ + + \ No newline at end of file diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java index eaf819340..d9be6458b 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/IExtRepoFolderService.java @@ -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 { - /** - * 保存 - * - * @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 ids); - - /** - * 通过id查询 - * - * @param id - * @return - */ + /** + * 通过id查询 + * + * @param id + * @return + */ ExtRepoFolder queryById(String id); /** - * 列表查询 - * - * @return - */ + * 列表查询 + * + * @return + */ List queryList(); - /** - * 查询返回树结构 - * @return - */ - List queryTreeList(); + /** + * 查询返回树结构 + * + * @return + */ + List queryTreeList(); - /** - * 是否有管理权限 - * @param folderId - * @return - */ - boolean haveManageAuth(String folderId); + /** + * 是否有管理权限 + * + * @param folderId + * @return + */ + boolean haveManageAuth(String folderId); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoDataServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoDataServiceImpl.java index 72f4f50c9..4f07b2182 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoDataServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/extRepo/service/impl/ExtRepoDataServiceImpl.java @@ -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 getListBySupFolder(String supFolder){ + private List getListBySupFolder(String supFolder) { ExtRepoFolder erf = new ExtRepoFolder(); erf.setSupFolder(supFolder); QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(erf, new HashMap<>()); @@ -104,53 +101,57 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl authManage_orig = erf_orig.getAuthManageList(); - List authManage_new = erf_new.getAuthManageList(); + //管理权限 + Map authManage_orig = getAuthMap(erf_orig.getAuthManage(), erf_orig.getAuthManageIds()); + Map authManage_new = getAuthMap(erf_new.getAuthManage(), erf_new.getAuthManageIds()); //增加管理权限的人 - List addManageRole = getDefList(authManage_new, authManage_orig); + Map addManageRole = getDefMap(authManage_new, authManage_orig); //删除管理权限的人 - List delManageRole = getDefList(authManage_orig, authManage_new); + Map delManageRole = getDefMap(authManage_orig, authManage_new); - List authView_orig = erf_orig.getAuthViewList(); - List authView_new = erf_new.getAuthViewList(); + //查看权限 + Map authView_orig = getAuthMap(erf_orig.getAuthView(), erf_orig.getAuthViewIds()); + Map authView_new = getAuthMap(erf_new.getAuthView(), erf_new.getAuthViewIds()); //增加查看权限的人 - List addViewRole = getDefList(authView_new, authView_orig); + Map addViewRole = getDefMap(authView_new, authView_orig); //删除查看权限的人 - List delViewRole = getDefList(authView_orig, authView_new); + Map delViewRole = getDefMap(authView_orig, authView_new); List allSubFolder = getAllSubFolder(erf_orig.getId()); //存储变化的对象 List updateFolder = new ArrayList(); for (ExtRepoFolder erf : allSubFolder) { boolean isChange = false; - List authManage_erf = erf.getAuthManageList(); - List authView_erf = erf.getAuthViewList(); - for (String add : addManageRole) { - if (!authManage_erf.contains(add)) { - authManage_erf.add(add); + Map authManage_erf = getAuthMap(erf.getAuthManage(), erf.getAuthManageIds()); + Map 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 getDefList(List listA, List listB) { - List res = new ArrayList(); - for (String s : listA) { - if (StringUtils.isNotBlank(s) && !listB.contains(s)) { - res.add(s); + private Map getDefMap(Map mapA, Map mapB) { + Map res = new HashMap(); + 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 ids) { - removeByIds(ids); - } - /** * 通过id查询 * @@ -272,8 +262,12 @@ public class ExtRepoFolderServiceImpl extends ServiceImpl getStringList(String listStr) { + List res = new ArrayList(); + if (null != listStr) { + res = Arrays.asList(listStr.split(",")); + } + return res; + } + + private Map getAuthMap(String strKey, String strValue) { + Map resMap = new HashMap(); + List keyList = getStringList(strKey); + List valueList = getStringList(strValue); + for (int i = 0; i < keyList.size(); i++) { + resMap.put(keyList.get(i), valueList.get(i)); + } + return resMap; + } }