<?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.manager.dao.mapper.SysApproveEmailMapper">

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.system.email.approve.SysApproveEmailSearchEntity">

        select count(*) from sys_approve_email
        <where>
            <if test="email!=null and email!=''">
                and `email` like concat(#{email},"%")
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.pojo.table.SysApproveEmailTable"
            parameterType="com.crm.rely.backend.core.entity.system.email.approve.SysApproveEmailSearchEntity">
        select * from sys_approve_email
        <where>
            <if test="email!=null and email!=''">
                and `email` like concat(#{email},"%")
            </if>
        </where>
        order by id desc
        limit #{page.offset},#{page.row}
    </select>

    <select id="findEmailStr" resultType="String">
        select GROUP_CONCAT(`email` SEPARATOR ',') from sys_approve_email
        where `email` in
        <foreach collection="emails" index="idx" item="email" open="(" close=")" separator=",">
            #{email}
        </foreach>
    </select>

    <select id="findByEmail" resultType="com.crm.rely.backend.core.pojo.table.SysApproveEmailTable">
        select * from sys_approve_email where `email` = #{email} limit 1
    </select>

</mapper>