<?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.qmth.jkserver.dao.UserDao">

    <sql id="userCommonSql">
        select *,bs.name as schoolName from jk_user t
        left join basic_school bs on bs.id = t.school_id
        <where>
            <if test="userName != null and userName != ''">
                and (t.user_name like concat('%', #{userName}, '%') or t.real_name like concat('%', #{userName}, '%'))
            </if>
        </where>
        order by bs.name
    </sql>

    <select id="findByUserName" resultType="com.qmth.jkserver.model.User">
        <include refid="userCommonSql" />
    </select>

    <select id="findByUserNameByPage" resultType="com.qmth.jkserver.model.User">
        <include refid="userCommonSql" />
    </select>
</mapper>
