当前位置:网站首页>树状类查询组件
树状类查询组件
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;
}
边栏推荐
- Core points of assembly language
- Flex & Bison 開始
- 判断预约时间是否已经过期
- leetcode_ 136_ A number that appears only once
- The sum of logarithms in group 52--e of Niuke Xiaobai monthly race (two points)
- UE4 学习记录二 给角色添加骨架,皮肤,及运动动画
- 信息学奥赛一本通 1353:表达式括号匹配(stack) | 洛谷 P1739 表达式括号匹配
- 我的vscode
- cookie、session、token
- Circuit module analysis exercise 6 (switch)
猜你喜欢

Use and difference between ue4\ue5 blueprint node delay and retroggable delay

Pit resolution encountered using East OCR (compile LAMS)

做接口测试,这3种工具到底什么时候用?

character string

ES6 learning -- let
2、一个向量乘它的转置,其几何意义是什么?

Fegin client entry test

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

Meta universe standard forum established

Ble Low Power Bluetooth networking process and Bluetooth role introduction
随机推荐
konva系列教程2:绘制图形
首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
Idea shortcut
Utilisation de la classe Ping d'Unity
[untitled] open an item connection. If it cannot be displayed normally, Ping the IP address
[modulebuilder] GP service realizes the intersection selection of two layers in SDE
电路模块分析练习5(电源)
毕业旅行 | 伦敦5日游行程推荐
Multithreaded learning 1
最近准备翻译外国优质文章
leetcode_ 136_ A number that appears only once
多台云服务器的 Kubernetes 集群搭建
Flex & Bison Start
24class static member
Paper notes: multi tag learning MSWl
Common MySQL database functions and queries
Ue4 Ue5 combine le plug - in de reconnaissance vocale de bureau pour la reconnaissance vocale
【ModuleBuilder】GP服务实现SDE中两个图层相交选取
Circuit module analysis exercise 6 (switch)
What is Unified Extensible Firmware Interface (UEFI)?