根据界面需求优化

This commit is contained in:
wh
2026-05-08 22:38:32 +08:00
parent d679340f3c
commit 4065d993e2
13 changed files with 128 additions and 59 deletions

View File

@@ -11,6 +11,7 @@ import com.labelsys.backend.dto.common.PageResult;
import com.labelsys.backend.dto.request.AnnotationResultPageQuery;
import com.labelsys.backend.dto.request.MergeReviewResultRequest;
import com.labelsys.backend.dto.response.AnnotationResultCompareResponse;
import com.labelsys.backend.dto.response.AnnotationResultDetailResponse;
import com.labelsys.backend.dto.response.AnnotationResultResponse;
import com.labelsys.backend.entity.AnnotationResult;
import com.labelsys.backend.entity.AnnotationResultHistory;
@@ -80,7 +81,7 @@ public class AnnotationResultService {
}
}
public AnnotationResultResponse getResult(LoginUser currentUser, Long resultId) {
public AnnotationResultDetailResponse getResult(LoginUser currentUser, Long resultId) {
try {
AnnotationResult result = annotationResultMapper.findActiveByIdAndCompanyId(resultId,
currentUser.companyId());
@@ -91,7 +92,13 @@ public class AnnotationResultService {
throw new BusinessException(ResultCode.NOT_FOUND, "结果不存在");
}
//assertResultPermission(currentUser, result);
return toResponse(result);
// 加载文件内容
QaContent qaContent = loadQaContent(result);
DiffContent diffContent = Boolean.TRUE.equals(result.getRequiresManualReview()) ?
loadDiffSummary(result) : null;
return toDetailResponse(result, qaContent, diffContent);
} catch (BusinessException e) {
throw e;
} catch (Exception e) {
@@ -101,6 +108,48 @@ public class AnnotationResultService {
}
}
private AnnotationResultDetailResponse toDetailResponse(AnnotationResult result,
QaContent qaContent, DiffContent diffContent) {
// 转换 QA 内容(仅保留 records
AnnotationResultDetailResponse.QaContentDto qaContentDto = new AnnotationResultDetailResponse.QaContentDto(
qaContent.records().stream()
.map(r -> new AnnotationResultDetailResponse.QaRecordDto(
r.id(), r.question(), r.answer(), r.requiresReview()))
.toList()
);
// 转换差异内容(仅保留 records
AnnotationResultDetailResponse.DiffContentDto diffContentDto = null;
if (diffContent != null) {
diffContentDto = new AnnotationResultDetailResponse.DiffContentDto(
diffContent.records().stream()
.map(r -> new AnnotationResultDetailResponse.DiffRecordDto(
r.qaId(), r.question(), r.extractAnswer(),
r.verifyAnswer(), r.diffReason(), r.mergedAnswer()))
.toList()
);
}
return new AnnotationResultDetailResponse(
result.getId(),
result.getTaskId(),
result.getTaskName(),
result.getResourceId(),
result.getResourceName(),
deriveStatus(result),
result.getRequiresManualReview(),
result.getIsDeleted(),
result.getQaContentFilePath(),
result.getDiffSummaryFilePath(),
qaContentDto,
diffContentDto,
result.getReviewComment(),
result.getReviewedAt(),
result.getCreatedAt()
);
}
public AnnotationResultCompareResponse compareResult(LoginUser currentUser, Long resultId) {
try {
AnnotationResult result = annotationResultMapper.findActiveByIdAndCompanyId(resultId,