<?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.SysEmailRecordMapper">


    <select id="searchPageList"
            parameterType="com.crm.rely.backend.core.entity.system.email.record.SysEmailRecordSearchEntity"
            resultType="com.crm.rely.backend.core.pojo.table.SysEmailRecordTable">
        select *
        from sys_email_record
        <where>
            <if test="status != null ">
                and status=#{status}
            </if>
            <if test="users != null and users != ''">
                and users like concat('%',#{users},'%')
            </if>
            <if test="startDate != null">
                and send_date <![CDATA[ >= ]]> #{startDate}
            </if>
            <if test="endDate != null">
                and send_date <![CDATA[ < ]]> #{endDate}
            </if>
        </where>
        order by send_date desc
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>

    </select>

    <select id="searchPageCount"
            parameterType="com.crm.rely.backend.core.entity.system.email.record.SysEmailRecordSearchEntity"
            resultType="Integer">
        select count(*)
        from sys_email_record
        <where>
            <if test="status != null ">
                and status=#{status}
            </if>
            <if test="users != null and users != ''">
                and users like concat('%',#{users},'%')
            </if>
            <if test="startDate != null">
                and send_date <![CDATA[ >= ]]> #{startDate}
            </if>
            <if test="endDate != null">
                and send_date <![CDATA[ < ]]> #{endDate}
            </if>
        </where>

    </select>

</mapper>