PsHooN7979 07-30
240730 박세훈 api POST로 수정
@ccedf4cbad4f10aa2c0fea616ef601ecb9cde399
src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
--- src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
@@ -93,7 +93,7 @@
      *
      * 게시글 수정
      */
-    @PutMapping("/update.json")
+    @PostMapping("/update.json")
     public String updateBoard(@RequestBody BoardVO boardVO) throws Exception {
         try {
             int result = boardService.updateBoard(boardVO);
@@ -113,7 +113,7 @@
      *
      * 게시글 삭제
      */
-    @DeleteMapping("/delete.json")
+    @PostMapping("/delete.json")
     public String deleteBoard(@RequestBody Map<String, String> request) throws Exception {
         try{
             String bbsId = request.get("bbsId");
src/main/java/com/takensoft/ai_lms/lms/class_book/web/ClassBookController.java
--- src/main/java/com/takensoft/ai_lms/lms/class_book/web/ClassBookController.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/web/ClassBookController.java
@@ -66,10 +66,10 @@
      * param   ClassBookDAO
      * @return
      * @throws  Exception
-     *
+
      * 반 교재 삭제
      */
-    @DeleteMapping("/delete.json")
+    @PostMapping("/delete.json")
     public String deleteClassBook(@RequestBody ClassBookVO classBookVO) throws Exception {
         try {
             int result = classBookService.deleteClassBook(classBookVO);
src/main/java/com/takensoft/ai_lms/lms/survey/dao/SurveyDAO.java
--- src/main/java/com/takensoft/ai_lms/lms/survey/dao/SurveyDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/dao/SurveyDAO.java
@@ -27,7 +27,10 @@
     int updateSurvey(SurveyVO surveyVO) throws Exception;
 
     // 설문 조사 삭제
-    int deleteSurvey(String srvyId) throws Exception;
+    void deleteSurvey(String srvyId) throws Exception;
+
+    // 설문 조사 상제 삭세
+    void deleteSurveyDetail(String srvyId) throws Exception;
 
     // 설문 조사 상세 정보 등록
     void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception;
src/main/java/com/takensoft/ai_lms/lms/survey/service/Impl/SurveyServiceImpl.java
--- src/main/java/com/takensoft/ai_lms/lms/survey/service/Impl/SurveyServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/service/Impl/SurveyServiceImpl.java
@@ -9,6 +9,7 @@
 import lombok.RequiredArgsConstructor;
 import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -50,11 +51,15 @@
     }
 
     // 설문 조사 삭제
+    @Transactional
     @Override
-    public int deleteSurvey(String srvyId) throws Exception {
-        return surveyDAO.deleteSurvey(srvyId);
+    public void deleteSurveyWithDetails(String srvyId) throws Exception {
+        surveyDAO.deleteSurveyDetail(srvyId);
+        surveyDAO.deleteSurvey(srvyId);
     }
 
+
+
     // 설문 조사 상세 정보
     @Override
     public void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception {
src/main/java/com/takensoft/ai_lms/lms/survey/service/SurveyService.java
--- src/main/java/com/takensoft/ai_lms/lms/survey/service/SurveyService.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/service/SurveyService.java
@@ -25,7 +25,7 @@
     int updateSurvey(SurveyVO surveyVO) throws Exception;
 
     // 설문 조사 삭제
-    int deleteSurvey(String srvyId) throws Exception;
+    void deleteSurveyWithDetails(String srvyId) throws Exception;
 
     // 설문 조사 상세 정보
     void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception;
src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
--- src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
+++ src/main/java/com/takensoft/ai_lms/lms/survey/web/SurveyController.java
@@ -47,18 +47,18 @@
     }
 
 
-    @GetMapping("/list.json")
+    @PostMapping("/list.json")
     public List<SurveyVO> surveyList(SurveyVO surveyVO) throws Exception {
         return surveyService.surveyList(surveyVO);
     }
 
-    @GetMapping("detailList.json")
+    @PostMapping("detailList.json")
     public List<SurveyDetailVO> surveyDetailVOList(SurveyDetailVO surveyDetailVO) throws Exception {
         return surveyService.surveyDetailList(surveyDetailVO);
     }
 
 
-    @PutMapping("/update.json")
+    @PostMapping("/update.json")
     public String updateSurvey (@RequestBody SurveyVO surveyVO) throws Exception {
         try {
             int result = surveyService.updateSurvey(surveyVO);
@@ -73,19 +73,10 @@
     }
 
 
-    @DeleteMapping("/delete.json")
-    public String deleteSurvey (@RequestBody Map<String, String> request) throws Exception {
-        try {
-            String srvyId = request.get("srvyId");
-            int result = surveyService.deleteSurvey(srvyId);
-            if ( result > 0) {
-                return "success";
-            } else {
-                return "fail";
-            }
-        } catch (Exception e) {
-            return "Error";
-        }
+    @PostMapping("/delete.json")
+    public ResponseEntity<Void> deleteSurvey (@RequestBody SurveyVO surveyVO) throws Exception {
+        surveyService.deleteSurveyWithDetails(surveyVO.getSrvyId());
+        return ResponseEntity.noContent().build();
     }
 
 
src/main/resources/mybatis/mapper/lms/survey-SQL.xml
--- src/main/resources/mybatis/mapper/lms/survey-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/survey-SQL.xml
@@ -114,6 +114,11 @@
         WHERE srvy_id = #{srvyId}
     </delete>
 
+    <delete id="deleteSurveyDetail" parameterType="String">
+        DELETE FROM survey_detail
+        WHERE srvy_id = #{srvyId}
+    </delete>
+
 
 
 
Add a comment
List