bug
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.ShopStore;
|
||||
import com.peanut.modules.common.entity.ShopStore;
|
||||
|
||||
public interface ShopStoreService extends IService<ShopStore> {
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.entity.ShopStore;
|
||||
import com.peanut.modules.common.entity.ShopStore;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ShopStoreToProductDao extends MPJBaseMapper<ShopStoreToProductEntity> {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
@@ -28,6 +28,8 @@ public class ShopStore implements Serializable {
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("shop_store_to_product")
|
||||
public class ShopStoreToProductEntity {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer storeId;
|
||||
|
||||
private Integer productId;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private ShopStore shopStore;
|
||||
|
||||
@TableField(exist = false)
|
||||
private ShopProduct shopProduct;
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
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.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.ShopStoreService;
|
||||
import com.peanut.modules.common.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.common.entity.ShopStore;
|
||||
import com.peanut.modules.master.service.PayPaymentOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
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.ShopStoreToProductEntity;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.master.service.ShopStoreService;
|
||||
import com.peanut.modules.common.entity.ShopStore;
|
||||
import com.peanut.modules.master.service.ShopStoreToProductService;
|
||||
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("masterShopStore")
|
||||
@RequestMapping("master/shopStore")
|
||||
public class ShopStoreController {
|
||||
|
||||
@Autowired
|
||||
private ShopStoreService shopStoreService;
|
||||
|
||||
@Autowired
|
||||
private ShopStoreToProductService shopStoreToProductService;
|
||||
|
||||
/**
|
||||
* 获取小店列表
|
||||
*/
|
||||
@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(@RequestBody Map<String,Integer> map) {
|
||||
int id = map.get("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(@RequestBody Map<String,Integer> map) {
|
||||
int id = map.get("id");
|
||||
return shopStoreService.delStore(id);
|
||||
}
|
||||
|
||||
@RequestMapping("/getStoreProductList")
|
||||
public R getStoreProductList(@RequestBody Map<String,Integer> map){
|
||||
List<ShopStoreToProductEntity> storeId = shopStoreToProductService.getStoreProductList(map.get("storeId"));
|
||||
return R.ok().put("list",storeId);
|
||||
}
|
||||
|
||||
@RequestMapping("/getCanBindProductList")
|
||||
public R getCanBindProductList(@RequestBody ParamTo param){
|
||||
Page canBindProductList = shopStoreToProductService.getCanBindProductList(param);
|
||||
return R.ok().put("page",canBindProductList);
|
||||
}
|
||||
|
||||
@RequestMapping("/bindStoreAndProduct")
|
||||
public R bindStoreAndProduct(@RequestBody Map<String,Integer> map){
|
||||
return shopStoreToProductService.bindStoreAndProduct(map.get("storeId"),map.get("productId"));
|
||||
}
|
||||
|
||||
@RequestMapping("/unbindStoreAndProduct")
|
||||
public R unbindStoreAndProduct(@RequestBody Map<String,Integer> map){
|
||||
shopStoreToProductService.getBaseMapper().deleteById(map.get("id"));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/editStoreProductSort")
|
||||
public R editStoreProductSort(@RequestBody Map<String,Integer> map){
|
||||
return shopStoreToProductService.editStoreProductSort(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ShopStore;
|
||||
|
||||
public interface ShopStoreService extends IService<ShopStore> {
|
||||
R delStore(int id);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ShopStoreToProductService extends IService<ShopStoreToProductEntity> {
|
||||
|
||||
List<ShopStoreToProductEntity> getStoreProductList(int id);
|
||||
|
||||
Page getCanBindProductList(ParamTo param);
|
||||
|
||||
R bindStoreAndProduct(int storeId,int productId);
|
||||
|
||||
R editStoreProductSort(Map<String,Integer> map);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.dao.ShopStoreDao;
|
||||
import com.peanut.modules.common.dao.ShopStoreToProductDao;
|
||||
import com.peanut.modules.common.entity.ShopStore;
|
||||
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
|
||||
import com.peanut.modules.master.service.ShopStoreService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("shopStore")
|
||||
public class ShopStoreServiceImpl extends ServiceImpl<ShopStoreDao, ShopStore> implements ShopStoreService {
|
||||
@Autowired
|
||||
private ShopStoreToProductDao shopStoreToProductDao;
|
||||
|
||||
@Override
|
||||
public R delStore(int id) {
|
||||
Integer integer = shopStoreToProductDao.selectCount(new LambdaQueryWrapper<ShopStoreToProductEntity>().eq(ShopStoreToProductEntity::getStoreId, id));
|
||||
if(integer>0){
|
||||
return R.error("请先清空后,再操作");
|
||||
}
|
||||
this.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.dao.ShopProductDao;
|
||||
import com.peanut.modules.common.dao.ShopStoreDao;
|
||||
import com.peanut.modules.common.dao.ShopStoreToProductDao;
|
||||
import com.peanut.modules.common.entity.ShopProduct;
|
||||
import com.peanut.modules.common.entity.ShopStoreToProductEntity;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.master.service.ShopStoreToProductService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("masterShopStoreToProductService")
|
||||
public class ShopStoreToProductServiceImpl extends ServiceImpl<ShopStoreToProductDao, ShopStoreToProductEntity> implements ShopStoreToProductService {
|
||||
@Autowired
|
||||
private ShopStoreDao shopStoreDao;
|
||||
@Autowired
|
||||
private ShopProductDao shopProductDao;
|
||||
|
||||
@Override
|
||||
public List<ShopStoreToProductEntity> getStoreProductList(int id) {
|
||||
List<ShopStoreToProductEntity> shopStoreToProductEntities = this.getBaseMapper().selectList(new LambdaQueryWrapper<ShopStoreToProductEntity>()
|
||||
.eq(ShopStoreToProductEntity::getStoreId, id).orderByAsc(ShopStoreToProductEntity::getSort));
|
||||
for (ShopStoreToProductEntity s : shopStoreToProductEntities){
|
||||
s.setShopStore(shopStoreDao.selectById(s.getStoreId()));
|
||||
s.setShopProduct(shopProductDao.selectById(s.getProductId()));
|
||||
}
|
||||
return shopStoreToProductEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ShopProduct> getCanBindProductList(ParamTo param) {
|
||||
List<Integer> collect = this.getBaseMapper().selectList(new LambdaQueryWrapper<ShopStoreToProductEntity>()
|
||||
.eq(ShopStoreToProductEntity::getStoreId, param.getId()))
|
||||
.stream().map(ShopStoreToProductEntity::getProductId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<ShopProduct> shopProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
shopProductLambdaQueryWrapper.like(StringUtils.isNotBlank(param.getKeywords()),ShopProduct::getProductName,param.getKeywords());
|
||||
shopProductLambdaQueryWrapper.notIn(ShopProduct::getProductId,collect);
|
||||
Page<ShopProduct> shopProductPage = shopProductDao.selectPage(new Page<>(param.getPage(), param.getLimit()), shopProductLambdaQueryWrapper);
|
||||
return shopProductPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R bindStoreAndProduct(int storeId, int productId) {
|
||||
//check
|
||||
ShopStoreToProductEntity one = this.getOne(new LambdaQueryWrapper<ShopStoreToProductEntity>()
|
||||
.eq(ShopStoreToProductEntity::getStoreId, storeId)
|
||||
.eq(ShopStoreToProductEntity::getProductId, productId));
|
||||
if (one!=null){
|
||||
return R.error("重复绑定");
|
||||
}
|
||||
ShopStoreToProductEntity shopStoreToProductEntity = new ShopStoreToProductEntity();
|
||||
shopStoreToProductEntity.setStoreId(storeId);
|
||||
shopStoreToProductEntity.setProductId(productId);
|
||||
this.save(shopStoreToProductEntity);
|
||||
return R.ok().put("result",shopStoreToProductEntity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public R editStoreProductSort(Map<String, Integer> map) {
|
||||
ShopStoreToProductEntity info = this.getById(map.get("id"));
|
||||
info.setSort(map.get("sort"));
|
||||
this.updateById(info);
|
||||
return R.ok().put("result",info);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user