<?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="net.lab1024.smartadmin.module.business.email.EmailDao">

    <resultMap id="EmailEntity" type="net.lab1024.smartadmin.module.business.email.domain.entity.EmailEntity"></resultMap>


    <select id="queryByPage" resultMap="EmailEntity">
        select
          id,
          title,
          to_emails,
          send_status,
          create_time,
          update_time
        from t_email
        <where>
            <if test="queryDTO.startDate != null and queryDTO.startDate != ''">
                AND DATE_FORMAT(create_time, '%Y-%m-%d') &gt;= #{queryDTO.startDate}
            </if>
            <if test="queryDTO.endDate != null and queryDTO.endDate != ''">
                AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{queryDTO.endDate}
            </if>
            <if test="queryDTO.title != null and queryDTO.title != ''">
                AND INSTR(title,#{queryDTO.title})
            </if>
            <if test="queryDTO.sendStatus != null">
                AND send_status = #{queryDTO.sendStatus}
            </if>
        </where>
    </select>

    <delete id="deleteById">
        delete from t_email where id = #{id}
    </delete>

    <delete id="deleteByIds">
        delete from t_email where id in
        <foreach collection="idList" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>
    </delete>

</mapper>