首页标签树
This commit is contained in:
@@ -3,11 +3,15 @@ package com.peanut.modules.common.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CoursePsyche;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CoursePsycheService extends IService<CoursePsyche> {
|
||||
|
||||
List<CoursePsyche> getCoursePsycheTree();
|
||||
|
||||
List<CoursePsyche> getChildCoursePsycheTree(ParamTo param);
|
||||
|
||||
List<CoursePsyche> getCoursePsycheList();
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.peanut.modules.common.dao.CourseToPsycheDao;
|
||||
import com.peanut.modules.common.entity.CoursePsyche;
|
||||
import com.peanut.modules.common.entity.CourseToPsyche;
|
||||
import com.peanut.modules.common.service.CoursePsycheService;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -48,6 +49,31 @@ public class CoursePsycheServiceImpl extends ServiceImpl<CoursePsycheDao, Course
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CoursePsyche> getChildCoursePsycheTree(ParamTo param) {
|
||||
List<CoursePsyche> psyches = this.list(new QueryWrapper<>());
|
||||
List<CoursePsyche> psychesTree = psyches.stream().filter((coursePsyche) ->
|
||||
coursePsyche.getPid() == param.getId()
|
||||
).map((psyche)->{
|
||||
psyche.setChildren(getChildPsycheChildrens(psyche,psyches));
|
||||
return psyche;
|
||||
}).sorted((sort1,sort2)->{
|
||||
return (sort1.getSort() == null? 0 : sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return psychesTree;
|
||||
}
|
||||
private List<CoursePsyche> getChildPsycheChildrens(CoursePsyche root, List<CoursePsyche> all){
|
||||
List<CoursePsyche> children = all.stream().filter(coursePsyche -> {
|
||||
return root.getId().equals(coursePsyche.getPid());
|
||||
}).map(coursePsyche -> {
|
||||
coursePsyche.setChildren(getChildPsycheChildrens(coursePsyche, all));
|
||||
return coursePsyche;
|
||||
}).sorted((sort1,sort2)->{
|
||||
return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CoursePsyche> getCoursePsycheList() {
|
||||
return this.Psyches(0);
|
||||
|
||||
Reference in New Issue
Block a user