当前位置:网站首页>树状类查询组件
树状类查询组件
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;
}
边栏推荐
- Ble Low Power Bluetooth networking process and Bluetooth role introduction
- UE4\UE5 蓝图节点Delay与Retriggerable Delay的使用与区别
- Unity technical manual - getKey and getaxis and getbutton
- 漏刻有时API接口实战开发系列(13):小鹅通云服务PHP-API二维数组传参解决方案
- Several optimization scenarios using like fuzzy retrieval in SQL
- 电路模块分析练习6(开关)
- Idea shortcut
- Sword finger offer 46 Translate numbers to strings (DP)
- 牛客小白月賽52--E 分組求對數和(二分)
- Xampp重启后,MySQL服务就启动不了。
猜你喜欢

元宇宙标准论坛成立

Live800在线客服系统:跨越时空做生意,从每次互动开始

Why is the frame rate calculated by opencv wrong?

How to use drawing comparison function in CAD

论文笔记: 多标签学习 MSWL
![[opencv450 samples] inpaint restores the selected region in the image using the region neighborhood](/img/36/8ad6034473382f66f315eb70440711.png)
[opencv450 samples] inpaint restores the selected region in the image using the region neighborhood

Oracle - getting started
2、一个向量乘它的转置,其几何意义是什么?

问题记录与思考

Ue4 Ue5 combine le plug - in de reconnaissance vocale de bureau pour la reconnaissance vocale
随机推荐
LM small programmable controller software (based on CoDeSys) note XVII: PTO pulse function block
Fegin client entry test
[opencv450 samples] read the image path list and maintain the proportional display
Pointer strengthening and improvement
ES6 - numerical extension and object extension
#24class静态成员
My C language learning process
Idea shortcut
信息学奥赛一本通 1353:表达式括号匹配(stack) | 洛谷 P1739 表达式括号匹配
Fastjson deserialization randomness failed
Xinchida nd04 nd04c nrf52832 (52810) ble module (low power Bluetooth communication module) at command test
RK3568+鸿蒙工控板工业网关视频网关解决方案
After xampp restarts, the MySQL service cannot be started.
Repoptimizer: it's actually repvgg2
Implementation of sequence table: static and dynamic
cookie、session、token
Efr32bg22 ble module (low power Bluetooth communication module) at command test
Oracle -- table operation
【opencv450-samples】inpaint 使用区域邻域恢复图像中的选定区域
百度:2022年十大热度攀升专业出炉,第一名无悬念!