图书和营销标签、小店

This commit is contained in:
wuchunlei
2024-03-21 09:22:27 +08:00
parent c536752f14
commit b68d7201d6
22 changed files with 734 additions and 0 deletions

View File

@@ -0,0 +1,234 @@
package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.entity.*;
import com.peanut.modules.book.service.*;
import lombok.extern.slf4j.Slf4j;
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.List;
import java.util.Map;
/**
* 商品书和营销标签
*/
@Slf4j
@RestController
@RequestMapping("book/labelAndMarket")
public class BookLabelAndMarketController {
@Autowired
private ShopProductBookLabelService labelService;
@Autowired
private ShopProductBookMarketService marketService;
@Autowired
private ShopProductToBookLabelService toLabelService;
@Autowired
private ShopProductToBookMarketService toMarketService;
@Autowired
private ShopProductService productService;
/**
* 图书标签树
*/
@RequestMapping(path = "/labelTree")
public R labelTree() {
List<ShopProductBookLabel> labelsTree = labelService.labelTree();
return R.ok().put("result", labelsTree);
}
/**
* 获取图书标签列表
*/
@RequestMapping(path = "/getLabelListByPid")
public R getLabelListByPid(String pid) {
LambdaQueryWrapper<ShopProductBookLabel> wrapper = new LambdaQueryWrapper();
wrapper.eq(ShopProductBookLabel::getPid,pid);
wrapper.orderByAsc(ShopProductBookLabel::getSort);
wrapper.orderByAsc(ShopProductBookLabel::getCreateTime);
List<ShopProductBookLabel> labelTopList = labelService.list(wrapper);
return R.ok().put("result", labelTopList);
}
/**
* 图书营销标签树
*/
@RequestMapping(path = "/marketTree")
public R marketTree() {
List<ShopProductBookMarket> marketsTree = marketService.marketTree();
return R.ok().put("result", marketsTree);
}
/**
* 获取图书营销标签列表
*/
@RequestMapping(path = "/getMakertListByPid")
public R getMakertListByPid(String pid) {
LambdaQueryWrapper<ShopProductBookMarket> wrapper = new LambdaQueryWrapper();
wrapper.eq(ShopProductBookMarket::getPid,pid);
wrapper.orderByAsc(ShopProductBookMarket::getSort);
wrapper.orderByAsc(ShopProductBookMarket::getCreateTime);
List<ShopProductBookMarket> marketTopList = marketService.list(wrapper);
return R.ok().put("result", marketTopList);
}
@RequestMapping(path = "/getLabelById")
public R getLabelById(String id) {
return R.ok().put("result",labelService.getById(id));
}
@RequestMapping(path = "/saveOrUpdateLabel")
public R saveOrUpdateLabel(@RequestBody ShopProductBookLabel label) {
labelService.saveOrUpdate(label);
return R.ok();
}
@RequestMapping(path = "/delLabel")
public R delLabel(String id) {
labelService.removeById(id);
return R.ok();
}
@RequestMapping(path = "/getMarketById")
public R getMarketById(String id) {
return R.ok().put("result",marketService.getById(id));
}
@RequestMapping(path = "/saveOrUpdateMarket")
public R saveOrUpdateMarket(@RequestBody ShopProductBookMarket market) {
marketService.saveOrUpdate(market);
return R.ok();
}
@RequestMapping(path = "/delMarket")
public R delMarket(String id) {
marketService.removeById(id);
return R.ok();
}
/**
* 获取书标签列表
*/
@RequestMapping("/getToLabelList")
public R getToLabelList(@RequestBody Map params){
MPJLambdaWrapper<ShopProductToBookLabel> wrapper = new MPJLambdaWrapper();
wrapper.selectAll(ShopProductToBookLabel.class);
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToBookLabel::getProductId);
if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){
wrapper.like(ShopProduct::getProductName,params.get("productName").toString());
}
if (params.containsKey("productId")&&!"".equals(params.get("productId").toString())){
wrapper.eq(ShopProductToBookLabel::getProductId,params.get("productId").toString());
}
if (params.containsKey("bookLabelId")&&!"".equals(params.get("bookLabelId").toString())){
wrapper.eq(ShopProductToBookLabel::getBookLabelId,params.get("bookLabelId").toString());
}
Page<ShopProductToBookLabel> page = toLabelService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
List<ShopProductToBookLabel> res = page.getRecords();
if (res.size() > 0) {
for (ShopProductToBookLabel item : res) {
item.setProduct(productService.getById(item.getProductId()));
item.setLabel(labelService.getById(item.getBookLabelId()));
}
}
page.setRecords(res);
return R.ok().put("result", page);
}
/**
* 获取营销标签列表
*/
@RequestMapping("/getToMarketList")
public R getToMarketList(@RequestBody Map params){
MPJLambdaWrapper<ShopProductToBookMarket> wrapper = new MPJLambdaWrapper();
wrapper.selectAll(ShopProductToBookMarket.class);
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToBookMarket::getProductId);
if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){
wrapper.like(ShopProduct::getProductName,params.get("productName").toString());
}
if (params.containsKey("productId")&&!"".equals(params.get("productId").toString())){
wrapper.eq(ShopProductToBookMarket::getProductId,params.get("productId").toString());
}
if (params.containsKey("bookMarketId")&&!"".equals(params.get("bookMarketId").toString())){
wrapper.eq(ShopProductToBookMarket::getBookMarketId,params.get("bookMarketId").toString());
}
Page<ShopProductToBookMarket> page = toMarketService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
List<ShopProductToBookMarket> res = page.getRecords();
if (res.size() > 0) {
for (ShopProductToBookMarket item : res) {
item.setProduct(productService.getById(item.getProductId()));
item.setMarket(marketService.getById(item.getBookMarketId()));
}
}
page.setRecords(res);
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) {
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();
}
}
@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) {
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();
}
}
@RequestMapping(path = "/delToMarket")
public R delToMarket(String id) {
toMarketService.removeById(id);
return R.ok();
}
}

View File

@@ -0,0 +1,54 @@
package com.peanut.modules.book.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.entity.ShopStore;
import com.peanut.modules.book.service.ShopStoreService;
import lombok.extern.slf4j.Slf4j;
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
@RequestMapping("book/shopStore")
public class ShopStoreController {
@Autowired
private ShopStoreService shopStoreService;
/**
* 获取小店列表
*/
@RequestMapping("/getStoreList")
public R getStoreList(@RequestBody Map params){
MPJLambdaWrapper<ShopStore> wrapper = new MPJLambdaWrapper();
if (params.containsKey("name")&&!"".equals(params.get("name").toString())){
wrapper.like(ShopStore::getName,params.get("name").toString());
}
Page<ShopStore> page = shopStoreService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("result", page);
}
@RequestMapping(path = "/getStoreById")
public R getStoreById(String id) {
return R.ok().put("result",shopStoreService.getById(id));
}
@RequestMapping(path = "/saveOrUpdateStore")
public R saveOrUpdateStore(@RequestBody ShopStore store) {
shopStoreService.saveOrUpdate(store);
return R.ok();
}
@RequestMapping(path = "/delStore")
public R delStore(String id) {
shopStoreService.removeById(id);
return R.ok();
}
}