<?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.mall.coupon.mapper.HomeAdvMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.coupon.domain.entity.HomeAdv">
            <id column="id" property="id"/>
            <id column="name" property="name"/>
            <id column="pic" property="pic"/>
            <id column="start_time" property="startTime"/>
            <id column="end_time" property="endTime"/>
            <id column="status" property="status"/>
            <id column="click_count" property="clickCount"/>
            <id column="url" property="url"/>
            <id column="note" property="note"/>
            <id column="sort" property="sort"/>
            <id column="publisher_id" property="publisherId"/>
            <id column="auth_id" property="authId"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,name,pic,start_time,end_time,status,click_count,url,note,sort,publisher_id,auth_id
    </sql>

    <!-- 分页查询首页轮播广告内容 -->
    <select id="selectListByPage" resultType="com.mall.coupon.domain.vo.HomeAdvVo">
        select
        <include refid="Base_Column_List"/>
        from sms_home_adv
        <where>
                <if test="dto.id != null and dto.id != ''">
                    and id like CONCAT('%',#{dto.id},'%')
                </if>
                <if test="dto.name != null and dto.name != ''">
                    and name like CONCAT('%',#{dto.name},'%')
                </if>
                <if test="dto.pic != null and dto.pic != ''">
                    and pic like CONCAT('%',#{dto.pic},'%')
                </if>
                <if test="dto.startTime != null and dto.startTime != ''">
                    and start_time like CONCAT('%',#{dto.startTime},'%')
                </if>
                <if test="dto.endTime != null and dto.endTime != ''">
                    and end_time like CONCAT('%',#{dto.endTime},'%')
                </if>
                <if test="dto.status != null and dto.status != ''">
                    and status like CONCAT('%',#{dto.status},'%')
                </if>
                <if test="dto.clickCount != null and dto.clickCount != ''">
                    and click_count like CONCAT('%',#{dto.clickCount},'%')
                </if>
                <if test="dto.url != null and dto.url != ''">
                    and url like CONCAT('%',#{dto.url},'%')
                </if>
                <if test="dto.note != null and dto.note != ''">
                    and note like CONCAT('%',#{dto.note},'%')
                </if>
                <if test="dto.sort != null and dto.sort != ''">
                    and sort like CONCAT('%',#{dto.sort},'%')
                </if>
                <if test="dto.publisherId != null and dto.publisherId != ''">
                    and publisher_id like CONCAT('%',#{dto.publisherId},'%')
                </if>
                <if test="dto.authId != null and dto.authId != ''">
                    and auth_id like CONCAT('%',#{dto.authId},'%')
                </if>
        </where>
    </select>

</mapper>
