图书和营销标签、小店

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,11 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.ShopProductBookLabel;
import java.util.List;
public interface ShopProductBookLabelService extends IService<ShopProductBookLabel> {
List<ShopProductBookLabel> labelTree();
}

View File

@@ -0,0 +1,12 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.ShopProductBookMarket;
import java.util.List;
public interface ShopProductBookMarketService extends IService<ShopProductBookMarket> {
List<ShopProductBookMarket> marketTree();
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.ShopProductToBookLabel;
public interface ShopProductToBookLabelService extends IService<ShopProductToBookLabel> {
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.ShopProductToBookMarket;
public interface ShopProductToBookMarketService extends IService<ShopProductToBookMarket> {
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.book.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.book.entity.ShopStore;
public interface ShopStoreService extends IService<ShopStore> {
}

View File

@@ -0,0 +1,47 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.ShopProductBookLabelDao;
import com.peanut.modules.book.entity.ShopProductBookLabel;
import com.peanut.modules.book.service.ShopProductBookLabelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service("shopProductBookLabelService")
public class ShopProductBookLabelServiceImpl extends ServiceImpl<ShopProductBookLabelDao, ShopProductBookLabel> implements ShopProductBookLabelService {
@Autowired
private ShopProductBookLabelDao labelDao;
@Override
public List<ShopProductBookLabel> labelTree() {
List<ShopProductBookLabel> labels = labelDao.selectList(new QueryWrapper<>());
List<ShopProductBookLabel> labelsTree = labels.stream().filter((shopProductBookLabel) ->
shopProductBookLabel.getPid() == 0
).map((label)->{
label.setChildren(getLabelChildrens(label,labels));
return label;
}).sorted((label1,label2)->{
return (label1.getSort() == null? 0 : label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
}).collect(Collectors.toList());
return labelsTree;
}
private List<ShopProductBookLabel> getLabelChildrens(ShopProductBookLabel root,List<ShopProductBookLabel> all){
List<ShopProductBookLabel> children = all.stream().filter(shopProductBookLabel -> {
return root.getId().equals(shopProductBookLabel.getPid());
}).map(shopProductBookLabel -> {
shopProductBookLabel.setChildren(getLabelChildrens(shopProductBookLabel, all));
return shopProductBookLabel;
}).sorted((label1,label2)->{
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
}).collect(Collectors.toList());
return children;
}
}

View File

@@ -0,0 +1,48 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.R;
import com.peanut.modules.book.dao.ShopProductBookMarketDao;
import com.peanut.modules.book.entity.ShopProductBookMarket;
import com.peanut.modules.book.service.ShopProductBookMarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service("shopProductBookMarketService")
public class ShopProductBookMarketServiceImpl extends ServiceImpl<ShopProductBookMarketDao, ShopProductBookMarket> implements ShopProductBookMarketService {
@Autowired
private ShopProductBookMarketDao marketDao;
@Override
public List<ShopProductBookMarket> marketTree() {
List<ShopProductBookMarket> markets = marketDao.selectList(new QueryWrapper<>());
List<ShopProductBookMarket> marketsTree = markets.stream().filter((shopProductBookMarket) ->
shopProductBookMarket.getPid() == 0
).map((market)->{
market.setChildren(getMarketChildrens(market,markets));
return market;
}).sorted((sort1,sort2)->{
return (sort1.getSort() == null? 0 : sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
}).collect(Collectors.toList());
return marketsTree;
}
private List<ShopProductBookMarket> getMarketChildrens(ShopProductBookMarket root,List<ShopProductBookMarket> all){
List<ShopProductBookMarket> children = all.stream().filter(shopProductBookMarket -> {
return root.getId().equals(shopProductBookMarket.getPid());
}).map(shopProductBookMarket -> {
shopProductBookMarket.setChildren(getMarketChildrens(shopProductBookMarket, all));
return shopProductBookMarket;
}).sorted((sort1,sort2)->{
return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
}).collect(Collectors.toList());
return children;
}
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.ShopProductToBookLabelDao;
import com.peanut.modules.book.entity.ShopProductToBookLabel;
import com.peanut.modules.book.service.ShopProductToBookLabelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("shopProductToBookLabelService")
public class ShopProductToBookLabelServiceImpl extends ServiceImpl<ShopProductToBookLabelDao, ShopProductToBookLabel> implements ShopProductToBookLabelService {
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.ShopProductToBookMarketDao;
import com.peanut.modules.book.entity.ShopProductToBookMarket;
import com.peanut.modules.book.service.ShopProductToBookMarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("shopProductToBookMarketService")
public class ShopProductToBookMarketServiceImpl extends ServiceImpl<ShopProductToBookMarketDao, ShopProductToBookMarket> implements ShopProductToBookMarketService {
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.book.dao.ShopStoreDao;
import com.peanut.modules.book.entity.ShopStore;
import com.peanut.modules.book.service.ShopStoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("shopStore")
public class ShopStoreServiceImpl extends ServiceImpl<ShopStoreDao, ShopStore> implements ShopStoreService {
}