znpt-backend/core/src/main/resources/mapper/UserMapper.xml

44 lines
1.8 KiB
XML
Raw Normal View History

2025-04-10 14:07:11 +08:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dite.znpt.mapper.UserMapper">
2025-04-10 14:07:11 +08:00
<sql id="Base_Column_List">
a.user_id, a.name, a.role_type, a.company_id,
2025-04-11 23:17:53 +08:00
a.password, a.status
2025-04-10 14:07:11 +08:00
</sql>
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.UserListResp">
SELECT
u.user_id, u.account, u.status, u.name, d.dept_name, u.identity_card, u.mobile, u.email, u.hiredate, u.birthdate, GROUP_CONCAT(p.post_name) AS post_name
FROM user u
LEFT JOIN dept d ON u.dept_id = d.dept_id
LEFT JOIN user_post up ON u.user_id = up.user_id
LEFT JOIN post p ON up.post_id = p.post_id
2025-04-10 14:07:11 +08:00
<where>
<if test="account != null and account != ''">
AND u.account LIKE concat ('%', #{account}, '%')
</if>
<if test="name != null and name != ''">
AND u.name LIKE concat ('%', #{name}, '%')
</if>
<if test="mobile != null and mobile != ''">
AND u.mobile LIKE concat ('%', #{mobile}, '%')
</if>
<if test="email != null and email != ''">
AND u.email LIKE concat ('%', #{email}, '%')
</if>
<if test="deptId != null and deptId != ''">
AND d.dept_id = #{deptId}
</if>
<if test="postId != null and postId != ''">
AND p.post_id = #{postId}
</if>
2025-04-11 23:17:53 +08:00
<if test="status != null">
AND u.status = #{status}
2025-04-11 23:17:53 +08:00
</if>
2025-04-10 14:07:11 +08:00
</where>
GROUP BY u.user_id, u.account, u.status, u.name, d.dept_name, u.identity_card, u.mobile, u.email, u.hiredate, u.birthdate
2025-04-10 14:07:11 +08:00
</select>
</mapper>