主页-我的课程
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
public class MedicineLabelAndMarketController {
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.*;
|
||||
import com.peanut.modules.master.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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("masterSociologyLabelAndMarket")
|
||||
@RequestMapping("master/sociologyLabelAndMarket")
|
||||
public class SociologyLabelAndMarketController {
|
||||
|
||||
@Autowired
|
||||
private ShopProductSociologyLabelService labelService;
|
||||
@Autowired
|
||||
private ShopProductSociologyMarketService marketService;
|
||||
@Autowired
|
||||
private ShopProductToSociologyLabelService toLabelService;
|
||||
@Autowired
|
||||
private ShopProductToSociologyMarketService toMarketService;
|
||||
@Autowired
|
||||
private ShopProductService productService;
|
||||
|
||||
/**
|
||||
* 标签树
|
||||
*/
|
||||
@RequestMapping(path = "/labelTree")
|
||||
public R labelTree() {
|
||||
List<ShopProductSociologyLabel> labelsTree = labelService.labelTree();
|
||||
return R.ok().put("result", labelsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标签列表
|
||||
*/
|
||||
@RequestMapping(path = "/getLabelListByPid")
|
||||
public R getLabelListByPid(String pid) {
|
||||
LambdaQueryWrapper<ShopProductSociologyLabel> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductSociologyLabel::getPid,pid);
|
||||
wrapper.orderByAsc(ShopProductSociologyLabel::getSort);
|
||||
wrapper.orderByAsc(ShopProductSociologyLabel::getCreateTime);
|
||||
List<ShopProductSociologyLabel> labelTopList = labelService.list(wrapper);
|
||||
return R.ok().put("result", labelTopList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 营销标签树
|
||||
*/
|
||||
@RequestMapping(path = "/marketTree")
|
||||
public R marketTree() {
|
||||
List<ShopProductSociologyMarket> marketsTree = marketService.marketTree();
|
||||
return R.ok().put("result", marketsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销标签列表
|
||||
*/
|
||||
@RequestMapping(path = "/getMakertListByPid")
|
||||
public R getMakertListByPid(String pid) {
|
||||
LambdaQueryWrapper<ShopProductSociologyMarket> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductSociologyMarket::getPid,pid);
|
||||
wrapper.orderByAsc(ShopProductSociologyMarket::getSort);
|
||||
wrapper.orderByAsc(ShopProductSociologyMarket::getCreateTime);
|
||||
List<ShopProductSociologyMarket> marketTopList = marketService.list(wrapper);
|
||||
return R.ok().put("result", marketTopList);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/getLabelById")
|
||||
public R getLabelById(String id) {
|
||||
return R.ok().put("result",labelService.getById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateLabel")
|
||||
public R saveOrUpdateLabel(@RequestBody ShopProductSociologyLabel label) {
|
||||
if (label.getId()==null){
|
||||
if(label.getPid()==0){
|
||||
labelService.save(label);
|
||||
return R.ok().put("result",label);
|
||||
}else {
|
||||
ShopProductSociologyLabel l = labelService.getById(label.getPid());
|
||||
if (l.getIsLast()==1){
|
||||
return R.error("请将父标签设置为非最后一集");
|
||||
}else {
|
||||
labelService.save(label);
|
||||
return R.ok().put("result",label);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (label.getIsLast() == 1){
|
||||
List llast = labelService.list(new LambdaQueryWrapper<ShopProductSociologyLabel>()
|
||||
.eq(ShopProductSociologyLabel::getPid,label.getId()));
|
||||
if (llast.size()>0){
|
||||
return R.error("请先删除子集,再设置为最后一集");
|
||||
}else {
|
||||
labelService.saveOrUpdate(label);
|
||||
return R.ok().put("result",label);
|
||||
}
|
||||
}else {
|
||||
labelService.saveOrUpdate(label);
|
||||
return R.ok().put("result",label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delLabel")
|
||||
public R delLabel(String id) {
|
||||
ShopProductSociologyLabel label = labelService.getById(id);
|
||||
if (label.getIsLast()==1){
|
||||
MPJLambdaWrapper<ShopProductToSociologyLabel> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(ShopProductToSociologyLabel::getSociologyLabelId,id);
|
||||
List<ShopProductToSociologyLabel> tolables = toLabelService.list(wrapper);
|
||||
if (tolables.size()>0){
|
||||
return R.error("请先移除商品");
|
||||
}else {
|
||||
labelService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}else {
|
||||
List<ShopProductSociologyLabel> labelList = labelService.list(new LambdaQueryWrapper<ShopProductSociologyLabel>().eq(ShopProductSociologyLabel::getPid,id));
|
||||
if (labelList.size() > 0) {
|
||||
return R.error("请先删除子集");
|
||||
}else {
|
||||
labelService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/getMarketById")
|
||||
public R getMarketById(String id) {
|
||||
return R.ok().put("result",marketService.getById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateMarket")
|
||||
public R saveOrUpdateMarket(@RequestBody ShopProductSociologyMarket market) {
|
||||
if (market.getId()==null){
|
||||
if(market.getPid()==0){
|
||||
marketService.save(market);
|
||||
return R.ok().put("result",market);
|
||||
}else {
|
||||
ShopProductSociologyMarket m = marketService.getById(market.getPid());
|
||||
if (m.getIsLast()==1){
|
||||
return R.error("请将父标签设置为非最后一集");
|
||||
}else {
|
||||
marketService.save(market);
|
||||
return R.ok().put("result",market);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if (market.getIsLast() == 1){
|
||||
List mList = marketService.list(new LambdaQueryWrapper<ShopProductSociologyMarket>()
|
||||
.eq(ShopProductSociologyMarket::getPid,market.getId()));
|
||||
if (mList.size()>0){
|
||||
return R.error("请先删除子集,再设置为最后一集");
|
||||
}else {
|
||||
marketService.saveOrUpdate(market);
|
||||
return R.ok().put("result",market);
|
||||
}
|
||||
}else {
|
||||
marketService.saveOrUpdate(market);
|
||||
return R.ok().put("result",market);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delMarket")
|
||||
public R delMarket(String id) {
|
||||
ShopProductSociologyMarket market = marketService.getById(id);
|
||||
if (market.getIsLast()==1){
|
||||
MPJLambdaWrapper<ShopProductToSociologyMarket> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(ShopProductToSociologyMarket::getSociologyMarketId,id);
|
||||
List<ShopProductToSociologyMarket> tomarkets = toMarketService.list(wrapper);
|
||||
if (tomarkets.size()>0){
|
||||
return R.error("请先移除商品");
|
||||
}else {
|
||||
marketService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}else {
|
||||
List<ShopProductSociologyMarket> marketList = marketService.list(new LambdaQueryWrapper<ShopProductSociologyMarket>().eq(ShopProductSociologyMarket::getPid,id));
|
||||
if (marketList.size() > 0) {
|
||||
return R.error("请先删除子集");
|
||||
}else {
|
||||
marketService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未关联商品列表
|
||||
*/
|
||||
@RequestMapping("/getNotToLabelList")
|
||||
public R getNotToLabelList(@RequestBody Map params){
|
||||
LambdaQueryWrapper<ShopProduct> wrapper = new LambdaQueryWrapper();
|
||||
if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){
|
||||
wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString());
|
||||
}
|
||||
if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){
|
||||
wrapper.like(ShopProduct::getProductName,params.get("productName").toString());
|
||||
}
|
||||
if (params.containsKey("sociologyLabelId")&&!"".equals(params.get("sociologyLabelId").toString())){
|
||||
String sql = "select product_id from shop_product_to_sociology_label where del_flag = 0 and sociology_label_id = "+params.get("sociologyLabelId");
|
||||
wrapper.notInSql(ShopProduct::getProductId,sql);
|
||||
}
|
||||
if (params.containsKey("bookMarketId")&&!"".equals(params.get("bookMarketId").toString())){
|
||||
String sql = "select product_id from shop_product_to_sociology_market where del_flag = 0 and sociology_market_id = "+params.get("sociologyMarketId");
|
||||
wrapper.notInSql(ShopProduct::getProductId,sql);
|
||||
}
|
||||
Page<ShopProduct> page = productService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取书标签列表
|
||||
*/
|
||||
@RequestMapping("/getToLabelList")
|
||||
public R getToLabelList(@RequestBody Map params){
|
||||
MPJLambdaWrapper<ShopProductToSociologyLabel> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.selectAll(ShopProductToSociologyLabel.class);
|
||||
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToSociologyLabel::getProductId);
|
||||
if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){
|
||||
wrapper.like(ShopProduct::getProductName,params.get("productName").toString());
|
||||
}
|
||||
if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){
|
||||
wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString());
|
||||
}
|
||||
if (params.containsKey("productId")&&!"".equals(params.get("productId").toString())){
|
||||
wrapper.eq(ShopProductToSociologyLabel::getProductId,params.get("productId").toString());
|
||||
}
|
||||
if (params.containsKey("sociologyLabelId")&&!"".equals(params.get("sociologyLabelId").toString())){
|
||||
wrapper.eq(ShopProductToSociologyLabel::getSociologyLabelId,params.get("sociologyLabelId").toString());
|
||||
}
|
||||
Page<ShopProductToSociologyLabel> page = toLabelService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
List<ShopProductToSociologyLabel> res = page.getRecords();
|
||||
if (res.size() > 0) {
|
||||
for (ShopProductToSociologyLabel item : res) {
|
||||
item.setProduct(productService.getById(item.getProductId()));
|
||||
item.setLabel(labelService.getById(item.getSociologyLabelId()));
|
||||
}
|
||||
}
|
||||
page.setRecords(res);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销标签列表
|
||||
*/
|
||||
@RequestMapping("/getToMarketList")
|
||||
public R getToMarketList(@RequestBody Map params){
|
||||
MPJLambdaWrapper<ShopProductToSociologyMarket> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.selectAll(ShopProductToSociologyMarket.class);
|
||||
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToSociologyMarket::getProductId);
|
||||
if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){
|
||||
wrapper.like(ShopProduct::getProductName,params.get("productName").toString());
|
||||
}
|
||||
if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){
|
||||
wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString());
|
||||
}
|
||||
if (params.containsKey("productId")&&!"".equals(params.get("productId").toString())){
|
||||
wrapper.eq(ShopProductToBookMarket::getProductId,params.get("productId").toString());
|
||||
}
|
||||
if (params.containsKey("sociologyMarketId")&&!"".equals(params.get("sociologyMarketId").toString())){
|
||||
wrapper.eq(ShopProductToSociologyMarket::getSociologyMarketId,params.get("sociologyMarketId").toString());
|
||||
}
|
||||
Page<ShopProductToSociologyMarket> page = toMarketService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
List<ShopProductToSociologyMarket> res = page.getRecords();
|
||||
if (res.size() > 0) {
|
||||
for (ShopProductToSociologyMarket item : res) {
|
||||
item.setProduct(productService.getById(item.getProductId()));
|
||||
item.setMarket(marketService.getById(item.getSociologyMarketId()));
|
||||
}
|
||||
}
|
||||
page.setRecords(res);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveToLabel")
|
||||
public R saveToLabel(@RequestBody Map params) {
|
||||
if (!StringUtils.isEmpty(params.get("productId").toString())){
|
||||
String[] ids = params.get("productId").toString().split(",");
|
||||
if (ids.length > 0) {
|
||||
for (String id : ids) {
|
||||
ShopProductToSociologyLabel toLabel = new ShopProductToSociologyLabel();
|
||||
toLabel.setSociologyLabelId(Integer.parseInt(params.get("sociologyLabelId").toString()));
|
||||
toLabel.setProductId(Integer.parseInt(id));
|
||||
toLabelService.save(toLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveToMarket")
|
||||
public R saveToMarket(@RequestBody Map params) {
|
||||
if (!StringUtils.isEmpty(params.get("productId").toString())){
|
||||
String[] ids = params.get("productId").toString().split(",");
|
||||
if (ids.length > 0) {
|
||||
for (String id : ids) {
|
||||
ShopProductToSociologyMarket toMarket = new ShopProductToSociologyMarket();
|
||||
toMarket.setSociologyMarketId(Integer.parseInt(params.get("sociologyMarketId").toString()));
|
||||
toMarket.setProductId(Integer.parseInt(id));
|
||||
toMarketService.save(toMarket);
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delToLable")
|
||||
public R delToLable(String lableId,String productId) {
|
||||
if(StringUtils.isNotEmpty(productId)){
|
||||
String[] productIds = productId.split(",");
|
||||
for(String id : productIds){
|
||||
LambdaQueryWrapper<ShopProductToSociologyLabel> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductToSociologyLabel::getSociologyLabelId,lableId);
|
||||
wrapper.eq(ShopProductToSociologyLabel::getProductId,id);
|
||||
toLabelService.remove(wrapper);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delToMarket")
|
||||
public R delToMarket(String marketId,String productId) {
|
||||
if(StringUtils.isNotEmpty(productId)){
|
||||
String[] productIds = productId.split(",");
|
||||
for(String id : productIds){
|
||||
LambdaQueryWrapper<ShopProductToSociologyMarket> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductToSociologyMarket::getSociologyMarketId,marketId);
|
||||
wrapper.eq(ShopProductToSociologyMarket::getProductId,id);
|
||||
toMarketService.remove(wrapper);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
|
||||
|
||||
public interface ShopProductMedicineLabelService extends IService<ShopProductMedicineLabel> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
|
||||
|
||||
public interface ShopProductMedicineMarketService extends IService<ShopProductMedicineMarket> {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProductSociologyLabel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ShopProductSociologyLabelService extends IService<ShopProductSociologyLabel> {
|
||||
|
||||
List<ShopProductSociologyLabel> labelTree();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProductSociologyMarket;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ShopProductSociologyMarketService extends IService<ShopProductSociologyMarket> {
|
||||
|
||||
List<ShopProductSociologyMarket> marketTree();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProductToMedicineLabel;
|
||||
|
||||
public interface ShopProductToMedicineLabelService extends IService<ShopProductToMedicineLabel> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProductToMedicineMarket;
|
||||
|
||||
public interface ShopProductToMedicineMarketService extends IService<ShopProductToMedicineMarket> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProductToSociologyLabel;
|
||||
|
||||
public interface ShopProductToSociologyLabelService extends IService<ShopProductToSociologyLabel> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ShopProductToSociologyMarket;
|
||||
|
||||
public interface ShopProductToSociologyMarketService extends IService<ShopProductToSociologyMarket> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("medicineShopProductMedicineLabelService")
|
||||
public class ShopProductMedicineLabelServiceImpl extends ServiceImpl<ShopProductMedicineLabelDao, ShopProductMedicineLabel> implements ShopProductMedicineLabelService {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("medicineShopProductMedicineMarketService")
|
||||
public class ShopProductMedicineMarketServiceImpl extends ServiceImpl<ShopProductMedicineMarketDao, ShopProductMedicineMarket> implements ShopProductMedicineMarketService {
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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.ShopProductSociologyLabelDao;
|
||||
import com.peanut.modules.common.entity.ShopProductSociologyLabel;
|
||||
import com.peanut.modules.master.service.ShopProductSociologyLabelService;
|
||||
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("sociologyShopProductSociologyLabelService")
|
||||
public class ShopProductSociologyLabelServiceImpl extends ServiceImpl<ShopProductSociologyLabelDao, ShopProductSociologyLabel> implements ShopProductSociologyLabelService {
|
||||
|
||||
@Autowired
|
||||
private ShopProductSociologyLabelDao labelDao;
|
||||
|
||||
@Override
|
||||
public List<ShopProductSociologyLabel> labelTree() {
|
||||
List<ShopProductSociologyLabel> labels = labelDao.selectList(new QueryWrapper<>());
|
||||
List<ShopProductSociologyLabel> labelsTree = labels.stream().filter((shopProductSociologyLabel) ->
|
||||
shopProductSociologyLabel.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<ShopProductSociologyLabel> getLabelChildrens(ShopProductSociologyLabel root,List<ShopProductSociologyLabel> all){
|
||||
List<ShopProductSociologyLabel> children = all.stream().filter(shopProductSociologyLabel -> {
|
||||
return root.getId().equals(shopProductSociologyLabel.getPid());
|
||||
}).map(shopProductSociologyLabel -> {
|
||||
shopProductSociologyLabel.setChildren(getLabelChildrens(shopProductSociologyLabel, all));
|
||||
return shopProductSociologyLabel;
|
||||
}).sorted((label1,label2)->{
|
||||
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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.ShopProductSociologyMarketDao;
|
||||
import com.peanut.modules.common.entity.ShopProductSociologyMarket;
|
||||
import com.peanut.modules.master.service.ShopProductSociologyMarketService;
|
||||
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("sociologyShopProductSociologyMarketService")
|
||||
public class ShopProductSociologyMarketServiceImpl extends ServiceImpl<ShopProductSociologyMarketDao, ShopProductSociologyMarket> implements ShopProductSociologyMarketService {
|
||||
|
||||
@Autowired
|
||||
private ShopProductSociologyMarketDao marketDao;
|
||||
|
||||
@Override
|
||||
public List<ShopProductSociologyMarket> marketTree() {
|
||||
List<ShopProductSociologyMarket> markets = marketDao.selectList(new QueryWrapper<>());
|
||||
List<ShopProductSociologyMarket> marketsTree = markets.stream().filter((shopProductSociologyMarket) ->
|
||||
shopProductSociologyMarket.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<ShopProductSociologyMarket> getMarketChildrens(ShopProductSociologyMarket root,List<ShopProductSociologyMarket> all){
|
||||
List<ShopProductSociologyMarket> children = all.stream().filter(shopProductSociologyMarket -> {
|
||||
return root.getId().equals(shopProductSociologyMarket.getPid());
|
||||
}).map(shopProductSociologyMarket -> {
|
||||
shopProductSociologyMarket.setChildren(getMarketChildrens(shopProductSociologyMarket, all));
|
||||
return shopProductSociologyMarket;
|
||||
}).sorted((sort1,sort2)->{
|
||||
return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("medicineShopProductToMedicineLabelService")
|
||||
public class ShopProductToMedicineLabelServiceImpl extends ServiceImpl<ShopProductToMedicineLabelDao, ShopProductToMedicineLabel> implements ShopProductToMedicineLabelService {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("medicineShopProductToMedicineMarketService")
|
||||
public class ShopProductToMedicineMarketServiceImpl extends ServiceImpl<ShopProductToMedicineMarketDao, ShopProductToMedicineMarket> implements ShopProductToMedicineMarketService {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.ShopProductToSociologyLabelDao;
|
||||
import com.peanut.modules.common.entity.ShopProductToSociologyLabel;
|
||||
import com.peanut.modules.master.service.ShopProductToSociologyLabelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("sociologyShopProductToSociologyLabelService")
|
||||
public class ShopProductToSociologyLabelServiceImpl extends ServiceImpl<ShopProductToSociologyLabelDao, ShopProductToSociologyLabel> implements ShopProductToSociologyLabelService {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.ShopProductToSociologyMarketDao;
|
||||
import com.peanut.modules.common.entity.ShopProductToSociologyMarket;
|
||||
import com.peanut.modules.master.service.ShopProductToSociologyMarketService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("sociologyShopProductToSociologyMarketService")
|
||||
public class ShopProductToSociologyMarketServiceImpl extends ServiceImpl<ShopProductToSociologyMarketDao, ShopProductToSociologyMarket> implements ShopProductToSociologyMarketService {
|
||||
}
|
||||
Reference in New Issue
Block a user