Selaa lähdekoodia

小小训练营活动
直播间商品

zouxuan 3 vuotta sitten
vanhempi
commit
fe71a7882e

+ 0 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LiveGoodsMapperDto.java

@@ -38,9 +38,6 @@ public class LiveGoodsMapperDto {
     @ApiModelProperty(value = "状态(1,上下架  0,下架)",required = false)
     private Boolean status = false;
 
-    @ApiModelProperty(value = "直播间销售价",required = false)
-    private BigDecimal livePrice;
-
     public Integer getId() {
         return id;
     }
@@ -128,12 +125,4 @@ public class LiveGoodsMapperDto {
     public void setStatus(Boolean status) {
         this.status = status;
     }
-
-    public BigDecimal getLivePrice() {
-        return livePrice;
-    }
-
-    public void setLivePrice(BigDecimal livePrice) {
-        this.livePrice = livePrice;
-    }
 }

+ 10 - 121
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LiveGoods.java

@@ -13,23 +13,11 @@ public class LiveGoods {
 
 	@ApiModelProperty(value = "商品编号",required = false)
 	private Integer id;
-	
-	@ApiModelProperty(value = "产品分类",required = false)
-	private Integer goodsCategoryId;
-	
-	@ApiModelProperty(value = "商品货号",required = false)
-	private String sn;
-	
+
 	@ApiModelProperty(value = "商品名称",required = true)
 	@NotBlank(message = "商品名称不可为空")
 	private String name;
-	
-	@ApiModelProperty(value = "品牌",required = false)
-	private String brand;
-	
-	@ApiModelProperty(value = "规格",required = false)
-	private String specification;
-	
+
 	@ApiModelProperty(value = "展示图片的地址",required = true)
 	@NotBlank(message = "图片地址不可为空")
 	private String image;
@@ -49,27 +37,12 @@ public class LiveGoods {
 	@NotNull(message = "原价不可为空")
 	private java.math.BigDecimal originalPrice;
 	
-	@ApiModelProperty(value = "页面简介",required = false)
-	private String brief;
+	@ApiModelProperty(value = "商品详情链接",required = false)
+	private String goodsDetailUrl;
 	
 	@ApiModelProperty(value = "商品的详细描述",required = false)
 	private String desc;
-	
-	@ApiModelProperty(value = "是否是新品(1,是  0,否)",required = false)
-	private Boolean newFlag = false;
-	
-	@ApiModelProperty(value = "是否置顶(1,置顶   0,不置顶)",required = false)
-	private Boolean topFlag = false;
-	
-	@ApiModelProperty(value = "状态(1,上下架  0,下架)",required = false)
-	private Boolean status = false;
-	
-	@ApiModelProperty(value = "备注",required = false)
-	private String memo;
-	
-	@ApiModelProperty(value = "发布时间",required = false)
-	private java.util.Date publishTime;
-	
+
 	@ApiModelProperty(value = "创建时间",required = false)
 	private java.util.Date createTime;
 	
@@ -78,32 +51,13 @@ public class LiveGoods {
 	
 	@ApiModelProperty(value = "机构",required = false)
 	private Integer tenantId;
-	
-	@ApiModelProperty(value = "附件商品列表编号(用逗号分开)",required = false)
-	private String complementGoodsIdList;
-
-	public Boolean getNewFlag() {
-		return newFlag;
-	}
-
-	public void setNewFlag(Boolean newFlag) {
-		this.newFlag = newFlag;
-	}
-
-	public Boolean getTopFlag() {
-		return topFlag;
-	}
 
-	public void setTopFlag(Boolean topFlag) {
-		this.topFlag = topFlag;
+	public String getGoodsDetailUrl() {
+		return goodsDetailUrl;
 	}
 
-	public Boolean getStatus() {
-		return status;
-	}
-
-	public void setStatus(Boolean status) {
-		this.status = status;
+	public void setGoodsDetailUrl(String goodsDetailUrl) {
+		this.goodsDetailUrl = goodsDetailUrl;
 	}
 
 	public void setId(Integer id){
@@ -113,23 +67,7 @@ public class LiveGoods {
 	public Integer getId(){
 		return this.id;
 	}
-			
-	public void setGoodsCategoryId(Integer goodsCategoryId){
-		this.goodsCategoryId = goodsCategoryId;
-	}
-	
-	public Integer getGoodsCategoryId(){
-		return this.goodsCategoryId;
-	}
-			
-	public void setSn(String sn){
-		this.sn = sn;
-	}
-	
-	public String getSn(){
-		return this.sn;
-	}
-			
+
 	public void setName(String name){
 		this.name = name;
 	}
@@ -138,22 +76,6 @@ public class LiveGoods {
 		return this.name;
 	}
 			
-	public void setBrand(String brand){
-		this.brand = brand;
-	}
-	
-	public String getBrand(){
-		return this.brand;
-	}
-			
-	public void setSpecification(String specification){
-		this.specification = specification;
-	}
-	
-	public String getSpecification(){
-		return this.specification;
-	}
-			
 	public void setImage(String image){
 		this.image = image;
 	}
@@ -194,14 +116,6 @@ public class LiveGoods {
 		return this.originalPrice;
 	}
 			
-	public void setBrief(String brief){
-		this.brief = brief;
-	}
-	
-	public String getBrief(){
-		return this.brief;
-	}
-			
 	public void setDesc(String desc){
 		this.desc = desc;
 	}
@@ -210,22 +124,6 @@ public class LiveGoods {
 		return this.desc;
 	}
 
-	public void setMemo(String memo){
-		this.memo = memo;
-	}
-	
-	public String getMemo(){
-		return this.memo;
-	}
-			
-	public void setPublishTime(java.util.Date publishTime){
-		this.publishTime = publishTime;
-	}
-	
-	public java.util.Date getPublishTime(){
-		return this.publishTime;
-	}
-			
 	public void setCreateTime(java.util.Date createTime){
 		this.createTime = createTime;
 	}
@@ -249,15 +147,6 @@ public class LiveGoods {
 	public Integer getTenantId(){
 		return this.tenantId;
 	}
-			
-	public void setComplementGoodsIdList(String complementGoodsIdList){
-		this.complementGoodsIdList = complementGoodsIdList;
-	}
-	
-	public String getComplementGoodsIdList(){
-		return this.complementGoodsIdList;
-	}
-			
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 0 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/LiveGoodsMapper.java

@@ -19,9 +19,6 @@ public class LiveGoodsMapper {
 	/** 销量 */
 	private Integer sellCount;
 	
-	/** 直播间销售价 */
-	private java.math.BigDecimal livePrice;
-	
 	/** 状态(1,上架  0,下架) */
 	private Boolean status = false;
 	
@@ -62,14 +59,6 @@ public class LiveGoodsMapper {
 	public Integer getSellCount(){
 		return this.sellCount;
 	}
-			
-	public void setLivePrice(java.math.BigDecimal livePrice){
-		this.livePrice = livePrice;
-	}
-	
-	public java.math.BigDecimal getLivePrice(){
-		return this.livePrice;
-	}
 
 	public Boolean getStatus() {
 		return status;

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/LiveGoodsMapperQueryInfo.java

@@ -0,0 +1,16 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class LiveGoodsMapperQueryInfo extends QueryInfo {
+
+    private Boolean status;
+
+    public Boolean getStatus() {
+        return status;
+    }
+
+    public void setStatus(Boolean status) {
+        this.status = status;
+    }
+}

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LiveGoodsMapperService.java

@@ -3,6 +3,9 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.LiveGoodsMapper;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.Collection;
+import java.util.List;
+
 public interface LiveGoodsMapperService extends BaseService<Integer, LiveGoodsMapper> {
 
     void add(LiveGoodsMapper liveGoodsMapper);
@@ -13,4 +16,5 @@ public interface LiveGoodsMapperService extends BaseService<Integer, LiveGoodsMa
 
     void upGoods(Integer liveGoodsId, String liveId);
 
+    List<LiveGoodsMapper> findByLiveGoodsIdAndStatus(Integer goodsId, Boolean status);
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/LiveGoodsService.java

@@ -7,5 +7,5 @@ public interface LiveGoodsService extends BaseService<Integer, LiveGoods> {
 
     void updateLiveGoods(LiveGoods liveGoods);
 
-    void updateStatus(Integer liveGoodsId, Boolean status);
+    void deleteLiveGoods(Integer goodsId);
 }

+ 10 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LiveGoodsMapperServiceImpl.java

@@ -49,13 +49,18 @@ public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoo
 				.of(imLiveBroadcastRoomService.getBaseMapper().selectOne(new QueryWrapper<ImLiveBroadcastRoom>().eq("room_uid_",liveId))).
 				orElseThrow(() -> new RuntimeException("直播间不存在"));
 		//通知直播间商品上架
-		this.publishRoomMsg(imLiveBroadcastRoom,ImRoomMessage.LIVE_GOODS_UP);
+		this.publishRoomMsg(imLiveBroadcastRoom);
 	}
 
-	private void publishRoomMsg(ImLiveBroadcastRoom imLiveBroadcastRoom,String msgType) {
+	@Override
+	public List<LiveGoodsMapper> findByLiveGoodsIdAndStatus(Integer goodsId, Boolean status) {
+		return liveGoodsMapperDao.findByLiveGoodsIdAndStatus(goodsId,status);
+	}
+
+	private void publishRoomMsg(ImLiveBroadcastRoom imLiveBroadcastRoom) {
 		ImRoomMessage message = new ImRoomMessage();
 		message.setIsIncludeSender(1);
-		message.setObjectName(msgType);
+		message.setObjectName(ImRoomMessage.LIVE_GOODS_CHANGE);
 		message.setToChatroomId(imLiveBroadcastRoom.getRoomUid());
 		message.setFromUserId(imLiveBroadcastRoom.getSpeakerId().toString());
 		message.setContent(liveGoodsMapperDao.getLiveGoodsList(imLiveBroadcastRoom.getRoomUid()));
@@ -76,7 +81,7 @@ public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoo
 		//下架直播间商品
 		liveGoodsMapperDao.updateStatus(liveId,liveGoodsId,false);
 		//通知直播间,商品下架
-		this.publishRoomMsg(imLiveBroadcastRoom,ImRoomMessage.LIVE_GOODS_DOWN);
+		this.publishRoomMsg(imLiveBroadcastRoom);
 	}
 
 	@Override
@@ -91,7 +96,7 @@ public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoo
 				ImLiveBroadcastRoom imLiveBroadcastRoom = Optional
 						.of(imLiveBroadcastRoomService.getBaseMapper().selectOne(new QueryWrapper<ImLiveBroadcastRoom>().eq("room_uid_",liveGoodsMapper.getLiveId()))).
 						orElseThrow(() -> new RuntimeException("直播间不存在"));
-				this.publishRoomMsg(imLiveBroadcastRoom,ImRoomMessage.LIVE_GOODS_DOWN);
+				this.publishRoomMsg(imLiveBroadcastRoom);
 			}
 		}
 	}

+ 13 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LiveGoodsServiceImpl.java

@@ -1,20 +1,16 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.dao.LiveGoodsMapperDao;
-import com.ym.mec.biz.dal.entity.LiveGoodsMapper;
+import com.ym.mec.biz.dal.dao.LiveGoodsDao;
+import com.ym.mec.biz.dal.entity.LiveGoods;
 import com.ym.mec.biz.service.LiveGoodsMapperService;
+import com.ym.mec.biz.service.LiveGoodsService;
 import com.ym.mec.common.dal.BaseDAO;
-import org.springframework.beans.factory.annotation.Autowired;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.biz.dal.entity.LiveGoods;
-import com.ym.mec.biz.service.LiveGoodsService;
-import com.ym.mec.biz.dal.dao.LiveGoodsDao;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.List;
 import java.util.Optional;
-import java.util.stream.Collectors;
 
 @Service
 public class LiveGoodsServiceImpl extends BaseServiceImpl<Integer, LiveGoods>  implements LiveGoodsService {
@@ -34,19 +30,20 @@ public class LiveGoodsServiceImpl extends BaseServiceImpl<Integer, LiveGoods>  i
     public void updateLiveGoods(LiveGoods liveGoods) {
 		Optional.of(liveGoodsDao.get(liveGoods.getId())).orElseThrow(() -> new RuntimeException("商品信息不存在"));
 		//下架直播间商品,并通知直播间
-		if (!liveGoods.getStatus()) liveGoodsMapperService.downGoods(liveGoods.getId());
+//		if (!liveGoods.getStatus()) liveGoodsMapperService.downGoods(liveGoods.getId());
 		//更新商品信息
 		liveGoodsDao.update(liveGoods);
+		//通知直播间
+		liveGoodsMapperService.downGoods(liveGoods.getId());
 	}
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void updateStatus(Integer liveGoodsId, Boolean status) {
-		LiveGoods liveGoods = Optional.of(liveGoodsDao.get(liveGoodsId)).
-				orElseThrow(() -> new RuntimeException("商品信息不存在"));
-		//下架直播间商品,并通知直播间
-		if (!status) liveGoodsMapperService.downGoods(liveGoodsId);
-		liveGoods.setStatus(status);
-		liveGoodsDao.update(liveGoods);
+	public void deleteLiveGoods(Integer goodsId) {
+		//如果商品没有被直播间使用,则删除商品
+		if (liveGoodsMapperService.findByLiveGoodsIdAndStatus(goodsId,null).size() > 0) {
+			throw new RuntimeException("商品已被直播间使用,不能删除");
+		}
+		liveGoodsDao.delete(goodsId);
 	}
 }

+ 28 - 55
mec-biz/src/main/resources/config/mybatis/LiveGoodsMapper.xml

@@ -8,24 +8,14 @@
 	
 	<resultMap type="com.ym.mec.biz.dal.entity.LiveGoods" id="LiveGoods">
 		<result column="id_" property="id" />
-		<result column="goods_category_id_" property="goodsCategoryId" />
-		<result column="sn_" property="sn" />
 		<result column="name_" property="name" />
-		<result column="brand_" property="brand" />
-		<result column="specification_" property="specification" />
 		<result column="image_" property="image" />
 		<result column="stock_count_" property="stockCount" />
 		<result column="sell_count_" property="sellCount" />
 		<result column="current_price_" property="currentPrice" />
 		<result column="original_price_" property="originalPrice" />
-		<result column="brief_" property="brief" />
+		<result column="goods_detail_url_" property="goodsDetailUrl" />
 		<result column="desc_" property="desc" />
-		<result column="new_flag_" property="newFlag" />
-		<result column="top_flag_" property="topFlag" />
-		<result column="status_" property="status" />
-		<result column="memo_" property="memo" />
-		<result column="publish_time_" property="publishTime" />
-		<result column="complement_goods_id_list_" property="complementGoodsIdList" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 		<result column="tenant_id_" property="tenantId" />
@@ -43,70 +33,42 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LiveGoods" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO live_goods (goods_category_id_,sn_,name_,brand_,specification_,image_,stock_count_,sell_count_,current_price_,
-		                        original_price_,brief_,desc_,new_flag_,top_flag_,status_,memo_,publish_time_,complement_goods_id_list_,
+		INSERT INTO live_goods (name_,image_,stock_count_,sell_count_,current_price_,
+		                        original_price_,goods_detail_url_,desc_,
 		                        create_time_,update_time_,tenant_id_)
-		VALUES(#{id},#{goodsCategoryId},#{sn},#{name},#{brand},#{specification},#{image},#{stockCount},#{sellCount},#{currentPrice},
-		       #{originalPrice},#{brief},#{desc},#{newFlag},#{topFlag},#{status},#{memo},NOW(),#{complementGoodsIdList},
-		       NOW(),NOW(),#{tenantId})
+		VALUES(#{name},#{image},#{stockCount},#{sellCount},#{currentPrice},
+		       #{originalPrice},#{goodsDetailUrl},#{desc},NOW(),NOW(),#{tenantId})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.LiveGoods">
 		UPDATE live_goods <set>
-		<if test="specification != null">
-		specification_ = #{specification},
-		</if>
-		<if test="status != null">
-		status_ = #{status},
-		</if>
-		<if test="topFlag != null">
-		top_flag_ = #{topFlag},
-		</if>
-		<if test="newFlag != null">
-		new_flag_ = #{newFlag},
-		</if>
-		<if test="sn != null">
-		sn_ = #{sn},
-		</if>
 		<if test="tenantId != null">
-		tenant_id_ = #{tenantId},
+			tenant_id_ = #{tenantId},
 		</if>
 		<if test="originalPrice != null">
-		original_price_ = #{originalPrice},
-		</if>
-		<if test="memo != null">
-		memo_ = #{memo},
+			original_price_ = #{originalPrice},
 		</if>
 		<if test="name != null">
-		name_ = #{name},
-		</if>
-		<if test="complementGoodsIdList != null">
-		complement_goods_id_list_ = #{complementGoodsIdList},
+			name_ = #{name},
 		</if>
 		<if test="stockCount != null">
-		stock_count_ = #{stockCount},
+			stock_count_ = #{stockCount},
 		</if>
 		<if test="currentPrice != null">
-		current_price_ = #{currentPrice},
-		</if>
-		<if test="goodsCategoryId != null">
-		goods_category_id_ = #{goodsCategoryId},
-		</if>
-		<if test="brand != null">
-		brand_ = #{brand},
-		</if>
-		<if test="brief != null">
-		brief_ = #{brief},
+			current_price_ = #{currentPrice},
 		</if>
 		<if test="sellCount != null">
-		sell_count_ = #{sellCount},
+			sell_count_ = #{sellCount},
 		</if>
 		<if test="image != null">
-		image_ = #{image},
+			image_ = #{image},
 		</if>
 		<if test="desc != null">
-		desc_ = #{desc},
+			desc_ = #{desc},
+		</if>
+		<if test="goodsDetailUrl != null">
+			goods_detail_url_ = #{goodsDetailUrl},
 		</if>
 		update_time_ = NOW()
 	</set> WHERE id_ = #{id}
@@ -116,14 +78,25 @@
 	<delete id="delete" >
 		DELETE FROM live_goods WHERE id_ = #{id} 
 	</delete>
+	<sql id="queryPageSql">
+		<where>
+			<if test="search != null and search != ''">
+				(name_ like '%${search}%' OR id_ = #{search})
+			</if>
+		</where>
+	</sql>
 	
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="LiveGoods" parameterType="map">
-		SELECT * FROM live_goods ORDER BY id_ <include refid="global.limit"/>
+		SELECT * FROM live_goods
+		<include refid="queryPageSql" />
+		ORDER BY id_
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM live_goods
+		<include refid="queryPageSql" />
 	</select>
 </mapper>

+ 24 - 11
mec-biz/src/main/resources/config/mybatis/LiveGoodsMapperMapper.xml

@@ -11,7 +11,6 @@
 		<result column="goods_id_" property="goodsId" />
 		<result column="live_id_" property="liveId" />
 		<result column="sell_count_" property="sellCount" />
-		<result column="live_price_" property="livePrice" />
 		<result column="status_" property="status" />
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
@@ -29,8 +28,8 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.LiveGoodsMapper" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO live_goods_mapper (goods_id_,live_id_,sell_count_,live_price_,status_,create_time_,update_time_)
-		VALUES(#{goodsId},#{liveId},#{sellCount},#{livePrice},#{status},NOW(),NOW())
+		INSERT INTO live_goods_mapper (goods_id_,live_id_,sell_count_,status_,create_time_,update_time_)
+		VALUES(#{goodsId},#{liveId},#{sellCount},#{status},NOW(),NOW())
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -42,9 +41,6 @@
 		<if test="liveId != null">
 		live_id_ = #{liveId},
 		</if>
-		<if test="livePrice != null">
-		live_price_ = #{livePrice},
-		</if>
 		<if test="sellCount != null">
 		sell_count_ = #{sellCount},
 		</if>
@@ -66,15 +62,33 @@
 	<delete id="delete" >
 		DELETE FROM live_goods_mapper WHERE id_ = #{id} 
 	</delete>
-	
+	<sql id="queryPageSql">
+		<where>
+			<if test="liveId != null and liveId != ''">
+				AND lgm.live_id_ = #{liveId}
+			</if>
+			<if test="search != null and search != ''">
+				AND (lg.name_ LIKE '%${search}%' OR lg.id_ = ${search})
+			</if>
+			<if test="status != null">
+				AND lgm.status_ = #{status}
+			</if>
+		</where>
+	</sql>
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="LiveGoodsMapper" parameterType="map">
-		SELECT * FROM live_goods_mapper ORDER BY id_ <include refid="global.limit"/>
+		SELECT lg.*,lg.status_ FROM live_goods_mapper lgm
+		LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
+		<include refid="queryPageSql" />
+		ORDER BY lgm.id_
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM live_goods_mapper
+		SELECT COUNT(lgm.id_) FROM live_goods_mapper lgm
+		LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
+		<include refid="queryPageSql" />
 	</select>
 	<select id="findByLiveGoodsIdAndStatus" resultMap="LiveGoodsMapper">
 		SELECT * FROM live_goods_mapper WHERE goods_id_ = #{goodsId} AND status_ = #{status}
@@ -87,7 +101,6 @@
 		<result column="id_" property="id" />
 		<result column="image_" property="image" />
 		<result column="sell_count_" property="sellCount" />
-		<result column="live_price_" property="livePrice" />
 		<result column="status_" property="status" />
 		<result column="name_" property="name" />
 		<result column="original_price_" property="originalPrice" />
@@ -97,7 +110,7 @@
 		<result column="memo_" property="memo" />
 	</resultMap>
 	<select id="getLiveGoodsList" resultMap="LiveGoodsMapperDto">
-		SELECT lg.id_,lg.image_,lgm.sell_count_,lgm.live_price_,
+		SELECT lg.id_,lg.image_,lgm.sell_count_,
 		       lgm.status_,lg.name_,lg.original_price_,lg.current_price_,lg.brief_,lg.desc_,lg.memo_
 		FROM live_goods_mapper lgm
 		LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_

+ 2 - 5
mec-common/common-core/src/main/java/com/ym/mec/common/entity/ImRoomMessage.java

@@ -15,11 +15,8 @@ public class ImRoomMessage extends BaseMessage {
     //objectName 类型-观看者数量-该消息只有主播端接
     public static final String MEMBER_COUNT = "RC:Chatroom:MemberCountUp";
 
-    //objectName 类型-商品上架
-    public static final String LIVE_GOODS_UP = "DY:LIVE_GOODS_UP";
-
-    //objectName 类型-商品下架
-    public static final String LIVE_GOODS_DOWN = "DY:LIVE_GOODS_DOWN";
+    //objectName 类型-商品变更
+    public static final String LIVE_GOODS_CHANGE = "DY:LIVE_GOODS_CHANGE";
 
     /**
      * <p>必传

+ 21 - 6
mec-web/src/main/java/com/ym/mec/web/controller/LiveGoodsController.java

@@ -4,10 +4,10 @@ import com.ym.mec.biz.dal.entity.LiveGoods;
 import com.ym.mec.biz.service.LiveGoodsService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.QueryInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -22,6 +22,13 @@ public class LiveGoodsController extends BaseController {
     @Autowired
     private LiveGoodsService liveGoodsService;
 
+    @ApiOperation("分页查询直播间商品")
+    @PostMapping(value = "/page")
+    @PreAuthorize("@pcs.hasPermissions('liveGoods/page')")
+    public HttpResponseResult page(QueryInfo queryInfo) {
+        return succeed(liveGoodsService.queryPage(queryInfo));
+    }
+
     @ApiOperation("新增直播间商品")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('liveGoods/add')")
@@ -38,11 +45,19 @@ public class LiveGoodsController extends BaseController {
         return succeed();
     }
 
-    @ApiOperation("上架、下架直播间商品")
-    @PostMapping("/updateStatus")
-    @PreAuthorize("@pcs.hasPermissions('liveGoods/updateStatus')")
-    public HttpResponseResult updateStatus(Integer liveGoodsId, Boolean status) {
-        liveGoodsService.updateStatus(liveGoodsId, status);
+    @ApiOperation("删除直播间商品")
+    @PostMapping(value = "/delete")
+    @PreAuthorize("@pcs.hasPermissions('liveGoods/delete')")
+    public HttpResponseResult delete(Integer goodsId) {
+        liveGoodsService.deleteLiveGoods(goodsId);
         return succeed();
     }
+
+//    @ApiOperation("上架、下架直播间商品")
+//    @PostMapping("/updateStatus")
+//    @PreAuthorize("@pcs.hasPermissions('liveGoods/updateStatus')")
+//    public HttpResponseResult updateStatus(Integer liveGoodsId, Boolean status) {
+//        liveGoodsService.updateStatus(liveGoodsId, status);
+//        return succeed();
+//    }
 }

+ 33 - 0
mec-web/src/main/java/com/ym/mec/web/controller/LiveGoodsMapperController.java

@@ -1,11 +1,17 @@
 package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.dal.entity.LiveGoodsMapper;
+import com.ym.mec.biz.dal.page.LiveGoodsMapperQueryInfo;
 import com.ym.mec.biz.service.LiveGoodsMapperService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.QueryInfo;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -21,6 +27,13 @@ public class LiveGoodsMapperController extends BaseController {
     @Autowired
     private LiveGoodsMapperService liveGoodsMapperService;
 
+    @ApiOperation("分页查询直播间商品")
+    @PostMapping("/page")
+    @PreAuthorize("@pcs.hasPermissions('liveGoodsMapper/page')")
+    public HttpResponseResult page(LiveGoodsMapperQueryInfo queryInfo) {
+        return succeed(liveGoodsMapperService.queryPage(queryInfo));
+    }
+
     @ApiOperation("新增直播间商品关联")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('liveGoodsMapper/add')")
@@ -28,4 +41,24 @@ public class LiveGoodsMapperController extends BaseController {
         liveGoodsMapperService.add(liveGoodsMapper);
         return succeed();
     }
+
+    @ApiOperation("上架、下架直播间商品")
+    @PostMapping("/updateStatus")
+    @PreAuthorize("@pcs.hasPermissions('liveGoodsMapper/updateStatus')")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "liveGoodsId", value = "商品编号", required = true, dataType = "long"),
+            @ApiImplicitParam(name = "status", value = "状态:1-上架,0-下架", required = true,dataType = "boolean"),
+            @ApiImplicitParam(name = "liveId", value = "房间号", required = true,dataType = "String")
+    })
+    public HttpResponseResult updateStatus(Integer liveGoodsId, String liveId, Boolean status) {
+        if (liveGoodsId == null || status == null || StringUtils.isEmpty(liveId)) {
+            throw new BizException("参数不能为空");
+        }
+        if (status) {
+            liveGoodsMapperService.upGoods(liveGoodsId, liveId);
+        }else {
+            liveGoodsMapperService.downGoods(liveGoodsId, liveId);
+        }
+        return succeed();
+    }
 }