Przeglądaj źródła

fix: 修复通过websocket发送私密评论的bug

ChenSiTong 6 lat temu
rodzic
commit
7e0a3dc784

+ 11 - 6
src/main/java/nju/seec/helper/controller/CommentController.java

@@ -42,7 +42,9 @@ public class CommentController {
     public CommentVO createComment(LoginUser user,
                                    @Validated @RequestBody CommentDTO commentDTO) {
         CommentVO commentVO = commentService.createComment(user, commentDTO);
-        CommentWebsocket.sendAllMessageToOneSlide(commentDTO.getSlideId(), JsonUtils.toJson(commentVO));
+        if (commentVO.getShow()) {
+            CommentWebsocket.sendAllMessageToOneSlide(commentDTO.getSlideId(), JsonUtils.toJson(commentVO));
+        }
         return commentVO;
     }
 
@@ -101,11 +103,11 @@ public class CommentController {
      */
     @Auth(roles = {UserRole.TEACHER, UserRole.STUDENT}, message = "获取自己的评论")
     @GetMapping("/slide/{slideId}/self")
-    public PageResponse<CommentVO> getSelfComments(LoginUser user,
-                                                   @PathVariable Long slideId,
-                                                   @RequestParam(required = false, defaultValue = "1") Integer pageNumber,
-                                                   @RequestParam(required = false, defaultValue = "true") Boolean show,
-                                                   @PageableDefault(Integer.MAX_VALUE) Pageable pageable) {
+    public PageResponse<CommentVO> getSelfCommentsBySlide(LoginUser user,
+                                                          @PathVariable Long slideId,
+                                                          @RequestParam(required = false, defaultValue = "1") Integer pageNumber,
+                                                          @RequestParam(required = false, defaultValue = "true") Boolean show,
+                                                          @PageableDefault(Integer.MAX_VALUE) Pageable pageable) {
         return PageResponse.of(commentService.getSelfCommentsBySlideAndPageNumber(user, slideId, pageNumber, show, pageable));
     }
 
@@ -120,6 +122,9 @@ public class CommentController {
         commentService.modifyCommentShow(user, commentId, show);
     }
 
+    /**
+     * 取得自己的评论
+     */
     @Auth(roles = {UserRole.TEACHER, UserRole.STUDENT}, message = "获取自己的评论")
     @GetMapping("/self")
     public PageResponse<CommentVO> getSelfComments(LoginUser user,

+ 0 - 9
src/main/java/nju/seec/helper/controller/NoticeController.java

@@ -30,10 +30,6 @@ public class NoticeController {
 
     /**
      * 发布公告
-     *
-     * @param user
-     * @param noticeDTO
-     * @return
      */
     @Auth(roles = UserRole.TEACHER, message = "发布公告")
     @PostMapping
@@ -44,11 +40,6 @@ public class NoticeController {
 
     /**
      * 修改公告
-     *
-     * @param user
-     * @param noticeId
-     * @param noticeDTO
-     * @return
      */
     @Auth(roles = UserRole.TEACHER, message = "修改公告")
     @PutMapping("/{noticeId}")

+ 6 - 3
src/main/java/nju/seec/helper/controller/QuestionController.java

@@ -132,15 +132,18 @@ public class QuestionController {
     }
 
     /**
-     * 取得收藏评价的题目
+     * 取得收藏的题目
      */
-    @Auth(roles = {UserRole.TEACHER, UserRole.STUDENT}, message = "取得收藏评价的题目")
+    @Auth(roles = {UserRole.TEACHER, UserRole.STUDENT}, message = "取得收藏的题目")
     @GetMapping("/collected")
     public PageResponse<BaseQuestionVO> getCollectedQuestions(LoginUser user, @PageableDefault(size = Integer.MAX_VALUE) Pageable pageable) {
         return PageResponse.of(questionService.getCollectedAndRatedQuestions(user, true, null, pageable));
     }
 
-    @Auth(roles = {UserRole.TEACHER, UserRole.STUDENT}, message = "取得收藏评价的题目")
+    /**
+     * 取得评价的题目
+     */
+    @Auth(roles = {UserRole.TEACHER, UserRole.STUDENT}, message = "取得评价的题目")
     @GetMapping("/rated")
     public PageResponse<BaseQuestionVO> getRatedQuestions(LoginUser user, @PageableDefault(size = Integer.MAX_VALUE) Pageable pageable) {
         return PageResponse.of(questionService.getCollectedAndRatedQuestions(user, null, true, pageable));

+ 0 - 1
src/main/java/nju/seec/helper/controller/QuizController.java

@@ -117,7 +117,6 @@ public class QuizController {
     /**
      * 提交作答
      */
-//    @ExerciseRecord
     @Event(type = EventType.QUIZ, action = EventAction.COMPLETE)
     @Auth(roles = {UserRole.STUDENT}, message = "提交作答")
     @PostMapping("/{quizId}/student-answer")

+ 6 - 0
src/main/java/nju/seec/helper/controller/RecordController.java

@@ -21,11 +21,17 @@ public class RecordController {
         this.recordService = recordService;
     }
 
+    /**
+     * 取得所有记录
+     */
     @GetMapping
     public List<ExerciseRecord> getAllRecords() {
         return recordService.getAllRecords();
     }
 
+    /**
+     * 取得某人的记录
+     */
     @GetMapping("/{userId}")
     public List<ExerciseRecord> getRecordsByUserId(@PathVariable String userId) {
         return recordService.getRecordsByUserId(userId);