<?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="cn.iocoder.yudao.module.shop.mapper.ShopRepairGoodsMapper">

    <resultMap type="cn.iocoder.yudao.module.shop.entity.ShopRepairGoods" id="ShopRepairGoodsResult">
        <result property="id"    column="id"    />
        <result property="categoryId"    column="category_id"    />
        <result property="title"    column="title"    />
        <result property="price"    column="price"    />
        <result property="image"    column="image"    />
        <result property="images"    column="images"    />
        <result property="isSpecial"    column="is_special"    />
        <result property="goodsDesc"    column="goods_desc"    />
    </resultMap>

    <sql id="selectShopRepairGoodsVo">
        select id, category_id, title, price, image, images, is_special, goods_desc from shop_repair_goods
    </sql>

    <select id="selectShopRepairGoodsList" parameterType="cn.iocoder.yudao.module.shop.entity.ShopRepairGoods" resultMap="ShopRepairGoodsResult">
        <include refid="selectShopRepairGoodsVo"/>
        <where>
            <if test="categoryId != null "> and category_id = #{categoryId}</if>
            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
            <if test="isSpecial != null "> and is_special = #{isSpecial}</if>
        </where>
    </select>

    <select id="selectShopRepairGoodsById" parameterType="Long" resultMap="ShopRepairGoodsResult">
        <include refid="selectShopRepairGoodsVo"/>
        where id = #{id}
    </select>

    <insert id="insertShopRepairGoods" parameterType="cn.iocoder.yudao.module.shop.entity.ShopRepairGoods" useGeneratedKeys="true" keyProperty="id">
        insert into shop_repair_goods
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="categoryId != null">category_id,</if>
            <if test="title != null">title,</if>
            <if test="price != null">price,</if>
            <if test="image != null">image,</if>
            <if test="images != null">images,</if>
            <if test="isSpecial != null">is_special,</if>
            <if test="goodsDesc != null">goods_desc,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="categoryId != null">#{categoryId},</if>
            <if test="title != null">#{title},</if>
            <if test="price != null">#{price},</if>
            <if test="image != null">#{image},</if>
            <if test="images != null">#{images},</if>
            <if test="isSpecial != null">#{isSpecial},</if>
            <if test="goodsDesc != null">#{goodsDesc},</if>
         </trim>
    </insert>

    <update id="updateShopRepairGoods" parameterType="cn.iocoder.yudao.module.shop.entity.ShopRepairGoods">
        update shop_repair_goods
        <trim prefix="SET" suffixOverrides=",">
            <if test="categoryId != null">category_id = #{categoryId},</if>
            <if test="title != null">title = #{title},</if>
            <if test="price != null">price = #{price},</if>
            <if test="image != null">image = #{image},</if>
            <if test="images != null">images = #{images},</if>
            <if test="isSpecial != null">is_special = #{isSpecial},</if>
            <if test="goodsDesc != null">goods_desc = #{goodsDesc},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteShopRepairGoodsById" parameterType="Long">
        delete from shop_repair_goods where id = #{id}
    </delete>

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