<?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.iformall.mapper.PushLimitMapper">
    <resultMap id="BaseResultMap" type="com.iformall.domain.po.PushLimit">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <result column="msg_amount" jdbcType="INTEGER" property="msgAmount"/>
        <result column="coupon_amount" jdbcType="INTEGER" property="couponAmount"/>
        <result column="coupon_day" jdbcType="INTEGER" property="couponDay"/>
        <result column="time_enable" jdbcType="TINYINT" property="timeEnable"/>
        <result column="time_start" jdbcType="VARCHAR" property="timeStart"/>
        <result column="time_end" jdbcType="VARCHAR" property="timeEnd"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="enable" jdbcType="TINYINT" property="enable"/>
    </resultMap>

    <sql id="allColumns">
	    `id`,`tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`time_enable`,`time_start`,`time_end`,`create_time`,`update_time`,`enable`
	</sql>

    <sql id="dynamicWhereConditions">
        where 1 = 1

        <if test=" null != id ">
            and `id` = #{id}
        </if>

        <if test=" null != tenantId ">
            and `tenant_id` = #{tenantId}
        </if>

        <if test=" null != msgAmount ">
            and `msg_amount` = #{msgAmount}
        </if>

        <if test=" null != couponAmount ">
            and `coupon_amount` = #{couponAmount}
        </if>

        <if test=" null != couponDay ">
            and `coupon_day` = #{couponDay}
        </if>

        <if test=" null != timeEnable ">
            and `time_enable` = #{timeEnable}
        </if>

        <if test=" null != timeStart ">
            and `time_start` like concat('%', #{timeStart},'%')
        </if>

        <if test=" null != timeEnd ">
            and `time_end` like concat('%', #{timeEnd},'%')
        </if>

        <if test=" null != createTime ">
            and `create_time` = #{createTime}
        </if>

        <if test=" null != updateTime ">
            and `update_time` = #{updateTime}
        </if>
        <if test=" null != enable ">
            and `enable` = #{enable}
        </if>
        <if test=" null != ids ">
            and id in
            <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
                #{idItem}
            </foreach>
        </if>
        <if test=" null != sortColumns">order by ${sortColumns}</if>
    </sql>

    <select id="findList" parameterType="com.iformall.domain.po.PushLimit" resultMap="BaseResultMap">
        select
        <include refid="allColumns"/>
        from push_limit
        <include refid="dynamicWhereConditions"/>
    </select>


</mapper>
