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

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

        select count(*) from sys_email_config
        <where>
            <if test="fromAccount!=null and fromAccount!=''">
                and `from_account`=#{fromAccount}
            </if>
            <if test="transportProtocol!=null and transportProtocol!=''">
                and transport_protocol=#{transportProtocol}
            </if>
            <if test="smtpHost!=null and smtpHost!=''">
                and smtp_host=#{smtpHost}
            </if>
            <if test="smtpAuth!=null">
                and smtp_auth=#{smtpAuth}
            </if>
        </where>

    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.pojo.table.SysEmailConfigTable"
            parameterType="com.crm.rely.backend.core.entity.system.email.config.SysEmailConfigSearchEntity">

        select * from sys_email_config
        <where>
            <if test="fromAccount!=null and fromAccount!=''">
                and `from_account`=#{fromAccount}
            </if>
            <if test="transportProtocol!=null and transportProtocol!=''">
                and transport_protocol=#{transportProtocol}
            </if>
            <if test="smtpHost!=null and smtpHost!=''">
                and smtp_host=#{smtpHost}
            </if>
            <if test="smtpAuth!=null">
                and smtp_auth=#{smtpAuth}
            </if>
        </where>
        <if test="page!=null'">
            limit #{page.offset},#{page.row}
        </if>

    </select>


</mapper>