PsHooN7979 07-30
240730 박세훈 설문 조사 상세 정보 수정
@cab1ef6daf42bd876d790c94bb3cc395059c373d
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
@@ -29,8 +29,8 @@
     // 설문 조사 삭제
     int deleteSurvey(String srvyId) throws Exception;
 
-    // 설문 조사 상세 정보
-    int insertSurveyDetail(SurveyDetailVO surveyDetailVO) throws Exception;
+    // 설문 조사 상세 정보 등록
+    void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception;
 
     // 설문 조사 상세 정보 조회
     List<SurveyDetailVO> surveyDetailList(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
@@ -14,9 +14,9 @@
 
 
 /**
- * @author  : 박세훈
+ * @author : 박세훈
  * since   : 2024.07.29
- *
+ * <p>
  * 설문 조사 관련 ServiceImpl
  */
 @Service("surveyService")
@@ -31,7 +31,7 @@
 
     // 설문 조사 등록
     @Override
-    public int insertSurvey(SurveyVO surveyVO) throws Exception{
+    public int insertSurvey(SurveyVO surveyVO) throws Exception {
         String srvyId = surveyIdgn.getNextStringId();
         surveyVO.setSrvyId(srvyId);
         return surveyDAO.insertSurvey(surveyVO);
@@ -57,10 +57,12 @@
 
     // 설문 조사 상세 정보
     @Override
-    public int insertSurveyDetail(SurveyDetailVO surveyDetailVO) throws Exception {
-        String srvyDtlId = surveyDetailIdgn.getNextStringId();
-        surveyDetailVO.setSrvyDtlId(srvyDtlId);
-        return surveyDAO.insertSurveyDetail(surveyDetailVO);
+    public void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception {
+        for (SurveyDetailVO detail : surveyDetailVO) {
+            String srvyDtlId = surveyDetailIdgn.getNextStringId();
+            detail.setSrvyDtlId(srvyDtlId);
+        }
+        surveyDAO.insertSurveyDetail(surveyDetailVO);
     }
 
     // 설문 조사 상세 정보 조회
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
@@ -28,7 +28,7 @@
     int deleteSurvey(String srvyId) throws Exception;
 
     // 설문 조사 상세 정보
-    int insertSurveyDetail(SurveyDetailVO surveyDetailVO) throws Exception;
+    void insertSurveyDetail(List<SurveyDetailVO> surveyDetailVO) throws Exception;
 
     // 설문 조사 상세 정보 조회
     List<SurveyDetailVO> surveyDetailList(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
@@ -5,6 +5,8 @@
 import com.takensoft.ai_lms.lms.survey.vo.SurveyDetailVO;
 import com.takensoft.ai_lms.lms.survey.vo.SurveyVO;
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -39,17 +41,9 @@
     }
 
     @PostMapping("/insertDetail.json")
-    public String insertDetailSurvey(@RequestBody SurveyDetailVO surveyDetailVO) throws Exception {
-        try {
-            int result = surveyService.insertSurveyDetail(surveyDetailVO);
-            if ( result > 0) {
-                return "success";
-            } else {
-                return "fail";
-            }
-        } catch (Exception e) {
-            return "Error";
-        }
+    public ResponseEntity<Void> insertDetailSurvey(@RequestBody List<SurveyDetailVO> surveyDetailVO) throws Exception {
+        surveyService.insertSurveyDetail(surveyDetailVO);
+        return new ResponseEntity<>(HttpStatus.CREATED);
     }
 
 
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
@@ -45,16 +45,20 @@
         내 용 : 설문 조사 상세 정보 등록
     -->
 
-    <insert id="insertSurveyDetail">
+    <insert id="insertSurveyDetail" parameterType="java.util.List">
         INSERT INTO survey_detail(  srvy_dtl_id,
                                     srvy_dtl_cnt,
                                     srvy_id)
-        VALUES (#{srvyDtlId},
-                #{srvyDtlCnt},
-                #{srvyId});
+        VALUES
+        <foreach collection="list" item="detail" separator=",">
+                (#{detail.srvyDtlId},
+                 #{detail.srvyDtlCnt},
+                 #{detail.srvyId})
+        </foreach>
     </insert>
 
 
+
     <!--
         작성자 : 박세훈
         작성일 : 2024.07.29
Add a comment
List