feat: 项目分页查询关联sys_user表返回创建人真实姓名

- VO 添加 createByName 字段
- Mapper XML 添加 LEFT JOIN sys_user 查询
- 使用 IFNULL 处理空值降级
- 添加逻辑删除过滤条件
- 通过代码审查
This commit is contained in:
wkc
2026-02-26 17:15:14 +08:00
parent 324c978584
commit b8f798ee5d
2 changed files with 16 additions and 9 deletions

View File

@@ -44,6 +44,9 @@ public class CcdiProjectVO {
/** 创建时间 */
private Date createTime;
/** 创建者 */
/** 创建者(用户名) */
private String createBy;
/** 创建者姓名(真实姓名) */
private String createByName;
}

View File

@@ -15,24 +15,28 @@
<result property="lowRiskCount" column="low_risk_count"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="createByName" column="create_by_name"/>
</resultMap>
<!-- 分页查询项目列表 -->
<select id="selectProjectPage" resultMap="ProjectVOResultMap">
SELECT
project_id, project_name, description, config_type,
status, is_archived, target_count, high_risk_count,
medium_risk_count, low_risk_count, create_time, create_by
FROM ccdi_project
p.project_id, p.project_name, p.description, p.config_type,
p.status, p.is_archived, p.target_count, p.high_risk_count,
p.medium_risk_count, p.low_risk_count, p.create_time,
p.create_by,
IFNULL(u.nick_name, p.create_by) AS create_by_name
FROM ccdi_project p
LEFT JOIN sys_user u ON p.create_by = u.user_name AND u.del_flag = '0'
<where>
del_flag = '0'
p.del_flag = '0'
<if test="queryDTO.projectName != null and queryDTO.projectName != ''">
AND project_name LIKE CONCAT('%', #{queryDTO.projectName}, '%')
AND p.project_name LIKE CONCAT('%', #{queryDTO.projectName}, '%')
</if>
<if test="queryDTO.status != null and queryDTO.status != ''">
AND status = #{queryDTO.status}
AND p.status = #{queryDTO.status}
</if>
</where>
ORDER BY create_time DESC
ORDER BY p.create_time DESC
</select>
</mapper>