当前位置:网站首页>树状类查询组件
树状类查询组件
2022-06-25 22:00:00 【EntyIU】
有时候我们有查询分类的查询需求,并且我们也不确定会有多少层,需要从顶层查到最底层,可以使用以下的方法
@GetMapping(value = "/ttt")
public HttpResult hui(){
LambdaQueryWrapper<Company> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(Company::getParentId,-1);
List<Company> list=companyService.list(queryWrapper);
List<CompanyRes> companyRes = ConvertUtils.convertList(list, CompanyRes.class);
getAll(companyRes);
return HttpResult.ok(companyRes);
}
/**
*多次回调自己实现查询到底的业务
*/
public void getAll(List<CompanyRes> list){
list.stream().map(a->{
LambdaQueryWrapper<Company> queryWrapper=new LambdaQueryWrapper<>();
queryWrapper.eq(Company::getParentId,a.getId());
List<Company> list1=companyService.list(queryWrapper);
List<CompanyRes> companyRes = ConvertUtils.convertList(list1, CompanyRes.class);
if (companyRes!=null){
getAll(companyRes);
a.setList(companyRes);
}
return a;
}).collect(Collectors.toList());
}
/**
*反参类
*/
@Data
public class CompanyRes {
@TableId(type = IdType.ID_WORKER)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/** 公司名称 */
private String companyName;
/**
* 父级公司id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long parentId;
/**
* 公司法人
*/
private String legalPerson;
/**
* 公司地址
*/
private String companyAddress;
/**
* 公司联系方式
*/
private String companyPhone;
private List<CompanyRes> list;
}
边栏推荐
- 【AXI】解读AXI协议原子化访问
- UE4_ Ue5 combines the offline voice recognition plug-in for speech recognition
- 毕业旅行 | 伦敦5日游行程推荐
- Oracle - data query
- 23class introduction
- 牛客小白月賽52--E 分組求對數和(二分)
- 24class static member
- The Ping class of unity uses
- STM32 development board + smart cloud aiot+ home monitoring and control system
- NLP text summary: use the pre training model to perform text summary tasks [transformers:pipeline, T5, Bart, Pegasus]
猜你喜欢

Ue4 Ue5 combine le plug - in de reconnaissance vocale de bureau pour la reconnaissance vocale

多台云服务器的 Kubernetes 集群搭建

RepOptimizer: 其实是RepVGG2

UE4_UE5結合offline voice recognition插件做語音識別功能

Efr32bg22 ble module (low power Bluetooth communication module) at command test

How to add cartoon characters to the blog park?

The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars

Oracle -- table operation

Several optimization scenarios using like fuzzy retrieval in SQL

Pit resolution encountered using East OCR (compile LAMS)
随机推荐
Day4 branch and loop summary and operation
LM small programmable controller software (based on CoDeSys) note XVII: PTO pulse function block
Unity technical manual - getKey and getaxis and getbutton
[2023 proofreading and bidding questions] Part 1: Measurement Technology FPGA post (roughly analytical version)
ES6 -- formal parameter setting initial value, extension operator, iterator, and generating function
[modulebuilder] GP service realizes the intersection selection of two layers in SDE
UE4_UE5结合offline voice recognition插件做语音识别功能
Leetcode(435)——无重叠区间
. SQL database import error: / *! 40101 SET @OLD_ COLLATION_ [email protected]@COLLATION_ CONNECTION */
2. What is the geometric meaning of a vector multiplying its transpose?
Flex & Bison 开始
Pit resolution encountered using East OCR (compile LAMS)
24class static member
The applet draws a simple pie chart
The sum of logarithms in group 52--e of Niuke Xiaobai monthly race (two points)
Somme logarithmique (deux points) pour le Groupe 52 - - e de la course de la lune blanche de niuke
CTS RTS RX TX in serial port flow control UART (direct communication between serial port module and MCU)
CAD中图纸比较功能怎么用
字符串
STM32开发板+机智云AIoT+家庭监测控制系统