<?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.ruoyi.mall.mapper.MallGoodsSpecValueMapper">

    <resultMap type="MallGoodsSpecValue" id="MallGoodsSpecValueResult">
        <result property="id"    column="id"    />
        <result property="specId"    column="spec_id"    />
        <result property="value"    column="value"    />
        <result property="status"    column="status"    />
        <result property="sort"    column="sort"    />
        <result property="createAt"    column="create_at"    />
        <result property="updateAt"    column="update_at"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectMallGoodsSpecValueVo">
        select id, spec_id, `value`, status, sort, create_at, update_at, del_flag from mall_goods_spec_value
    </sql>

    <select id="selectMallGoodsSpecValueList" parameterType="MallGoodsSpecValue" resultMap="MallGoodsSpecValueResult">
        <include refid="selectMallGoodsSpecValueVo"/>
        <where>
            <if test="specId != null  and specId != ''"> and spec_id = #{specId}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
             and del_flag ='0'
        </where>
    </select>

    <select id="selectMallGoodsSpecValueById" parameterType="Long" resultMap="MallGoodsSpecValueResult">
        <include refid="selectMallGoodsSpecValueVo"/>
        where id = #{id}
    </select>

    <insert id="insertMallGoodsSpecValue" parameterType="MallGoodsSpecValue" useGeneratedKeys="true" keyProperty="id">
        insert into mall_goods_spec_value
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="specId != null">spec_id,</if>
            <if test="value != null">`value`,</if>
            <if test="status != null">status,</if>
            <if test="sort != null">sort,</if>
            <if test="createAt != null">create_at,</if>
            <if test="updateAt != null">update_at,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="specId != null">#{specId},</if>
            <if test="value != null">#{value},</if>
            <if test="status != null">#{status},</if>
            <if test="sort != null">#{sort},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="updateAt != null">#{updateAt},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallGoodsSpecValue" parameterType="MallGoodsSpecValue">
        update mall_goods_spec_value
        <trim prefix="SET" suffixOverrides=",">
            <if test="specId != null">spec_id = #{specId},</if>
            <if test="value != null">`value` = #{value},</if>
            <if test="status != null">status = #{status},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="updateAt != null">update_at = #{updateAt},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="removeBySpecId" parameterType="Long">
        update mall_goods_spec_value
        set  del_flag = '1'
        where spec_id = #{specId}
    </update>

    <delete id="deleteMallGoodsSpecValueById" parameterType="Long">
        delete from mall_goods_spec_value where id = #{id}
    </delete>

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