fix(aihr): scope interview results to tenant
This commit is contained in:
+4
-2
@@ -119,9 +119,10 @@ public class AihrInterviewService {
|
|||||||
StringBuilder sql = new StringBuilder("""
|
StringBuilder sql = new StringBuilder("""
|
||||||
SELECT finished_time, candidate_name, position_code, total_score, result, ai_summary, questions_json
|
SELECT finished_time, candidate_name, position_code, total_score, result, ai_summary, questions_json
|
||||||
FROM aihr_interview_result
|
FROM aihr_interview_result
|
||||||
WHERE tenant_id = '000000'
|
WHERE tenant_id = ?
|
||||||
""");
|
""");
|
||||||
List<Object> args = new ArrayList<>();
|
List<Object> args = new ArrayList<>();
|
||||||
|
args.add(tenantId());
|
||||||
if (!isBlank(candidateId)) {
|
if (!isBlank(candidateId)) {
|
||||||
sql.append(" AND candidate_id = ?");
|
sql.append(" AND candidate_id = ?");
|
||||||
args.add(clean(candidateId));
|
args.add(clean(candidateId));
|
||||||
@@ -222,7 +223,7 @@ public class AihrInterviewService {
|
|||||||
INSERT INTO aihr_interview_result
|
INSERT INTO aihr_interview_result
|
||||||
(tenant_id, session_id, candidate_id, candidate_name, position_code, total_score, 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)
|
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
|
ON DUPLICATE KEY UPDATE
|
||||||
candidate_id = VALUES(candidate_id),
|
candidate_id = VALUES(candidate_id),
|
||||||
candidate_name = VALUES(candidate_name),
|
candidate_name = VALUES(candidate_name),
|
||||||
@@ -239,6 +240,7 @@ public class AihrInterviewService {
|
|||||||
finished_time = VALUES(finished_time),
|
finished_time = VALUES(finished_time),
|
||||||
update_time = now()
|
update_time = now()
|
||||||
""",
|
""",
|
||||||
|
tenantId(),
|
||||||
sessionId,
|
sessionId,
|
||||||
session.candidate().id(),
|
session.candidate().id(),
|
||||||
session.candidate().name(),
|
session.candidate().name(),
|
||||||
|
|||||||
+14
@@ -3,6 +3,7 @@ package org.dromara.aihr.service;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.dromara.aihr.domain.AihrInterviewDto.CandidateLinkRequest;
|
import org.dromara.aihr.domain.AihrInterviewDto.CandidateLinkRequest;
|
||||||
import org.dromara.aihr.domain.AihrInterviewDto.CandidateLinkResponse;
|
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.Tag;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
@@ -89,4 +90,17 @@ class AihrInterviewServiceTest {
|
|||||||
assertSame(linked, result);
|
assertSame(linked, result);
|
||||||
verify(jdbcTemplate).update(anyString(), eq("000000"), eq("candidate-3"), eq("employee-3"), eq("hr"));
|
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.<RowMapper<RecordResponse>>any(), eq("000000")))
|
||||||
|
.thenReturn(java.util.List.of());
|
||||||
|
|
||||||
|
assertEquals(java.util.List.of(), service.records(20));
|
||||||
|
|
||||||
|
verify(jdbcTemplate).query(anyString(), org.mockito.ArgumentMatchers.<RowMapper<RecordResponse>>any(), eq("000000"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user