员工加角色(查询、交接待完善)

This commit is contained in:
xiao-fajia 2024-08-14 20:12:00 +08:00
parent de5f19d3d2
commit f0206a1cb2
2 changed files with 13 additions and 5 deletions

View File

@ -103,10 +103,14 @@ public class CompanyStaff extends TenantBaseDO {
/** 附件urlsinfra_file表中的url多个英文逗号拼接 */ /** 附件urlsinfra_file表中的url多个英文逗号拼接 */
private String fileUrls; private String fileUrls;
/** 员工角色ID集合 */ /** 员工角色ID集合,新增修改的时候用 */
@TableField(exist = false) @TableField(exist = false)
private List<Long> roleIds; private List<Long> roleIds;
/** 员工角色IDS(,分隔),查询的时候用 */
@TableField(exist = false)
private String roleIdsStr;
/** 员工角色名称们(,分隔) */ /** 员工角色名称们(,分隔) */
@TableField(exist = false) @TableField(exist = false)
private String roleNames; private String roleNames;

View File

@ -22,7 +22,8 @@
<result property="content" column="cs_content" jdbcType="VARCHAR"/> <result property="content" column="cs_content" jdbcType="VARCHAR"/>
<result property="uniqueCode" column="cs_unique_code" jdbcType="VARCHAR"/> <result property="uniqueCode" column="cs_unique_code" jdbcType="VARCHAR"/>
<result property="fileUrls" column="cs_file_urls" jdbcType="VARCHAR"/> <result property="fileUrls" column="cs_file_urls" jdbcType="VARCHAR"/>
<result property="roleNames" column="role_names" /> <result property="roleNames" column="role_names"/>
<result property="roleIdsStr" column="role_ids_str"/>
</resultMap> </resultMap>
<sql id="Base_SQL"> <sql id="Base_SQL">
@ -43,19 +44,22 @@
cs.content AS cs_content, cs.content AS cs_content,
cs.unique_code AS cs_unique_code, cs.unique_code AS cs_unique_code,
cs.file_urls AS cs_file_urls, cs.file_urls AS cs_file_urls,
rn.role_names AS role_names rn.role_names AS role_names,
rn.role_ids AS role_ids_str
FROM company_staff cs FROM company_staff cs
LEFT JOIN LEFT JOIN
( (
SELECT cs.user_id, SELECT cs.user_id,
sr.id, sr.id,
GROUP_CONCAT(DISTINCT sr.name ORDER BY sr.name SEPARATOR ',') AS role_names GROUP_CONCAT(DISTINCT sr.name ORDER BY sr.name SEPARATOR ',') AS role_names,
GROUP_CONCAT(DISTINCT sr.id ORDER BY sr.id SEPARATOR ',') AS role_ids
FROM company_staff cs FROM company_staff cs
LEFT JOIN LEFT JOIN
system_user_role sur ON cs.user_id = sur.user_id system_user_role sur ON cs.user_id = sur.user_id
LEFT JOIN LEFT JOIN
system_role sr ON sur.role_id = sr.id system_role sr ON sur.role_id = sr.id
WHERE cs.deleted = '0' AND sur.deleted = '0' WHERE cs.deleted = '0'
AND sur.deleted = '0'
GROUP BY cs.user_id GROUP BY cs.user_id
) rn ON cs.user_id = rn.user_id ) rn ON cs.user_id = rn.user_id
WHERE cs.deleted = '0' WHERE cs.deleted = '0'