<?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.GoodsServerDimensionMapper">

    <resultMap type="com.younike.system.domain.GoodsServerDimension" id="GoodsServerDimensionResult">
        <result property="id"    column="id"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="dimensionId"    column="dimension_id"    />
        <result property="score"    column="score"    />
        <result property="serverId"    column="server_id"    />
        <result property="isDel"    column="is_del"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="version"    column="version"    />
    </resultMap>
    <resultMap type="com.younike.system.domain.vo.GoodsServerDimensionVo" id="GoodsServerDimensionVoResult">
        <result property="id"    column="id"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="dimensionId"    column="dimension_id"    />
        <result property="score"    column="score"    />
        <result property="serverId"    column="server_id"    />
        <result property="isDel"    column="is_del"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="version"    column="version"    />
        <result property="dimensionName"    column="dimensionName"    />

    </resultMap>



    <sql id="selectGoodsServerDimensionVo">
        select id, goods_id, dimension_id, score, server_id, is_del, create_time, update_time, version from goods_server_dimension
    </sql>

    <select id="selectGoodsServerDimensionList" parameterType="com.younike.system.domain.GoodsServerDimension" resultMap="GoodsServerDimensionResult">
        <include refid="selectGoodsServerDimensionVo"/>
        <where>
            <if test="goodsId != null "> and goods_id = #{goodsId}</if>
            <if test="dimensionId != null  and dimensionId != ''"> and dimension_id = #{dimensionId}</if>
            <if test="score != null "> and score = #{score}</if>
            <if test="serverId != null "> and server_id = #{serverId}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="version != null "> and version = #{version}</if>
        </where>
    </select>

    <select id="selectGoodsServerDimensionById" parameterType="Long" resultMap="GoodsServerDimensionResult">
        <include refid="selectGoodsServerDimensionVo"/>
        where id = #{id}
    </select>

    <insert id="insertGoodsServerDimension" parameterType="com.younike.system.domain.GoodsServerDimension" useGeneratedKeys="true" keyProperty="id">
        insert into goods_server_dimension
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="goodsId != null">goods_id,</if>
            <if test="dimensionId != null and dimensionId != ''">dimension_id,</if>
            <if test="score != null">score,</if>
            <if test="serverId != null">server_id,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="version != null">version,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="goodsId != null">#{goodsId},</if>
            <if test="dimensionId != null and dimensionId != ''">#{dimensionId},</if>
            <if test="score != null">#{score},</if>
            <if test="serverId != null">#{serverId},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="version != null">#{version},</if>
         </trim>
    </insert>

    <update id="updateGoodsServerDimension" parameterType="com.younike.system.domain.GoodsServerDimension">
        update goods_server_dimension
        <trim prefix="SET" suffixOverrides=",">
            <if test="goodsId != null">goods_id = #{goodsId},</if>
            <if test="dimensionId != null and dimensionId != ''">dimension_id = #{dimensionId},</if>
            <if test="score != null">score = #{score},</if>
            <if test="serverId != null">server_id = #{serverId},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="version != null">version = #{version},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGoodsServerDimensionById" parameterType="Long">
        delete from goods_server_dimension where id = #{id}
    </delete>

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