Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public ResponseEntity<ApiResponse<QuestionResDTO.UpdateDeleteRes>> updateQuestio
@RequestBody QuestionReqDTO.UpdateReq request,
@AuthenticationPrincipal Long userId
) {
return ResponseUtil.success(QuestionSuccessCode.QUESTION_UPDATED,
questionService.updateQuestion(questionId, request, userId));
return ResponseUtil.success(QuestionSuccessCode.QUESTION_UPDATED,
questionService.updateQuestion(questionId, request, userId));
}

// 질문 삭제
Expand All @@ -92,8 +92,19 @@ public ResponseEntity<ApiResponse<QuestionResDTO.UpdateDeleteRes>> deleteQuestio
@PathVariable Long questionId,
@AuthenticationPrincipal Long userId
) {
return ResponseUtil.success(QuestionSuccessCode.QUESTION_DELETED,
questionService.deleteQuestion(questionId, userId));
return ResponseUtil.success(QuestionSuccessCode.QUESTION_DELETED,
questionService.deleteQuestion(questionId, userId));
}

// 질문 상태 완료 전환 (관리자 전용)
// PATCH /api/questions/{questionId}/status
@PatchMapping("/api/questions/{questionId}/status")
public ResponseEntity<ApiResponse<QuestionResDTO.StatusUpdateRes>> updateQuestionStatus(
@PathVariable Long questionId,
@AuthenticationPrincipal Long userId
) {
return ResponseUtil.success(QuestionSuccessCode.QUESTION_STATUS_UPDATED,
questionService.updateQuestionStatus(questionId, userId));
}

// 이해도 체크 생성
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ public record CommentResponse(
) {
}

// 질문 상태 변경 응답
public record StatusUpdateRes(
Long id,
Boolean isResolved,
LocalDateTime updatedAt
) {
}

// 질문 방 전체 응답
public record QuestionRoomResponse(
SessionResponse session,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,10 @@ public void softDelete() {
this.deletedAt = LocalDateTime.now();
this.updatedAt = LocalDateTime.now();
}

// 질문 상태를 해결 완료로 변경 (관리자만 호출)
public void markResolved() {
this.isResolved = true;
this.updatedAt = LocalDateTime.now();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum QuestionSuccessCode implements BaseCode {
UNDERSTANDING_RESPONSE_OK(HttpStatus.OK, "QUESTION200_4", "이해도 응답이 반영되었습니다."),
QUESTION_UPDATED(HttpStatus.OK, "QUESTION200_5", "질문이 수정되었습니다."),
QUESTION_DELETED(HttpStatus.OK, "QUESTION200_6", "질문이 삭제되었습니다."),
QUESTION_STATUS_UPDATED(HttpStatus.OK, "QUESTION200_7", "질문 상태가 변경되었습니다."),
QUESTION_CREATED(HttpStatus.CREATED, "QUESTION201_1", "질문이 등록되었습니다."),
COMMENT_CREATED(HttpStatus.CREATED, "QUESTION201_2", "댓글이 등록되었습니다."),
UNDERSTANDING_CHECK_CREATED(HttpStatus.CREATED, "QUESTION201_3", "이해도 체크가 생성되었습니다.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ public QuestionResDTO.UpdateDeleteRes deleteQuestion(Long questionId, Long userI
);
}

// 질문 상태 완료 전환
// PATCH /api/questions/{questionId}/status
@Transactional
public QuestionResDTO.StatusUpdateRes updateQuestionStatus(Long questionId, Long userId) {
User loginUser = findLoginUser(userId);
validateAdmin(loginUser); // 관리자만 호출 가능

Question question = findQuestion(questionId);
question.markResolved();

return new QuestionResDTO.StatusUpdateRes(
question.getId(), question.getIsResolved(), question.getUpdatedAt()
);
}

// 이해도 체크 생성
@Transactional
public QuestionResDTO.UnderstandingCheckCreateResponse createUnderstandingCheck(
Expand Down
Loading