<?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.spring.mapper.EmailUsersMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.spring.domain.entity.EmailUsersEntity">
            <id column="id" property="id"/>
            <id column="email" property="email"/>
            <id column="password" property="password"/>
            <id column="host" property="host"/>
            <id column="port" property="port"/>
            <id column="smtp_agreement" property="smtpAgreement"/>
            <id column="open_ssl" property="openSsl"/>
            <id column="is_default" property="isDefault"/>
            <id column="create_time" property="createTime"/>
            <id column="update_time" property="updateTime"/>
            <id column="create_user" property="createUser"/>
            <id column="update_user" property="updateUser"/>
            <id column="is_deleted" property="isDeleted"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,email,password,host,port,smtp_agreement,open_ssl,is_default,create_time,update_time,create_user,update_user,is_deleted
    </sql>

    <!-- 分页查询邮箱发送表内容 -->
    <select id="selectListByPage" resultType="com.spring.domain.vo.EmailUsersVo">
        select
        base.*,
        create_user.username as create_username,
        update_user.username as update_username
        from sys_email_users base
        left join sys_user create_user on create_user.id = base.create_user
        left join sys_user update_user on update_user.id = base.update_user
        <where>
            base.is_deleted = 0
                <if test="dto.id != null and dto.id != ''">
                    and base.id like CONCAT('%',#{dto.id},'%')
                </if>
                <if test="dto.email != null and dto.email != ''">
                    and base.email like CONCAT('%',#{dto.email},'%')
                </if>
                <if test="dto.password != null and dto.password != ''">
                    and base.password like CONCAT('%',#{dto.password},'%')
                </if>
                <if test="dto.host != null and dto.host != ''">
                    and base.host like CONCAT('%',#{dto.host},'%')
                </if>
                <if test="dto.port != null and dto.port != ''">
                    and base.port like CONCAT('%',#{dto.port},'%')
                </if>
                <if test="dto.smtpAgreement != null and dto.smtpAgreement != ''">
                    and base.smtp_agreement like CONCAT('%',#{dto.smtpAgreement},'%')
                </if>
                <if test="dto.openSsl != null and dto.openSsl != ''">
                    and base.open_ssl like CONCAT('%',#{dto.openSsl},'%')
                </if>
                <if test="dto.isDefault != null and dto.isDefault != ''">
                    and base.is_default like CONCAT('%',#{dto.isDefault},'%')
                </if>
                <if test="dto.createTime != null and dto.createTime != ''">
                    and base.create_time like CONCAT('%',#{dto.createTime},'%')
                </if>
                <if test="dto.updateTime != null and dto.updateTime != ''">
                    and base.update_time like CONCAT('%',#{dto.updateTime},'%')
                </if>
                <if test="dto.createUser != null and dto.createUser != ''">
                    and base.create_user like CONCAT('%',#{dto.createUser},'%')
                </if>
                <if test="dto.updateUser != null and dto.updateUser != ''">
                    and base.update_user like CONCAT('%',#{dto.updateUser},'%')
                </if>
                <if test="dto.isDeleted != null and dto.isDeleted != ''">
                    and base.is_deleted like CONCAT('%',#{dto.isDeleted},'%')
                </if>
        </where>
    </select>

</mapper>
