<?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.miaxis.school.mapper.SchoolInfoMapper">

    <resultMap type="SchoolInfo" id="SchoolInfoResult">
        <result property="id"    column="id"    />
        <result property="cityCode"    column="city_code"    />
        <result property="cityName"    column="city_name"    />
        <result property="areaCode"    column="area_code"    />
        <result property="areaName"    column="area_name"    />
        <result property="schoolNo"    column="school_no"    />
        <result property="schoolName"    column="school_name"    />
        <result property="shortName"    column="short_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSchoolInfoVo">
        select * from school_info
    </sql>

    <select id="selectSchoolInfoList" parameterType="SchoolInfo" resultMap="SchoolInfoResult">
        <include refid="selectSchoolInfoVo"/>
        <where>
            <if test="cityCode != null  and cityCode != ''"> and city_code = #{cityCode}</if>
            <if test="cityName != null  and cityName != ''"> and city_name like concat('%', #{cityName}, '%')</if>
            <if test="areaCode != null  and areaCode != ''"> and area_code = #{areaCode}</if>
            <if test="areaName != null  and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
            <if test="schoolNo != null  and schoolNo != ''"> and school_no = #{schoolNo}</if>
            <if test="schoolName != null  and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if>
            <if test="shortName != null  and shortName != ''"> and short_name like concat('%', #{shortName}, '%')</if>
        </where>
    </select>

    <select id="queryNames" resultType="map">
        select distinct ${choseColumName} as name , ${choseColumCode} as code from school_info where ${choseColumName} is not null
        <if test="conditionColumName1 != null  and conditionColumName1 != ''">
        and ${conditionColumName1} = #{value1}
      </if>
        <if test="conditionColumName2 != null  and conditionColumName2 != ''">
            and ${conditionColumName2} = #{value2}
        </if>

    </select>

</mapper>
