|  |  | 
 |  |  | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
 |  |  | <mapper namespace="com.vincent.rsf.server.system.mapper.UserMapper"> | 
 |  |  |  | 
 |  |  |     <!-- 根据账号查询 --> | 
 |  |  |     <select id="selectByUsername" resultType="com.vincent.rsf.server.system.entity.User"> | 
 |  |  |         select * from sys_user | 
 |  |  |         where 1=1 | 
 |  |  |         and deleted = 0 | 
 |  |  |         and username = #{username} | 
 |  |  |         <if test="tenantId != null"> | 
 |  |  |             AND tenant_id = #{tenantId} | 
 |  |  |         </if> | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="selectPageRel" resultType="com.vincent.rsf.server.system.entity.User"> | 
 |  |  |         select | 
 |  |  |         su.* | 
 |  |  |         DISTINCT su.* | 
 |  |  |         from sys_user su | 
 |  |  |         left join sys_dept sd on su.dept_id = sd.id | 
 |  |  |         left join ( | 
 |  |  |             select * | 
 |  |  |             from sys_user_role sur | 
 |  |  |             group by sur.user_id | 
 |  |  |         ) sur on sur.user_id = su.id | 
 |  |  |         left join sys_user_role sur on sur.user_id = su.id | 
 |  |  |         where 1=1 | 
 |  |  |         and su.deleted = 0 | 
 |  |  |  | 
 |  |  | 
 |  |  |         </if> | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="selectByUsernameWithoutTenant" resultType="com.vincent.rsf.server.system.entity.User"> | 
 |  |  |         select * from sys_user | 
 |  |  |         where 1=1 | 
 |  |  |         and deleted = 0 | 
 |  |  |         and username = #{username} | 
 |  |  |         <if test="tenantId != null"> | 
 |  |  |             AND tenant_id = #{tenantId} | 
 |  |  |         </if> | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="selectByEmailWithoutTenant" resultType="com.vincent.rsf.server.system.entity.User"> | 
 |  |  |         select * from sys_user | 
 |  |  |         where 1=1 | 
 |  |  |         and deleted = 0 | 
 |  |  |         and email = #{email} | 
 |  |  |         <if test="tenantId != null"> | 
 |  |  |             AND tenant_id = #{tenantId} | 
 |  |  |         </if> | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  | </mapper> |