<?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.fibo.ddp.common.dao.approval.ApprovalConfigMapper">

    <resultMap type="com.fibo.ddp.common.model.approval.ApprovalConfig" id="ApprovalConfigMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="approvalType" column="approval_type" jdbcType="VARCHAR"/>
        <result property="approvalName" column="approval_name" jdbcType="VARCHAR"/>
        <result property="approvalDesc" column="approval_desc" jdbcType="VARCHAR"/>
        <result property="approvalStatus" column="approval_status" jdbcType="INTEGER"/>
        <result property="organId" column="organ_id" jdbcType="INTEGER"/>
        <result property="createUserId" column="create_user_id" jdbcType="INTEGER"/>
        <result property="updateUserId" column="update_user_id" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <!--新增所有列-->
    <insert id="insertOrUpdate" keyProperty="id" useGeneratedKeys="true">
        insert into riskmanage.t_approval_config(approval_type, approval_name, approval_desc, approval_status, organ_id, create_user_id, update_user_id, create_time, update_time)
        values (#{approvalType}, #{approvalName}, #{approvalDesc}, #{approvalStatus}, #{organId}, #{createUserId}, #{updateUserId}, #{createTime}, #{updateTime})
        on duplicate key update
        approval_type = values(approval_type) , approval_name = values(approval_name) , approval_desc =
        values(approval_desc) , approval_status = values(approval_status) , organ_id = values(organ_id) , create_user_id
        = values(create_user_id) , update_user_id = values(update_user_id) , create_time = values(create_time) ,
        update_time = values(update_time)
    </insert>


    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into riskmanage.t_approval_config(approval_type, approval_name, approval_desc, approval_status, organ_id,
        create_user_id, update_user_id )
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.approvalType}, #{entity.approvalName}, #{entity.approvalDesc}, #{entity.approvalStatus},
            #{entity.organId}, #{entity.createUserId}, #{entity.updateUserId})
        </foreach>
        on duplicate key update
        approval_type = values(approval_type) , approval_name = values(approval_name) , approval_desc =
        values(approval_desc) , approval_status = values(approval_status) , organ_id = values(organ_id) ,
        create_user_id = values(create_user_id) , update_user_id = values(update_user_id)
    </insert>

</mapper>

