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

45 lines
2.0 KiB
XML

<?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">
<sql id="Base_Column_List">
a.user_id, a.name, a.role_type, a.company_id,
a.password, a.status
</sql>
<select id="queryBySelective" resultType="com.dite.znpt.domain.vo.UserListResp">
SELECT u.user_id, u.account, u.status, u.name, u.user_code, u.user_type, u.user_status, d.dept_name, u.mobile, u.create_time,
GROUP_CONCAT(r.role_name) AS role_name,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_role ur ON u.user_id = ur.user_id
LEFT JOIN role r ON ur.role_id = r.role_id
LEFT JOIN user_post up ON up.user_id = u.user_id
LEFT JOIN post p ON p.post_id = up.post_id
WHERE u.del_flag = '0'
<if test="userCode != null and userCode != ''">
AND u.user_code LIKE concat ('%', #{userCode}, '%')
</if>
<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="deptId != null and deptId != ''">
AND d.dept_id = #{deptId}
</if>
<if test="userStatus != null and userStatus!=''">
AND u.user_status = #{userStatus}
</if>
<if test="userType != null and userType!=''">
AND u.user_Type = #{userType}
</if>
GROUP BY u.user_id, u.account, u.status, u.name, u.user_code, u.user_type, u.user_status, d.dept_name, u.mobile, u.create_time
</select>
</mapper>