<?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.system.mapper.ShopGoodsMapper"> <resultMap type="ShopGoods" id="ShopGoodsResult"> <result property="id" column="id" /> <result property="shopId" column="shop_id" /> <result property="goodsId" column="goods_id" /> <result property="turn" column="turn" /> <result property="createdAt" column="created_at" /> <result property="updatedAt" column="updated_at" /> </resultMap> <sql id="selectShopGoodsVo"> select id, shop_id, goods_id, turn, created_at, updated_at from shop_goods </sql> <select id="selectShopGoodsList" parameterType="ShopGoods" resultMap="ShopGoodsResult"> <include refid="selectShopGoodsVo"/> <where> <if test="shopId != null and shopId != ''"> and shop_id = #{shopId}</if> <if test="goodsId != null and goodsId != ''"> and goods_id = #{goodsId}</if> <if test="turn != null and turn != ''"> and turn = #{turn}</if> <if test="createdAt != null "> and created_at = #{createdAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if> </where> </select> <select id="selectShopGoodsById" parameterType="String" resultMap="ShopGoodsResult"> <include refid="selectShopGoodsVo"/> where id = #{id} </select> <insert id="insertShopGoods" parameterType="ShopGoods" useGeneratedKeys="true" keyProperty="id"> insert into shop_goods <trim prefix="(" suffix=")" suffixOverrides=","> <if test="shopId != null and shopId != ''">shop_id,</if> <if test="goodsId != null and goodsId != ''">goods_id,</if> <if test="turn != null and turn != ''">turn,</if> <if test="createdAt != null">created_at,</if> <if test="updatedAt != null">updated_at,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="shopId != null and shopId != ''">#{shopId},</if> <if test="goodsId != null and goodsId != ''">#{goodsId},</if> <if test="turn != null and turn != ''">#{turn},</if> <if test="createdAt != null">#{createdAt},</if> <if test="updatedAt != null">#{updatedAt},</if> </trim> </insert> <update id="updateShopGoods" parameterType="ShopGoods"> update shop_goods <trim prefix="SET" suffixOverrides=","> <if test="shopId != null and shopId != ''">shop_id = #{shopId},</if> <if test="goodsId != null and goodsId != ''">goods_id = #{goodsId},</if> <if test="turn != null and turn != ''">turn = #{turn},</if> <if test="createdAt != null">created_at = #{createdAt},</if> <if test="updatedAt != null">updated_at = #{updatedAt},</if> </trim> where id = #{id} </update> <delete id="deleteShopGoodsById" parameterType="String"> delete from shop_goods where id = #{id} </delete> <delete id="deleteShopGoodsByIds" parameterType="String"> delete from shop_goods where id in <foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> </delete> <select id="selectShopCategoryGoods" resultType="com.ruoyi.system.domain.Goods"> select g.* from shop_goods sg ,goods g where sg.goods_id =g.id and g.state ='1' and g.is_deleted =0 and shop_id =#{shopId} order by sg.turn </select> <select id="selectShopCategoryGoodsByCategoryId" resultType="com.ruoyi.system.domain.Goods"> select g.id, g.name, g.category, g.price, g.discount, g.take_time, g.spec, g.pics, g.`desc`, g.remarks, sg.state, g.code from shop_goods sg ,goods g where sg.goods_id =g.id and g.state ='1' and g.is_deleted =0 and shop_id =#{shopId} and category =#{categoryId} order by sg.turn </select> </mapper>