<?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.datacollection.AttendQuoteSyncSetMapper">
    <resultMap id="BaseResultMap" type="com.engine.salary.entity.datacollection.po.AttendQuoteFieldSettingPO">
        <result column="id" property="id"/>
        <result column="source_type" property="sourceType"/>
        <result column="current_setting_content" property="currentSettingContent"/>
        <result column="default_setting_content" property="defaultSettingContent"/>
        <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="tenant_key" property="tenantKey"/>
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        t
        .
        id
        , t.source_type
        , t.current_setting_content
        , t.default_setting_content
        , t.create_time
        , t.update_time
        , t.creator
        , t.delete_type
        , t.tenant_key
    </sql>

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

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

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

            <if test="id != null">
                id,
            </if>
            <if test="sourceType != null">
                source_type,
            </if>
            <if test="currentSettingContent != null">
                current_setting_content,
            </if>
            <if test="defaultSettingContent != null">
                default_setting_content,
            </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>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id},
            </if>
            <if test="sourceType != null">
                #{sourceType},
            </if>
            <if test="currentSettingContent != null">
                #{currentSettingContent},
            </if>
            <if test="defaultSettingContent != null">
                #{defaultSettingContent},
            </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>
        </trim>
    </insert>

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

            <if test="id != null">
                id,
            </if>
            <if test="sourceType != null">
                source_type,
            </if>
            <if test="currentSettingContent != null">
                current_setting_content,
            </if>
            <if test="defaultSettingContent != null">
                default_setting_content,
            </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>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id},
            </if>
            <if test="sourceType != null">
                #{sourceType},
            </if>
            <if test="currentSettingContent != null">
                #{currentSettingContent},
            </if>
            <if test="defaultSettingContent != null">
                #{defaultSettingContent},
            </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>
        </trim>
    </insert>

    <!-- 更新,更新全部字段 -->
    <update id="update" parameterType="com.engine.salary.entity.datacollection.po.AttendQuoteFieldSettingPO">
        UPDATE hrsa_attend_quote_sync_set
        <set>
            source_type=#{sourceType},
            current_setting_content=#{currentSettingContent},
            default_setting_content=#{defaultSettingContent},
            create_time=#{createTime},
            update_time=#{updateTime},
            creator=#{creator},
            delete_type=#{deleteType},
            tenant_key=#{tenantKey},
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>


    <!-- 更新不为NULL的字段 -->
    <update id="updateIgnoreNull" parameterType="com.engine.salary.entity.datacollection.po.AttendQuoteFieldSettingPO">
        UPDATE hrsa_attend_quote_sync_set
        <set>
            <if test="sourceType != null">
                source_type=#{sourceType},
            </if>
            <if test="currentSettingContent != null">
                current_setting_content=#{currentSettingContent},
            </if>
            <if test="defaultSettingContent != null">
                default_setting_content=#{defaultSettingContent},
            </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="deleteType != null">
                delete_type=#{deleteType},
            </if>
            <if test="tenantKey != null">
                tenant_key=#{tenantKey},
            </if>
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>


    <!-- 根据主键删除记录 -->
    <delete id="delete" parameterType="com.engine.salary.entity.datacollection.po.AttendQuoteFieldSettingPO">
        UPDATE hrsa_attend_quote_sync_set
        SET delete_type=1
        WHERE id = #{id}
          AND delete_type = 0
    </delete>

    <select id="listSome" resultMap="BaseResultMap">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_attend_quote_sync_set t
        WHERE delete_type = 0
        <if test="param.sourceType != null and param.sourceType != ''">
            AND source_type = #{param.sourceType}
        </if>
    </select>


</mapper>