<?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.crm.email.dao.mapper.SysEmailUnsubscribeMapper">


    <select id="searchPageList"
            parameterType="com.crm.rely.backend.core.entity.system.email.unsubscribe.SysEmailUnsubscribeSearchListEntity"
            resultType="com.crm.rely.backend.core.pojo.table.SysEmailUnsubscribeTable">
        select *
        from sys_email_unsubscribe
        <where>
            <if test="fromAccount != null and fromAccount != ''">
                and from_account like concat('%',#{fromAccount},'%')
            </if>
            <if test="toAccount != null and toAccount != ''">
                and to_account like concat('%',#{toAccount},'%')
            </if>
            <if test="startDate != null">
                and add_time <![CDATA[ >= ]]> #{startDate}
            </if>
            <if test="endDate != null">
                and add_time <![CDATA[ < ]]> #{endDate}
            </if>
        </where>
        order by add_time desc
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>

    </select>

    <select id="searchPageCount"
            parameterType="com.crm.rely.backend.core.entity.system.email.unsubscribe.SysEmailUnsubscribeSearchListEntity"
            resultType="Integer">
        select count(*)
        from sys_email_unsubscribe
        <where>
            <if test="fromAccount != null and fromAccount != ''">
                and from_account like concat('%',#{fromAccount},'%')
            </if>
            <if test="toAccount != null and toAccount != ''">
                and to_account like concat('%',#{toAccount},'%')
            </if>
            <if test="startDate != null">
                and add_time <![CDATA[ >= ]]> #{startDate}
            </if>
            <if test="endDate != null">
                and add_time <![CDATA[ < ]]> #{endDate}
            </if>
        </where>

    </select>

</mapper>