1:首页多租户查询优化 2:景点列表查询优化

This commit is contained in:
2025-10-09 21:08:01 +08:00
parent ff47d983e3
commit a96b775e01
11 changed files with 414 additions and 201 deletions
@@ -54,7 +54,9 @@ public class DashboardController {
anchor = com.central.common.context.LoginUserContextHolder.getCurrentTenantId();
}
}
} catch (Exception ignored) { }
} catch (Exception ignored) {
log.error("获取当前登录用户租户失败");
}
boolean withChildren = (includeChildren == null) || Boolean.TRUE.equals(includeChildren);
params.put("tenantId", anchor);
params.put("includeChildren", withChildren);
@@ -58,21 +58,6 @@ public class TenantResolverService {
log.warn("租户 {} 没有子孙租户,返回自身", anchor);
return Collections.singletonList(anchor);
}
log.info("租户 {} 获取到 {} 个租户(含自身及子孙): {}",
anchor, tenantIds.size(),
tenantIds.size() <= 20 ? tenantIds : tenantIds.subList(0, 20) + "...");
// 特别检查:如果是webApp,验证是否包含了所有预期的租户
if ("webApp".equals(anchor)) {
String[] expectedTenants = {"xcApp", "ymgApp", "zcapp", "zhapp", "djhApp", "sndApp", "sntApp", "tyApp", "ljtxApp", "yfApp"};
for (String expected : expectedTenants) {
if (!tenantIds.contains(expected)) {
log.error("警告:webApp的子孙租户列表缺少预期的租户: {}", expected);
}
}
}
return tenantIds;
} catch (Exception e) {
log.error("获取租户层级失败: {}", e.getMessage(), e);
@@ -1,6 +1,8 @@
package com.central.order.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.central.common.datascope.annotation.IgnoreTenantScope;
import com.central.common.feign.UserService;
import com.central.common.model.PageResult;
import com.central.common.model.Result;
import com.central.common.service.impl.SuperServiceImpl;
@@ -37,6 +39,8 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
@Autowired
private FileCenterService fileCenterService;
@Autowired
private UserService userCenterService;
/**
* 列表
@@ -44,8 +48,22 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
* @return
*/
@Override
@IgnoreTenantScope
public PageResult<Tourism> findList(Map<String, Object> params){
Page<Tourism> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
String anchor= MapUtils.getString(params,"tenantId");
try {
if (anchor == null || anchor.isEmpty()) {
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
if (anchor == null || anchor.isEmpty()) {
anchor = com.central.common.context.LoginUserContextHolder.getCurrentTenantId();
}
}
} catch (Exception ignored) {
log.error("获取当前登录用户租户失败");
}
List<String> tenantIds = userCenterService.getSonTenantIds(anchor);
params.put("tenantIds",tenantIds);
List<Tourism> list = baseMapper.findList(page, params);
return PageResult.<Tourism>builder().data(list).resp_code(0).count(page.getTotal()).build();
}