Pārlūkot izejas kodu

feat:完成作文整体分析与逐句分析接口开发

白白 1 gadu atpakaļ
vecāks
revīzija
d37b5fbcbf

+ 3 - 3
src/main/java/com/njuzr/eaibackend/controller/EvaluationController.java

@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.*;
  */
 @Slf4j
 @RestController
-@RequestMapping("/api/correct")
+@RequestMapping("/api/evaluation")
 public class EvaluationController {
 
     private final AIEvaluationService aiEvaluationService;;
@@ -27,7 +27,7 @@ public class EvaluationController {
         return MyResponse.success(aiEvaluationService.rewrite(assignmentId, studentId));
     }
 
-    @PostMapping("/perSentence")
+    @PostMapping("/sentence")
     public MyResponse rewritePerSentence(
             @RequestParam Long assignmentId,
             @RequestParam Long studentId
@@ -53,7 +53,7 @@ public class EvaluationController {
         return MyResponse.success(aiEvaluationService.getRewritePerSentence(assignmentId, studentId, version));
     }
 
-    @GetMapping("/record")
+    @GetMapping("/record/list")
     public MyResponse getRewriteVersionList(
             @RequestParam Long assignmentId,
             @RequestParam Long studentId,

+ 8 - 5
src/main/java/com/njuzr/eaibackend/service/AIEvaluationService.java

@@ -268,7 +268,7 @@ public class AIEvaluationService {
             sentenceEvaluation.setStudentId(studentId);
             sentenceEvaluation.setContent(content);
             sentenceEvaluation.setNo(i+1);
-            sentenceEvaluation.setSentence(res[i] + "\n");
+            sentenceEvaluation.setSentence(res[i] + ".");
             sentenceEvaluation.setVersion(engagement.getVersion());
             sentenceEvaluationMapper.insert(sentenceEvaluation);
 
@@ -286,15 +286,15 @@ public class AIEvaluationService {
      * @return
      */
     public String getRewrite(Long assignmentId, Long studentId, int version){
-        QueryWrapper<SentenceEvaluation> queryWrapper =  new QueryWrapper<>();
+        QueryWrapper<OverallEvaluation> queryWrapper =  new QueryWrapper<>();
         queryWrapper.eq("assignment_id", assignmentId);
         queryWrapper.eq("student_id", studentId);
         queryWrapper.eq("version", version);
-        SentenceEvaluation sentenceEvaluation = sentenceEvaluationMapper.selectOne(queryWrapper);
-        if(sentenceEvaluation == null){
+        OverallEvaluation overallEvaluation = overallEvaluationMapper.selectOne(queryWrapper);
+        if(overallEvaluation == null){
             throw MyException.create(HttpStatus.BAD_REQUEST, "AI批改不存在");
         }
-        return sentenceEvaluation.getContent();
+        return overallEvaluation.getEvaluation();
     }
 
     /**
@@ -311,6 +311,9 @@ public class AIEvaluationService {
         queryWrapper.eq("version", version);
         List<SentenceEvaluation> sentenceEvaluations = sentenceEvaluationMapper.selectList(queryWrapper);
 
+        if(sentenceEvaluations.isEmpty()){
+            throw MyException.create(HttpStatus.BAD_REQUEST, "AI批改不存在");
+        }
         // 按no属性进行排序
         return sentenceEvaluations.stream().sorted(Comparator.comparing(SentenceEvaluation::getNo)).toList();
     }