@@ -1,158 +1,89 @@
 package codesquad.qua;
 
-import codesquad.answer.Answer;
-import codesquad.answer.AnswerRepository;
-import codesquad.user.User;
-import codesquad.utils.SessionUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
+import codesquad.exception.QuestionDeleteException;
+import codesquad.exception.QuestionEditException;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Controller;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpSession;
-import java.util.NoSuchElementException;
 
 @Controller
+@RequiredArgsConstructor
+@Slf4j
 public class QuestionController {
 
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-    @Autowired
-    QuestionRepository questionRepository;
-
-    @Autowired
-    AnswerRepository answerRepository;
+    private final QuestionService questionService;
 
     @GetMapping("/questions/form")
     public String createForm(HttpSession session) {
-        User user = SessionUtil.getUserBySession(session);
-
-        if (user == null) {
+        if (!questionService.setCreateForm(session)) {
             return "/login";
         }
 
         return "qna/form";
     }
 
     @PostMapping("/questions")
-    public String create(Question question, HttpSession session) {
-        User user = SessionUtil.getUserBySession(session);
-
-        if (user == null) {
+    public String createQuestion(QuestionDto questionDto, HttpSession session) {
+        if (!questionService.create(questionDto, session)) {
             return "/login";
         }
 
-        question.setWriter(user);
-        questionRepository.save(question);
-        logger.info("user : {}", question.getWriter().getName());
         return "redirect:/";
     }
 
     @GetMapping("/")
-    public String list(Model model) {
-        model.addAttribute("question", questionRepository.findAll());
+    public String showQuestionList(Model model) {
+        model.addAttribute("question", questionService.list());
         return "qna/list";
     }
 
     @GetMapping("/questions/{id}")
-    public String qnaInfo(Model model, @PathVariable("id") Long id) {
-        Question question = findQuestionById(id);
-        model.addAttribute("question", question);
-        model.addAttribute("count", countAnswers(question));
-
+    public String showQuestion(Model model, @PathVariable("id") Long id) {
+        model.addAttribute("question", questionService.findQuestionById(id));
+        model.addAttribute("count", questionService.countAnswers(id));
         return "qna/show";
     }
 
-    @Transactional
     @PutMapping("/questions/{id}")
-    public String update(Question changedQuestion, @PathVariable("id") Long id, HttpSession session) {
-        User user = SessionUtil.getUserBySession(session);
-        Question savedQuestion = findQuestionById(id);
-
-        if (user == null || !isQuestionMatchUser(user, savedQuestion)) {
+    public String updateQuestion(QuestionDto changedQuestion, @PathVariable("id") Long id, HttpSession session) {
+        try {
+            questionService.update(changedQuestion, id, session);
+        } catch (QuestionEditException showException) {
             return "qna/show_failed";
         }
 
-        logger.info("user: {}", user.getName());
-        logger.info("question: {}", savedQuestion.getWriter());
-
-        savedQuestion.update(changedQuestion);
-
         return "redirect:/";
     }
 
     @GetMapping("/questions/{id}/updateForm")
     public String updateForm(Model model, @PathVariable("id") Long id, HttpSession session) {
-        User user = SessionUtil.getUserBySession(session);
-        Question savedQuestion = findQuestionById(id);
-
-        if (user == null || !isQuestionMatchUser(user, savedQuestion)) {
+        try {
+            questionService.setUpdateForm(id, session);
+        } catch (QuestionEditException showException) {
             return "qna/show_failed";
         }
 
-        logger.info("user: {}", user.getName());
-        logger.info("question: {}", savedQuestion.getWriter());
-
-        model.addAttribute("question", savedQuestion);
+        model.addAttribute("question", questionService.findQuestionById(id));
 
         return "qna/updateForm";
     }
 
     @DeleteMapping("/questions/{id}")
-    @Transactional
-    public String remove(@PathVariable("id") Long id, HttpSession session) {
-        User user = SessionUtil.getUserBySession(session);
-        Question savedQuestion = findQuestionById(id);
-
-        logger.info("user: {}", user.getName());
-        logger.info("question: {}", savedQuestion.getWriter());
+    public String removeQuestion(@PathVariable("id") Long id, HttpSession session) {
 
-        if (user == null || !isQuestionMatchUser(user, savedQuestion)) {
+        try {
+            questionService.remove(id, session);
+        } catch (QuestionEditException showException) {
             return "qna/show_failed";
-        }
-
-        if (!canDeleteQuestion(savedQuestion, user)) {
+        } catch (QuestionDeleteException deleteException) {
             return "qna/delete_failed";
         }
 
-        savedQuestion.changeDeleteFlag();
-
-        for (Answer answer : savedQuestion.getAnswers()) {
-            answer.changeDeletedFlag();
-        }
-
         return "redirect:/questions/" + id;
     }
-
-    private Question findQuestionById(Long id) {
-        return questionRepository.findById(id)
-                                 .orElseThrow(NoSuchElementException::new);
-    }
-
-    private boolean isQuestionMatchUser(User loginUser, Question question) {
-        return question.equalsWriter(loginUser);
-    }
-
-    private boolean canDeleteQuestion(Question deletedQuestion, User user) {
-        if (deletedQuestion.hasAnswers()) {
-            for (Answer answer : deletedQuestion.getAnswers()) {
-                if (!answer.equalsWriter(user)) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
-    private int countAnswers(Question question) {
-        int count = 0;
-        for (Answer answer : question.getAnswers()) {
-            if (!answer.isDeletedFlag()) {
-                count++;
-            }
-        }
-        return count;
-    }
 }
\ No newline at end of file

리뷰: 오 맞습니다 저도 사용자 정의 예외를 사용하기 전에 올려주신 링크를 봤습니다.
링크에 대해서 보면 굳이 나눌 필요 없이, IllegalArgumentException, IllegalstateException에 따라 다른 뷰를 보여줄 수 있지만, 이때는 명시적으로 보여주는게 낫지 않을까 라는 생각을 했습니다