123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?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.live.mapper.LiveGoodsMapper">
- <resultMap type="LiveGoods" id="LiveGoodsResult">
- <result property="goodsId" column="goods_id" />
- <result property="liveId" column="live_id" />
- <result property="companyId" column="company_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="storeId" column="store_id" />
- <result property="productId" column="product_id" />
- <result property="createTime" column="create_time" />
- <result property="createBy" column="create_by" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- <result property="status" column="status" />
- <result property="stock" column="stock" />
- <result property="sort" column="sort" />
- </resultMap>
- <sql id="selectLiveGoodsVo">
- select goods_id, live_id, company_id, company_user_id, store_id, product_id, create_time, create_by, update_by, update_time, remark, status, stock, sort from live_goods
- </sql>
- <select id="selectLiveGoodsList" parameterType="LiveGoods" resultMap="LiveGoodsResult">
- <include refid="selectLiveGoodsVo"/>
- <where>
- <if test="liveId != null "> and live_id = #{liveId}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="storeId != null "> and store_id = #{storeId}</if>
- <if test="productId != null "> and product_id = #{productId}</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="stock != null "> and stock = #{stock}</if>
- <if test="sort != null "> and sort = #{sort}</if>
- </where>
- </select>
- <select id="selectLiveGoodsByGoodsId" parameterType="Long" resultMap="LiveGoodsResult">
- <include refid="selectLiveGoodsVo"/>
- where goods_id = #{goodsId}
- </select>
- <insert id="insertLiveGoods" parameterType="LiveGoods" useGeneratedKeys="true" keyProperty="goodsId">
- insert into live_goods
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="liveId != null">live_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="storeId != null">store_id,</if>
- <if test="productId != null">product_id,</if>
- <if test="createTime != null">create_time,</if>
- <if test="createBy != null">create_by,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- <if test="status != null">status,</if>
- <if test="stock != null">stock,</if>
- <if test="sort != null">sort,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="liveId != null">#{liveId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="storeId != null">#{storeId},</if>
- <if test="productId != null">#{productId},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- <if test="status != null">#{status},</if>
- <if test="stock != null">#{stock},</if>
- <if test="sort != null">#{sort},</if>
- </trim>
- </insert>
- <update id="updateLiveGoods" parameterType="LiveGoods">
- update live_goods
- <trim prefix="SET" suffixOverrides=",">
- <if test="liveId != null">live_id = #{liveId},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="storeId != null">store_id = #{storeId},</if>
- <if test="productId != null">product_id = #{productId},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="status != null">status = #{status},</if>
- <if test="stock != null">stock = #{stock},</if>
- <if test="sort != null">sort = #{sort},</if>
- </trim>
- where goods_id = #{goodsId}
- </update>
- <delete id="deleteLiveGoodsByGoodsId" parameterType="Long">
- delete from live_goods where goods_id = #{goodsId}
- </delete>
- <delete id="deleteLiveGoodsByGoodsIds" parameterType="String">
- delete from live_goods where goods_id in
- <foreach item="goodsId" collection="array" open="(" separator="," close=")">
- #{goodsId}
- </foreach>
- </delete>
- <select id="selectStoreIdByLiveId" parameterType="Long" resultType="Long">
- select distinct store_id from live_goods where live_id = #{liveId}
- </select>
- <insert id="insertLiveGoodsList">
- INSERT INTO live_goods (
- live_id, company_id, company_user_id, store_id,
- product_id, create_time, create_by, update_by,
- update_time, remark, status, stock, sort
- ) VALUES
- <foreach collection="liveGoodsList" item="item" separator=",">
- (
- #{item.liveId}, #{item.companyId}, #{item.companyUserId}, #{item.storeId},
- #{item.productId}, #{item.createTime}, #{item.createBy}, #{item.updateBy},
- #{item.updateTime}, #{item.remark}, #{item.status}, #{item.stock}, #{item.sort}
- )
- </foreach>
- </insert>
- <select id="selectProductIdsByLiveId" resultType="string">
- SELECT product_id
- FROM live_goods
- WHERE live_id = #{liveId}
- </select>
- <select id="selectProductListByLiveId" parameterType="LiveGoods" resultType="com.fs.live.vo.LiveGoodsVo">
- select lg.goods_id,sp.img_url,sp.product_name,sp.price,sp.stock,sp.sales from live_goods lg
- LEFT JOIN fs_store_product sp
- ON lg.store_id = sp.store_id AND lg.product_id = sp.product_id
- <where>
- <if test="liveId != null "> and live_id = #{liveId}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="storeId != null "> and store_id = #{storeId}</if>
- <if test="productId != null "> and product_id = #{productId}</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="stock != null "> and stock = #{stock}</if>
- <if test="sort != null "> and sort = #{sort}</if>
- </where>
- </select>
- </mapper>
|