添加商品描述和价格冗余字段

This commit is contained in:
xiaofeng
2019-07-16 01:08:26 +08:00
parent c1e34b908c
commit 2dc243a18f
9 changed files with 91 additions and 14 deletions

View File

@@ -37,6 +37,16 @@ public class ProductSpuCollectionMessage {
*/
private String spuImage;
/**
* 卖点
*/
private String sellPoint;
/**
* 价格,单位:分
*/
private Integer price;
/**
* 1 收藏 2 取消
*/

View File

@@ -6,11 +6,14 @@ import cn.iocoder.mall.product.api.constant.ProductErrorCodeEnum;
import cn.iocoder.mall.product.api.message.ProductSpuCollectionMessage;
import cn.iocoder.mall.product.dao.ProductSpuMapper;
import cn.iocoder.mall.product.dataobject.ProductSpuDO;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* ProductSpuCollectionServiceImpl
@@ -47,9 +50,14 @@ public class ProductSpuCollectionServiceImpl implements ProductSpuCollectionServ
*/
private void sendProductSpuCollectionMessage(final ProductSpuDO productSpuDO, final Integer hasCollectionType,
final Integer userId) {
List<String> result = Lists.newArrayList(Splitter.on(",").omitEmptyStrings().trimResults().split(productSpuDO.getPicUrls()));
ProductSpuCollectionMessage productSpuCollectionMessage = new ProductSpuCollectionMessage()
.setSpuId(productSpuDO.getId()).setSpuName(productSpuDO.getName())
.setSpuImage(productSpuDO.getPicUrls()).setHasCollectionType(hasCollectionType)
.setSpuId(productSpuDO.getId())
.setSpuName(productSpuDO.getName())
.setSpuImage(result.size() > 0 ? result.get(0) : "")
.setSellPoint(productSpuDO.getSellPoint())
.setPrice(productSpuDO.getPrice())
.setHasCollectionType(hasCollectionType)
.setUserId(userId);
rocketMQTemplate.convertAndSend(ProductSpuCollectionMessage.TOPIC, productSpuCollectionMessage);
}