<?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.fs.store.mapper.FsIntegralGoodsMapper">

    <resultMap type="FsIntegralGoods" id="FsIntegralGoodsResult">
        <result property="goodsId"    column="goods_id"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="images"    column="images"    />
        <result property="goodsName"    column="goods_name"    />
        <result property="otPrice"    column="ot_price"    />
        <result property="goodsType"    column="goods_type"    />
        <result property="status"    column="status"    />
        <result property="integral"    column="integral"    />
        <result property="sort"    column="sort"    />
        <result property="stock"    column="stock"    />
        <result property="descs"    column="descs"    />
        <result property="createTime"    column="create_time"    />
        <result property="barCode"    column="bar_code"    />
    </resultMap>

    <sql id="selectFsIntegralGoodsVo">
        select goods_id, img_url, images,bar_code, goods_name, ot_price, goods_type, status, integral, sort, stock, descs, create_time from fs_integral_goods
    </sql>

    <select id="selectFsIntegralGoodsList" parameterType="FsIntegralGoods" resultMap="FsIntegralGoodsResult">
        <include refid="selectFsIntegralGoodsVo"/>
        <where>
            <if test="goodsName != null  and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
            <if test="goodsType != null "> and goods_type = #{goodsType}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="integral != null "> and integral = #{integral}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
        </where>
    </select>

    <select id="selectFsIntegralGoodsByGoodsId" parameterType="Long" resultMap="FsIntegralGoodsResult">
        <include refid="selectFsIntegralGoodsVo"/>
        where goods_id = #{goodsId}
    </select>

    <insert id="insertFsIntegralGoods" parameterType="FsIntegralGoods">
        insert into fs_integral_goods
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="goodsId != null">goods_id,</if>
            <if test="imgUrl != null and imgUrl != ''">img_url,</if>
            <if test="images != null">images,</if>
            <if test="goodsName != null and goodsName != ''">goods_name,</if>
            <if test="otPrice != null">ot_price,</if>
            <if test="goodsType != null">goods_type,</if>
            <if test="status != null">status,</if>
            <if test="integral != null">integral,</if>
            <if test="sort != null">sort,</if>
            <if test="stock != null">stock,</if>
            <if test="descs != null">descs,</if>
            <if test="createTime != null">create_time,</if>
            <if test="barCode != null">bar_code,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="goodsId != null">#{goodsId},</if>
            <if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
            <if test="images != null">#{images},</if>
            <if test="goodsName != null and goodsName != ''">#{goodsName},</if>
            <if test="otPrice != null">#{otPrice},</if>
            <if test="goodsType != null">#{goodsType},</if>
            <if test="status != null">#{status},</if>
            <if test="integral != null">#{integral},</if>
            <if test="sort != null">#{sort},</if>
            <if test="stock != null">#{stock},</if>
            <if test="descs != null">#{descs},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="barCode != null">#{barCode},</if>
         </trim>
    </insert>

    <update id="updateFsIntegralGoods" parameterType="FsIntegralGoods">
        update fs_integral_goods
        <trim prefix="SET" suffixOverrides=",">
            <if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
            <if test="images != null">images = #{images},</if>
            <if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
            <if test="otPrice != null">ot_price = #{otPrice},</if>
            <if test="goodsType != null">goods_type = #{goodsType},</if>
            <if test="status != null">status = #{status},</if>
            <if test="integral != null">integral = #{integral},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="stock != null">stock = #{stock},</if>
            <if test="descs != null">descs = #{descs},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="barCode != null">bar_code = #{barCode},</if>
        </trim>
        where goods_id = #{goodsId}
    </update>

    <delete id="deleteFsIntegralGoodsByGoodsId" parameterType="Long">
        delete from fs_integral_goods where goods_id = #{goodsId}
    </delete>

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