<?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.sqx.modules.banner.dao.BannerDao">

    <select id="selectList" resultType="com.sqx.modules.banner.entity.Banner">
        select b.*,c.city_name from banner b left join  city_info c on b.city_id = c.id
        where classify=#{classify}
         <if test="cityName!=null and cityName!=''">
             and (c.city_name = #{cityName} or c.city_name is null)
         </if>
          and `state`=1
        order by `sort` asc
    </select>

    <select id="selectLists" resultType="com.sqx.modules.banner.entity.Banner">
        select b.*,c.city_name from banner b left join city_info c on b.city_id = c.id
        <where>
            <if test="banner.classify!=null">
                and b.classify = #{banner.classify}
            </if>
            <if test="banner.cityId!=null">
                and b.city_id = #{banner.cityId}
            </if>
            <if test="banner.cityName!=null and banner.cityName!=''">
                and c.city_name = #{banner.cityName}
            </if>
        </where>
        order by `sort` asc
    </select>
    <select id="selectPage" resultType="com.sqx.modules.banner.entity.Banner">
        select * from banner
        where classify=#{classify}
        <if test="state!=null and state!=-1">
            and state=#{state}
        </if>
    </select>


</mapper>