From 47ae9a2a0d8a1196603ddd7835563413bbe14824 Mon Sep 17 00:00:00 2001
From: huangjiayang <5265313@qq.com>
Date: 星期二, 22 四月 2025 15:14:12 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
aps-modules/aps-system/src/main/java/com/aps/system/mapper/SysDeptMapper.java | 2 +
aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java | 34 ++++++++++-------
aps-api/aps-api-system/src/main/java/com/aps/system/api/domain/SysDept.java | 11 +++++
aps-common/aps-common-datascope/src/main/java/com/aps/common/datascope/aspect/DataScopeAspect.java | 8 ++--
aps-modules/aps-system/src/main/java/com/aps/system/domain/SysRoleDept.java | 13 ++++++
aps-modules/aps-system/src/main/resources/mapper/system/SysDeptMapper.xml | 16 +++++++
aps-modules/aps-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml | 4 +-
7 files changed, 67 insertions(+), 21 deletions(-)
diff --git a/aps-api/aps-api-system/src/main/java/com/aps/system/api/domain/SysDept.java b/aps-api/aps-api-system/src/main/java/com/aps/system/api/domain/SysDept.java
index 49e771d..52ad60d 100644
--- a/aps-api/aps-api-system/src/main/java/com/aps/system/api/domain/SysDept.java
+++ b/aps-api/aps-api-system/src/main/java/com/aps/system/api/domain/SysDept.java
@@ -51,6 +51,8 @@
/** 鐖堕儴闂ㄥ悕绉� */
private String parentName;
+
+ private String orgCode;
/** 瀛愰儴闂� */
private List<SysDept> children = new ArrayList<SysDept>();
@@ -181,6 +183,14 @@
this.children = children;
}
+ public String getOrgCode() {
+ return orgCode;
+ }
+
+ public void setOrgCode(String orgCode) {
+ this.orgCode = orgCode;
+ }
+
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -198,6 +208,7 @@
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
+ .append("orgCode", getOrgCode())
.toString();
}
}
diff --git a/aps-common/aps-common-datascope/src/main/java/com/aps/common/datascope/aspect/DataScopeAspect.java b/aps-common/aps-common-datascope/src/main/java/com/aps/common/datascope/aspect/DataScopeAspect.java
index 4d31f2d..b449065 100644
--- a/aps-common/aps-common-datascope/src/main/java/com/aps/common/datascope/aspect/DataScopeAspect.java
+++ b/aps-common/aps-common-datascope/src/main/java/com/aps/common/datascope/aspect/DataScopeAspect.java
@@ -118,7 +118,7 @@
break;
}
else if (DATA_SCOPE_CUSTOM.equals(dataScope))
- {
+ { /*鑷畾涔夋暟鎹潈闄�*/
if (scopeCustomIds.size() > 1)
{
// 澶氫釜鑷畾鏁版嵁鏉冮檺浣跨敤in鏌ヨ锛岄伩鍏嶅娆℃嫾鎺ャ��
@@ -130,15 +130,15 @@
}
}
else if (DATA_SCOPE_DEPT.equals(dataScope))
- {
+ { /*鏈儴闂ㄦ暟鎹潈闄�*/
sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
}
else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
- {
+ { /*鏈儴闂ㄤ互鍙婁互涓嬫暟鎹潈闄�*/
sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId()));
}
else if (DATA_SCOPE_SELF.equals(dataScope))
- {
+ { /*浠呮湰浜烘暟鎹潈闄�*/
if (StringUtils.isNotBlank(userAlias))
{
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
diff --git a/aps-modules/aps-system/src/main/java/com/aps/system/domain/SysRoleDept.java b/aps-modules/aps-system/src/main/java/com/aps/system/domain/SysRoleDept.java
index e439a08..b52fe8f 100644
--- a/aps-modules/aps-system/src/main/java/com/aps/system/domain/SysRoleDept.java
+++ b/aps-modules/aps-system/src/main/java/com/aps/system/domain/SysRoleDept.java
@@ -16,6 +16,10 @@
/** 閮ㄩ棬ID */
private Long deptId;
+
+ /**閮ㄩ棬缁勭粐缂栫爜*/
+ private String deptOrgCode;
+
public Long getRoleId()
{
return roleId;
@@ -36,11 +40,20 @@
this.deptId = deptId;
}
+
+ public String getDeptOrgCode() {
+ return deptOrgCode;
+ }
+
+ public void setDeptOrgCode(String deptOrgCode) {
+ this.deptOrgCode = deptOrgCode;
+ }
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("roleId", getRoleId())
.append("deptId", getDeptId())
+ .append("deptOrgCode", getDeptOrgCode())
.toString();
}
}
diff --git a/aps-modules/aps-system/src/main/java/com/aps/system/mapper/SysDeptMapper.java b/aps-modules/aps-system/src/main/java/com/aps/system/mapper/SysDeptMapper.java
index 838bb84..0e97158 100644
--- a/aps-modules/aps-system/src/main/java/com/aps/system/mapper/SysDeptMapper.java
+++ b/aps-modules/aps-system/src/main/java/com/aps/system/mapper/SysDeptMapper.java
@@ -115,4 +115,6 @@
* @return 缁撴灉
*/
public int deleteDeptById(Long deptId);
+
+ List<SysDept> selectDeptListByIdList(List<Long> deptIdList);
}
diff --git a/aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java b/aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java
index 30ab94f..9eab4bf 100644
--- a/aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java
+++ b/aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java
@@ -1,10 +1,9 @@
package com.aps.system.service.impl;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
+
+import com.aps.system.api.domain.SysDept;
+import com.aps.system.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -19,10 +18,6 @@
import com.aps.system.domain.SysRoleDept;
import com.aps.system.domain.SysRoleMenu;
import com.aps.system.domain.SysUserRole;
-import com.aps.system.mapper.SysRoleDeptMapper;
-import com.aps.system.mapper.SysRoleMapper;
-import com.aps.system.mapper.SysRoleMenuMapper;
-import com.aps.system.mapper.SysUserRoleMapper;
import com.aps.system.service.ISysRoleService;
/**
@@ -45,6 +40,8 @@
@Autowired
private SysRoleDeptMapper roleDeptMapper;
+ @Autowired
+ private SysDeptMapper deptMapper;
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瑙掕壊鏁版嵁
*
@@ -320,12 +317,21 @@
int rows = 1;
// 鏂板瑙掕壊涓庨儴闂紙鏁版嵁鏉冮檺锛夌鐞�
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
- for (Long deptId : role.getDeptIds())
+ Long[] deptIds = role.getDeptIds();
+ List<SysDept> sysDepts = deptMapper.selectDeptListByIdList(Arrays.asList(deptIds));
+
+ for (Long deptId : deptIds)
{
- SysRoleDept rd = new SysRoleDept();
- rd.setRoleId(role.getRoleId());
- rd.setDeptId(deptId);
- list.add(rd);
+ Optional<SysDept> first = sysDepts.stream().filter(sysDept -> sysDept.getDeptId().equals(deptId)).findFirst();
+ if(first.isPresent()){
+ SysDept sysDept = first.get();
+ SysRoleDept rd = new SysRoleDept();
+ rd.setRoleId(role.getRoleId());
+ rd.setDeptId(deptId);
+ rd.setDeptOrgCode(sysDept.getOrgCode());
+ list.add(rd);
+ }
+
}
if (list.size() > 0)
{
diff --git a/aps-modules/aps-system/src/main/resources/mapper/system/SysDeptMapper.xml b/aps-modules/aps-system/src/main/resources/mapper/system/SysDeptMapper.xml
index c4db34b..cb98780 100644
--- a/aps-modules/aps-system/src/main/resources/mapper/system/SysDeptMapper.xml
+++ b/aps-modules/aps-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -20,10 +20,13 @@
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
+ <result property="orgCode" column="org_code" />
</resultMap>
<sql id="selectDeptVo">
- select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
+ select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
+ d.del_flag, d.create_by, d.create_time ,
+ d.org_code
from sys_dept d
</sql>
@@ -97,6 +100,7 @@
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
+ <if test="orgCode != null and orgCode != ''">org_code,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -109,6 +113,7 @@
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
+ <if test="orgCode != null and orgCode != ''">#{orgCode},</if>
now()
)
</insert>
@@ -125,6 +130,7 @@
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ <if test="orgCode != null and orgCode != ''">org_code = #{orgCode},</if>
update_time = now()
</set>
where dept_id = #{deptId}
@@ -153,5 +159,13 @@
<delete id="deleteDeptById" parameterType="Long">
update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
+ <select id="selectDeptListByIdList" parameterType="Long" resultMap="SysDeptResult">
+ <include refid="selectDeptVo"/>
+ where d.del_flag = '0' and dept_id in
+ <foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
+ #{deptId}
+ </foreach>
+ order by d.parent_id, d.order_num
+ </select>
</mapper>
\ No newline at end of file
diff --git a/aps-modules/aps-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml b/aps-modules/aps-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml
index f71ae30..76abcfd 100644
--- a/aps-modules/aps-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml
+++ b/aps-modules/aps-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml
@@ -25,9 +25,9 @@
</delete>
<insert id="batchRoleDept">
- insert into sys_role_dept(role_id, dept_id) values
+ insert into sys_role_dept(role_id, dept_id,dept_org_code) values
<foreach item="item" index="index" collection="list" separator=",">
- (#{item.roleId},#{item.deptId})
+ (#{item.roleId},#{item.deptId},#{item.deptOrgCode})
</foreach>
</insert>
--
Gitblit v1.9.3