管理端-课程营销标签

This commit is contained in:
wuchunlei
2024-04-19 10:39:40 +08:00
parent 9009b18ce6
commit a855db66a9
8 changed files with 294 additions and 15 deletions

View File

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

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.master.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.CourseToMarketEntity;
public interface CourseToMarketService extends IService<CourseToMarketEntity> {
}

View File

@@ -0,0 +1,48 @@
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.CourseMarketDao;
import com.peanut.modules.common.entity.CourseMarketEntity;
import com.peanut.modules.master.service.CourseMarketService;
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("masterCourseMarketService")
public class CourseMarketServiceImpl extends ServiceImpl<CourseMarketDao, CourseMarketEntity> implements CourseMarketService {
@Autowired
private CourseMarketDao marketDao;
@Override
public List<CourseMarketEntity> marketTree() {
List<CourseMarketEntity> markets = marketDao.selectList(new QueryWrapper<>());
List<CourseMarketEntity> marketsTree = markets.stream().filter((courseMarketEntity) ->
courseMarketEntity.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<CourseMarketEntity> getMarketChildrens(CourseMarketEntity root,List<CourseMarketEntity> all){
List<CourseMarketEntity> children = all.stream().filter(courseMarketEntity -> {
return root.getId().equals(courseMarketEntity.getPid());
}).map(courseMarketEntity -> {
courseMarketEntity.setChildren(getMarketChildrens(courseMarketEntity, all));
return courseMarketEntity;
}).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.master.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.CourseToMarketDao;
import com.peanut.modules.common.entity.CourseToMarketEntity;
import com.peanut.modules.master.service.CourseToMarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("masterCourseToMarketService")
public class CourseToMarketServiceImpl extends ServiceImpl<CourseToMarketDao, CourseToMarketEntity> implements CourseToMarketService {
}