| <?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.mzl.flower.mapper.system.UserMapper"> | 
|     <select id="loginUser" resultType="com.mzl.flower.entity.system.User"> | 
|         SELECT * | 
|         FROM t_user t | 
|         WHERE t.deleted = 0 AND t.status = 'A' | 
|         and t.type = 'customer' | 
|         and (t.login_name = #{username} or t.tel = #{username}) | 
|     </select> | 
|   | 
|     <select id="getActiveUser" resultType="com.mzl.flower.entity.system.User"> | 
|         SELECT * | 
|         FROM t_user t | 
|         WHERE (t.login_name = #{username} or t.tel = #{username}) | 
|         AND t.status = 'A' | 
|         AND t.deleted = 0 | 
|         AND (t.`type` IN | 
|             <foreach collection="userTypes" item="type" open="(" separator="," close=")"> | 
|                 #{type} | 
|             </foreach> | 
|         ) | 
|     </select> | 
|   | 
|     <select id="searchUser" resultType="com.mzl.flower.dto.response.system.UserListDTO"> | 
|         SELECT | 
|         u.ID AS id, | 
|         u.LOGIN_NAME AS loginName, | 
|         u.TEL AS tel, | 
|         u.NICK_NAME AS nickName, | 
|         u.STATUS AS STATUS, | 
|         uu.NICK_NAME AS createdName, | 
|         u.create_time AS createdDate, | 
|         u.IS_SYS AS isSys, | 
|         (SELECT GROUP_CONCAT(DISTINCT(role.ID)) FROM t_role role INNER JOIN t_user_role ur ON ur.ROLE_ID = role.ID | 
|             WHERE | 
|             ur.USER_ID = u.ID | 
|             ORDER BY ROLE_NAME | 
|         ) AS roleIds, | 
|         (SELECT GROUP_CONCAT(DISTINCT(ROLE_NAME)) FROM t_role role INNER JOIN t_user_role ur ON ur.ROLE_ID = role.ID | 
|             WHERE | 
|             ur.USER_ID = u.ID | 
|             ORDER BY ROLE_NAME | 
|         ) AS roleDesc, | 
|         e.birthday, | 
|         e.gender, | 
|         e.id_card, | 
|         e.post_name, | 
|         e.work_content, | 
|         e.in_date, | 
|         e.salary | 
|         FROM t_user u | 
|         LEFT JOIN t_user uu ON u.create_by = uu.id | 
|         left join t_employee e on e.user_id = u.id | 
|         where u.deleted = 0 | 
|         <if test="condition.loginName != null and condition.loginName != ''"> | 
|             AND (u.LOGIN_NAME LIKE concat('%', #{condition.loginName},'%') | 
|                 or u.NICK_NAME LIKE concat('%', #{condition.loginName},'%') | 
|                 or u.tel LIKE concat('%', #{condition.loginName},'%') | 
|             ) | 
|         </if> | 
|         <if test="condition.status != null and condition.status != ''"> | 
|             AND u.STATUS = #{condition.status} | 
|         </if> | 
|         AND (u.`type` in | 
|             <foreach collection="condition.userTypes" item="type" open="(" separator="," close=")"> | 
|                 #{type} | 
|             </foreach> | 
|         ) | 
|         order by u.create_time desc | 
|     </select> | 
|   | 
|     <select id="selectUserRoleDesc" resultType="string"> | 
|         SELECT GROUP_CONCAT(DISTINCT(ROLE_NAME)) | 
|         FROM t_role role | 
|         INNER JOIN t_user_role ur ON ur.ROLE_ID = role.ID | 
|         WHERE ur.USER_ID = #{userId} | 
|         ORDER BY ROLE_NAME | 
|     </select> | 
|     <select id="getByOpenID" resultType="com.mzl.flower.entity.system.User"> | 
|         SELECT | 
|             t.* | 
|         FROM | 
|             t_user_wechat w | 
|                 LEFT JOIN t_user t ON t.id = w.user_id WHERE w.open_id = #{openId} | 
|         AND t.`type` IN | 
|         <foreach collection="userTypes" item="type" open="(" separator="," close=")"> | 
|             #{type} | 
|         </foreach> | 
|   | 
|     </select> | 
| </mapper> |