<?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.vote.system.mapper.VoteFormTemplatesMapper">

    <resultMap id="BaseResultMap" type="com.vote.system.domain.VoteFormTemplates">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="templateName" column="template_name" jdbcType="VARCHAR"/>
        <result property="fieldName" column="field_name" jdbcType="VARCHAR"/>
        <result property="sortOrder" column="sort_order" jdbcType="INTEGER"/>
        <result property="templateJson" column="template_json" jdbcType="VARCHAR"/>
        <result property="images" column="images" jdbcType="VARCHAR"/>
        <result property="description" column="description" jdbcType="VARCHAR"/>
        <result property="status" column="status" jdbcType="TINYINT"/>
        <result property="isDeleted" column="is_deleted" jdbcType="VARCHAR"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,template_name,field_name,sort_order,template_json,
        images,description,status,
        created_at,updated_at
    </sql>
    <insert id="insertBatchSomeColumn">
        INSERT INTO vote_form_templates (template_name, field_name, sort_order, template_json, images, description,
        status)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="item.templateName != null">
                    #{item.templateName,jdbcType=VARCHAR}
                </if>
                <if test="item.fieldName != null">
                    ,#{item.fieldName,jdbcType=VARCHAR}
                </if>
                <if test="item.sortOrder != null">
                    ,#{item.sortOrder,jdbcType=INTEGER}
                </if>
                <if test="item.templateJson != null">
                    ,#{item.templateJson,jdbcType=VARCHAR}
                </if>
                <if test="item.images != null">
                    ,#{item.images,jdbcType=VARCHAR}
                </if>
                <if test="item.description != null">
                    ,#{item.description,jdbcType=VARCHAR}
                </if>
                <if test="item.status != null">
                    ,#{item.status,jdbcType=TINYINT}
                </if>
            </trim>
        </foreach>
    </insert>

</mapper>
