From 0854d8e7f7640f1f522fab11f1cd47bed709cc4c Mon Sep 17 00:00:00 2001 From: "yangyang.wang@dhc.com.cn" Date: Fri, 2 Aug 2024 15:36:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/dhc/DhcAreaController.java | 20 ++ .../DhcDataAuthController.java | 26 ++- .../controller/system/SysUserController.java | 26 ++- .../ruoyi/common/core/domain/TreeSelect.java | 14 ++ .../common/core/domain/entity/DhcArea.java | 10 + .../com/ruoyi/dhc/domain/DhcDataAuth.java | 121 ----------- .../service/impl/DhcDataAuthServiceImpl.java | 93 -------- .../com/ruoyi/dhc/domain/DhcDataAuth.java | 201 ++++++++++++++++++ .../ruoyi/dhc/domain/DhcDataAuthDetail.java | 77 +++++++ .../ruoyi/dhc/mapper/DhcDataAuthMapper.java | 30 ++- .../dhc/service/IDhcDataAuthService.java | 2 +- .../service/impl/DhcDataAuthServiceImpl.java | 129 +++++++++++ .../mapper/system}/DhcDataAuthMapper.xml | 64 ++++-- sql/基础功能.sql | 29 ++- 14 files changed, 589 insertions(+), 253 deletions(-) rename ruoyi-admin/src/main/java/com/ruoyi/web/controller/{dhc => system}/DhcDataAuthController.java (84%) delete mode 100644 ruoyi-plan/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java delete mode 100644 ruoyi-plan/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuthDetail.java rename {ruoyi-plan => ruoyi-system}/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java (65%) rename {ruoyi-plan => ruoyi-system}/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java (98%) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java rename {ruoyi-plan/src/main/resources/mapper/dhc => ruoyi-system/src/main/resources/mapper/system}/DhcDataAuthMapper.xml (51%) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/dhc/DhcAreaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/dhc/DhcAreaController.java index c6e905d..cfa7bf3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/dhc/DhcAreaController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/dhc/DhcAreaController.java @@ -13,7 +13,10 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 区域Controller @@ -130,4 +133,21 @@ public class DhcAreaController extends BaseController { return success(dhcAreaService.selectAreaTreeList(area)); } + + /** + * 查询区域信息 + */ + @GetMapping("/queryAreaMaplist") + public List>queryAreaMaplist(DhcArea dhcArea) + { + List list = dhcAreaService.selectDhcAreaList(dhcArea); + List> mapList = new ArrayList<>(); + for (DhcArea model : list) { + Map map = new HashMap<>(); + map.put("value", model.getAreaCode()); + map.put("label", model.getAreaName()); + mapList.add(map); + } + return mapList; + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/dhc/DhcDataAuthController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/DhcDataAuthController.java similarity index 84% rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/dhc/DhcDataAuthController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/DhcDataAuthController.java index fa6cabe..3dfb769 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/dhc/DhcDataAuthController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/DhcDataAuthController.java @@ -1,7 +1,13 @@ -package com.ruoyi.web.controller.dhc; +package com.ruoyi.web.controller.system; import java.util.List; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.dhc.domain.DhcDataAuth; +import com.ruoyi.dhc.service.IDhcDataAuthService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -16,8 +22,6 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.dhc.domain.DhcDataAuth; -import com.ruoyi.dhc.service.IDhcDataAuthService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; @@ -25,10 +29,10 @@ import com.ruoyi.common.core.page.TableDataInfo; * 数据权限Controller * * @author ruoyi - * @date 2024-07-30 + * @date 2024-08-01 */ @RestController -@RequestMapping("/dhc/auth") +@RequestMapping("/dhc/authData") public class DhcDataAuthController extends BaseController { @Autowired @@ -37,7 +41,7 @@ public class DhcDataAuthController extends BaseController /** * 查询数据权限列表 */ - @PreAuthorize("@ss.hasPermi('dhc:auth:list')") + @PreAuthorize("@ss.hasPermi('dhc:authData:list')") @GetMapping("/list") public TableDataInfo list(DhcDataAuth dhcDataAuth) { @@ -49,7 +53,7 @@ public class DhcDataAuthController extends BaseController /** * 导出数据权限列表 */ - @PreAuthorize("@ss.hasPermi('dhc:auth:export')") + @PreAuthorize("@ss.hasPermi('dhc:authData:export')") @Log(title = "数据权限", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, DhcDataAuth dhcDataAuth) @@ -62,7 +66,7 @@ public class DhcDataAuthController extends BaseController /** * 获取数据权限详细信息 */ - @PreAuthorize("@ss.hasPermi('dhc:auth:query')") + @PreAuthorize("@ss.hasPermi('dhc:authData:query')") @GetMapping(value = "/{dataAuthId}") public AjaxResult getInfo(@PathVariable("dataAuthId") Long dataAuthId) { @@ -72,7 +76,7 @@ public class DhcDataAuthController extends BaseController /** * 新增数据权限 */ - @PreAuthorize("@ss.hasPermi('dhc:auth:add')") + @PreAuthorize("@ss.hasPermi('dhc:authData:add')") @Log(title = "数据权限", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody DhcDataAuth dhcDataAuth) @@ -83,7 +87,7 @@ public class DhcDataAuthController extends BaseController /** * 修改数据权限 */ - @PreAuthorize("@ss.hasPermi('dhc:auth:edit')") + @PreAuthorize("@ss.hasPermi('dhc:authData:edit')") @Log(title = "数据权限", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody DhcDataAuth dhcDataAuth) @@ -94,7 +98,7 @@ public class DhcDataAuthController extends BaseController /** * 删除数据权限 */ - @PreAuthorize("@ss.hasPermi('dhc:auth:remove')") + @PreAuthorize("@ss.hasPermi('dhc:authData:remove')") @Log(title = "数据权限", businessType = BusinessType.DELETE) @DeleteMapping("/{dataAuthIds}") public AjaxResult remove(@PathVariable Long[] dataAuthIds) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index e29b862..136a318 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -4,10 +4,8 @@ import java.util.List; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; -import com.ruoyi.dhc.service.ISysDeptService; -import com.ruoyi.dhc.service.ISysPostService; -import com.ruoyi.dhc.service.ISysRoleService; -import com.ruoyi.dhc.service.ISysUserService; +import com.ruoyi.dhc.domain.DhcDataAuth; +import com.ruoyi.dhc.service.*; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -54,6 +52,9 @@ public class SysUserController extends BaseController @Autowired private ISysPostService postService; + @Autowired + private IDhcDataAuthService dhcDataAuthService; + /** * 获取用户列表 */ @@ -254,4 +255,21 @@ public class SysUserController extends BaseController { return success(deptService.selectDeptTreeList(dept)); } + + /** + * 查询数据权限列表 + */ + @PreAuthorize("@ss.hasPermi('system:user:query')") + @GetMapping("/authData/{userId}") + public AjaxResult authData(@PathVariable("userId") Long userId) + { + AjaxResult ajax = AjaxResult.success(); + SysUser user = userService.selectUserById(userId); + DhcDataAuth dhcDataAuth = new DhcDataAuth(); + dhcDataAuth.setUserId(userId); + List list = dhcDataAuthService.selectDhcDataAuthList(dhcDataAuth); + ajax.put("user", user); + ajax.put("authData", list); + return ajax; + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java index 560b7a4..dcb73f5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java @@ -21,6 +21,9 @@ public class TreeSelect implements Serializable /** 节点ID */ private Long id; + /** 节点ID */ + private Long value; + /** 节点名称 */ private String label; @@ -36,6 +39,7 @@ public class TreeSelect implements Serializable public TreeSelect(SysDept dept) { this.id = dept.getDeptId(); + this.value = dept.getDeptId(); this.label = dept.getDeptName(); this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } @@ -43,6 +47,7 @@ public class TreeSelect implements Serializable public TreeSelect(SysMenu menu) { this.id = menu.getMenuId(); + this.value = menu.getMenuId(); this.label = menu.getMenuName(); this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } @@ -50,6 +55,7 @@ public class TreeSelect implements Serializable public TreeSelect(DhcArea area) { this.id = area.getAreaId(); + this.value = area.getAreaId(); this.label = area.getAreaName(); this.children = area.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); } @@ -82,4 +88,12 @@ public class TreeSelect implements Serializable { this.children = children; } + + public Long getValue() { + return value; + } + + public void setValue(Long value) { + this.value = value; + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/DhcArea.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/DhcArea.java index bb62231..7cedf24 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/DhcArea.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/DhcArea.java @@ -63,9 +63,19 @@ public class DhcArea extends BaseEntity /** 父区域名称 */ private String parentName; + private boolean isEdit = false; + /** 子部门 */ private List children = new ArrayList(); + public boolean isEdit() { + return isEdit; + } + + public void setEdit(boolean edit) { + isEdit = edit; + } + public String getProductLineCode() { return productLineCode; } diff --git a/ruoyi-plan/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java b/ruoyi-plan/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java deleted file mode 100644 index 7246dab..0000000 --- a/ruoyi-plan/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.ruoyi.dhc.domain; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; - -/** - * 数据权限对象 dhc_data_auth - * - * @author ruoyi - * @date 2024-07-30 - */ -public class DhcDataAuth extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 数据权限ID */ - private Long dataAuthId; - - /** 部门ID */ - @Excel(name = "部门ID") - private Long deptId; - - /** 权限控制点 */ - @Excel(name = "权限控制点") - private String authNode; - - /** 产品线编码 */ - @Excel(name = "产品线编码") - private String productLineCode; - - /** 区域类型 */ - @Excel(name = "区域类型") - private String areaType; - - /** 区域编码 */ - @Excel(name = "区域编码") - private String areaCodes; - - /** 区域名称 */ - @Excel(name = "区域名称") - private String areaNames; - - public void setDataAuthId(Long dataAuthId) - { - this.dataAuthId = dataAuthId; - } - - public Long getDataAuthId() - { - return dataAuthId; - } - public void setDeptId(Long deptId) - { - this.deptId = deptId; - } - - public Long getDeptId() - { - return deptId; - } - public void setAuthNode(String authNode) - { - this.authNode = authNode; - } - - public String getAuthNode() - { - return authNode; - } - public void setProductLineCode(String productLineCode) - { - this.productLineCode = productLineCode; - } - - public String getProductLineCode() - { - return productLineCode; - } - public void setAreaType(String areaType) - { - this.areaType = areaType; - } - - public String getAreaType() - { - return areaType; - } - public void setAreaCodes(String areaCodes) - { - this.areaCodes = areaCodes; - } - - public String getAreaCodes() - { - return areaCodes; - } - public void setAreaNames(String areaNames) - { - this.areaNames = areaNames; - } - - public String getAreaNames() - { - return areaNames; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("dataAuthId", getDataAuthId()) - .append("deptId", getDeptId()) - .append("authNode", getAuthNode()) - .append("productLineCode", getProductLineCode()) - .append("areaType", getAreaType()) - .append("areaCodes", getAreaCodes()) - .append("areaNames", getAreaNames()) - .toString(); - } -} diff --git a/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java b/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java deleted file mode 100644 index 0540f85..0000000 --- a/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.ruoyi.dhc.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.dhc.mapper.DhcDataAuthMapper; -import com.ruoyi.dhc.domain.DhcDataAuth; -import com.ruoyi.dhc.service.IDhcDataAuthService; - -/** - * 数据权限Service业务层处理 - * - * @author ruoyi - * @date 2024-07-30 - */ -@Service -public class DhcDataAuthServiceImpl implements IDhcDataAuthService -{ - @Autowired - private DhcDataAuthMapper dhcDataAuthMapper; - - /** - * 查询数据权限 - * - * @param dataAuthId 数据权限主键 - * @return 数据权限 - */ - @Override - public DhcDataAuth selectDhcDataAuthByDataAuthId(Long dataAuthId) - { - return dhcDataAuthMapper.selectDhcDataAuthByDataAuthId(dataAuthId); - } - - /** - * 查询数据权限列表 - * - * @param dhcDataAuth 数据权限 - * @return 数据权限 - */ - @Override - public List selectDhcDataAuthList(DhcDataAuth dhcDataAuth) - { - return dhcDataAuthMapper.selectDhcDataAuthList(dhcDataAuth); - } - - /** - * 新增数据权限 - * - * @param dhcDataAuth 数据权限 - * @return 结果 - */ - @Override - public int insertDhcDataAuth(DhcDataAuth dhcDataAuth) - { - return dhcDataAuthMapper.insertDhcDataAuth(dhcDataAuth); - } - - /** - * 修改数据权限 - * - * @param dhcDataAuth 数据权限 - * @return 结果 - */ - @Override - public int updateDhcDataAuth(DhcDataAuth dhcDataAuth) - { - return dhcDataAuthMapper.updateDhcDataAuth(dhcDataAuth); - } - - /** - * 批量删除数据权限 - * - * @param dataAuthIds 需要删除的数据权限主键 - * @return 结果 - */ - @Override - public int deleteDhcDataAuthByDataAuthIds(Long[] dataAuthIds) - { - return dhcDataAuthMapper.deleteDhcDataAuthByDataAuthIds(dataAuthIds); - } - - /** - * 删除数据权限信息 - * - * @param dataAuthId 数据权限主键 - * @return 结果 - */ - @Override - public int deleteDhcDataAuthByDataAuthId(Long dataAuthId) - { - return dhcDataAuthMapper.deleteDhcDataAuthByDataAuthId(dataAuthId); - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java b/ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java new file mode 100644 index 0000000..31b4f5e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java @@ -0,0 +1,201 @@ +package com.ruoyi.dhc.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.util.List; + +/** + * 数据权限对象 dhc_data_auth + * + * @author ruoyi + * @date 2024-08-01 + */ +public class DhcDataAuth extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 数据权限ID */ + private Long dataAuthId; + /** 用户ID */ + private Long userId; + /** 部门ID */ + @Excel(name = "部门ID") + private Long deptId; + + /** 权限控制点 */ + @Excel(name = "部门树ID") + private String deptAllId; + + /** 权限控制点 */ + @Excel(name = "部门树名称") + private String deptAllName; + + /** 权限控制点 */ + @Excel(name = "权限控制点") + private String authNode; + + /** 产品线编码 */ + @Excel(name = "产品线编码") + private String productLineCode; + + /** 区域类型 */ + @Excel(name = "区域类型") + private String areaType; + + /** 类型(0区域 1.客户) */ + private String detailType; + + /** 数据权限明细 */ + + List detailList; + + List detailCodes; + + List deptIds; + + private String detailNames; + + private boolean editFlag; + + private List dataAuthIds; + + public List getDataAuthIds() { + return dataAuthIds; + } + + public void setDataAuthIds(List dataAuthIds) { + this.dataAuthIds = dataAuthIds; + } + + public boolean getEditFlag() { + return editFlag; + } + + public void setEditFlag(boolean editFlag) { + this.editFlag = editFlag; + } + + public List getDeptIds() { + return deptIds; + } + + public void setDeptIds(List deptIds) { + this.deptIds = deptIds; + } + + public String getDetailNames() { + return detailNames; + } + + public void setDetailNames(String detailNames) { + this.detailNames = detailNames; + } + + public String getDeptAllId() { + return deptAllId; + } + + public void setDeptAllId(String deptAllId) { + this.deptAllId = deptAllId; + } + + public String getDeptAllName() { + return deptAllName; + } + + public void setDeptAllName(String deptAllName) { + this.deptAllName = deptAllName; + } + + public List getDetailCodes() { + return detailCodes; + } + + public void setDetailCodes(List detailCodes) { + this.detailCodes = detailCodes; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getDetailType() { + return detailType; + } + + public void setDetailType(String detailType) { + this.detailType = detailType; + } + + public List getDetailList() { + return detailList; + } + + public void setDetailList(List detailList) { + this.detailList = detailList; + } + + public void setDataAuthId(Long dataAuthId) + { + this.dataAuthId = dataAuthId; + } + + public Long getDataAuthId() + { + return dataAuthId; + } + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + public Long getDeptId() + { + return deptId; + } + public void setAuthNode(String authNode) + { + this.authNode = authNode; + } + + public String getAuthNode() + { + return authNode; + } + public void setProductLineCode(String productLineCode) + { + this.productLineCode = productLineCode; + } + + public String getProductLineCode() + { + return productLineCode; + } + public void setAreaType(String areaType) + { + this.areaType = areaType; + } + + public String getAreaType() + { + return areaType; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("dataAuthId", getDataAuthId()) + .append("deptId", getDeptId()) + .append("authNode", getAuthNode()) + .append("productLineCode", getProductLineCode()) + .append("areaType", getAreaType()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuthDetail.java b/ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuthDetail.java new file mode 100644 index 0000000..150c0aa --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuthDetail.java @@ -0,0 +1,77 @@ +package com.ruoyi.dhc.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 数据权限明细对象 dhc_data_auth_detail + * + * @author ruoyi + * @date 2024-08-01 + */ +public class DhcDataAuthDetail extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 数据权限ID */ + private Long dataAuthId; + + /** 类型(0区域 1.客户) */ + private String detailType; + + /** 权限明细编码 */ + private String detailCode; + + /** 权限明细名称 */ + @Excel(name = "权限明细名称") + private String detailName; + + public void setDataAuthId(Long dataAuthId) + { + this.dataAuthId = dataAuthId; + } + + public Long getDataAuthId() + { + return dataAuthId; + } + public void setDetailType(String detailType) + { + this.detailType = detailType; + } + + public String getDetailType() + { + return detailType; + } + public void setDetailCode(String detailCode) + { + this.detailCode = detailCode; + } + + public String getDetailCode() + { + return detailCode; + } + public void setDetailName(String detailName) + { + this.detailName = detailName; + } + + public String getDetailName() + { + return detailName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("dataAuthId", getDataAuthId()) + .append("detailType", getDetailType()) + .append("detailCode", getDetailCode()) + .append("detailName", getDetailName()) + .toString(); + } +} diff --git a/ruoyi-plan/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java b/ruoyi-system/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java similarity index 65% rename from ruoyi-plan/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java index e69e9f1..8528298 100644 --- a/ruoyi-plan/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java @@ -1,13 +1,15 @@ package com.ruoyi.dhc.mapper; -import java.util.List; import com.ruoyi.dhc.domain.DhcDataAuth; +import com.ruoyi.dhc.domain.DhcDataAuthDetail; + +import java.util.List; /** * 数据权限Mapper接口 * * @author ruoyi - * @date 2024-07-30 + * @date 2024-08-01 */ public interface DhcDataAuthMapper { @@ -58,4 +60,28 @@ public interface DhcDataAuthMapper * @return 结果 */ public int deleteDhcDataAuthByDataAuthIds(Long[] dataAuthIds); + + /** + * 批量删除数据权限明细 + * + * @param dhcDataAuth 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDataAuthDetailByDataAuthIds(DhcDataAuth dhcDataAuth); + + /** + * 批量新增数据权限明细 + * + * @param list 数据权限明细列表 + * @return 结果 + */ + public int batchAddDataAuthDetail(List list); + /** + * 查询数据权限明细 + * + * @param dhcDataAuth 数据权限明细列表 + * @return 结果 + */ + public List selectDhcDataAuthDetailList(DhcDataAuth dhcDataAuth); + } diff --git a/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java b/ruoyi-system/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java similarity index 98% rename from ruoyi-plan/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java rename to ruoyi-system/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java index 2d2227f..eb01878 100644 --- a/ruoyi-plan/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java @@ -7,7 +7,7 @@ import com.ruoyi.dhc.domain.DhcDataAuth; * 数据权限Service接口 * * @author ruoyi - * @date 2024-07-30 + * @date 2024-08-01 */ public interface IDhcDataAuthService { diff --git a/ruoyi-system/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java new file mode 100644 index 0000000..f44582e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java @@ -0,0 +1,129 @@ +package com.ruoyi.dhc.service.impl; + +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.dhc.domain.DhcDataAuth; +import com.ruoyi.dhc.domain.DhcDataAuthDetail; +import com.ruoyi.dhc.mapper.DhcDataAuthMapper; +import com.ruoyi.dhc.service.IDhcDataAuthService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 数据权限Service业务层处理 + * + * @author ruoyi + * @date 2024-08-01 + */ +@Service +public class DhcDataAuthServiceImpl implements IDhcDataAuthService +{ + @Autowired + private DhcDataAuthMapper dhcDataAuthMapper; + + /** + * 查询数据权限 + * + * @param dataAuthId 数据权限主键 + * @return 数据权限 + */ + @Override + public DhcDataAuth selectDhcDataAuthByDataAuthId(Long dataAuthId) + { + return dhcDataAuthMapper.selectDhcDataAuthByDataAuthId(dataAuthId); + } + + /** + * 查询数据权限列表 + * + * @param dhcDataAuth 数据权限 + * @return 数据权限 + */ + @Override + public List selectDhcDataAuthList(DhcDataAuth dhcDataAuth) + { List list = dhcDataAuthMapper.selectDhcDataAuthList(dhcDataAuth); + list.forEach(item->{ + item.setDetailType("0"); + List detailList = dhcDataAuthMapper.selectDhcDataAuthDetailList(item); + String[] array = item.getDeptAllId().split("/"); + List deptIds = new ArrayList<>(); + for (String deptId : array) { + deptIds.add(Long.valueOf(deptId)); + } + item.setDeptIds(deptIds); + item.setDetailList(detailList); + item.setEditFlag(false); + item.setDetailCodes(detailList.stream().map(model->{return model.getDetailCode();}).collect(Collectors.toList())); + item.setDetailNames(StringUtils.join(detailList.stream().map(model->{return model.getDetailName();}).collect(Collectors.toList()),"/")); + }); + return list; + } + + /** + * 新增数据权限 + * + * @param dhcDataAuth 数据权限 + * @return 结果 + */ + @Override + public int insertDhcDataAuth(DhcDataAuth dhcDataAuth) + { + if (dhcDataAuth.getDataAuthId() != null) { + dhcDataAuthMapper.deleteDhcDataAuthByDataAuthId(dhcDataAuth.getDataAuthId()); + dhcDataAuthMapper.deleteDataAuthDetailByDataAuthIds(dhcDataAuth); + } + int count = dhcDataAuthMapper.insertDhcDataAuth(dhcDataAuth); + dhcDataAuth.getDetailList().forEach(item->{ + item.setDataAuthId(dhcDataAuth.getDataAuthId()); + }); + dhcDataAuthMapper.batchAddDataAuthDetail(dhcDataAuth.getDetailList()); + return count; + } + + /** + * 修改数据权限 + * + * @param dhcDataAuth 数据权限 + * @return 结果 + */ + @Override + public int updateDhcDataAuth(DhcDataAuth dhcDataAuth) + { + dhcDataAuthMapper.deleteDataAuthDetailByDataAuthIds(dhcDataAuth); + dhcDataAuthMapper.batchAddDataAuthDetail(dhcDataAuth.getDetailList()); + return dhcDataAuthMapper.updateDhcDataAuth(dhcDataAuth); + } + + /** + * 批量删除数据权限 + * + * @param dataAuthIds 需要删除的数据权限主键 + * @return 结果 + */ + @Override + public int deleteDhcDataAuthByDataAuthIds(Long[] dataAuthIds) + { DhcDataAuth dhcDataAuth = new DhcDataAuth(); + dhcDataAuth.setDataAuthIds(new ArrayList<>(Arrays.asList(dataAuthIds))); + dhcDataAuthMapper.deleteDataAuthDetailByDataAuthIds(dhcDataAuth); + return dhcDataAuthMapper.deleteDhcDataAuthByDataAuthIds(dataAuthIds); + } + + /** + * 删除数据权限信息 + * + * @param dataAuthId 数据权限主键 + * @return 结果 + */ + @Override + public int deleteDhcDataAuthByDataAuthId(Long dataAuthId) + { + DhcDataAuth dhcDataAuth = new DhcDataAuth(); + dhcDataAuth.setDataAuthId(dataAuthId); + dhcDataAuthMapper.deleteDataAuthDetailByDataAuthIds(dhcDataAuth); + return dhcDataAuthMapper.deleteDhcDataAuthByDataAuthId(dataAuthId); + } +} diff --git a/ruoyi-plan/src/main/resources/mapper/dhc/DhcDataAuthMapper.xml b/ruoyi-system/src/main/resources/mapper/system/DhcDataAuthMapper.xml similarity index 51% rename from ruoyi-plan/src/main/resources/mapper/dhc/DhcDataAuthMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/DhcDataAuthMapper.xml index baef70c..c9432fd 100644 --- a/ruoyi-plan/src/main/resources/mapper/dhc/DhcDataAuthMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/DhcDataAuthMapper.xml @@ -6,27 +6,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - - + + + + + + + + + - select data_auth_id, dept_id, auth_node, product_line_code, area_type, area_codes, area_names from dhc_data_auth + select data_auth_id, user_id, dept_id, auth_node, product_line_code, area_type,b.dept_all_id,dept_all_Name from dhc_data_auth @@ -38,32 +45,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into dhc_data_auth + user_id, dept_id, + dept_all_id, + dept_all_Name, auth_node, product_line_code, area_type, - area_codes, - area_names, + #{userId}, #{deptId}, + #{deptAllId}, + #{deptAllName}, #{authNode}, #{productLineCode}, #{areaType}, - #{areaCodes}, - #{areaNames}, update dhc_data_auth + user_id = #{userId}, dept_id = #{deptId}, + dept_all_id = #{deptAllId}, + dept_all_Name = #{deptAllName}, auth_node = #{authNode}, product_line_code = #{productLineCode}, area_type = #{areaType}, - area_codes = #{areaCodes}, - area_names = #{areaNames}, where data_auth_id = #{dataAuthId} @@ -78,4 +88,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{dataAuthId} + + delete from dhc_data_auth_detail + + and data_auth_id = #{dataAuthId} + and detail_type = #{detailType} + + and detail_code in + + #{detailCode} + + + + and data_auth_id in + + #{dataAuthId} + + + + + + insert into dhc_data_auth_detail(data_auth_id, detail_type, detail_code, detail_name) values + + (#{item.dataAuthId},#{item.detailType},#{item.detailCode},#{item.detailName}) + + + \ No newline at end of file diff --git a/sql/基础功能.sql b/sql/基础功能.sql index 1d6f0e2..5f3c0c8 100644 --- a/sql/基础功能.sql +++ b/sql/基础功能.sql @@ -4,16 +4,29 @@ drop table if exists dhc_data_auth; create table dhc_data_auth ( data_auth_id bigint NOT NULL auto_increment COMMENT '数据权限ID', + user_id bigint(20) NOT NULL comment '用户ID', dept_id bigint(20) NOT NULL comment '部门ID', + dept_all_id varchar(1000) NOT NULL comment '部门树ID', + dept_all_Name varchar(1000) NOT NULL comment '部门树名称', auth_node varchar(32) NOT NULL comment '权限控制点', product_line_code varchar(32) NOT NULL comment '产品线编码', area_type varchar(32) default '' NOT NULL comment '区域类型', - area_codes varchar(1000) default '' NOT NULL comment '区域编码', - area_names varchar(2000) default '' NOT NULL comment '区域名称', primary key (data_auth_id) ) engine=innodb auto_increment=1 comment = '数据权限表'; + +-- ---------------------------- +-- 2、数据权限明细表 +-- ---------------------------- +drop table if exists dhc_data_auth_datail; +create table dhc_data_auth_detail ( + data_auth_id bigint NOT NULL COMMENT '数据权限ID', + detail_type char(1) NOT NULL comment '类型(0区域 1.客户)', + detail_code varchar(32) NOT NULL comment '权限明细编码', + detail_name varchar(64) NOT NULL comment '权限明细名称', + primary key (data_auth_id, detail_type, detail_code) +) engine=innodb auto_increment=1 comment = '数据权限明细表'; -- ---------------------------- --- 2、产品线-区域类型-区域层级关系表 +-- 3、产品线-区域类型-区域层级关系表 -- ---------------------------- drop table if exists dhc_product_line_area; create table dhc_product_line_area ( @@ -23,7 +36,7 @@ create table dhc_product_line_area ( primary key (product_line_code,area_type,area_level) ) engine=innodb auto_increment=1 comment = '产品线-区域类型-区域层级关系表'; -- ---------------------------- --- 3、区域表 +-- 4、区域表 -- ---------------------------- drop table if exists dhc_area; create table dhc_area ( @@ -46,7 +59,7 @@ create table dhc_area ( ) engine=innodb auto_increment=1 comment = '区域表'; -- ---------------------------- --- 4、国家表 +-- 5、国家表 -- ---------------------------- drop table if exists dhc_country; create table dhc_country ( @@ -65,7 +78,7 @@ create table dhc_country ( primary key (country_id) ) engine=innodb auto_increment=1 comment = '国家表'; -- ---------------------------- --- 5、生产基地与产品线关系表 +-- 6、生产基地与产品线关系表 -- ---------------------------- drop table if exists dhc_production_base_line; create table dhc_production_base_line ( @@ -74,7 +87,7 @@ create table dhc_production_base_line ( primary key (product_line_code,production_base_code) ) engine=innodb auto_increment=1 comment = '生产基地与产品线关系表'; -- ---------------------------- --- 6、品牌表 +-- 7、品牌表 -- ---------------------------- drop table if exists dhc_brand; create table dhc_brand ( @@ -89,7 +102,7 @@ create table dhc_brand ( primary key (brand_id) ) engine=innodb auto_increment=1 comment = '品牌表'; -- ---------------------------- --- 7、供应商信息表 +-- 8、供应商信息表 -- ---------------------------- drop table if exists dhc_supplier; create table dhc_supplier (