<?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.liquidnet.service.kylin.mapper.KylinBannersMapper">
    <select id="detail" parameterType="java.lang.String">
        SELECT
        *
        FROM kylin_banners
        <where>
            banners_id=#{bannersId}
        </where>
    </select>

    <!-- admin banner列表 -->
    <select id="searchBannersList" parameterType="java.util.Map" resultType="com.liquidnet.service.kylin.dao.BannerDetailsListDao">
        SELECT *
        FROM kylin_banners
        <where>
            is_deleted = 1
            <if test="bannersName != ''">
                AND banners_name LIKE concat('%', #{bannersName}, '%')
            </if>
            <if test="targetType != ''">
                AND target_type=${targetType}
            </if>
            <if test="isOnline != ''">
                AND is_online=${isOnline}
            </if>
            <if test="promotionType != ''">
                AND promotion_type=${promotionType}
            </if>
        </where>
        ORDER BY banners_sort DESC
    </select>

    <!-- admin banner列表数量 -->
    <select id="searchBannersCount" parameterType="java.util.Map" resultType="long">
        SELECT COUNT(0)
        FROM kylin_banners
        <where>
            is_deleted = 1
            <if test="bannersName != ''">
                AND banners_name LIKE concat('%', #{bannersName}, '%')
            </if>
            <if test="targetType != ''">
                AND target_type=#{targetType}
            </if>
            <if test="isOnline != ''">
                AND is_online=#{isOnline}
            </if>
            <if test="promotionType != ''">
                AND promotion_type=#{promotionType}
            </if>
        </where>
    </select>

</mapper>
