<?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="cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper">

	<select id="getUsersByRoleRescue" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
		SELECT
		distinct su.*
		FROM
		system_users su
		INNER JOIN system_user_role ur on ur.user_id = su.id
		INNER JOIN system_role role on ur.role_id = role.id
		where role.code = #{roleCode}
		<if test="searchValue !=null and searchValue!=''">
			and (mobile like concat('%',#{searchValue},'%')  or nickname  like concat('%',#{searchValue},'%') )
		</if>
		<if test="deptIds !=null and deptIds.size()>0">
			AND su.dept_id in
			<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
				#{deptId}
			</foreach>
		</if>
	</select>

	<select id="getStudentNumberByUserId" resultType="Integer">
		select distinct count(1) number from drive_school_reservation_course where coach_id = #{userId}
	</select>

	<select id="getStudentNumber" resultType="String">
		select distinct phone from drive_school_pay where jxId = #{deptId} and state = '3'
	</select>
	<select id="selectUserByPhone" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
		select su.*
		from system_users su where su.mobile = #{phone} and su.deleted = '0'
	</select>
    <select id="getUserByMobileWithoutTenant"
            resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
		SELECT
			*
		FROM
			system_users
		WHERE
			mobile = #{phoneNumber}
		  AND deleted = 0
	</select>
</mapper>
