<?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.salaryacct.SalaryAcctSobConfigMapper">
    <resultMap id="BaseResultMap" type="com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO">
        <result column="adjust_rule_config" property="adjustRuleConfig"/>
        <result column="back_item_config" property="backItemConfig"/>
        <result column="basic_config" property="basicConfig"/>
        <result column="check_rule_config" property="checkRuleConfig"/>
        <result column="create_time" property="createTime"/>
        <result column="creator" property="creator"/>
        <result column="delete_type" property="deleteType"/>
        <result column="employee_field_config" property="employeeFieldConfig"/>
        <result column="id" property="id"/>
        <result column="item_config" property="itemConfig"/>
        <result column="item_group_config" property="itemGroupConfig"/>
        <result column="salary_acct_record_id" property="salaryAcctRecordId"/>
        <result column="tenant_key" property="tenantKey"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        t
        .
        adjust_rule_config
        , t.back_item_config
        , t.basic_config
        , t.check_rule_config
        , t.create_time
        , t.creator
        , t.delete_type
        , t.employee_field_config
        , t.id
        , t.item_config
        , t.item_group_config
        , t.salary_acct_record_id
        , t.tenant_key
        , t.update_time
    </sql>

    <!-- 查询全部 -->
    <select id="listAll" resultMap="BaseResultMap">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_acct_sob_config t
        WHERE delete_type = 0
    </select>

    <select id="getById" resultMap="BaseResultMap" parameterType="Long">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_acct_sob_config t
        WHERE id = #{id} AND delete_type = 0
    </select>

    <!-- 根据主键获取单条记录 -->
    <select id="getBySalaryAcctRecordId" resultMap="BaseResultMap" parameterType="Long">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_acct_sob_config t
        WHERE salary_acct_record_id = #{salaryAcctRecordId} AND delete_type = 0
    </select>

    <!-- 条件查询 -->
    <select id="listSome" resultMap="BaseResultMap"
            parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_acct_sob_config t
        WHERE delete_type = 0
        <if test="adjustRuleConfig != null">
            AND adjust_rule_config = #{adjustRuleConfig}
        </if>
        <if test="backItemConfig != null">
            AND back_item_config = #{backItemConfig}
        </if>
        <if test="basicConfig != null">
            AND basic_config = #{basicConfig}
        </if>
        <if test="checkRuleConfig != null">
            AND check_rule_config = #{checkRuleConfig}
        </if>
        <if test="createTime != null">
            AND create_time = #{createTime}
        </if>
        <if test="creator != null">
            AND creator = #{creator}
        </if>
        <if test="deleteType != null">
            AND delete_type = #{deleteType}
        </if>
        <if test="employeeFieldConfig != null">
            AND employee_field_config = #{employeeFieldConfig}
        </if>
        <if test="id != null">
            AND id = #{id}
        </if>
        <if test="itemConfig != null">
            AND item_config = #{itemConfig}
        </if>
        <if test="itemGroupConfig != null">
            AND item_group_config = #{itemGroupConfig}
        </if>
        <if test="salaryAcctRecordId != null">
            AND salary_acct_record_id = #{salaryAcctRecordId}
        </if>
        <if test="tenantKey != null">
            AND tenant_key = #{tenantKey}
        </if>
        <if test="updateTime != null">
            AND update_time = #{updateTime}
        </if>
        <if test="ids != null and ids.size()>0">
            AND id IN
            <foreach collection="ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY id DESC
    </select>


    <!-- 插入不为NULL的字段 -->
    <insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO">
        INSERT INTO hrsa_salary_acct_sob_config
        <trim prefix="(" suffix=")" suffixOverrides=",">

            <if test="adjustRuleConfig != null">
                adjust_rule_config,
            </if>
            <if test="backItemConfig != null">
                back_item_config,
            </if>
            <if test="basicConfig != null">
                basic_config,
            </if>
            <if test="checkRuleConfig != null">
                check_rule_config,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="deleteType != null">
                delete_type,
            </if>
            <if test="employeeFieldConfig != null">
                employee_field_config,
            </if>
            <if test="id != null">
                id,
            </if>
            <if test="itemConfig != null">
                item_config,
            </if>
            <if test="itemGroupConfig != null">
                item_group_config,
            </if>
            <if test="salaryAcctRecordId != null">
                salary_acct_record_id,
            </if>
            <if test="tenantKey != null">
                tenant_key,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="adjustRuleConfig != null">
                #{adjustRuleConfig},
            </if>
            <if test="backItemConfig != null">
                #{backItemConfig},
            </if>
            <if test="basicConfig != null">
                #{basicConfig},
            </if>
            <if test="checkRuleConfig != null">
                #{checkRuleConfig},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="creator != null">
                #{creator},
            </if>
            <if test="deleteType != null">
                #{deleteType},
            </if>
            <if test="employeeFieldConfig != null">
                #{employeeFieldConfig},
            </if>
            <if test="id != null">
                #{id},
            </if>
            <if test="itemConfig != null">
                #{itemConfig},
            </if>
            <if test="itemGroupConfig != null">
                #{itemGroupConfig},
            </if>
            <if test="salaryAcctRecordId != null">
                #{salaryAcctRecordId},
            </if>
            <if test="tenantKey != null">
                #{tenantKey},
            </if>
            <if test="updateTime != null">
                #{updateTime},
            </if>
        </trim>
    </insert>

    <!-- 更新,更新全部字段 -->
    <update id="update" parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO">
        UPDATE hrsa_salary_acct_sob_config
        <set>
            adjust_rule_config=#{adjustRuleConfig},
            back_item_config=#{backItemConfig},
            basic_config=#{basicConfig},
            check_rule_config=#{checkRuleConfig},
            create_time=#{createTime},
            creator=#{creator},
            delete_type=#{deleteType},
            employee_field_config=#{employeeFieldConfig},
            item_config=#{itemConfig},
            item_group_config=#{itemGroupConfig},
            salary_acct_record_id=#{salaryAcctRecordId},
            tenant_key=#{tenantKey},
            update_time=#{updateTime},
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>


    <!-- 更新不为NULL的字段 -->
    <update id="updateIgnoreNull" parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctSobConfigPO">
        UPDATE hrsa_salary_acct_sob_config
        <set>
            <if test="adjustRuleConfig != null">
                adjust_rule_config=#{adjustRuleConfig},
            </if>
            <if test="backItemConfig != null">
                back_item_config=#{backItemConfig},
            </if>
            <if test="basicConfig != null">
                basic_config=#{basicConfig},
            </if>
            <if test="checkRuleConfig != null">
                check_rule_config=#{checkRuleConfig},
            </if>
            <if test="createTime != null">
                create_time=#{createTime},
            </if>
            <if test="creator != null">
                creator=#{creator},
            </if>
            <if test="deleteType != null">
                delete_type=#{deleteType},
            </if>
            <if test="employeeFieldConfig != null">
                employee_field_config=#{employeeFieldConfig},
            </if>
            <if test="itemConfig != null">
                item_config=#{itemConfig},
            </if>
            <if test="itemGroupConfig != null">
                item_group_config=#{itemGroupConfig},
            </if>
            <if test="salaryAcctRecordId != null">
                salary_acct_record_id=#{salaryAcctRecordId},
            </if>
            <if test="tenantKey != null">
                tenant_key=#{tenantKey},
            </if>
            <if test="updateTime != null">
                update_time=#{updateTime},
            </if>
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>


    <!-- 根据主键删除记录 -->
    <delete id="delete">
        UPDATE hrsa_salary_acct_sob_config
        SET delete_type=1
        WHERE id = #{id}
          AND delete_type = 0
    </delete>

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

    <delete id="deleteBySalaryAcctRecordIds">
        UPDATE hrsa_salary_acct_sob_config
        SET delete_type = 1
        WHERE delete_type = 0
        AND salary_acct_record_id IN
        <foreach collection="salaryAcctRecordIds" open="(" item="salaryAcctRecordId" separator="," close=")">
            #{salaryAcctRecordId}
        </foreach>
    </delete>


</mapper>