员工加角色完成

This commit is contained in:
xiao-fajia 2024-08-15 08:58:31 +08:00
parent 3addbe0b9b
commit f6bc245454

View File

@ -25,45 +25,47 @@
<result property="roleNames" column="role_names"/> <result property="roleNames" column="role_names"/>
</resultMap> </resultMap>
<sql id="Base_SQL">
SELECT cs.id AS cs_id,
cs.corp_id AS cs_corp_id,
cs.user_id AS cs_user_id,
cs.dept_id AS cs_dept_id,
cs.work_no AS cs_work_no,
cs.name AS cs_name,
cs.tel AS cs_tel,
cs.sex AS cs_sex,
cs.address AS cs_address,
cs.work_date AS cs_work_date,
cs.work_year AS cs_work_year,
cs.joined_date AS cs_joined_date,
cs.joined_year AS cs_joined_year,
cs.education AS cs_education,
cs.content AS cs_content,
cs.unique_code AS cs_unique_code,
cs.file_urls AS cs_file_urls,
rn.role_names AS role_names
FROM company_staff cs
LEFT JOIN
(
SELECT cs.user_id,
sr.id,
GROUP_CONCAT(DISTINCT sr.name ORDER BY sr.name SEPARATOR ',') AS role_names
FROM company_staff cs
LEFT JOIN
system_user_role sur ON cs.user_id = sur.user_id
LEFT JOIN
system_role sr ON sur.role_id = sr.id
WHERE cs.deleted = '0'
AND sur.deleted = '0'
GROUP BY cs.user_id
) rn ON cs.user_id = rn.user_id
WHERE cs.deleted = '0'
</sql>
<select id="selectListPage" resultMap="BaseResultMap"> <select id="selectListPage" resultMap="BaseResultMap">
<include refid="Base_SQL"/> SELECT cs.id AS cs_id,
cs.corp_id AS cs_corp_id,
cs.user_id AS cs_user_id,
cs.dept_id AS cs_dept_id,
cs.work_no AS cs_work_no,
cs.name AS cs_name,
cs.tel AS cs_tel,
cs.sex AS cs_sex,
cs.address AS cs_address,
cs.work_date AS cs_work_date,
cs.work_year AS cs_work_year,
cs.joined_date AS cs_joined_date,
cs.joined_year AS cs_joined_year,
cs.education AS cs_education,
cs.content AS cs_content,
cs.unique_code AS cs_unique_code,
cs.file_urls AS cs_file_urls,
rn.role_names AS role_names
FROM company_staff cs
LEFT JOIN
(
SELECT cs.user_id,
sr.id,
GROUP_CONCAT(DISTINCT sr.name ORDER BY sr.name SEPARATOR ',') AS role_names
FROM company_staff cs
LEFT JOIN
system_user_role sur ON cs.user_id = sur.user_id
LEFT JOIN
system_role sr ON sur.role_id = sr.id
WHERE cs.deleted = '0'
AND sur.deleted = '0'
<if test="map.roleIds != null and map.roleIds.size > 0">
and sr.id in
<foreach collection="map.roleIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
GROUP BY cs.user_id
) rn ON cs.user_id = rn.user_id
WHERE cs.deleted = '0'
<if test="map.name != null and map.name != ''"> <if test="map.name != null and map.name != ''">
and cs.name like concat('%', #{map.name}, '%') and cs.name like concat('%', #{map.name}, '%')
</if> </if>
@ -98,10 +100,7 @@
and cs.joined_date between #{map.joinedDateArray[0]} and #{map.joinedDateArray[1]} and cs.joined_date between #{map.joinedDateArray[0]} and #{map.joinedDateArray[1]}
</if> </if>
<if test="map.roleIds != null and map.roleIds.size > 0"> <if test="map.roleIds != null and map.roleIds.size > 0">
and rn.id in and rn.role_names is not null
<foreach collection="map.roleIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if> </if>
order by cs.create_time desc order by cs.create_time desc
</select> </select>