商品管理-国学、医学标签管理

This commit is contained in:
wuchunlei
2024-04-11 14:02:27 +08:00
parent fb0c1c7c10
commit 45d57ae5d6
10 changed files with 429 additions and 8 deletions

View File

@@ -2,6 +2,10 @@ package com.peanut.modules.master.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
import java.util.List;
public interface ShopProductMedicineLabelService extends IService<ShopProductMedicineLabel> {
List<ShopProductMedicineLabel> labelTree();
}

View File

@@ -2,6 +2,9 @@ package com.peanut.modules.master.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
import java.util.List;
public interface ShopProductMedicineMarketService extends IService<ShopProductMedicineMarket> {
List<ShopProductMedicineMarket> marketTree();
}

View File

@@ -1,13 +1,45 @@
package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductMedicineLabelDao;
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
import com.peanut.modules.medical.service.ShopProductMedicineLabelService;
import com.peanut.modules.master.service.ShopProductMedicineLabelService;
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("masterShopProductMedicineLabelService")
public class ShopProductMedicineLabelServiceImpl extends ServiceImpl<ShopProductMedicineLabelDao, ShopProductMedicineLabel> implements ShopProductMedicineLabelService {
@Autowired
private ShopProductMedicineLabelDao labelDao;
@Override
public List<ShopProductMedicineLabel> labelTree() {
List<ShopProductMedicineLabel> labels = labelDao.selectList(new QueryWrapper<>());
List<ShopProductMedicineLabel> labelsTree = labels.stream().filter((shopProductMedicineLabel) ->
shopProductMedicineLabel.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<ShopProductMedicineLabel> getLabelChildrens(ShopProductMedicineLabel root,List<ShopProductMedicineLabel> all){
List<ShopProductMedicineLabel> children = all.stream().filter(shopProductMedicineLabel -> {
return root.getId().equals(shopProductMedicineLabel.getPid());
}).map(shopProductMedicineLabel -> {
shopProductMedicineLabel.setChildren(getLabelChildrens(shopProductMedicineLabel, all));
return shopProductMedicineLabel;
}).sorted((label1,label2)->{
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
}).collect(Collectors.toList());
return children;
}
}

View File

@@ -1,13 +1,45 @@
package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductMedicineMarketDao;
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
import com.peanut.modules.medical.service.ShopProductMedicineMarketService;
import com.peanut.modules.master.service.ShopProductMedicineMarketService;
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("masterShopProductMedicineMarketService")
public class ShopProductMedicineMarketServiceImpl extends ServiceImpl<ShopProductMedicineMarketDao, ShopProductMedicineMarket> implements ShopProductMedicineMarketService {
@Autowired
private ShopProductMedicineMarketDao marketDao;
@Override
public List<ShopProductMedicineMarket> marketTree() {
List<ShopProductMedicineMarket> markets = marketDao.selectList(new QueryWrapper<>());
List<ShopProductMedicineMarket> marketsTree = markets.stream().filter((shopProductMedicineMarket) ->
shopProductMedicineMarket.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<ShopProductMedicineMarket> getMarketChildrens(ShopProductMedicineMarket root,List<ShopProductMedicineMarket> all){
List<ShopProductMedicineMarket> children = all.stream().filter(shopProductMedicineMarket -> {
return root.getId().equals(shopProductMedicineMarket.getPid());
}).map(shopProductMedicineMarket -> {
shopProductMedicineMarket.setChildren(getMarketChildrens(shopProductMedicineMarket, all));
return shopProductMedicineMarket;
}).sorted((sort1,sort2)->{
return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
}).collect(Collectors.toList());
return children;
}
}

View File

@@ -3,7 +3,7 @@ package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductToMedicineLabelDao;
import com.peanut.modules.common.entity.ShopProductToMedicineLabel;
import com.peanut.modules.medical.service.ShopProductToMedicineLabelService;
import com.peanut.modules.master.service.ShopProductToMedicineLabelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

View File

@@ -3,7 +3,7 @@ package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductToMedicineMarketDao;
import com.peanut.modules.common.entity.ShopProductToMedicineMarket;
import com.peanut.modules.medical.service.ShopProductToMedicineMarketService;
import com.peanut.modules.master.service.ShopProductToMedicineMarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;