批量添加直播商品
This commit is contained in:
@@ -3,6 +3,8 @@ package cn.lili.modules.broadcast.service;
|
||||
import cn.lili.modules.broadcast.entity.dos.Commodity;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 直播商品业务层
|
||||
*
|
||||
@@ -15,7 +17,7 @@ public interface CommodityService extends IService<Commodity> {
|
||||
* 添加直播商品
|
||||
* @return 添加结果
|
||||
*/
|
||||
boolean addCommodity(Commodity commodity);
|
||||
boolean addCommodity(List<Commodity> commodity);
|
||||
|
||||
/**
|
||||
* 删除直播商品
|
||||
|
||||
@@ -27,12 +27,14 @@ public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity
|
||||
private WechatLivePlayerUtil wechatLivePlayerUtil;
|
||||
|
||||
@Override
|
||||
public boolean addCommodity(Commodity commodity) {
|
||||
JSONObject json = wechatLivePlayerUtil.addGoods(commodity);
|
||||
commodity.setLiveGoodsId(Convert.toInt(json.getStr("goodsId")));
|
||||
commodity.setAuditId(json.getStr("auditId"));
|
||||
commodity.setStoreId(UserContext.getCurrentUser().getStoreId());
|
||||
return this.save(commodity);
|
||||
public boolean addCommodity(List<Commodity> commodityList) {
|
||||
for (Commodity commodity:commodityList) {
|
||||
JSONObject json = wechatLivePlayerUtil.addGoods(commodity);
|
||||
commodity.setLiveGoodsId(Convert.toInt(json.getStr("goodsId")));
|
||||
commodity.setAuditId(json.getStr("auditId"));
|
||||
commodity.setStoreId(UserContext.getCurrentUser().getStoreId());
|
||||
}
|
||||
return this.saveBatch(commodityList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user