<?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.simuwang.base.mapper.EmailTemplateMappingMapper">
    <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.EmailTemplateMappingDO">
        <id column="id" property="id"/>
        <result column="template_id" property="templateId"/>
        <result column="title" property="title"/>
        <result column="email" property="email"/>
        <result column="company_name" property="companyName"/>
        <result column="description" property="description"/>
        <result column="status" property="status"/>
        <result column="isvalid" property="isvalid"/>
        <result column="creatorid" property="creatorId"/>
        <result column="createtime" property="createTime"/>
        <result column="updaterid" property="updaterId"/>
        <result column="updatetime" property="updateTime"/>
    </resultMap>

    <select id="queryByEmail" resultType="com.simuwang.base.pojo.dos.EmailTemplateInfoDO">
        select t1.template_id as id,
               t2.direction as direction
        from PPW_EMAIL.email_template_mapping t1
            join PPW_EMAIL.email_template_info t2 on t2.id = t1.template_id and t2.isvalid = 1
        where t1.email = #{email}
          and t1.isvalid = 1
          and t2.status = 1
    </select>

</mapper>