1.通过 `tenant_info `表的 customer_id(对应`custom_info`表的主键id)来l获取每个租户的 id
2.拿着id到 `custom_info`表获取具体的客户对象
3.通过获取到的客户对象拿到具体的客户名,具体实现如下:
@AutoLog(value = "tenant_info-分页列表查询")
@ApiOperation(value = "tenant_info-分页列表查询", notes = "tenant_info-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<TenantInfo>> queryPageList(TenantInfo tenantInfo,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<TenantInfo> queryWrapper = QueryGenerator.initQueryWrapper(tenantInfo, req.getParameterMap());
Page<TenantInfo> page = new Page<TenantInfo>(pageNo, pageSize);
IPage<TenantInfo> pageList = tenantInfoService.page(page, queryWrapper);
pageList.getRecords().forEach(item -> {
if (item.getMonitorPonitIds() != null && item.getMonitorPonitIds().length() > 0) {
List<String> monitorIds = Arrays.asList(item.getMonitorPonitIds().split("\\|"));
List<@NotNull(message = "隐患点名称不能为空") String> monitorPointNames = monitorPointService
.listByIds(monitorIds)
.stream()
.map(MonitorPoint::getMonitorPointName)
.collect(Collectors.toList());
String newMonitorPointNameStr = Joiner.on(" | ").join(monitorPointNames);
item.setMonitorPointNames(newMonitorPointNameStr);
}
CustomerInfo customInfo = customInfoService.getById(item.getCustomerId());
String customerName=null;
if (!ObjectUtils.isEmpty(customInfo)){
customerName = customInfo.getCustomerName();
if (!ObjectUtils.isEmpty(customerName)){
item.setCustomerName(customerName);
}
}
});
return Result.OK(pageList);
}