Merge branch 'master' of https://gitee.com/wjl2008_admin/nuttyreading-java into zcc
This commit is contained in:
@@ -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("masterShopStore")
|
||||
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