소스 검색

Merge remote-tracking branch 'origin/saas_2022_05_17_activity' into saas_2022_05_17_activity

hgw 3 년 전
부모
커밋
55b78e6bde

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/LiveGoodsMapperDao.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.entity.LiveGoodsMapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface LiveGoodsMapperDao extends BaseDAO<Integer, LiveGoodsMapper> {
 
@@ -19,4 +20,8 @@ public interface LiveGoodsMapperDao extends BaseDAO<Integer, LiveGoodsMapper> {
     List<LiveGoodsMapperDto> getLiveGoodsList(@Param("liveId") String liveId);
 
     void batchInsert(@Param("liveGoodsMappers") List<LiveGoodsMapper> liveGoodsMappers);
+
+    int countLiveGoods(Map<String, Object> params);
+
+    List<LiveGoods> queryGoodsPage(Map<String, Object> params);
 }

+ 6 - 28
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LiveGoodsMapperDto.java

@@ -17,24 +17,18 @@ public class LiveGoodsMapperDto {
     @ApiModelProperty(value = "库存",required = true)
     private Integer stockCount;
 
-    @ApiModelProperty(value = "销量",required = false)
-    private Integer sellCount = 0;
-
     @ApiModelProperty(value = "现价",required = true)
     private java.math.BigDecimal currentPrice;
 
     @ApiModelProperty(value = "原价",required = true)
     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 = "备注",required = false)
-    private String memo;
-
     @ApiModelProperty(value = "状态(1,上下架  0,下架)",required = false)
     private Boolean status = false;
 
@@ -70,14 +64,6 @@ public class LiveGoodsMapperDto {
         this.stockCount = stockCount;
     }
 
-    public Integer getSellCount() {
-        return sellCount;
-    }
-
-    public void setSellCount(Integer sellCount) {
-        this.sellCount = sellCount;
-    }
-
     public BigDecimal getCurrentPrice() {
         return currentPrice;
     }
@@ -94,12 +80,12 @@ public class LiveGoodsMapperDto {
         this.originalPrice = originalPrice;
     }
 
-    public String getBrief() {
-        return brief;
+    public String getGoodsDetailUrl() {
+        return goodsDetailUrl;
     }
 
-    public void setBrief(String brief) {
-        this.brief = brief;
+    public void setGoodsDetailUrl(String goodsDetailUrl) {
+        this.goodsDetailUrl = goodsDetailUrl;
     }
 
     public String getDesc() {
@@ -110,14 +96,6 @@ public class LiveGoodsMapperDto {
         this.desc = desc;
     }
 
-    public String getMemo() {
-        return memo;
-    }
-
-    public void setMemo(String memo) {
-        this.memo = memo;
-    }
-
     public Boolean getStatus() {
         return status;
     }

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

@@ -44,12 +44,23 @@ public class LiveGoods extends BaseEntity {
 	@ApiModelProperty(value = "商品的详细描述",required = false)
 	private String desc;
 
+	@ApiModelProperty(value = "上下架状态",required = false)
+	private Boolean status = false;
+
 	@ApiModelProperty(value = "创建时间",required = false)
 	private java.util.Date createTime;
 	
 	@ApiModelProperty(value = "修改时间",required = false)
 	private java.util.Date updateTime;
 
+	public Boolean getStatus() {
+		return status;
+	}
+
+	public void setStatus(Boolean status) {
+		this.status = status;
+	}
+
 	public String getGoodsDetailUrl() {
 		return goodsDetailUrl;
 	}

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

@@ -1,11 +1,24 @@
 package com.ym.mec.biz.dal.page;
 
 import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
 
 public class LiveGoodsMapperQueryInfo extends QueryInfo {
 
+    @ApiModelProperty(value = "上下架状态",required = false)
     private Boolean status;
 
+    @ApiModelProperty(value = "直播房间号",required = false)
+    private String liveId;
+
+    public String getLiveId() {
+        return liveId;
+    }
+
+    public void setLiveId(String liveId) {
+        this.liveId = liveId;
+    }
+
     public Boolean getStatus() {
         return status;
     }

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

@@ -1,6 +1,9 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.entity.LiveGoods;
 import com.ym.mec.biz.dal.entity.LiveGoodsMapper;
+import com.ym.mec.biz.dal.page.LiveGoodsMapperQueryInfo;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
 import java.util.Collection;
@@ -17,4 +20,6 @@ public interface LiveGoodsMapperService extends BaseService<Integer, LiveGoodsMa
     void upGoods(Integer liveGoodsId, String liveId);
 
     List<LiveGoodsMapper> findByLiveGoodsIdAndStatus(Integer goodsId, Boolean status);
+
+    PageInfo<LiveGoods> queryGoodsPage(LiveGoodsMapperQueryInfo queryInfo);
 }

+ 26 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LiveGoodsMapperServiceImpl.java

@@ -3,20 +3,23 @@ package com.ym.mec.biz.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ym.mec.biz.dal.dao.LiveGoodsMapperDao;
 import com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom;
+import com.ym.mec.biz.dal.entity.LiveGoods;
 import com.ym.mec.biz.dal.entity.LiveGoodsMapper;
+import com.ym.mec.biz.dal.page.LiveGoodsMapperQueryInfo;
 import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
 import com.ym.mec.biz.service.LiveGoodsMapperService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.ImRoomMessage;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
+import com.ym.mec.util.collection.MapUtil;
 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.*;
 
 @Service
 public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoodsMapper>  implements LiveGoodsMapperService {
@@ -58,7 +61,27 @@ public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoo
 		return liveGoodsMapperDao.findByLiveGoodsIdAndStatus(goodsId,status);
 	}
 
-	private void publishRoomMsg(ImLiveBroadcastRoom imLiveBroadcastRoom) {
+    @Override
+    public PageInfo<LiveGoods> queryGoodsPage(LiveGoodsMapperQueryInfo queryInfo) {
+		PageInfo<LiveGoods> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<LiveGoods> dataList = null;
+		int count = liveGoodsMapperDao.countLiveGoods(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = liveGoodsMapperDao.queryGoodsPage(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+    }
+
+    private void publishRoomMsg(ImLiveBroadcastRoom imLiveBroadcastRoom) {
 		ImRoomMessage message = new ImRoomMessage();
 		message.setIsIncludeSender(1);
 		message.setObjectName(ImRoomMessage.LIVE_GOODS_CHANGE);

+ 1 - 0
mec-biz/src/main/resources/config/mybatis/LiveGoodsMapper.xml

@@ -19,6 +19,7 @@
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 		<result column="tenant_id_" property="tenantId" />
+		<result column="status_" property="status" />
 	</resultMap>
 	
 	<!-- 根据主键查询一条记录 -->

+ 33 - 9
mec-biz/src/main/resources/config/mybatis/LiveGoodsMapperMapper.xml

@@ -32,10 +32,10 @@
 		VALUES(#{goodsId},#{liveId},#{sellCount},NOW(),NOW())
 	</insert>
 	<insert id="batchInsert">
-		INSERT INTO live_goods_mapper (goods_id_,live_id_,sell_count_,create_time_,update_time_)
+		INSERT INTO live_goods_mapper (goods_id_,live_id_,create_time_,update_time_)
 		VALUES
 		<foreach collection="liveGoodsMappers" item="item" index="index" separator=",">
-			(#{item.goodsId},#{item.liveId},#{item.sellCount},NOW(),NOW())
+			(#{item.goodsId},#{item.liveId},NOW(),NOW())
 		</foreach>
 		ON DUPLICATE KEY UPDATE
 		goods_id_ = VALUES(goods_id_),
@@ -62,7 +62,7 @@
 	</update>
 	<update id="updateStatus">
 		UPDATE live_goods_mapper SET status_ = #{status},update_time_ = NOW()
-		WHERE id_ = #{liveGoodsId}
+		WHERE goods_id_ = #{liveGoodsId}
 		<if test="liveId != null and liveId != ''">
 		AND live_id_ = #{liveId}
 		</if>
@@ -87,7 +87,7 @@
 	</sql>
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="LiveGoodsMapper" parameterType="map">
-		SELECT lg.*,lg.status_ FROM live_goods_mapper lgm
+		SELECT lg.*,lgm.status_ FROM live_goods_mapper lgm
 		LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
 		<include refid="queryPageSql" />
 		ORDER BY lgm.id_
@@ -110,20 +110,44 @@
 	<resultMap id="LiveGoodsMapperDto" type="com.ym.mec.biz.dal.dto.LiveGoodsMapperDto">
 		<result column="id_" property="id" />
 		<result column="image_" property="image" />
-		<result column="sell_count_" property="sellCount" />
 		<result column="status_" property="status" />
 		<result column="name_" property="name" />
 		<result column="original_price_" property="originalPrice" />
 		<result column="current_price_" property="currentPrice" />
-		<result column="brief_" property="brief" />
+		<result column="goods_detail_url_" property="goodsDetailUrl" />
 		<result column="desc_" property="desc" />
-		<result column="memo_" property="memo" />
+		<result column="stock_count_" property="stockCount" />
 	</resultMap>
 	<select id="getLiveGoodsList" resultMap="LiveGoodsMapperDto">
-		SELECT lg.id_,lg.image_,lgm.sell_count_,
-		       lgm.status_,lg.name_,lg.original_price_,lg.current_price_,lg.brief_,lg.desc_,lg.memo_
+		SELECT lg.*,lgm.status_
 		FROM live_goods_mapper lgm
 		LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
 		WHERE lgm.live_id_ = #{liveId}
 	</select>
+	<sql id="queryPageSqlForGoods">
+		<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="countLiveGoods" resultType="java.lang.Integer">
+		SELECT COUNT(lgm.id_) FROM live_goods_mapper lgm
+		LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
+		<include refid="queryPageSqlForGoods" />
+	</select>
+	<select id="queryGoodsPage" resultMap="LiveGoodsMapperDto">
+		SELECT lg.*,lgm.status_
+		FROM live_goods_mapper lgm
+		LEFT JOIN live_goods lg ON lgm.goods_id_ = lg.id_
+		<include refid="queryPageSqlForGoods" />
+		ORDER BY lgm.id_
+		<include refid="global.limit"/>
+	</select>
 </mapper>

+ 4 - 3
mec-web/src/main/java/com/ym/mec/web/controller/LiveGoodsMapperController.java

@@ -1,12 +1,13 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.entity.LiveGoods;
 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 com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -32,8 +33,8 @@ public class LiveGoodsMapperController extends BaseController {
     @ApiOperation("分页查询直播间商品")
     @PostMapping("/page")
     @PreAuthorize("@pcs.hasPermissions('liveGoodsMapper/page')")
-    public HttpResponseResult page(LiveGoodsMapperQueryInfo queryInfo) {
-        return succeed(liveGoodsMapperService.queryPage(queryInfo));
+    public HttpResponseResult<PageInfo<LiveGoods>> page(LiveGoodsMapperQueryInfo queryInfo) {
+        return succeed(liveGoodsMapperService.queryGoodsPage(queryInfo));
     }
 
     @ApiOperation("新增直播间商品关联")