diff --git a/src/main/java/com/mangkyu/employment/interview/app/answer/controller/AnswerController.java b/src/main/java/com/mangkyu/employment/interview/app/answer/controller/AnswerController.java index dad6887..6bd0a08 100644 --- a/src/main/java/com/mangkyu/employment/interview/app/answer/controller/AnswerController.java +++ b/src/main/java/com/mangkyu/employment/interview/app/answer/controller/AnswerController.java @@ -5,7 +5,6 @@ import com.mangkyu.employment.interview.app.answer.dto.GetAnswerResponse; import com.mangkyu.employment.interview.app.answer.service.AnswerService; import com.mangkyu.employment.interview.app.common.erros.exception.QuizException; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -29,10 +28,4 @@ public class AnswerController { return ResponseEntity.ok(answerService.getAnswer(resourceId)); } - // TODO(MinKyu): 임시 삭제 - @DeleteMapping("/answer/{resourceId}") - public void deleteAnswer(@PathVariable final String resourceId) throws QuizException { - answerService.deleteAnswer(resourceId); - } - } \ No newline at end of file diff --git a/src/main/java/com/mangkyu/employment/interview/app/answer/service/AnswerService.java b/src/main/java/com/mangkyu/employment/interview/app/answer/service/AnswerService.java index 2daf49c..c73ceb1 100644 --- a/src/main/java/com/mangkyu/employment/interview/app/answer/service/AnswerService.java +++ b/src/main/java/com/mangkyu/employment/interview/app/answer/service/AnswerService.java @@ -5,7 +5,6 @@ import com.mangkyu.employment.interview.app.answer.dto.GetAnswerResponse; import com.mangkyu.employment.interview.app.answer.entity.Answer; import com.mangkyu.employment.interview.app.answer.repository.AnswerRepository; import com.mangkyu.employment.interview.app.common.erros.errorcode.CommonErrorCode; -import com.mangkyu.employment.interview.app.common.erros.errorcode.CustomErrorCode; import com.mangkyu.employment.interview.app.common.erros.exception.QuizException; import com.mangkyu.employment.interview.app.quiz.converter.QuizDtoConverter; import com.mangkyu.employment.interview.app.quiz.entity.Quiz; @@ -42,11 +41,4 @@ public class AnswerService { } } - @Transactional - public void deleteAnswer(final String resourceId) throws QuizException { - final Answer answer = answerRepository.findByResourceId(resourceId) - .orElseThrow(() -> new QuizException(CommonErrorCode.RESOURCE_NOT_FOUND)); - answerRepository.delete(answer); - } - } diff --git a/src/main/java/com/mangkyu/employment/interview/app/quiz/service/QuizService.java b/src/main/java/com/mangkyu/employment/interview/app/quiz/service/QuizService.java index a60d127..5e6772d 100644 --- a/src/main/java/com/mangkyu/employment/interview/app/quiz/service/QuizService.java +++ b/src/main/java/com/mangkyu/employment/interview/app/quiz/service/QuizService.java @@ -1,5 +1,6 @@ package com.mangkyu.employment.interview.app.quiz.service; +import com.mangkyu.employment.interview.app.answer.repository.AnswerRepository; import com.mangkyu.employment.interview.app.common.erros.errorcode.CommonErrorCode; import com.mangkyu.employment.interview.app.common.erros.exception.QuizException; import com.mangkyu.employment.interview.app.quiz.converter.QuizDtoConverter; @@ -46,6 +47,8 @@ public class QuizService { .orElseThrow(() -> new QuizException(CommonErrorCode.RESOURCE_NOT_FOUND)); } + private final AnswerRepository answerRepository; + public GetQuizResponse getQuiz(final String resourceId) throws QuizException { final Quiz quiz = findQuiz(resourceId); return QuizDtoConverter.convert(quiz, enumMapperFactory.getElement(EnumMapperKey.QUIZ_CATEGORY, quiz.getQuizCategory())); diff --git a/src/main/resources/static/js/quiz/edit.js b/src/main/resources/static/js/quiz/edit.js index 77b3781..3265730 100644 --- a/src/main/resources/static/js/quiz/edit.js +++ b/src/main/resources/static/js/quiz/edit.js @@ -1,4 +1,6 @@ $(document).ready(function () { + $("#innerEditor").append($("#description").val()) + let editor ClassicEditor.create(document.querySelector('#editor')) .then(newEditor => { @@ -11,10 +13,6 @@ $(document).ready(function () { $("#btn-edit-answer").click(function () { editAnswer(editor); }); - $("#btn-delete-answer").click(function () { - deleteAnswer(); - }); - }); function editAnswer(editor) { @@ -41,28 +39,4 @@ function editAnswer(editor) { alert("설명 추가 실패"); } }); -} - -function deleteAnswer() { - const answerResourceId = $("#answerResourceId").val(); - - if (!answerResourceId) { - alert("Answer Not Exists"); - return false; - } - - $.ajax({ - url: '/answer/' + answerResourceId, - type: 'DELETE', - contentType: 'application/json', - success: function () { - $("#description").text(''); - $("#answerResourceId").val(''); - alert("설명 삭제 성공"); - }, - error: function () { - alert("설명 삭제 실패"); - } - }); - } \ No newline at end of file diff --git a/src/main/resources/templates/quiz/editQuiz.html b/src/main/resources/templates/quiz/editQuiz.html index 8477bff..542fe28 100644 --- a/src/main/resources/templates/quiz/editQuiz.html +++ b/src/main/resources/templates/quiz/editQuiz.html @@ -33,13 +33,15 @@
+

- +
+ +
-