当前位置:网站首页>树状类查询组件
树状类查询组件
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;
}
边栏推荐
- [untitled] open an item connection. If it cannot be displayed normally, Ping the IP address
- Leaky API interface practical development series (13): gooseneck cloud service php-api two-dimensional array parameter transfer solution
- 【opencv450-samples】inpaint 使用区域邻域恢复图像中的选定区域
- Exclusive or operator simple logic operation a^=b
- RK3568+鸿蒙工控板工业网关视频网关解决方案
- Basic operator
- [eosio] eos/wax signature error is_ Canonical (c): signature is not canonical
- How to download the software package of CDH version
- Efr32bg22 ble module (low power Bluetooth communication module) at command test
- 牛客小白月賽52--E 分組求對數和(二分)
猜你喜欢
Live800在线客服系统:跨越时空做生意,从每次互动开始
leetcode_ 136_ A number that appears only once
Beacon realizes asset management and indoor positioning based on 5.2 ultra-low power Bluetooth module efr32 (bg22ax)
元宇宙标准论坛成立
Why is BeanUtils not recommended?
C language (I)
ES6 - numerical extension and object extension
UE4 学习记录二 给角色添加骨架,皮肤,及运动动画
Sword finger offer 46 Translate numbers to strings (DP)
Leaky API interface practical development series (13): gooseneck cloud service php-api two-dimensional array parameter transfer solution
随机推荐
Jupiter notebook common shortcut keys
【2023校招刷题】番外篇1:度量科技FPGA岗(大致解析版)
Actual combat: how to quickly change font color in typera (blog sharing - perfect) -2022.6.25 (solved)
论文笔记: 多标签学习 MSWL
小程序-视图与逻辑
To solve the incompatibility between VM and device/credential guard, an effective solution for the whole network
汇编语言核心要点
Es7/es9 -- new features and regularities
. SQL database import error: / *! 40101 SET @OLD_ COLLATION_ [email protected]@COLLATION_ CONNECTION */
Meta universe standard forum established
记一次beego通过go get命令后找不到bee.exe的坑
Multithreaded learning 1
毕业旅行 | 伦敦5日游行程推荐
What aspects should we start with in the feasibility analysis of dry goods?
[modulebuilder] GP service realizes the intersection selection of two layers in SDE
Implementation of sequence table: static and dynamic
The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars
【AXI】解读AXI协议原子化访问
Leaky API interface practical development series (13): gooseneck cloud service php-api two-dimensional array parameter transfer solution
Utilisation de la classe Ping d'Unity