fix(aihr): preserve dynamic tenant context
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
package org.dromara.aihr.service;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
@@ -192,7 +192,7 @@ public class AihrCandidateMaterialService {
|
||||
}
|
||||
|
||||
private String tenantId() {
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
return clean(tenantId, TENANT_ID);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.aihr.domain.AihrCaseDto.CurateRequest;
|
||||
import org.dromara.aihr.domain.AihrCaseDto.CurateResponse;
|
||||
import org.dromara.aihr.domain.AihrCaseDto.DetailResponse;
|
||||
@@ -300,7 +301,7 @@ public class AihrCaseService {
|
||||
}
|
||||
|
||||
private String tenantId() {
|
||||
return firstNonBlank(LoginHelper.getTenantId(), "000000");
|
||||
return firstNonBlank(TenantHelper.getTenantId(), "000000");
|
||||
}
|
||||
|
||||
private Optional<CaseSummary> organizeWithModel(CaseState state) {
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import org.dromara.aihr.domain.AihrDashboardDto.PipelineSummaryResponse;
|
||||
import org.dromara.aihr.domain.AihrDashboardDto.RiskResponse;
|
||||
import org.dromara.aihr.domain.AihrDashboardDto.StageResponse;
|
||||
import org.dromara.aihr.domain.AihrDashboardDto.TrainingRecordResponse;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -253,7 +253,7 @@ public class AihrDashboardService {
|
||||
}
|
||||
|
||||
private String tenantId() {
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
return tenantId == null || tenantId.isBlank() ? TENANT_ID : tenantId;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.aihr.domain.AihrInterviewDto.AnswerRequest;
|
||||
import org.dromara.aihr.domain.AihrInterviewDto.AnswerResponse;
|
||||
import org.dromara.aihr.domain.AihrInterviewDto.CandidateLinkRequest;
|
||||
@@ -310,7 +310,7 @@ public class AihrInterviewService {
|
||||
}
|
||||
|
||||
private String tenantId() {
|
||||
return firstNonBlank(LoginHelper.getTenantId(), "000000");
|
||||
return firstNonBlank(TenantHelper.getTenantId(), "000000");
|
||||
}
|
||||
|
||||
private void saveResult(String sessionId, InterviewSession session, ScoreResult score) {
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import org.dromara.aihr.domain.AihrOrgSyncDto.OrgProjectOption;
|
||||
import org.dromara.aihr.domain.AihrOrgSyncDto.OrgSnapshotResponse;
|
||||
import org.dromara.aihr.domain.AihrOrgSyncDto.SyncRequest;
|
||||
import org.dromara.aihr.domain.AihrOrgSyncDto.SyncResponse;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -763,7 +763,7 @@ public class AihrOrgSyncService {
|
||||
}
|
||||
|
||||
private String tenantId() {
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
return clean(tenantId).isBlank() ? TENANT_ID : tenantId.trim();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ import org.dromara.aihr.domain.AihrPracticeDto.TeamMemberResponse;
|
||||
import org.dromara.aihr.service.AihrPracticeLlmService.PracticeTurn;
|
||||
import org.dromara.aihr.service.AihrPracticeLlmService.DailyDrillAssessment;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -3957,7 +3957,7 @@ public class AihrPracticeSeedService {
|
||||
}
|
||||
|
||||
private String tenantId() {
|
||||
return firstNonBlank(LoginHelper.getTenantId(), TENANT_ID);
|
||||
return firstNonBlank(TenantHelper.getTenantId(), TENANT_ID);
|
||||
}
|
||||
|
||||
private String firstNonBlank(String first, String second) {
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package org.dromara.aihr.service;
|
||||
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@Tag("dev")
|
||||
class AihrTenantContextContractTest {
|
||||
|
||||
@Test
|
||||
void businessServicesUseDynamicTenantContext() throws Exception {
|
||||
Path moduleRoot = Path.of("src/main/java/org/dromara/aihr/service");
|
||||
if (!Files.exists(moduleRoot)) {
|
||||
moduleRoot = Path.of("ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service");
|
||||
}
|
||||
|
||||
for (String service : List.of(
|
||||
"AihrCandidateMaterialService.java",
|
||||
"AihrCaseService.java",
|
||||
"AihrDashboardService.java",
|
||||
"AihrInterviewService.java",
|
||||
"AihrOrgSyncService.java",
|
||||
"AihrPracticeSeedService.java"
|
||||
)) {
|
||||
String source = Files.readString(moduleRoot.resolve(service));
|
||||
assertTrue(source.contains("TenantHelper.getTenantId()"), service);
|
||||
assertFalse(source.contains("LoginHelper.getTenantId()"), service);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user