<?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.ximai.mes.md.mapper.MdProductLookMapper">

    <resultMap type="MdProductLook" id="MdProductLookResult">
        <result property="itemId"    column="item_id"    />
        <result property="length"    column="length"    />
        <result property="width"    column="width"    />
        <result property="height"    column="height"    />
        <result property="thick"    column="thick"    />
        <result property="weight"    column="weight"    />
        <result property="angleType"    column="angle_type"    />
        <result property="isAllotype"    column="is_allotype"    />
        <result property="isRightAngle"    column="is_right_angle"    />
        <result property="fillet"    column="fillet"    />
        <result property="angle"    column="angle"    />
        <result property="aperture"    column="aperture"    />
        <result property="singleLayerThick"    column="single_layer_thick"    />
        <result property="singleWeight"    column="single_weight"    />
        <result property="layerNum"    column="layer_num"    />
        <result property="isMould"    column="is_mould"    />
        <result property="isCoding"    column="is_coding"    />
        <result property="certification"    column="certification"    />
        <result property="shape"    column="shape"    />
        <result property="shapeSize"    column="shape_size"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="frontImg"    column="front_img"    />
        <result property="backImg"    column="back_img"    />
        <result property="frontColorName"    column="front_color_name"    />
        <result property="oppositeColorName"    column="opposite_color_name"    />
        <result property="coefficient"    column="coefficient"    />

    </resultMap>

    <sql id="selectMdProductLookVo">
        select item_id, length, width, height, front_img, back_img, front_color_name, opposite_color_name, coefficient, thick, weight, angle_type,is_allotype,is_right_angle,fillet, angle, aperture, single_layer_thick, single_weight, layer_num, is_mould, is_coding, certification, shape, shape_size, create_by, create_time, update_by, update_time from md_product_look
    </sql>

    <select id="selectMdProductLookList" parameterType="MdProductLook" resultMap="MdProductLookResult">
        <include refid="selectMdProductLookVo"/>
        <where>
            <if test="itemId != null "> and item_id = #{itemId}</if>
            <if test="length != null "> and length = #{length}</if>
            <if test="width != null "> and width = #{width}</if>
            <if test="height != null "> and height = #{height}</if>
            <if test="thick != null "> and thick = #{thick}</if>
            <if test="weight != null "> and weight = #{weight}</if>
            <if test="angleType != null  and angleType != ''"> and angle_type = #{angleType}</if>
            <if test="angle != null "> and angle = #{angle}</if>
            <if test="aperture != null "> and aperture = #{aperture}</if>
            <if test="singleLayerThick != null "> and single_layer_thick = #{singleLayerThick}</if>
            <if test="singleWeight != null "> and single_weight = #{singleWeight}</if>
            <if test="layerNum != null "> and layer_num = #{layerNum}</if>
            <if test="isMould != null  and isMould != ''"> and is_mould = #{isMould}</if>
            <if test="isCoding != null  and isCoding != ''"> and is_coding = #{isCoding}</if>
            <if test="certification != null  and certification != ''"> and certification = #{certification}</if>
            <if test="shape != null  and shape != ''"> and shape = #{shape}</if>
            <if test="shapeSize != null "> and shape_size = #{shapeSize}</if>
        </where>
    </select>

    <select id="selectMdProductLookByItemId" parameterType="Long" resultMap="MdProductLookResult">
        <include refid="selectMdProductLookVo"/>
        where item_id = #{itemId}
    </select>

    <insert id="insertMdProductLook" parameterType="MdProductLook">
        insert into md_product_look
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="itemId != null">item_id,</if>
            <if test="length != null">length,</if>
            <if test="width != null">width,</if>
            <if test="height != null">height,</if>
            <if test="thick != null">thick,</if>
            <if test="weight != null">weight,</if>
            <if test="angleType != null">angle_type,</if>
            <if test="isAllotype != null">is_allotype,</if>
            <if test="isRightAngle != null">is_right_angle,</if>
            <if test="fillet != null">fillet,</if>
            <if test="angle != null">angle,</if>
            <if test="aperture != null">aperture,</if>
            <if test="singleLayerThick != null">single_layer_thick,</if>
            <if test="singleWeight != null">single_weight,</if>
            <if test="layerNum != null">layer_num,</if>
            <if test="isMould != null">is_mould,</if>
            <if test="isCoding != null">is_coding,</if>
            <if test="certification != null">certification,</if>
            <if test="shape != null">shape,</if>
            <if test="shapeSize != null">shape_size,</if>
            <if test="createBy != null">create_by,</if>
            <if test="frontImg != null">front_img,</if>
            <if test="backImg != null">back_img,</if>
            <if test="frontColorName != null">front_color_name,</if>
            <if test="oppositeColorName != null">opposite_color_name,</if>
            <if test="coefficient != null">coefficient,</if>
            create_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="itemId != null">#{itemId},</if>
            <if test="length != null">#{length},</if>
            <if test="width != null">#{width},</if>
            <if test="height != null">#{height},</if>
            <if test="thick != null">#{thick},</if>
            <if test="weight != null">#{weight},</if>
            <if test="angleType != null">#{angleType},</if>
            <if test="isAllotype != null">#{isAllotype},</if>
            <if test="isRightAngle != null">#{isRightAngle},</if>
            <if test="fillet != null">#{fillet},</if>
            <if test="angle != null">#{angle},</if>
            <if test="aperture != null">#{aperture},</if>
            <if test="singleLayerThick != null">#{singleLayerThick},</if>
            <if test="singleWeight != null">#{singleWeight},</if>
            <if test="layerNum != null">#{layerNum},</if>
            <if test="isMould != null">#{isMould},</if>
            <if test="isCoding != null">#{isCoding},</if>
            <if test="certification != null">#{certification},</if>
            <if test="shape != null">#{shape},</if>
            <if test="shapeSize != null">#{shapeSize},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="frontImg != null">#{frontImg},</if>
            <if test="backImg != null">#{backImg},</if>
            <if test="frontColorName != null">#{frontColorName},</if>
            <if test="oppositeColorName != null">#{oppositeColorName},</if>
            <if test="coefficient != null">#{coefficient},</if>
            sysdate()
         </trim>
    </insert>

    <update id="updateMdProductLook" parameterType="MdProductLook">
        update md_product_look
        <trim prefix="SET" suffixOverrides=",">
            <if test="length != null">length = #{length},</if>
            <if test="width != null">width = #{width},</if>
            <if test="height != null">height = #{height},</if>
            <if test="thick != null">thick = #{thick},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="angleType != null">angle_type = #{angleType},</if>
            <if test="isAllotype != null">is_allotype = #{isAllotype},</if>
            <if test="isRightAngle != null">is_right_angle = #{isRightAngle},</if>
            <if test="fillet != null">fillet = #{fillet},</if>
            <if test="angle != null">angle = #{angle},</if>
            <if test="aperture != null">aperture = #{aperture},</if>
            <if test="singleLayerThick != null">single_layer_thick = #{singleLayerThick},</if>
            <if test="singleWeight != null">single_weight = #{singleWeight},</if>
            <if test="layerNum != null">layer_num = #{layerNum},</if>
            <if test="isMould != null">is_mould = #{isMould},</if>
            <if test="isCoding != null">is_coding = #{isCoding},</if>
            <if test="certification != null">certification = #{certification},</if>
            <if test="shape != null">shape = #{shape},</if>
            <if test="shapeSize != null">shape_size = #{shapeSize},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="frontImg != null">front_img = #{frontImg},</if>
            <if test="backImg != null">back_img = #{backImg},</if>
            <if test="frontColorName != null">front_color_name =#{frontColorName},</if>
            <if test="oppositeColorName != null">opposite_color_name = #{oppositeColorName},</if>
            <if test="coefficient != null">coefficient = #{coefficient},</if>
            update_time = sysdate()
        </trim>
        where item_id = #{itemId}
    </update>

    <delete id="deleteMdProductLookByItemId" parameterType="Long">
        delete from md_product_look where item_id = #{itemId}
    </delete>

    <delete id="deleteMdProductLookByItemIds" parameterType="String">
        delete from md_product_look where item_id in
        <foreach item="itemId" collection="array" open="(" separator="," close=")">
            #{itemId}
        </foreach>
    </delete>
</mapper>
