考试时间,题数写活
管理端新增商品
This commit is contained in:
@@ -3,8 +3,10 @@ package com.peanut.modules.master.controller;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.ShopProductBookService;
|
||||
import com.peanut.modules.common.entity.BookEntity;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.common.entity.ShopProductBookEntity;
|
||||
import com.peanut.modules.common.entity.ShopProductCourseEntity;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.common.vo.CourseCatalogueVo;
|
||||
@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -29,6 +32,8 @@ public class ShopProductController {
|
||||
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private ShopProductBookService shopProductBookService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
@@ -53,6 +58,33 @@ public class ShopProductController {
|
||||
return R.ok().put("detail",detail);
|
||||
}
|
||||
|
||||
@RequestMapping("/addProduct")
|
||||
public R addProduct(@RequestBody ShopProduct shopProduct){
|
||||
shopProduct.setCreateTime(new Date());
|
||||
String bkids = "";
|
||||
for (String s : shopProduct.getBookids()) {
|
||||
bkids += s + ",";
|
||||
}
|
||||
if (bkids != null && !bkids.isEmpty()) {
|
||||
String substring = bkids.substring(0, bkids.length() - 1);
|
||||
shopProduct.setBookId(substring);
|
||||
} else {
|
||||
shopProduct.setBookId("");
|
||||
}
|
||||
shopProductService.save(shopProduct);
|
||||
ShopProductBookEntity shopProductBookEntity = new ShopProductBookEntity();
|
||||
for (String s : shopProduct.getBookids()) {
|
||||
String bookIdList = s;
|
||||
if (bookIdList != null) {
|
||||
Integer product = shopProduct.getProductId();
|
||||
shopProductBookEntity.setProductId(product);
|
||||
shopProductBookEntity.setBookId(Integer.valueOf(bookIdList));
|
||||
shopProductBookService.save(shopProductBookEntity);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/editProductDetail")
|
||||
public R editProductDetail(@RequestBody ShopProduct shopProduct){
|
||||
shopProductService.updateById(shopProduct);
|
||||
|
||||
Reference in New Issue
Block a user