diff --git a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrInterviewService.java b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrInterviewService.java index 79bdb2ea..f8c91e3e 100644 --- a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrInterviewService.java +++ b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrInterviewService.java @@ -119,9 +119,10 @@ public class AihrInterviewService { StringBuilder sql = new StringBuilder(""" SELECT finished_time, candidate_name, position_code, total_score, result, ai_summary, questions_json FROM aihr_interview_result - WHERE tenant_id = '000000' + WHERE tenant_id = ? """); List args = new ArrayList<>(); + args.add(tenantId()); if (!isBlank(candidateId)) { sql.append(" AND candidate_id = ?"); args.add(clean(candidateId)); @@ -222,7 +223,7 @@ public class AihrInterviewService { INSERT INTO aihr_interview_result (tenant_id, session_id, candidate_id, candidate_name, position_code, total_score, result, suggestion, ai_summary, evidence, source, answers_json, questions_json, dimensions_json, finished_time, create_time, update_time) - VALUES ('000000', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now(), now()) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now(), now()) ON DUPLICATE KEY UPDATE candidate_id = VALUES(candidate_id), candidate_name = VALUES(candidate_name), @@ -239,6 +240,7 @@ public class AihrInterviewService { finished_time = VALUES(finished_time), update_time = now() """, + tenantId(), sessionId, session.candidate().id(), session.candidate().name(), diff --git a/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrInterviewServiceTest.java b/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrInterviewServiceTest.java index 14177974..ab54c639 100644 --- a/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrInterviewServiceTest.java +++ b/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrInterviewServiceTest.java @@ -3,6 +3,7 @@ package org.dromara.aihr.service; import com.fasterxml.jackson.databind.ObjectMapper; import org.dromara.aihr.domain.AihrInterviewDto.CandidateLinkRequest; import org.dromara.aihr.domain.AihrInterviewDto.CandidateLinkResponse; +import org.dromara.aihr.domain.AihrInterviewDto.RecordResponse; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.jdbc.core.JdbcTemplate; @@ -89,4 +90,17 @@ class AihrInterviewServiceTest { assertSame(linked, result); verify(jdbcTemplate).update(anyString(), eq("000000"), eq("candidate-3"), eq("employee-3"), eq("hr")); } + + @Test + @Tag("dev") + void interviewRecordsAreScopedToCurrentTenant() { + JdbcTemplate jdbcTemplate = mock(JdbcTemplate.class); + AihrInterviewService service = new AihrInterviewService(new ObjectMapper(), null, jdbcTemplate); + when(jdbcTemplate.query(anyString(), org.mockito.ArgumentMatchers.>any(), eq("000000"))) + .thenReturn(java.util.List.of()); + + assertEquals(java.util.List.of(), service.records(20)); + + verify(jdbcTemplate).query(anyString(), org.mockito.ArgumentMatchers.>any(), eq("000000")); + } }