Remove Delete APIs
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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("설명 삭제 실패");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@@ -33,13 +33,15 @@
|
||||
<div class="col-12x">
|
||||
<input type="hidden" th:value="${quiz.resourceId}" name="quizResourceId" id="quizResourceId"/>
|
||||
<input type="hidden" th:value="${answer.resourceId}" name="answerResourceId" id="answerResourceId"/>
|
||||
<input type="hidden" th:value="${answer.description}" name="description" id="description"/>
|
||||
<h2 class="contact-title" th:text="${quiz.title}"></h2>
|
||||
<div id="editor">
|
||||
<textarea contenteditable="true" name="description" id="description" placeholder="Enter title" th:text="${answer.description}"></textarea>
|
||||
<div id="innerEditor">
|
||||
<!-- <textarea contenteditable="true" name="description" id="description" placeholder="Enter title" th:text="${answer.description}"></textarea>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group mt-3">
|
||||
<button type="submit" class="button boxed-btn" id="btn-edit-answer">Edit</button>
|
||||
<button type="submit" class="button boxed-btn" id="btn-delete-answer">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user