<?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.ruoyi.oa.mapper.OaFurnitureTableMapper">

    <resultMap type="com.ruoyi.oa.domain.OaFurnitureTable" id="OaFurnitureTableResult">
        <result property="furnitureId" column="furniture_id"/>
        <result property="companyName" column="company_name"/>
        <result property="state" column="state"/>
        <result property="procurementOfProducts" column="procurement_of_products"/>
        <result property="contactGroup" column="contact_group"/>
        <result property="phone" column="phone"/>
        <result property="fax" column="fax"/>
        <result property="address" column="address"/>
        <result property="zip" column="zip"/>
        <result property="email" column="email"/>
        <result property="website" column="website"/>
        <result property="emailSendCount" column="email_send_count"/>
        <result property="lastEmailSendTime" column="last_email_send_time"/>
        <result property="contactPerson" column="contact_person"/>
        <result property="receiveCount" column="receive_count"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="delFlag" column="del_flag"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <update id="updateEmailSendInfo">
        UPDATE oa_furniture_table
        SET email_send_count = IFNULL(email_send_count,0) + 1,
            last_email_send_time = NOW()
        WHERE furniture_id = #{furnitureId}
    </update>

    <select id="selectEmailsByFurnitureIds" resultType="java.lang.String">
        SELECT email FROM oa_furniture_table
        WHERE furniture_id IN
        <foreach collection="list" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        AND del_flag = 0
        AND email IS NOT NULL AND email != ''
    </select>

</mapper>
