<?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.fizz.business.mapper.SetupTmMeshMapper">

    <resultMap type="SetupTmMesh" id="SetupTmMeshResult">
        <result property="steelGrade"    column="steel_grade"    />
        <result property="yieldStren"    column="yield_stren"    />
        <result property="thick"    column="thick"    />
        <result property="value1"    column="value1"    />
        <result property="value2"    column="value2"    />
        <result property="value3"    column="value3"    />
        <result property="value4"    column="value4"    />
        <result property="value5"    column="value5"    />
        <result property="value6"    column="value6"    />
        <result property="value7"    column="value7"    />
        <result property="value8"    column="value8"    />
        <result property="value9"    column="value9"    />
        <result property="value10"    column="value10"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSetupTmMeshVo">
        select steel_grade, yield_stren, thick, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, update_time, create_time from setup_tm_mesh
    </sql>

    <select id="selectSetupTmMeshList" parameterType="SetupTmMesh" resultMap="SetupTmMeshResult">
        <include refid="selectSetupTmMeshVo"/>
        <where>
            <if test="value1 != null "> and value1 = #{value1}</if>
            <if test="value2 != null "> and value2 = #{value2}</if>
            <if test="value3 != null "> and value3 = #{value3}</if>
            <if test="value4 != null "> and value4 = #{value4}</if>
            <if test="value5 != null "> and value5 = #{value5}</if>
            <if test="value6 != null "> and value6 = #{value6}</if>
            <if test="value7 != null "> and value7 = #{value7}</if>
            <if test="value8 != null "> and value8 = #{value8}</if>
            <if test="value9 != null "> and value9 = #{value9}</if>
            <if test="value10 != null "> and value10 = #{value10}</if>
        </where>
    </select>

    <select id="selectSetupTmMeshBySteelGrade" parameterType="String" resultMap="SetupTmMeshResult">
        <include refid="selectSetupTmMeshVo"/>
        <where>
            <if test="steelGrade != null ">and steel_grade = #{steelGrade}</if>
            <if test="yieldStren != null ">and yield_stren = #{yieldStren}</if>
            <if test="thick != null ">and thick = #{thick}</if>
        </where>
    </select>

    <insert id="insertSetupTmMesh" parameterType="SetupTmMesh">
        insert into setup_tm_mesh
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="steelGrade != null">steel_grade,</if>
            <if test="yieldStren != null">yield_stren,</if>
            <if test="thick != null">thick,</if>
            <if test="value1 != null">value1,</if>
            <if test="value2 != null">value2,</if>
            <if test="value3 != null">value3,</if>
            <if test="value4 != null">value4,</if>
            <if test="value5 != null">value5,</if>
            <if test="value6 != null">value6,</if>
            <if test="value7 != null">value7,</if>
            <if test="value8 != null">value8,</if>
            <if test="value9 != null">value9,</if>
            <if test="value10 != null">value10,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="steelGrade != null">#{steelGrade},</if>
            <if test="yieldStren != null">#{yieldStren},</if>
            <if test="thick != null">#{thick},</if>
            <if test="value1 != null">#{value1},</if>
            <if test="value2 != null">#{value2},</if>
            <if test="value3 != null">#{value3},</if>
            <if test="value4 != null">#{value4},</if>
            <if test="value5 != null">#{value5},</if>
            <if test="value6 != null">#{value6},</if>
            <if test="value7 != null">#{value7},</if>
            <if test="value8 != null">#{value8},</if>
            <if test="value9 != null">#{value9},</if>
            <if test="value10 != null">#{value10},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateSetupTmMesh" parameterType="SetupTmMesh">
        update setup_tm_mesh
        <trim prefix="SET" suffixOverrides=",">
            <if test="value1 != null">value1 = #{value1},</if>
            <if test="value2 != null">value2 = #{value2},</if>
            <if test="value3 != null">value3 = #{value3},</if>
            <if test="value4 != null">value4 = #{value4},</if>
            <if test="value5 != null">value5 = #{value5},</if>
            <if test="value6 != null">value6 = #{value6},</if>
            <if test="value7 != null">value7 = #{value7},</if>
            <if test="value8 != null">value8 = #{value8},</if>
            <if test="value9 != null">value9 = #{value9},</if>
            <if test="value10 != null">value10 = #{value10},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where steel_grade = #{steelGrade} and yield_stren = #{yieldStren} and thick = #{thick}
    </update>

    <delete id="deleteSetupTmMeshBySteelGrade" parameterType="String">
        delete from setup_tm_mesh where steel_grade = #{steelGrade}
    </delete>

    <delete id="deleteSetupTmMeshBySteelGrades" parameterType="String">
        DELETE FROM setup_tm_mesh
        WHERE
        <foreach item="item" index="index" collection="steelGrades" open="(" separator=") OR (" close=")">
            thick = #{thicks[${index}]}
            AND steel_grade = #{steelGrades[${index}]}
            AND yield_stren = #{yieldStrens[${index}]}
        </foreach>
    </delete>

</mapper>