<?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.hywz.mapper.AdsMatHyxtStampTaxWarningDMapper">
	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap id="adsMatHyxtStampTaxWarningDMap" type="com.ruoyi.hywz.entity.AdsMatHyxtStampTaxWarningD">
        <result property="id" column="id"/>
        <result property="sourceType" column="source_type"/>
        <result property="sourceId" column="source_id"/>
        <result property="checkGist" column="check_gist"/>
        <result property="checkType" column="check_type"/>
        <result property="content" column="content"/>
        <result property="status" column="status"/>
        <result property="createUserId" column="create_user_id"/>
        <result property="createUser" column="create_user"/>
        <result property="createUserName" column="create_user_name"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="isDeleted" column="is_deleted"/>
    </resultMap>

    <insert id="batchAddOrUpdate" parameterType="com.ruoyi.hywz.entity.AdsMatHyxtStampTaxWarningD">
        <foreach collection="list" item="item" index="index" separator=";">
            insert into ads_mat_hyxt_stamp_tax_warning_d
            (id,
            source_type,
            source_id,
            check_gist,
            check_type,
            content,
            status,
            create_time,
            update_time
            )
            select
            (case
            when exists (
                    SELECT 1 FROM ads_mat_hyxt_stamp_tax_warning_d
                    <where>
                        <if test="item.sourceType != null ">
                            source_type = #{item.sourceType}
                        </if>
                        <if test="item.sourceId != null ">
                            and source_id = #{item.sourceId}
                        </if>
                        <if test="item.content != null ">
                            and content = #{item.content}
                        </if>
                    </where>
                )
            then (
                SELECT id FROM ads_mat_hyxt_stamp_tax_warning_d
                <where>
                    <if test="item.sourceType != null ">
                        source_type = #{item.sourceType}
                    </if>
                    <if test="item.sourceId != null ">
                        and source_id = #{item.sourceId}
                    </if>
                    <if test="item.content != null ">
                        and content = #{item.content}
                    </if>
                </where>
                )
            else uuid() end),
            #{item.sourceType},
            #{item.sourceId},
            #{item.checkGist},
            #{item.checkType},
            #{item.content},
            #{item.status},
            now(),
            now()
            on duplicate key update
            <if test="item.sourceType != null ">
                source_type = #{item.sourceType},
            </if>
            <if test="item.sourceId != null ">
                source_id = #{item.sourceId},
            </if>
            <if test="item.checkGist != null ">
                check_gist = #{item.checkGist},
            </if>
            <if test="item.checkType != null ">
                check_type = #{item.checkType},
            </if>
            <if test="item.content != null ">
                content = #{item.content},
            </if>
            <if test="item.status != null ">
                status = #{item.status},
            </if>
            update_time = now()
        </foreach>
    </insert>

</mapper>
