This commit is contained in:
wangjinlei
2024-05-08 14:50:14 +08:00
parent e7909ba934
commit 9ff79cede2
11 changed files with 247 additions and 2 deletions

View File

@@ -25,6 +25,8 @@ public class CourseEntity {
private String image;
private String content;
private Date createTime;
@TableLogic

View File

@@ -48,6 +48,8 @@ public class ShopProductBookLabel implements Serializable {
@TableField(exist = false)
private List<ShopProductBookLabel> children;
@TableField(exist = false)
private boolean Select;
}

View File

@@ -48,6 +48,8 @@ public class ShopProductBookMarket implements Serializable {
@TableField(exist = false)
private List<ShopProductBookMarket> children;
@TableField(exist = false)
private boolean select;

View File

@@ -48,5 +48,7 @@ public class ShopProductMedicineLabel implements Serializable {
@TableField(exist = false)
private List<ShopProductMedicineLabel> children;
@TableField(exist = false)
private boolean select;
}

View File

@@ -48,5 +48,7 @@ public class ShopProductMedicineMarket implements Serializable {
@TableField(exist = false)
private List<ShopProductMedicineMarket> children;
@TableField(exist = false)
private boolean select;
}

View File

@@ -47,5 +47,7 @@ public class ShopProductSociologyLabel implements Serializable {
@TableField(exist = false)
private List<ShopProductSociologyLabel> children;
@TableField(exist = false)
private boolean select;
}

View File

@@ -47,5 +47,7 @@ public class ShopProductSociologyMarket implements Serializable {
@TableField(exist = false)
private List<ShopProductSociologyMarket> children;
@TableField(exist = false)
private boolean select;
}

View File

@@ -59,6 +59,12 @@ public class CourseController {
return R.ok();
}
@RequestMapping("/getCoursedetail")
public R getCoursedetail(@RequestBody ParamTo param){
CourseEntity course = courseService.getById(param.getId());
return R.ok().put("course",course);
}
@RequestMapping("/getCourseCatalogues")
public R getCourseCatalogues(@RequestBody ParamTo param){
List<CourseCatalogueEntity> courseCatalogues = courseCatalogueService.getCourseCatalogues(param.getId());

View File

@@ -52,4 +52,12 @@ public class ShopProductController {
return R.ok();
}
@RequestMapping("/getProductToLabel")
public R getProductToLabel(@RequestBody Map<String,Integer> map){
Map<String, Object> productId = shopProductService.getProductToLabel(map.get("productId"));
return R.ok().put("data",productId);
}
}

View File

@@ -8,4 +8,6 @@ import java.util.Map;
public interface ShopProductService extends IService<ShopProduct> {
Map<String,Object> getProductDetail(Integer productId);
Map<String,Object> getProductToLabel(Integer productId);
}

View File

@@ -1,18 +1,47 @@
package com.peanut.modules.master.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductDao;
import com.peanut.modules.common.entity.ShopProduct;
import com.peanut.modules.common.dao.*;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.master.service.ShopProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service("masterShopProductService")
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProduct> implements ShopProductService {
@Autowired
private ShopProductToBookLabelDao shopProductToBookLabelDao;
@Autowired
private ShopProductBookLabelDao shopProductBookLabelDao;
@Autowired
private ShopProductToBookMarketDao shopProductToBookMarketDao;
@Autowired
private ShopProductBookMarketDao shopProductBookMarketDao;
@Autowired
private ShopProductToMedicineLabelDao shopProductToMedicineLabelDao;
@Autowired
private ShopProductMedicineLabelDao shopProductMedicineLabelDao;
@Autowired
private ShopProductToMedicineMarketDao shopProductToMedicineMarketDao;
@Autowired
private ShopProductMedicineMarketDao shopProductMedicineMarketDao;
@Autowired
private ShopProductToSociologyLabelDao shopProductToSociologyLabelDao;
@Autowired
private ShopProductSociologyLabelDao shopProductSociologyLabelDao;
@Autowired
private ShopProductToSociologyMarketDao shopProductToSociologyMarketDao;
@Autowired
private ShopProductSociologyMarketDao shopProductSociologyMarketDao;
@Override
public Map<String, Object> getProductDetail(Integer productId) {
@@ -21,4 +50,190 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
flag.put("detail",detail);
return flag;
}
@Override
public Map<String, Object> getProductToLabel(Integer productId) {
HashMap<String, Object> flag = new HashMap<>();
//图书标签
List<Integer> bookLabelIds = shopProductToBookLabelDao.selectList(new LambdaQueryWrapper<ShopProductToBookLabel>().eq(ShopProductToBookLabel::getProductId, productId)).stream().map(ShopProductToBookLabel::getBookLabelId).collect(Collectors.toList());
List<ShopProductBookLabel> shopProductBookLabels = shopProductBookLabelDao.selectList(null);
List<ShopProductBookLabel> bookLabel = shopProductBookLabels.stream().filter((shopProductBookLabel -> shopProductBookLabel.getPid() == 0))
.map((l) -> {
if(l.getIsLast()==1){
l.setSelect(bookLabelIds.contains(l.getId()));
}
l.setChildren(getBookLabelChildrens(l, shopProductBookLabels,bookLabelIds));
return l;
}).sorted((label1,label2)->{
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
}).collect(Collectors.toList());
flag.put("bookLabel",bookLabel);
//图书运营标签
List<Integer> bookMarketIds = shopProductToBookMarketDao.selectList(new LambdaQueryWrapper<ShopProductToBookMarket>().eq(ShopProductToBookMarket::getProductId, productId)).stream().map(ShopProductToBookMarket::getBookMarketId).collect(Collectors.toList());
List<ShopProductBookMarket> shopProductBookMarkets = shopProductBookMarketDao.selectList(null);
List<ShopProductBookMarket> bookMarket = shopProductBookMarkets.stream().filter(shopProductBookMarket -> shopProductBookMarket.getPid() == 0)
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(bookMarketIds.contains(m.getId()));
}
m.setChildren(getBookMarketChildrens(m, shopProductBookMarkets, bookMarketIds));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
flag.put("bookMarket",bookMarket);
//国学标签
List<Integer> sociologyLabelIds = shopProductToSociologyLabelDao.selectList(new LambdaQueryWrapper<ShopProductToSociologyLabel>().eq(ShopProductToSociologyLabel::getProductId, productId)).stream().map(ShopProductToSociologyLabel::getSociologyLabelId).collect(Collectors.toList());
List<ShopProductSociologyLabel> shopProductSociologyLabels = shopProductSociologyLabelDao.selectList(null);
List<ShopProductSociologyLabel> sociologyLabel = shopProductSociologyLabels.stream().filter(m -> m.getPid() == 0)
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(sociologyLabelIds.contains(m.getId()));
}
m.setChildren(getSociologyLabelChildrens(m, shopProductSociologyLabels, sociologyLabelIds));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
flag.put("sociologyLabel",sociologyLabel);
//国学运营标签
List<Integer> sociologyMarketIds = shopProductToSociologyMarketDao.selectList(new LambdaQueryWrapper<ShopProductToSociologyMarket>().eq(ShopProductToSociologyMarket::getProductId, productId)).stream().map(ShopProductToSociologyMarket::getSociologyMarketId).collect(Collectors.toList());
List<ShopProductSociologyMarket> shopProductSociologyMarkets = shopProductSociologyMarketDao.selectList(null);
List<ShopProductSociologyMarket> sociologyMarket = shopProductSociologyMarkets.stream().filter(m -> m.getPid() == 0)
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(sociologyMarketIds.contains(m.getId()));
}
m.setChildren(getSociologyMarketChildrens(m, shopProductSociologyMarkets, sociologyMarketIds));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
flag.put("sociologyMarket",sociologyMarket);
//医学标签
List<Integer> medicineLabelIds = shopProductToMedicineLabelDao.selectList(new LambdaQueryWrapper<ShopProductToMedicineLabel>().eq(ShopProductToMedicineLabel::getProductId, productId)).stream().map(ShopProductToMedicineLabel::getMedicineLabelId).collect(Collectors.toList());
List<ShopProductMedicineLabel> shopProductMedicineLabels = shopProductMedicineLabelDao.selectList(null);
List<ShopProductMedicineLabel> medicineLabel = shopProductMedicineLabels.stream().filter(m -> m.getPid() == 0)
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(medicineLabelIds.contains(m.getId()));
}
m.setChildren(getMedicineLabelChildrens(m, shopProductMedicineLabels, medicineLabelIds));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
flag.put("medicineLabel",medicineLabel);
//医学运营标签
List<Integer> medicineMarketIds = shopProductToMedicineMarketDao.selectList(new LambdaQueryWrapper<ShopProductToMedicineMarket>().eq(ShopProductToMedicineMarket::getProductId, productId)).stream().map(ShopProductToMedicineMarket::getMedicineMarketId).collect(Collectors.toList());
List<ShopProductMedicineMarket> shopProductMedicineMarkets = shopProductMedicineMarketDao.selectList(null);
List<ShopProductMedicineMarket> medicineMarket = shopProductMedicineMarkets.stream().filter(m -> m.getPid() == 0)
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(medicineMarketIds.contains(m.getId()));
}
m.setChildren(getMedicineMarketChildrens(m, shopProductMedicineMarkets, medicineMarketIds));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
flag.put("medicineMarket",medicineMarket);
return flag;
}
private List<ShopProductBookLabel> getBookLabelChildrens(ShopProductBookLabel root,List<ShopProductBookLabel> all,List<Integer> bookLabelIds){
List<ShopProductBookLabel> children = all.stream().filter(shopProductBookLabel -> {
return root.getId().equals(shopProductBookLabel.getPid());
}).map(l -> {
if(l.getIsLast()==1){
l.setSelect(bookLabelIds.contains(l.getId()));
}
l.setChildren(getBookLabelChildrens(l, all,bookLabelIds));
return l;
}).sorted((label1,label2)->{
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
}).collect(Collectors.toList());
return children;
}
private List<ShopProductBookMarket> getBookMarketChildrens(ShopProductBookMarket market,List<ShopProductBookMarket> all,List<Integer> bookMarketIds){
List<ShopProductBookMarket> children = all.stream().filter((m) -> {
return m.getPid().equals(market.getId());
})
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(bookMarketIds.contains(m.getId()));
}
m.setChildren(getBookMarketChildrens(m, all, bookMarketIds));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
return children;
}
private List<ShopProductSociologyLabel> getSociologyLabelChildrens(ShopProductSociologyLabel root,List<ShopProductSociologyLabel> all,List<Integer> ids){
List<ShopProductSociologyLabel> children = all.stream().filter((m) -> {
return m.getPid().equals(root.getId());
})
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(ids.contains(m.getId()));
}
m.setChildren(getSociologyLabelChildrens(m, all, ids));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
return children;
}
private List<ShopProductSociologyMarket> getSociologyMarketChildrens(ShopProductSociologyMarket root,List<ShopProductSociologyMarket> all,List<Integer> ids){
List<ShopProductSociologyMarket> children = all.stream().filter((m) -> {
return m.getPid().equals(root.getId());
})
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(ids.contains(m.getId()));
}
m.setChildren(getSociologyMarketChildrens(m, all, ids));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
return children;
}
private List<ShopProductMedicineLabel> getMedicineLabelChildrens(ShopProductMedicineLabel root,List<ShopProductMedicineLabel> all,List<Integer> ids){
List<ShopProductMedicineLabel> children = all.stream().filter((m) -> {
return m.getPid().equals(root.getId());
})
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(ids.contains(m.getId()));
}
m.setChildren(getMedicineLabelChildrens(m, all, ids));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
return children;
}
private List<ShopProductMedicineMarket> getMedicineMarketChildrens(ShopProductMedicineMarket root,List<ShopProductMedicineMarket> all,List<Integer> ids){
List<ShopProductMedicineMarket> children = all.stream().filter((m) -> {
return m.getPid().equals(root.getId());
})
.map((m) -> {
if (m.getIsLast() == 1) {
m.setSelect(ids.contains(m.getId()));
}
m.setChildren(getMedicineMarketChildrens(m, all, ids));
return m;
}).sorted((label1, label2) -> {
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
}).collect(Collectors.toList());
return children;
}
}