修改图书标签方法

This commit is contained in:
wuchunlei
2024-03-21 18:05:22 +08:00
parent 6aa20d72b7
commit e53b954769
5 changed files with 83 additions and 41 deletions

View File

@@ -7,6 +7,7 @@ import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.book.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -86,7 +87,7 @@ public class BookLabelAndMarketController {
@RequestMapping(path = "/saveOrUpdateLabel")
public R saveOrUpdateLabel(@RequestBody ShopProductBookLabel label) {
labelService.saveOrUpdate(label);
return R.ok();
return R.ok().put("result",label);
}
@RequestMapping(path = "/delLabel")
@@ -103,7 +104,7 @@ public class BookLabelAndMarketController {
@RequestMapping(path = "/saveOrUpdateMarket")
public R saveOrUpdateMarket(@RequestBody ShopProductBookMarket market) {
marketService.saveOrUpdate(market);
return R.ok();
return R.ok().put("result",market);
}
@RequestMapping(path = "/delMarket")
@@ -174,53 +175,41 @@ public class BookLabelAndMarketController {
return R.ok().put("result", page);
}
@RequestMapping(path = "/getToLabelById")
public R getToLabelById(String id) {
return R.ok().put("result",toLabelService.getById(id));
}
@RequestMapping(path = "/saveToLabel")
public R saveToLabel(@RequestBody ShopProductToBookLabel toLabel) {
public R saveToLabel(@RequestBody Map params) {
LambdaQueryWrapper<ShopProductToBookLabel> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ShopProductToBookLabel::getBookLabelId,toLabel.getBookLabelId());
wrapper.eq(ShopProductToBookLabel::getProductId,toLabel.getProductId());
List list = toLabelService.list(wrapper);
if (list.size() > 0) {
return R.error("已存在");
}else {
toLabelService.save(toLabel);
return R.ok();
wrapper.eq(ShopProductToBookLabel::getBookLabelId,params.get("bookLabelId").toString());
toLabelService.remove(wrapper);
if (!StringUtils.isEmpty(params.get("productId").toString())){
String[] ids = params.get("productId").toString().split(",");
if (ids.length > 0) {
for (String id : ids) {
ShopProductToBookLabel toLabel = new ShopProductToBookLabel();
toLabel.setBookLabelId(Integer.parseInt(params.get("bookLabelId").toString()));
toLabel.setProductId(Integer.parseInt(id));
toLabelService.save(toLabel);
}
}
}
}
@RequestMapping(path = "/delToLabel")
public R delToLabel(String id) {
toLabelService.removeById(id);
return R.ok();
}
@RequestMapping(path = "/getToMarketById")
public R getToMarketById(String id) {
return R.ok().put("result",toMarketService.getById(id));
}
@RequestMapping(path = "/saveToMarket")
public R saveToMarket(@RequestBody ShopProductToBookMarket toMarket) {
public R saveToMarket(@RequestBody Map params) {
LambdaQueryWrapper<ShopProductToBookMarket> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ShopProductToBookMarket::getBookMarketId,toMarket.getBookMarketId());
wrapper.eq(ShopProductToBookMarket::getProductId,toMarket.getProductId());
List list = toMarketService.list(wrapper);
if (list.size() > 0) {
return R.error("已存在");
}else {
toMarketService.save(toMarket);
return R.ok();
wrapper.eq(ShopProductToBookMarket::getBookMarketId,params.get("bookMarketId").toString());
toMarketService.remove(wrapper);
if (!StringUtils.isEmpty(params.get("productId").toString())){
String[] ids = params.get("productId").toString().split(",");
if (ids.length > 0) {
for (String id : ids) {
ShopProductToBookMarket toMarket = new ShopProductToBookMarket();
toMarket.setBookMarketId(Integer.parseInt(params.get("bookLabelId").toString()));
toMarket.setProductId(Integer.parseInt(id));
toMarketService.save(toMarket);
}
}
}
}
@RequestMapping(path = "/delToMarket")
public R delToMarket(String id) {
toMarketService.removeById(id);
return R.ok();
}

View File

@@ -65,6 +65,7 @@ public class ShopProductController {
}
/**
* 新项目已重写
* 列表
*/
@RequestMapping("/list")