<?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.engine.salary.mapper.salarybill.SalaryTemplateMapper">

    <resultMap id="BaseResultMap" type="com.engine.salary.entity.salaryBill.po.SalaryTemplatePO">
        <result column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="salary_sob_id" property="salarySobId"/>
        <result column="use_type" property="useType"/>
        <result column="description" property="description"/>
        <result column="email_status" property="emailStatus"/>
        <result column="sms_status" property="smsStatus"/>
        <result column="send_email_id" property="sendEmailId"/>
        <result column="msg_status" property="msgStatus"/>
        <result column="theme" property="theme"/>
        <result column="background" property="background"/>
        <result column="text_content" property="textContent"/>
        <result column="text_content_position" property="textContentPosition"/>
        <result column="salary_item_null_status" property="salaryItemNullStatus"/>
        <result column="salary_item_zero_status" property="salaryItemZeroStatus"/>
        <result column="salary_item_setting" property="salaryItemSetting"/>
        <result column="replenish_name" property="replenishName"/>
        <result column="replenish_rule" property="replenishRule"/>
        <result column="replenish_salary_item_setting" property="replenishSalaryItemSetting"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="creator" property="creator"/>
        <result column="delete_type" property="deleteType"/>
        <result column="sms_setting" property="smsSetting"/>
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        t
        .
        id
        , t.name
        , t.salary_sob_id
        , t.use_type
        , t.description
        , t.email_status
        , t.sms_status
        , t.send_email_id
        , t.msg_status
        , t.theme
        , t.background
        , t.text_content
        , t.text_content_position
        , t.salary_item_null_status
        , t.salary_item_zero_status
        , t.salary_item_setting
        , t.replenish_name
        , t.replenish_rule
        , t.replenish_salary_item_setting
        , t.auto_send_status
        , t.auto_send_cycle_type
        , t.auto_send_day_of_month
        , t.auto_send_time_of_day
        , t.ack_feedback_status
        , t.feedback_status
        , t.auto_ack_days
        , t.feedback_url
        , t.mobile_feedback_url
        , t.create_time
        , t.update_time
        , t.creator
        , t.delete_type
        , t.sms_setting
    </sql>
    <select id="getById" resultType="com.engine.salary.entity.salaryBill.po.SalaryTemplatePO">
        SELECT id,
               name,
               salary_sob_id,
               use_type,
               description,
               email_status,
               sms_status,
               send_email_id,
               msg_status,
               theme,
               background,
               text_content,
               text_content_position,
               salary_item_null_status,
               salary_item_zero_status,
               salary_item_setting,
               replenish_name,
               replenish_rule,
               replenish_salary_item_setting,
               auto_send_status,
               auto_send_cycle_type,
               auto_send_day_of_month,
               auto_send_time_of_day,
               ack_feedback_status,
               feedback_status,
               auto_ack_days,
               feedback_url,
               mobile_feedback_url,
               create_time,
               update_time,
               creator,
               delete_type,
               sms_setting,
               tenant_key
        FROM hrsa_salary_template
        WHERE delete_type = 0
          AND id = #{id}
    </select>

    <sql id="salaryTemplateColumn">
        t1
        .
        id
        ,
        t1.name,
        t2.name AS salary_sob,
        t1.use_type,
        t1.description
    </sql>

    <sql id="paramSql">
        <if test="param.ids != null and param.ids.size()>0">
            AND t1.id IN
            <foreach collection="param.ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <!-- 模板名称 -->
        <if test="param.name != null and param.name != ''">
            AND t1.name like CONCAT('%',#{param.name},'%')
        </if>
        <!-- 薪资账套 -->
        <if test="param.salarySobId != null">
            AND t1.salary_sob_id = #{param.salarySobId}
        </if>
    </sql>
    <sql id="paramSql" databaseId="oracle">
        <if test="param.ids != null and param.ids.size()>0">
            AND t1.id IN
            <foreach collection="param.ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>

        <if test="param.name != null and param.name != ''">
            AND t1.name like '%'||#{param.name}||'%'
        </if>

        <if test="param.salarySobId != null">
            AND t1.salary_sob_id = #{param.salarySobId}
        </if>
    </sql>
    <sql id="paramSql" databaseId="sqlserver">
        <if test="param.ids != null and param.ids.size()>0">
            AND t1.id IN
            <foreach collection="param.ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>

        <if test="param.name != null and param.name != ''">
            AND t1.name like '%'+#{param.name}+'%'
        </if>

        <if test="param.salarySobId != null">
            AND t1.salary_sob_id = #{param.salarySobId}
        </if>
    </sql>

    <select id="list" resultType="com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO">
        SELECT
        <include refid="salaryTemplateColumn"/>
        FROM
        hrsa_salary_template t1
        LEFT JOIN hrsa_salary_sob t2 ON t1.salary_sob_id = t2.id
        WHERE
        t1.delete_type = 0
        AND t2.delete_type = 0
        <include refid="paramSql"/>
        ORDER BY t1.salary_sob_id,t1.id DESC
    </select>
    <select id="list" resultType="com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO" databaseId="oracle">
        SELECT

        t1.id,
        t1.name,
        t2.name AS salary_sob,
        t1.use_type,
        t1.description

        FROM
        hrsa_salary_template t1
        LEFT JOIN hrsa_salary_sob t2 ON t1.salary_sob_id = t2.id
        WHERE
        t1.delete_type = 0
        AND t2.delete_type = 0

        <if test="param.ids != null and param.ids.size()>0">
            AND t1.id IN
            <foreach collection="param.ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>

        <if test="param.name != null and param.name != ''">
            AND t1.name like '%'||#{param.name}||'%'
        </if>

        <if test="param.salarySobId != null">
            AND t1.salary_sob_id = #{param.salarySobId}
        </if>

        ORDER BY t1.salary_sob_id,t1.id DESC
    </select>
    <select id="list" resultType="com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO" databaseId="sqlserver">
        SELECT

        t1.id,
        t1.name,
        t2.name AS salary_sob,
        t1.use_type,
        t1.description

        FROM
        hrsa_salary_template t1
        LEFT JOIN hrsa_salary_sob t2 ON t1.salary_sob_id = t2.id
        WHERE
        t1.delete_type = 0
        AND t2.delete_type = 0

        <if test="param.ids != null and param.ids.size()>0">
            AND t1.id IN
            <foreach collection="param.ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>

        <if test="param.name != null and param.name != ''">
            AND t1.name like '%'+#{param.name}+'%'
        </if>

        <if test="param.salarySobId != null">
            AND t1.salary_sob_id = #{param.salarySobId}
        </if>

        ORDER BY t1.salary_sob_id,t1.id DESC
    </select>

    <update id="deleteByIds">
        UPDATE hrsa_salary_template
        SET delete_type = 1
        WHERE delete_type = 0
        AND id IN
        <foreach collection="ids" open="(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </update>


    <!-- 条件查询 -->
    <select id="listSome" resultMap="BaseResultMap"
            parameterType="com.engine.salary.entity.salaryBill.po.SalaryTemplatePO">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_template t
        WHERE delete_type = 0
        <if test="id != null and id != ''">
            AND id = #{id}
        </if>
        <if test="name != null and name != ''">
            AND name = #{name}
        </if>
        <if test="salarySobId != null and salarySobId != ''">
            AND salary_sob_id = #{salarySobId}
        </if>
        <if test="useType != null and useType != ''">
            AND use_type = #{useType}
        </if>
        <if test="description != null and description != ''">
            AND description = #{description}
        </if>
        <if test="emailStatus != null and emailStatus != ''">
            AND email_status = #{emailStatus}
        </if>
        <if test="sendEmailId != null and sendEmailId != ''">
            AND send_email_id = #{sendEmailId}
        </if>
        <if test="msgStatus != null and msgStatus != ''">
            AND msg_status = #{msgStatus}
        </if>
        <if test="theme != null and theme != ''">
            AND theme = #{theme}
        </if>
        <if test="background != null and background != ''">
            AND background = #{background}
        </if>
        <if test="textContent != null and textContent != ''">
            AND text_content = #{textContent}
        </if>
        <if test="textContentPosition != null and textContentPosition != ''">
            AND text_content_position = #{textContentPosition}
        </if>
        <if test="salaryItemNullStatus != null and salaryItemNullStatus != ''">
            AND salary_item_null_status = #{salaryItemNullStatus}
        </if>
        <if test="salaryItemZeroStatus != null and salaryItemZeroStatus != ''">
            AND salary_item_zero_status = #{salaryItemZeroStatus}
        </if>

        <if test="salaryItemSetting != null and salaryItemSetting != ''">
            AND salary_item_setting = #{salaryItemSetting}
        </if>
        <if test=" replenishName != null and replenishName != ''">
            AND replenish_name = #{replenishName}
        </if>
        <if test="replenishRule != null and replenishRule != ''">
            AND replenish_rule = #{replenishRule}
        </if>
        <if test="replenishSalaryItemSetting != null and replenishSalaryItemSetting != ''">
            AND replenish_salary_item_setting = #{replenishSalaryItemSetting}
        </if>
        <if test="createTime != null and createTime != ''">
            AND create_time = #{createTime}
        </if>
        <if test="updateTime != null and updateTime != ''">
            AND update_time = #{updateTime}
        </if>
        <if test="creator != null and creator != ''">
            AND creator = #{creator}
        </if>
        <if test="deleteType != null and deleteType != ''">
            AND delete_type = #{deleteType}
        </if>
        <if test="autoSendStatus != null and autoSendStatus != ''">
            AND auto_send_status = #{autoSendStatus}
        </if>
        <if test="ackFeedbackStatus != null and ackFeedbackStatus != ''">
            AND ack_feedback_status = #{ackFeedbackStatus}
        </if>
        <if test="salarySobIds != null and salarySobIds.size() > 0">
            AND salary_sob_id IN
            <foreach collection="salarySobIds" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY id DESC
    </select>

    <select id="listDefaultTemplates" resultMap="BaseResultMap">
        SELECT
        <include refid="baseColumns"/>
        FROM
        hrsa_salary_template t
        WHERE
        t.delete_type = 0 AND
        t.use_type = 1 AND
        t.salary_sob_id IN
        <if test="ids != null and ids.size() > 0">
            <foreach collection="ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY t.salary_sob_id,t.id DESC
    </select>

    <select id="listDTO" resultType="com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO">
        select
            t.id,
            t.name,
            t.replenish_name as replenishName,
            s.name as salarysob,
            s.id as salarySobId,
            t.use_type as useType,
            t.description,
            t.salary_sob_id
        from
            hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id
        where t.delete_type = 0
        <if test="id != null and id != ''">
            AND t.id = #{id}
        </if>
        <if test="name != null and name != ''">
            AND t.name like CONCAT('%',#{name},'%')
        </if>
        <if test="salarySobId != null and salarySobId != ''">
            AND t.salary_sob_id = #{salarySobId}
        </if>
        <if test=" replenishName != null and replenishName != ''">
            AND t.replenish_name = #{replenishName}
        </if>
        <if test="salarySobIds != null and salarySobIds.size() > 0">
            AND t.salary_sob_id IN
            <foreach collection="salarySobIds" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY id DESC
    </select>

    <select id="listDTO" resultType="com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO" databaseId="oracle">
        select
        t.id,
        t.name,
        t.replenish_name as replenishName,
        s.name as salarysob,
        s.id as salarySobId,
        t.use_type as useType,
        t.description,
        t.salary_sob_id
        from
        hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id
        where t.delete_type = 0
        <if test="id != null and id != ''">
            AND t.id = #{id}
        </if>
        <if test="name != null and name != ''">
            AND t.name like '%'||#{name}||'%'
        </if>
        <if test="salarySobId != null and salarySobId != ''">
            AND t.salary_sob_id = #{salarySobId}
        </if>
        <if test=" replenishName != null and replenishName != ''">
            AND t.replenish_name = #{replenishName}
        </if>
        <if test="salarySobIds != null and salarySobIds.size() > 0">
            AND t.salary_sob_id IN
            <foreach collection="salarySobIds" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY id DESC
    </select>

    <select id="listDTO" resultType="com.engine.salary.entity.salaryBill.dto.SalaryTemplateListDTO" databaseId="sqlserver">
        select
        t.id,
        t.name,
        t.replenish_name as replenishName,
        s.name as salarysob,
        s.id as salarySobId,
        t.use_type as useType,
        t.description,
        t.salary_sob_id
        from
        hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id
        where t.delete_type = 0
        <if test="id != null and id != ''">
            AND t.id = #{id}
        </if>
        <if test="name != null and name != ''">
            AND t.name like '%'+#{name}+'%'
        </if>
        <if test="salarySobId != null and salarySobId != ''">
            AND t.salary_sob_id = #{salarySobId}
        </if>
        <if test=" replenishName != null and replenishName != ''">
            AND t.replenish_name = #{replenishName}
        </if>
        <if test="salarySobIds != null and salarySobIds.size() > 0">
            AND t.salary_sob_id IN
            <foreach collection="salarySobIds" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY id DESC
    </select>

    <!-- 更新不为NULL的字段 -->
    <update id="updateIgnoreNull" parameterType="com.engine.salary.entity.salaryBill.po.SalaryTemplatePO">
        UPDATE hrsa_salary_template
        <set>
            <if test="name != null">
                name=#{name},
            </if>
            <if test="salarySobId != null">
                salary_sob_id=#{salarySobId},
            </if>
            <if test="useType != null">
                use_type=#{useType},
            </if>
            <if test="description != null">
                description=#{description},
            </if>
            <if test="emailStatus != null">
                email_status=#{emailStatus},
            </if>
            <if test="smsStatus != null">
                sms_status=#{smsStatus},
            </if>
            <if test="sendEmailId != null">
                send_email_id=#{sendEmailId},
            </if>
            <if test="msgStatus != null">
                msg_status=#{msgStatus},
            </if>
            <if test="theme != null">
                theme=#{theme},
            </if>
            <if test="background != null">
                background=#{background},
            </if>
            <if test="textContent != null">
                text_content=#{textContent},
            </if>
            <if test="textContentPosition != null">
                text_content_position=#{textContentPosition},
            </if>
            <if test="salaryItemNullStatus != null">
                salary_item_null_status=#{salaryItemNullStatus},
            </if>
            <if test="salaryItemZeroStatus != null">
                salary_item_zero_status=#{salaryItemZeroStatus},
            </if>
            <if test="salaryItemSetting != null">
                salary_item_setting=#{salaryItemSetting},
            </if>
            <if test="replenishName != null">
                replenish_name=#{replenishName},
            </if>
            <if test="replenishRule != null">
                replenish_rule=#{replenishRule},
            </if>
            <if test="replenishSalaryItemSetting != null">
                replenish_salary_item_setting=#{replenishSalaryItemSetting},
            </if>
            <if test="autoSendStatus != null">
                auto_send_status=#{autoSendStatus},
            </if>
            <if test="autoSendCycleType != null">
                auto_send_cycle_type=#{autoSendCycleType},
            </if>
            <if test="autoSendDayOfMonth != null">
                auto_send_day_of_month=#{autoSendDayOfMonth},
            </if>
            <if test="autoSendTimeOfDay != null">
                auto_send_time_of_day=#{autoSendTimeOfDay},
            </if>
            <if test="ackFeedbackStatus!= null">
                ack_feedback_status=#{ackFeedbackStatus},
            </if>
            <if test="feedbackStatus!= null">
                feedback_status=#{feedbackStatus},
            </if>
            <if test="autoAckDays != null">
                auto_ack_days=#{autoAckDays},
            </if>
            <if test="feedbackUrl != null">
                feedback_url=#{feedbackUrl},
            </if>
            <if test="mobileFeedbackUrl != null">
                mobile_feedback_url=#{mobileFeedbackUrl},
            </if>
            <if test="createTime != null">
                create_time=#{createTime},
            </if>
            <if test="updateTime != null">
                update_time=#{updateTime},
            </if>
            <if test="creator != null">
                creator=#{creator},
            </if>
            <if test="smsSetting != null">
                sms_setting=#{smsSetting}
            </if>
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>


    <!-- 插入不为NULL的字段 -->
    <insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.salaryBill.po.SalaryTemplatePO"
            keyProperty="id" keyColumn="id" useGeneratedKeys="true"
    >
        INSERT INTO hrsa_salary_template
        <trim prefix="(" suffix=")" suffixOverrides=",">

            <if test="id != null">
                id,
            </if>
            <if test="name != null">
                name,
            </if>
            <if test="salarySobId != null">
                salary_sob_id,
            </if>
            <if test="useType != null">
                use_type,
            </if>
            <if test="description != null">
                description,
            </if>
            <if test="emailStatus != null">
                email_status,
            </if>
            <if test="sendEmailId != null">
                send_email_id,
            </if>
            <if test="msgStatus != null">
                msg_status,
            </if>
            <if test="smsStatus != null">
                sms_status,
            </if>
            <if test="theme != null">
                theme,
            </if>
            <if test="background != null">
                background,
            </if>
            <if test="textContent != null">
                text_content,
            </if>
            <if test="textContentPosition != null">
                text_content_position,
            </if>
            <if test="salaryItemNullStatus != null">
                salary_item_null_status,
            </if>
            <if test="salaryItemZeroStatus != null">
                salary_item_zero_status,
            </if>
            <if test="salaryItemSetting != null">
                salary_item_setting,
            </if>
            <if test="replenishName != null">
                replenish_name,
            </if>
            <if test="replenishRule != null">
                replenish_rule,
            </if>
            <if test="replenishSalaryItemSetting != null">
                replenish_salary_item_setting,
            </if>
            <if test="autoSendStatus != null">
                auto_send_status,
            </if>
            <if test="autoSendCycleType != null">
                auto_send_cycle_type,
            </if>
            <if test="autoSendDayOfMonth != null">
                auto_send_day_of_month,
            </if>
            <if test="autoSendTimeOfDay != null">
                auto_send_time_of_day,
            </if>
            <if test="ackFeedbackStatus != null">
                ack_feedback_status,
            </if>
            <if test="feedbackStatus != null">
                feedback_status,
            </if>
            <if test="autoAckDays != null">
                auto_ack_days,
            </if>
            <if test="feedbackUrl != null">
                feedback_url,
            </if>
            <if test="mobileFeedbackUrl != null">
                mobile_feedback_url,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="deleteType != null">
                delete_type,
            </if>
            <if test="tenantKey != null">
                tenant_key,
            </if>
            <if test="smsSetting != null">
                sms_setting,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id},
            </if>
            <if test="name != null">
                #{name},
            </if>
            <if test="salarySobId != null">
                #{salarySobId},
            </if>
            <if test="useType != null">
                #{useType},
            </if>
            <if test="description != null">
                #{description},
            </if>
            <if test="emailStatus != null">
                #{emailStatus},
            </if>
            <if test="sendEmailId != null">
                #{sendEmailId},
            </if>
            <if test="msgStatus != null">
                #{msgStatus},
            </if>
            <if test="smsStatus != null">
                #{smsStatus},
            </if>
            <if test="theme != null">
                #{theme},
            </if>
            <if test="background != null">
                #{background},
            </if>
            <if test="textContent != null">
                #{textContent},
            </if>
            <if test="textContentPosition != null">
                #{textContentPosition},
            </if>
            <if test="salaryItemNullStatus != null">
                #{salaryItemNullStatus},
            </if>
            <if test="salaryItemZeroStatus != null">
                #{salaryItemZeroStatus},
            </if>
            <if test="salaryItemSetting != null">
                #{salaryItemSetting},
            </if>
            <if test="replenishName != null">
                #{replenishName},
            </if>
            <if test="replenishRule != null">
                #{replenishRule},
            </if>
            <if test="replenishSalaryItemSetting != null">
                #{replenishSalaryItemSetting},
            </if>
            <if test="autoSendStatus != null">
                #{autoSendStatus},
            </if>
            <if test="autoSendCycleType != null">
                #{autoSendCycleType},
            </if>
            <if test="autoSendDayOfMonth != null">
                #{autoSendDayOfMonth},
            </if>
            <if test="autoSendTimeOfDay != null">
                #{autoSendTimeOfDay},
            </if>
            <if test="ackFeedbackStatus != null">
                #{ackFeedbackStatus},
            </if>
            <if test="feedbackStatus != null">
                #{feedbackStatus},
            </if>
            <if test="autoAckDays != null">
                #{autoAckDays},
            </if>
            <if test="feedbackUrl != null">
                #{feedbackUrl},
            </if>
            <if test="mobileFeedbackUrl != null">
                #{mobileFeedbackUrl},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="updateTime != null">
                #{updateTime},
            </if>
            <if test="creator != null">
                #{creator},
            </if>
            <if test="deleteType != null">
                #{deleteType},
            </if>
            <if test="tenantKey != null">
                #{tenantKey},
            </if>
            <if test="smsSetting != null">
                #{smsSetting},
            </if>
        </trim>
    </insert>

    <insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.salaryBill.po.SalaryTemplatePO"
            databaseId="oracle"
    >
        <selectKey keyProperty="id" resultType="long" order="AFTER">
            select hrsa_salary_template_id.currval from dual
        </selectKey>
        INSERT INTO hrsa_salary_template
        <trim prefix="(" suffix=")" suffixOverrides=",">

            <if test="id != null">
                id,
            </if>
            <if test="name != null">
                name,
            </if>
            <if test="salarySobId != null">
                salary_sob_id,
            </if>
            <if test="useType != null">
                use_type,
            </if>
            <if test="description != null">
                description,
            </if>
            <if test="emailStatus != null">
                email_status,
            </if>
            <if test="sendEmailId != null">
                send_email_id,
            </if>
            <if test="msgStatus != null">
                msg_status,
            </if>
            <if test="smsStatus != null">
                sms_status,
            </if>
            <if test="theme != null">
                theme,
            </if>
            <if test="background != null">
                background,
            </if>
            <if test="textContent != null">
                text_content,
            </if>
            <if test="textContentPosition != null">
                text_content_position,
            </if>
            <if test="salaryItemNullStatus != null">
                salary_item_null_status,
            </if>
            <if test="salaryItemZeroStatus != null">
                salary_item_zero_status,
            </if>
            <if test="salaryItemSetting != null">
                salary_item_setting,
            </if>
            <if test="replenishName != null">
                replenish_name,
            </if>
            <if test="replenishRule != null">
                replenish_rule,
            </if>
            <if test="replenishSalaryItemSetting != null">
                replenish_salary_item_setting,
            </if>
            <if test="autoSendStatus != null">
                auto_send_status,
            </if>
            <if test="autoSendCycleType != null">
                auto_send_cycle_type,
            </if>
            <if test="autoSendDayOfMonth != null">
                auto_send_day_of_month,
            </if>
            <if test="autoSendTimeOfDay != null">
                auto_send_time_of_day,
            </if>
            <if test="ackFeedbackStatus != null">
                ack_feedback_status,
            </if>
            <if test="feedbackStatus != null">
                feedback_status,
            </if>
            <if test="autoAckDays != null">
                auto_ack_days,
            </if>
            <if test="feedbackUrl != null">
                feedback_url,
            </if>
            <if test="mobileFeedbackUrl != null">
                mobile_feedback_url,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="deleteType != null">
                delete_type,
            </if>
            <if test="tenantKey != null">
                tenant_key,
            </if>
            <if test="smsSetting != null">
                sms_setting,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id},
            </if>
            <if test="name != null">
                #{name},
            </if>
            <if test="salarySobId != null">
                #{salarySobId},
            </if>
            <if test="useType != null">
                #{useType},
            </if>
            <if test="description != null">
                #{description},
            </if>
            <if test="emailStatus != null">
                #{emailStatus},
            </if>
            <if test="sendEmailId != null">
                #{sendEmailId},
            </if>
            <if test="msgStatus != null">
                #{msgStatus},
            </if>
            <if test="smsStatus != null">
                #{smsStatus},
            </if>
            <if test="theme != null">
                #{theme},
            </if>
            <if test="background != null">
                #{background},
            </if>
            <if test="textContent != null">
                #{textContent},
            </if>
            <if test="textContentPosition != null">
                #{textContentPosition},
            </if>
            <if test="salaryItemNullStatus != null">
                #{salaryItemNullStatus},
            </if>
            <if test="salaryItemZeroStatus != null">
                #{salaryItemZeroStatus},
            </if>
            <if test="salaryItemSetting != null">
                #{salaryItemSetting},
            </if>
            <if test="replenishName != null">
                #{replenishName},
            </if>
            <if test="replenishRule != null">
                #{replenishRule},
            </if>
            <if test="replenishSalaryItemSetting != null">
                #{replenishSalaryItemSetting},
            </if>
            <if test="autoSendStatus != null">
                #{autoSendStatus},
            </if>
            <if test="autoSendCycleType != null">
                #{autoSendCycleType},
            </if>
            <if test="autoSendDayOfMonth != null">
                #{autoSendDayOfMonth},
            </if>
            <if test="autoSendTimeOfDay != null">
                #{autoSendTimeOfDay},
            </if>
            <if test="ackFeedbackStatus != null">
                #{ackFeedbackStatus},
            </if>
            <if test="feedbackStatus != null">
                #{feedbackStatus},
            </if>
            <if test="autoAckDays != null">
                #{autoAckDays},
            </if>
            <if test="feedbackUrl != null">
                #{feedbackUrl},
            </if>
            <if test="mobileFeedbackUrl != null">
                #{mobileFeedbackUrl},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="updateTime != null">
                #{updateTime},
            </if>
            <if test="creator != null">
                #{creator},
            </if>
            <if test="deleteType != null">
                #{deleteType},
            </if>
            <if test="tenantKey != null">
                #{tenantKey},
            </if>
            <if test="smsSetting != null">
                #{smsSetting},
            </if>
        </trim>
    </insert>


    <!-- 更新不为NULL的字段 -->
    <update id="updateUsetypeBySalarySobId" parameterType="com.engine.salary.entity.salaryBill.po.SalaryTemplatePO">
        UPDATE hrsa_salary_template
        <set>
            <if test="useType != null">
                use_type=#{useType}
            </if>
        </set>
        WHERE salary_sob_id=#{salarySobId} AND delete_type = 0
    </update>


</mapper>
