图书标签修改-加判断条件

This commit is contained in:
wuchunlei
2024-03-22 14:26:14 +08:00
parent e53b954769
commit 0bb2579337

View File

@@ -86,14 +86,30 @@ public class BookLabelAndMarketController {
@RequestMapping(path = "/saveOrUpdateLabel")
public R saveOrUpdateLabel(@RequestBody ShopProductBookLabel label) {
labelService.saveOrUpdate(label);
return R.ok().put("result",label);
if (label.getIsLast()==1){
labelService.saveOrUpdate(label);
return R.ok().put("result",label);
}else {
return R.error("父标签非最后一集");
}
}
@RequestMapping(path = "/delLabel")
public R delLabel(String id) {
labelService.removeById(id);
return R.ok();
ShopProductBookLabel label = labelService.getById(id);
if (label.getIsLast()==1){
MPJLambdaWrapper<ShopProductToBookLabel> wrapper = new MPJLambdaWrapper();
wrapper.eq(ShopProductToBookLabel::getBookLabelId,id);
List<ShopProductToBookLabel> tolables = toLabelService.list(wrapper);
if (tolables.size()>0){
return R.error("请先移除商品");
}else {
labelService.removeById(id);
return R.ok();
}
}else {
return R.error("请先删除子集,设置成最后一集");
}
}
@RequestMapping(path = "/getMarketById")
@@ -103,14 +119,30 @@ public class BookLabelAndMarketController {
@RequestMapping(path = "/saveOrUpdateMarket")
public R saveOrUpdateMarket(@RequestBody ShopProductBookMarket market) {
marketService.saveOrUpdate(market);
return R.ok().put("result",market);
if (market.getIsLast()==1){
marketService.saveOrUpdate(market);
return R.ok().put("result",market);
}else {
return R.error("父标签非最后一集");
}
}
@RequestMapping(path = "/delMarket")
public R delMarket(String id) {
marketService.removeById(id);
return R.ok();
ShopProductBookMarket market = marketService.getById(id);
if (market.getIsLast()==1){
MPJLambdaWrapper<ShopProductToBookMarket> wrapper = new MPJLambdaWrapper();
wrapper.eq(ShopProductToBookMarket::getBookMarketId,id);
List<ShopProductToBookMarket> tomarkets = toMarketService.list(wrapper);
if (tomarkets.size()>0){
return R.error("请先移除商品");
}else {
marketService.removeById(id);
return R.ok();
}
}else {
return R.error("请先删除子集,设置成最后一集");
}
}
@@ -220,4 +252,8 @@ public class BookLabelAndMarketController {
}