|
|
@@ -1,5 +1,6 @@
|
|
|
package com.njuzr.eaibackend.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.njuzr.eaibackend.dto.AssignmentDTO;
|
|
|
import com.njuzr.eaibackend.dto.AssignmentQueryDTO;
|
|
|
@@ -11,18 +12,24 @@ import com.njuzr.eaibackend.po.Engagement;
|
|
|
import com.njuzr.eaibackend.po.MyUserDetails;
|
|
|
import com.njuzr.eaibackend.service.AIDialogueService;
|
|
|
import com.njuzr.eaibackend.service.AssignmentService;
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Scanner;
|
|
|
+
|
|
|
/**
|
|
|
* @author: Leonezhurui
|
|
|
* @Date: 2024/3/5 - 20:01
|
|
|
* @Package: EAI-Backend
|
|
|
*/
|
|
|
-
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/api/assignment")
|
|
|
public class AssignmentController {
|
|
|
@@ -114,6 +121,9 @@ public class AssignmentController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ 已完成onlyOffice向Quill的更新
|
|
|
+ */
|
|
|
@PreAuthorize("hasRole('STUDENT')")
|
|
|
@PostMapping("/engage")
|
|
|
public MyResponse engageAssignment(
|
|
|
@@ -125,7 +135,9 @@ public class AssignmentController {
|
|
|
return MyResponse.success("参加作业成功");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ 已完成onlyOffice向Quill的更新
|
|
|
+ */
|
|
|
@GetMapping("/engage")
|
|
|
public MyResponse getEngagement(
|
|
|
@RequestParam Long studentId,
|
|
|
@@ -134,7 +146,9 @@ public class AssignmentController {
|
|
|
return MyResponse.success(assignmentService.getEngagement(studentId, assignmentId));
|
|
|
}
|
|
|
|
|
|
- // TODO: (柏琪) 新增接口
|
|
|
+ /**
|
|
|
+ 已完成onlyOffice向Quill的更新
|
|
|
+ */
|
|
|
@PostMapping("/engage/query")
|
|
|
public MyResponse findEngagementPage(
|
|
|
@RequestParam(value = "page", defaultValue = "1") int currentPage,
|
|
|
@@ -146,6 +160,9 @@ public class AssignmentController {
|
|
|
return MyResponse.success(assignmentService.findEngagementPage(page, assignmentId));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ 已完成onlyOffice向Quill的更新
|
|
|
+ */
|
|
|
@GetMapping("/engage/detail")
|
|
|
public MyResponse getDetailEngagement(
|
|
|
@RequestParam Long studentId,
|
|
|
@@ -154,6 +171,9 @@ public class AssignmentController {
|
|
|
return MyResponse.success(assignmentService.getDetailEngagement(studentId, assignmentId));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ 已完成onlyOffice向Quill的更新
|
|
|
+ */
|
|
|
@PutMapping("/engage/submit")
|
|
|
public MyResponse engagementSubmit(
|
|
|
@RequestParam Long studentId,
|
|
|
@@ -164,14 +184,24 @@ public class AssignmentController {
|
|
|
return MyResponse.success("作业提交成功");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ 已完成onlyOffice向Quill的更新
|
|
|
+ 替代onlyOffice的回调函数实现的功能
|
|
|
+ */
|
|
|
@PutMapping("/engage/stage")
|
|
|
- public MyResponse engagementStage(
|
|
|
- @RequestParam Long studentId,
|
|
|
- @RequestParam Long assignmentId
|
|
|
- ) {
|
|
|
- assignmentService.engagementStage(studentId, assignmentId);
|
|
|
- return MyResponse.success("作业暂存成功");
|
|
|
+ public MyResponse engagementStage(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
|
|
|
+ String body = scanner.hasNext() ? scanner.next() : "";
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
+ Long studentId = jsonObject.getLong("studentId");
|
|
|
+ Long assignmentId = jsonObject.getLong("assignmentId");
|
|
|
+ log.info("保存内容为:{}", jsonObject);
|
|
|
+ assignmentService.engagementStage(studentId, assignmentId, jsonObject);
|
|
|
+ return MyResponse.success("保存成功");
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@PreAuthorize("hasRole('TEACHER')")
|