fix(aihr): record authenticated sop reviewer
This commit is contained in:
+5
-1
@@ -29,6 +29,8 @@ import org.dromara.aihr.service.AihrSopSeedService;
|
||||
import org.dromara.aihr.service.AihrUploadQueueService;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -111,7 +113,9 @@ public class AihrSopController {
|
||||
@SaCheckRole(value = {TenantConstants.SUPER_ADMIN_ROLE_KEY, HR_OPERATOR_ROLE}, mode = SaMode.OR)
|
||||
@PostMapping("/reviews/{id}")
|
||||
public R<SopReviewResponse> review(@PathVariable Long id, @RequestBody(required = false) SopReviewRequest request) {
|
||||
SopReviewResponse response = sopSeedService.reviewSearch(id, request);
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
String operator = loginUser == null ? "unknown" : loginUser.getUsername();
|
||||
SopReviewResponse response = sopSeedService.reviewSearch(id, request, operator);
|
||||
return response == null ? R.fail("SOP问答评审记录不存在") : R.ok(response);
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -192,6 +192,10 @@ public class AihrSopSeedService {
|
||||
}
|
||||
|
||||
public SopReviewResponse reviewSearch(Long id, SopReviewRequest request) {
|
||||
return reviewSearch(id, request, null);
|
||||
}
|
||||
|
||||
public SopReviewResponse reviewSearch(Long id, SopReviewRequest request, String operator) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -202,7 +206,7 @@ public class AihrSopSeedService {
|
||||
WHERE tenant_id = ? AND id = ?
|
||||
""",
|
||||
request != null && Boolean.TRUE.equals(request.usable()),
|
||||
firstNonBlank(request == null ? null : request.reviewer(), "人工评审"),
|
||||
firstNonBlank(operator, "人工评审"),
|
||||
firstNonBlank(request == null ? null : request.note(), ""),
|
||||
Timestamp.valueOf(java.time.LocalDateTime.now()),
|
||||
Timestamp.valueOf(java.time.LocalDateTime.now()),
|
||||
|
||||
+13
@@ -104,6 +104,19 @@ public class AihrSopSeedServiceTest {
|
||||
assertTrue(code.contains("runLocalImportTask(taskId, plan)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("dev")
|
||||
public void sopReviewUsesAuthenticatedOperatorForAuditTrail() throws Exception {
|
||||
Path source = Path.of("src/main/java/org/dromara/aihr/controller/AihrSopController.java");
|
||||
if (!Files.exists(source)) {
|
||||
source = Path.of("ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/controller/AihrSopController.java");
|
||||
}
|
||||
String code = Files.readString(source);
|
||||
|
||||
assertTrue(code.contains("LoginHelper.getLoginUser()"));
|
||||
assertTrue(code.contains("reviewSearch(id, request, operator)"));
|
||||
}
|
||||
|
||||
private static AihrSopSeedService.KnowledgeHit hit(Long fragmentId, String title) {
|
||||
return new AihrSopSeedService.KnowledgeHit(fragmentId, title, "sop", "", "doc-" + fragmentId, "片段内容", 1, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user