From 94df6caae8038ab75e6b9324390a84184f8a783c Mon Sep 17 00:00:00 2001 From: isieun0908 Date: Tue, 25 Apr 2023 03:10:21 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A7=88=EB=AC=B8=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20API=20=EA=B0=9C=EB=B0=9C(#7)=20*=20Delete=20Controller=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C=20*=20deleteQuestion=20Service=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/controller/QuestionController.java | 9 +++++++++ .../classmate/question/service/QuestionService.java | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/classmate/src/main/java/devteamOne/classmate/question/controller/QuestionController.java b/classmate/src/main/java/devteamOne/classmate/question/controller/QuestionController.java index 3ab12cf..3a97b47 100644 --- a/classmate/src/main/java/devteamOne/classmate/question/controller/QuestionController.java +++ b/classmate/src/main/java/devteamOne/classmate/question/controller/QuestionController.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity.BodyBuilder; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -32,4 +33,12 @@ public Boolean modify(@PathVariable Long question_id, @RequestBody QuestionReque return true; } + + @DeleteMapping("/question/{question_id}") + public Boolean delete(@PathVariable Long question_id) { + + questionService.deleteQuestion(question_id); + + return true; + } } diff --git a/classmate/src/main/java/devteamOne/classmate/question/service/QuestionService.java b/classmate/src/main/java/devteamOne/classmate/question/service/QuestionService.java index 6e655a9..4e29b74 100644 --- a/classmate/src/main/java/devteamOne/classmate/question/service/QuestionService.java +++ b/classmate/src/main/java/devteamOne/classmate/question/service/QuestionService.java @@ -41,4 +41,12 @@ public void modifyContent(Long question_id, QuestionRequest questionRequest) { question.modifyContent(questionRequest.getContent()); questionRepository.save(question); } + + public void deleteQuestion(Long question_id) { + + // user 조회 및 권한 확인 + + // question 삭제 + questionRepository.deleteById(question_id); + } }