<?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.zhongzheng.modules.user.mapper.SchoolMapper">

    <resultMap type="com.zhongzheng.modules.user.domain.School" id="SchoolResult">
        <result property="id" column="id"/>
        <result property="schoolTypeId" column="school_type_id"/>
        <result property="schoolName" column="school_name"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="introduction" column="introduction"/>
        <result property="schoolCity" column="school_city"/>
        <result property="advantageSpecialty" column="advantage_specialty"/>
        <result property="contact" column="contact"/>
        <result property="phone" column="phone"/>
        <result property="address" column="address"/>
        <result property="dictCode" column="dict_code"/>
        <result property="dictLabel" column="dict_label"/>
    </resultMap>

    <select id="selectList" resultMap="SchoolResult">
        SELECT
        s.*,
        dd.dict_label
        FROM
        school s
        LEFT JOIN sys_dict_data dd ON s.dict_code = dd.dict_code
        WHERE
        1 = 1
        <if test="status != null and status.size()!=0 ">
            AND s.status in
            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="schoolName != null and schoolName != ''" >
            AND s.school_name like concat('%', #{schoolName}, '%')
        </if>
        <if test="contact != null and contact != ''" >
            AND s.contact like concat('%', #{contact}, '%')
        </if>
        <if test="phone != null and phone != ''" >
            AND s.phone = #{phone}
        </if>
        <if test="dictCode != null and dictCode != ''" >
            AND s.dict_code = #{dictCode}
        </if>
    </select>
</mapper>
