当前位置:网站首页>Course classification tree structure display
Course classification tree structure display
2022-06-11 03:37:00 【The bright moon is always fresh】
The course classification tree structure displays
1、 Analyze requirements

Refer to the existing modules for implementation
2、 Copy page elements
Reference has been made to tree page
3、 Page data structure

4、 Implementation interface
(1) establish vo
@Data
public class OneSubjectVo {
@ApiModelProperty(value = " Course category ID")
private String id;
@ApiModelProperty(value = " Category name ")
private String title;
private List<TwoSubjectVo> children =new ArrayList<>();
}
@Data
public class TwoSubjectVo {
@ApiModelProperty(value = " Course category ID")
private String id;
@ApiModelProperty(value = " Category name ")
private String title;
}
@ApiOperation(value = " Query all course classifications ")
@GetMapping("getAllSubject")
public R getAllSubject(){
List<OneSubjectVo> allSubjectList = subjectService.getAllSubject();
return R.ok().data("allSubject",allSubjectList);
}
// Query all course classifications
@Override
public List<OneSubjectVo> getAllSubject() {
//1 Query all first level classifications
QueryWrapper<EduSubject> wrapperOne = new QueryWrapper<>();
wrapperOne.eq("parent_id","0");
List<EduSubject> oneSubjectList = baseMapper.selectList(wrapperOne);
//2 Query all secondary classifications
QueryWrapper<EduSubject> wrapperTwo = new QueryWrapper<>();
// It's not equal to
wrapperTwo.ne("parent_id","0");
List<EduSubject> twoSubjectList = baseMapper.selectList(wrapperTwo);
//3 Package level 1 Classification
List<OneSubjectVo> allSubjectList = new ArrayList<>();
for (int i = 0; i <oneSubjectList.size() ; i++) {
//3.1 Take out each primary classification
EduSubject oneSubject = oneSubjectList.get(i);
//3.2EduSubject conversion OneSubjectVo
OneSubjectVo oneSubjectVo = new OneSubjectVo();
// oneSubjectVo.setId(oneSubject.getId());
// oneSubjectVo.setTitle(oneSubject.getTitle());
// No problem with fewer fields Too much is not enough
BeanUtils.copyProperties(oneSubject,oneSubjectVo);
allSubjectList.add(oneSubjectVo);
//4 Find the second level related to the root level and encapsulate it
List<TwoSubjectVo> twoSubjectVos = new ArrayList<>();
for (int m = 0; m < twoSubjectList.size(); m++) {
//4.1 Take out each secondary classification
EduSubject twoSubject = twoSubjectList.get(m);
//4.2 Determine whether it belongs to this level
if(twoSubject.getParentId().equals(oneSubject.getId())){
//4.3EduSubject conversion TwoSubjectVo
TwoSubjectVo twoSubjectVo = new TwoSubjectVo();
BeanUtils.copyProperties(twoSubject,twoSubjectVo);
twoSubjectVos.add(twoSubjectVo);
}
}
oneSubjectVo.setChildren(twoSubjectVos);
}
return allSubjectList;
}
边栏推荐
- OPENSSL ASN. 1, DER, PEM, X509
- Pthread in the multithreaded Trilogy
- C. Jump and Treasure(dp + 单调队列优化)
- Log4j use
- RequestContextHolder
- OpenGL第八章 材质material
- Why is vfly, a high-end brand of Yadi that does not live up to its name, not high-end?
- Tweenmax colorful ball bouncing animation
- SQL | 游戏行业部分指标
- J. Balanced Tree
猜你喜欢

Canvas rotation drawing H5 animation JS effect

has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header is present on the requested

Unity之数据持久化——Json

HikariPool-1 - Shutdown initiated... HikariPool-1 - Shutdown completed.

OPPO K9试水“捆绑销售”,消费者“赚了”还是“亏了”?

If no separation ----- > > login module nanny level source code analysis (0)

Logical deletion_ Swagger2 framework integration

Xu Li 618, how can Suning fight this hard battle?

618将至!全渠道开售,高价低配的OPPO Reno6能赢吗?

Oppo reno6 turned sour by "inner roll"
随机推荐
Parameter transfer format when the parameter of PostgreSQL function is a user-defined type
Unity's data persistence -- Jason
JS to realize coritization
Computer vision (AI) interview
RHEL7 切换字符编码为GBK
Azure Kubernates Service 更新|提升开发体验和效率
Multi thread alternate output ab
Right click PowerShell here function add
If there is no separation ----- > > log interpretation (3)
JS top icon menu click to switch background color JS special effect
Disk quota exceeded
postgresql 捕获函数中的异常
three.js炫酷科技感背景h5动画
[cloud native] what is micro service? How to build it? Teach you how to build the first micro service (framework)
OpenGL error Guide
023 MySQL index optimization tips - common cases of index failure
OpenGl第十章 投光物
has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header is present on the requested
JS the most commonly used sorting - hand tearing JS series
[elt.zip] openharmony paper Club - multi tier storage hierarchical data compression