批量添加直播商品
This commit is contained in:
parent
16cc989cdf
commit
00a0edeade
@ -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
|
||||
|
@ -15,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺端,直播商品接口
|
||||
*
|
||||
@ -37,8 +39,8 @@ public class CommodityController {
|
||||
|
||||
@ApiOperation(value = "添加店铺直播商品")
|
||||
@PostMapping
|
||||
public ResultMessage<Object> addCommodity(@Validated Commodity commodity) {
|
||||
if (commodityService.addCommodity(commodity)) {
|
||||
public ResultMessage<Object> addCommodity(@Validated List<Commodity> commodityList) {
|
||||
if (commodityService.addCommodity(commodityList)) {
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
}
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
|
Loading…
x
Reference in New Issue
Block a user