PsHooN7979 07-30
240730 박세훈 class_book 수정
@f84041896cdf06ce9020f5a8a30d1f56c117ead8
src/main/java/com/takensoft/ai_lms/lms/class_book/dao/ClassBookDAO.java
--- src/main/java/com/takensoft/ai_lms/lms/class_book/dao/ClassBookDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/dao/ClassBookDAO.java
@@ -18,7 +18,7 @@
 public interface ClassBookDAO {
 
     // 교재 등록
-    int registerBook(ClassBookVO classBookVO) throws Exception;
+    void registerBook(List<ClassBookVO> classBookVO) throws Exception;
 
     // 교재 삭제
     int deleteClassBook(ClassBookVO classBookVO) throws Exception;
src/main/java/com/takensoft/ai_lms/lms/class_book/service/ClassBookService.java
--- src/main/java/com/takensoft/ai_lms/lms/class_book/service/ClassBookService.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/service/ClassBookService.java
@@ -16,7 +16,7 @@
 public interface ClassBookService {
 
     // 교재 등록
-    int registerBook(ClassBookVO classBookVO) throws Exception;
+    void registerBook(List<ClassBookVO> classBookVO) throws Exception;
 
     // 교재 삭제
     int deleteClassBook(ClassBookVO classBookVO) throws Exception;
src/main/java/com/takensoft/ai_lms/lms/class_book/service/Impl/ClassBookServiceImpl.java
--- src/main/java/com/takensoft/ai_lms/lms/class_book/service/Impl/ClassBookServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/service/Impl/ClassBookServiceImpl.java
@@ -26,8 +26,8 @@
 
     // 교재 등록
     @Override
-    public int registerBook(ClassBookVO classBookVO) throws Exception {
-        return classBookDAO.registerBook(classBookVO);
+    public void registerBook(List<ClassBookVO> classBookVO) throws Exception {
+        classBookDAO.registerBook(classBookVO);
     }
 
     // 교재 삭제
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
@@ -8,6 +8,7 @@
 import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
+import java.util.List;
 
 @RestController
 @RequiredArgsConstructor
@@ -26,18 +27,9 @@
      * 반 교재 등록
      */
     @PostMapping("/register.json")
-    public String registerBook(@RequestBody ClassBookVO classBookVO) throws Exception {
-        try {
-            int result = classBookService.registerBook(classBookVO);
-            if (result > 0) {
-                return "success";
-            } else {
-                return "fail";
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            return "Error";
-        }
+    public ResponseEntity<Void> registerBook(@RequestBody List<ClassBookVO> classBookVO) throws Exception {
+        classBookService.registerBook(classBookVO);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
 
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
@@ -43,7 +43,7 @@
     @PostMapping("/insertDetail.json")
     public ResponseEntity<Void> insertDetailSurvey(@RequestBody List<SurveyDetailVO> surveyDetailVO) throws Exception {
         surveyService.insertSurveyDetail(surveyDetailVO);
-        return new ResponseEntity<>(HttpStatus.CREATED);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
 
@@ -76,7 +76,7 @@
     @PostMapping("/delete.json")
     public ResponseEntity<Void> deleteSurvey (@RequestBody SurveyVO surveyVO) throws Exception {
         surveyService.deleteSurveyWithDetails(surveyVO.getSrvyId());
-        return ResponseEntity.noContent().build();
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
 
src/main/resources/mybatis/mapper/lms/class_book-SQL.xml
--- src/main/resources/mybatis/mapper/lms/class_book-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/class_book-SQL.xml
@@ -14,9 +14,13 @@
     <insert id="registerBook" parameterType="String" >
         INSERT INTO class_book( book_id,
                                 scls_id
-        ) VALUES ( #{bookId},
-                    #{sclsId}
-        );
+        )
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+                   (#{item.bookId},
+                    #{item.sclsId}
+                    )
+        </foreach>
     </insert>
 
 
Add a comment
List