<?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.distributed.print.business.mapper.TPProfessionalMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.distributed.print.business.entity.TPProfessional">
        <id column="id" property="id" />
        <result column="school_id" property="schoolId" />
        <result column="name" property="name" />
        <result column="org_id" property="orgId" />
        <result column="create_id" property="createId" />
        <result column="create_time" property="createTime" />
        <result column="update_id" property="updateId" />
        <result column="update_time" property="updateTime" />
    </resultMap>
    <select id="pageData"
            resultType="com.qmth.distributed.print.business.bean.dto.professional.ProfessionalDto">
        select
            tpp.id,
            tpp.name,
            tpp.org_id,
            tpp.create_id,
            tpp.create_time,
            tpp.update_id,
            tpp.update_time,
            so.name orgName,
            su.login_name loginName,
            su.real_name userName
        from t_p_professional tpp
            left join sys_org so on tpp.org_id = so.id
            left join sys_user su on tpp.create_id = su.id
        <where>
            <if test="schoolId != null">
                and tpp.school_id = #{schoolId}
            </if>
            <if test="name != null and name != ''">
                and tpp.name like concat('%',#{name},'%')
            </if>
            <if test="orgId != null">
                and tpp.org_id = #{orgId}
            </if>
            <if test="dpr != null">
                <if test="dpr.requestUserId != null">
                    AND tpp.create_id = #{dpr.requestUserId}
                    AND tpp.org_id = su.org_id
                </if>
                <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
                    AND tpp.org_id IN
                    <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
                        #{item}
                    </foreach>
                </if>
            </if>
        </where>
    </select>

</mapper>
