管理端-课程营销标签
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
Reference in New Issue
Block a user