<?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.vetti.hotake.mapper.HotakeNotificationPreferencesMapper">
    
    <resultMap type="HotakeNotificationPreferences" id="HotakeNotificationPreferencesResult">
        <result property="id"    column="id"    />
        <result property="emailJobAlerts"    column="email_job_alerts"    />
        <result property="emailApplicationUpdates"    column="email_application_updates"    />
        <result property="emailAiMatchSuggestions"    column="email_ai_match_suggestions"    />
        <result property="emailNewsletter"    column="email_newsletter"    />
        <result property="pushNewMessages"    column="push_new_messages"    />
        <result property="pushInterviewReminders"    column="push_interview_reminders"    />
        <result property="mailMarketingEmails"    column="mail_marketing_emails"    />
        <result property="mailPartnerOffers"    column="mail_partner_offers"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectHotakeNotificationPreferencesVo">
        select id, email_job_alerts, email_application_updates, email_ai_match_suggestions, 
               email_newsletter, push_new_messages, push_interview_reminders, 
               mail_marketing_emails, mail_partner_offers,
               del_flag, create_by, create_time, update_by, update_time, remark 
        from hotake_notification_preferences
    </sql>

    <select id="selectHotakeNotificationPreferencesList" parameterType="HotakeNotificationPreferences" resultMap="HotakeNotificationPreferencesResult">
        <include refid="selectHotakeNotificationPreferencesVo"/>
        <where>  
            <if test="emailJobAlerts != null"> and email_job_alerts = #{emailJobAlerts}</if>
            <if test="emailApplicationUpdates != null"> and email_application_updates = #{emailApplicationUpdates}</if>
            <if test="emailAiMatchSuggestions != null"> and email_ai_match_suggestions = #{emailAiMatchSuggestions}</if>
            <if test="emailNewsletter != null"> and email_newsletter = #{emailNewsletter}</if>
            <if test="pushNewMessages != null"> and push_new_messages = #{pushNewMessages}</if>
            <if test="pushInterviewReminders != null"> and push_interview_reminders = #{pushInterviewReminders}</if>
            <if test="mailMarketingEmails != null"> and mail_marketing_emails = #{mailMarketingEmails}</if>
            <if test="mailPartnerOffers != null"> and mail_partner_offers = #{mailPartnerOffers}</if>
            <if test="delFlag != null  and delFlag != ''"> and del_flag = #{delFlag}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
        </where>
    </select>
    
    <select id="selectHotakeNotificationPreferencesById" parameterType="Long" resultMap="HotakeNotificationPreferencesResult">
        <include refid="selectHotakeNotificationPreferencesVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertHotakeNotificationPreferences" parameterType="HotakeNotificationPreferences" useGeneratedKeys="true" keyProperty="id">
        insert into hotake_notification_preferences
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="emailJobAlerts != null">email_job_alerts,</if>
            <if test="emailApplicationUpdates != null">email_application_updates,</if>
            <if test="emailAiMatchSuggestions != null">email_ai_match_suggestions,</if>
            <if test="emailNewsletter != null">email_newsletter,</if>
            <if test="pushNewMessages != null">push_new_messages,</if>
            <if test="pushInterviewReminders != null">push_interview_reminders,</if>
            <if test="mailMarketingEmails != null">mail_marketing_emails,</if>
            <if test="mailPartnerOffers != null">mail_partner_offers,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="emailJobAlerts != null">#{emailJobAlerts},</if>
            <if test="emailApplicationUpdates != null">#{emailApplicationUpdates},</if>
            <if test="emailAiMatchSuggestions != null">#{emailAiMatchSuggestions},</if>
            <if test="emailNewsletter != null">#{emailNewsletter},</if>
            <if test="pushNewMessages != null">#{pushNewMessages},</if>
            <if test="pushInterviewReminders != null">#{pushInterviewReminders},</if>
            <if test="mailMarketingEmails != null">#{mailMarketingEmails},</if>
            <if test="mailPartnerOffers != null">#{mailPartnerOffers},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateHotakeNotificationPreferences" parameterType="HotakeNotificationPreferences">
        update hotake_notification_preferences
        <trim prefix="SET" suffixOverrides=",">
            <if test="emailJobAlerts != null">email_job_alerts = #{emailJobAlerts},</if>
            <if test="emailApplicationUpdates != null">email_application_updates = #{emailApplicationUpdates},</if>
            <if test="emailAiMatchSuggestions != null">email_ai_match_suggestions = #{emailAiMatchSuggestions},</if>
            <if test="emailNewsletter != null">email_newsletter = #{emailNewsletter},</if>
            <if test="pushNewMessages != null">push_new_messages = #{pushNewMessages},</if>
            <if test="pushInterviewReminders != null">push_interview_reminders = #{pushInterviewReminders},</if>
            <if test="mailMarketingEmails != null">mail_marketing_emails = #{mailMarketingEmails},</if>
            <if test="mailPartnerOffers != null">mail_partner_offers = #{mailPartnerOffers},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteHotakeNotificationPreferencesById" parameterType="Long">
        delete from hotake_notification_preferences where id = #{id}
    </delete>

    <delete id="deleteHotakeNotificationPreferencesByIds" parameterType="String">
        delete from hotake_notification_preferences where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
