修改图书标签方法
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public class ShopProductController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新项目已重写
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
|
||||
@@ -1,4 +1,40 @@
|
||||
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.common.entity.ShopProduct;
|
||||
import com.peanut.modules.master.service.ShopProductService;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("masterShopProduct")
|
||||
@RequestMapping("master/shopProduct")
|
||||
public class ShopProductController {
|
||||
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/listByPage")
|
||||
public R listByPage(@RequestBody Map<String, Object> params) {
|
||||
MPJLambdaWrapper<ShopProduct> wrapper = new MPJLambdaWrapper();
|
||||
if (StringUtils.isNotEmpty(params.get("productName").toString())) {
|
||||
wrapper.like(ShopProduct::getProductName, params.get("productName"));
|
||||
}
|
||||
wrapper.orderByAsc(ShopProduct::getSort);
|
||||
wrapper.orderByAsc(ShopProduct::getCreateTime);
|
||||
Page<ShopProduct> res = shopProductService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
|
||||
return R.ok().put("result", res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
public interface ShopProductService {
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
|
||||
public interface ShopProductService extends IService<ShopProduct> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.ShopProductDao;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.master.service.ShopProductService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterShopProductService")
|
||||
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProduct> implements ShopProductService {
|
||||
}
|
||||
Reference in New Issue
Block a user