refactor(tenant): 优化及修复租户相关部分代码

- 移动 TenantExtensionProperties 到 common 模块
- 修复 MenuController#tree 接口 setExcludeMenuIdList 方法判断非默认租户条件缺失
- 修复更新租户套餐菜单,没有及时更新在线用户数据权限(后面考虑重构 satoken 权限数据读取部分)
- TenantService 接口 getByDomain => getIdByDomain、getByCode => getIdByCode
- 移除 MenuService 中已废弃的方法
- LogDaoLocalImpl 还原(未测出租户用户操作,无租户 ID 问题)
- 优化 pg 数据库脚本,移除菜单表的租户相关字段
- 其他代码优化
This commit is contained in:
2025-07-20 23:13:07 +08:00
parent ada6f3ef5c
commit 84b2c39a30
24 changed files with 164 additions and 233 deletions

View File

@@ -20,7 +20,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.continew.admin.system.mapper.LogMapper;
import top.continew.admin.system.service.UserService;
import top.continew.starter.extension.tenant.autoconfigure.TenantProperties;
import top.continew.starter.log.annotation.ConditionalOnEnabledLog;
import top.continew.starter.log.dao.LogDao;
import top.continew.starter.trace.autoconfigure.TraceProperties;
@@ -39,10 +38,7 @@ public class LogConfiguration {
* 日志持久层接口本地实现类
*/
@Bean
public LogDao logDao(UserService userService,
LogMapper logMapper,
TraceProperties traceProperties,
TenantProperties tenantProperties) {
return new LogDaoLocalImpl(userService, logMapper, traceProperties, tenantProperties);
public LogDao logDao(UserService userService, LogMapper logMapper, TraceProperties traceProperties) {
return new LogDaoLocalImpl(userService, logMapper, traceProperties);
}
}

View File

@@ -41,7 +41,7 @@ import top.continew.admin.system.service.UserService;
import top.continew.starter.core.constant.StringConstants;
import top.continew.starter.core.util.ExceptionUtils;
import top.continew.starter.core.util.StrUtils;
import top.continew.starter.extension.tenant.autoconfigure.TenantProperties;
import top.continew.starter.extension.tenant.context.TenantContextHolder;
import top.continew.starter.extension.tenant.util.TenantUtils;
import top.continew.starter.log.dao.LogDao;
import top.continew.starter.log.model.LogRecord;
@@ -67,7 +67,6 @@ public class LogDaoLocalImpl implements LogDao {
private final UserService userService;
private final LogMapper logMapper;
private final TraceProperties traceProperties;
private final TenantProperties tenantProperties;
@Async
@Override
@@ -88,12 +87,8 @@ public class LogDaoLocalImpl implements LogDao {
logDO.setCreateTime(LocalDateTime.ofInstant(logRecord.getTimestamp(), ZoneId.systemDefault()));
// 设置操作人
this.setCreateUser(logDO, logRequest, logResponse);
String strTenantId = logRequest.getHeaders().get(tenantProperties.getTenantIdHeader());
if (StrUtil.isNotBlank(strTenantId)) {
TenantUtils.execute(Long.parseLong(strTenantId), () -> logMapper.insert(logDO));
} else {
logMapper.insert(logDO);
}
// 保存记录
TenantUtils.execute(TenantContextHolder.getTenantId(), () -> logMapper.insert(logDO));
}
/**