<?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.younike.system.mapper.GoodsSpecificationMapper">
    
    <resultMap type="com.younike.system.domain.GoodsSpecification" id="GoodsSpecificationResult">
        <result property="goodsSpecificationId"    column="goods_specification_id"    />
        <result property="specificationDesc"    column="specification_desc"    />
        <result property="times"    column="times"    />
        <result property="currentPrice"    column="current_price"    />
        <result property="scribingPrice"    column="scribing_price"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="merchantId"    column="merchant_id"    />
        <result property="delFlag"    column="del_flag"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectGoodsSpecificationVo">
        select goods_specification_id, specification_desc, times, current_price, scribing_price, goods_id, merchant_id, del_flag, create_by, create_time, update_by, update_time, remark from goods_specification
    </sql>

    <select id="selectGoodsSpecificationList" parameterType="com.younike.system.domain.GoodsSpecification" resultMap="GoodsSpecificationResult">
        <include refid="selectGoodsSpecificationVo"/>
        <where>  
            <if test="specificationDesc != null  and specificationDesc != ''"> and specification_desc = #{specificationDesc}</if>
            <if test="times != null "> and times = #{times}</if>
            <if test="currentPrice != null "> and current_price = #{currentPrice}</if>
            <if test="scribingPrice != null "> and scribing_price = #{scribingPrice}</if>
            <if test="goodsId != null "> and goods_id = #{goodsId}</if>
            <if test="merchantId != null "> and merchant_id = #{merchantId}</if>
        </where>
    </select>
    
    <select id="selectGoodsSpecificationByGoodsSpecificationId" parameterType="Long" resultMap="GoodsSpecificationResult">
        <include refid="selectGoodsSpecificationVo"/>
        where goods_specification_id = #{goodsSpecificationId}
    </select>
        
    <insert id="insertGoodsSpecification" parameterType="com.younike.system.domain.GoodsSpecification" useGeneratedKeys="true" keyProperty="goodsSpecificationId">
        insert into goods_specification
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="specificationDesc != null and specificationDesc != ''">specification_desc,</if>
            <if test="times != null">times,</if>
            <if test="currentPrice != null">current_price,</if>
            <if test="scribingPrice != null">scribing_price,</if>
            <if test="goodsId != null">goods_id,</if>
            <if test="merchantId != null">merchant_id,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="specificationDesc != null and specificationDesc != ''">#{specificationDesc},</if>
            <if test="times != null">#{times},</if>
            <if test="currentPrice != null">#{currentPrice},</if>
            <if test="scribingPrice != null">#{scribingPrice},</if>
            <if test="goodsId != null">#{goodsId},</if>
            <if test="merchantId != null">#{merchantId},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateGoodsSpecification" parameterType="com.younike.system.domain.GoodsSpecification">
        update goods_specification
        <trim prefix="SET" suffixOverrides=",">
            <if test="specificationDesc != null and specificationDesc != ''">specification_desc = #{specificationDesc},</if>
            <if test="times != null">times = #{times},</if>
            <if test="currentPrice != null">current_price = #{currentPrice},</if>
            <if test="scribingPrice != null">scribing_price = #{scribingPrice},</if>
            <if test="goodsId != null">goods_id = #{goodsId},</if>
            <if test="merchantId != null">merchant_id = #{merchantId},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where goods_specification_id = #{goodsSpecificationId}
    </update>

    <delete id="deleteGoodsSpecificationByGoodsSpecificationId" parameterType="Long">
        delete from goods_specification where goods_specification_id = #{goodsSpecificationId}
    </delete>

    <delete id="deleteGoodsSpecificationByGoodsSpecificationIds" parameterType="String">
        delete from goods_specification where goods_specification_id in 
        <foreach item="goodsSpecificationId" collection="array" open="(" separator="," close=")">
            #{goodsSpecificationId}
        </foreach>
    </delete>


</mapper>