구자현 구자현 07-31
240731 구자현 controller POST 변경 및 로드맵 로직 수정
@964de7789c028b8ad322b66b57b51056615824c0
src/main/java/com/takensoft/ai_lms/lms/book/dao/BookDAO.java
--- src/main/java/com/takensoft/ai_lms/lms/book/dao/BookDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/book/dao/BookDAO.java
@@ -36,7 +36,7 @@
      *
      * 교재 등록
      */
-    void insertBook(BookVO book);
+    int insertBook(BookVO bookVO);
 
     /**
      * @author  : 구자현
@@ -44,7 +44,7 @@
      *
      * 교재 제목 수정
      */
-    void updateBook(BookVO book);
+    int updateBook(BookVO bookVO);
 
     /**
      * @author  : 구자현
@@ -52,5 +52,6 @@
      *
      * 교재 삭제
      */
-    void deleteBook(String book_id);
+    int deleteBook(String book_id);
+
 }
src/main/java/com/takensoft/ai_lms/lms/book/service/BookService.java
--- src/main/java/com/takensoft/ai_lms/lms/book/service/BookService.java
+++ src/main/java/com/takensoft/ai_lms/lms/book/service/BookService.java
@@ -33,7 +33,7 @@
      *
      * 교재 등록
      */
-    void insertBook(BookVO book);
+    int insertBook(BookVO book);
 
     /**
      * @author  : 구자현
@@ -41,7 +41,7 @@
      *
      * 교재 제목 수정
      */
-    void updateBook(BookVO book);
+    int updateBook(BookVO book);
 
     /**
      * @author  : 구자현
@@ -49,5 +49,6 @@
      *
      * 교재 삭제
      */
-    void deleteBook(String book_id);
+    int deleteBook(String book_id);
+
 }
src/main/java/com/takensoft/ai_lms/lms/book/service/Impl/BookServiceImpl.java
--- src/main/java/com/takensoft/ai_lms/lms/book/service/Impl/BookServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/book/service/Impl/BookServiceImpl.java
@@ -52,10 +52,10 @@
      * 교재 등록
      */
     @Override
-    public void insertBook(BookVO book) {
+    public int insertBook(BookVO book) {
         String book_id = bookIdgn.getNextStringId();
         book.setBook_id(book_id);
-        bookDAO.insertBook(book);
+        return bookDAO.insertBook(book);
     }
 
     /**
@@ -65,8 +65,8 @@
      * 교재 제목 수정
      */
     @Override
-    public void updateBook(BookVO book) {
-        bookDAO.updateBook(book);
+    public int updateBook(BookVO book) {
+        return bookDAO.updateBook(book);
     }
 
     /**
@@ -76,7 +76,8 @@
      * 교재 삭제
      */
     @Override
-    public void deleteBook(String book_id) {
-        bookDAO.deleteBook(book_id);
+    public int deleteBook(String book_id) {
+        return bookDAO.deleteBook(book_id);
     }
+
 }
(파일 끝에 줄바꿈 문자 없음)
src/main/java/com/takensoft/ai_lms/lms/book/web/BookController.java
--- src/main/java/com/takensoft/ai_lms/lms/book/web/BookController.java
+++ src/main/java/com/takensoft/ai_lms/lms/book/web/BookController.java
@@ -3,9 +3,9 @@
 import com.takensoft.ai_lms.lms.book.service.Impl.BookServiceImpl;
 import com.takensoft.ai_lms.lms.book.vo.BookVO;
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
 
 /**
  * @author  : 구자현
@@ -26,9 +26,9 @@
      *
      * 전체 교재 목록 출력
      */
-    @GetMapping("/findAll.json")
-    public List<BookVO> getAllBooks() {
-        return bookServiceImpl.getAllBooks();
+    @PostMapping("/findAll.json")
+    public ResponseEntity<?> getAllBooks() {
+        return new ResponseEntity<>(bookServiceImpl.getAllBooks(), HttpStatus.OK);
     }
 
     /**
@@ -37,9 +37,9 @@
      *
      * 책의 상세 정보
      */
-    @GetMapping("/find.json")
-    public BookVO getBookById(@RequestBody BookVO bookVO) {
-        return bookServiceImpl.getBookById(bookVO.getBook_id());
+    @PostMapping("/find.json")
+    public ResponseEntity<?> getBookById(@RequestBody BookVO bookVO) {
+        return new ResponseEntity<>(bookServiceImpl.getBookById(bookVO.getBook_id()), HttpStatus.OK);
     }
 
     /**
@@ -49,8 +49,8 @@
      * 교재 등록
      */
     @PostMapping("/insert.json")
-    public void insertBook(@RequestBody BookVO book) {
-        bookServiceImpl.insertBook(book);
+    public ResponseEntity<?> insertBook(@RequestBody BookVO book) {
+        return new ResponseEntity<>(bookServiceImpl.insertBook(book), HttpStatus.OK);
     }
 
     /**
@@ -59,9 +59,9 @@
      *
      * 교재 제목 수정
      */
-    @PutMapping("/update.json")
-    public void updateBook(@RequestBody BookVO book) {
-        bookServiceImpl.updateBook(book);
+    @PostMapping("/update.json")
+    public ResponseEntity<?> updateBook(@RequestBody BookVO book) {
+        return new ResponseEntity<>(bookServiceImpl.updateBook(book), HttpStatus.OK);
     }
 
     /**
@@ -70,9 +70,9 @@
      *
      * 교재 삭제
      */
-    @DeleteMapping("/delete.json")
-    public void deleteBook(@RequestBody BookVO bookVO) {
-        bookServiceImpl.deleteBook(bookVO.getBook_id());
+    @PostMapping("/delete.json")
+    public ResponseEntity<?> deleteBook(@RequestBody BookVO bookVO) {
+        return new ResponseEntity<>(bookServiceImpl.deleteBook(bookVO.getBook_id()), HttpStatus.OK);
     }
 
 }
(파일 끝에 줄바꿈 문자 없음)
src/main/java/com/takensoft/ai_lms/lms/unit_learning/dao/UnitLearningDAO.java
--- src/main/java/com/takensoft/ai_lms/lms/unit_learning/dao/UnitLearningDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/unit_learning/dao/UnitLearningDAO.java
@@ -18,17 +18,9 @@
      * @author  : 구자현
      * @since   : 2024.07.26
      *
-     * 전체 로드맵 목록 출력
-     */
-    List<UnitLearningVO> getAllUnitLearning();
-
-    /**
-     * @author  : 구자현
-     * @since   : 2024.07.26
-     *
      * 로드맵의 상세 정보
      */
-    UnitLearningVO getUnitLearningBySeq(int seq);
+    List<UnitLearningVO> getUnitLearning(String unit_id, String book_id);
 
     /**
      * @author  : 구자현
@@ -36,7 +28,7 @@
      *
      * 로드맵 등록
      */
-    void insertUnitLearning(UnitLearningVO scheduleVO);
+    int insertUnitLearning(List<UnitLearningVO> unitLearningVO);
 
     /**
      * @author  : 구자현
@@ -44,7 +36,7 @@
      *
      * 로드맵 순서 수정
      */
-    void updateUnitLearning(UnitLearningVO scheduleVO);
+    int updateUnitLearning(UnitLearningVO unitLearningVO);
 
     /**
      * @author  : 구자현
@@ -52,5 +44,6 @@
      *
      * 로드맵 삭제
      */
-    void deleteUnitLearning(int seq);
+    int deleteUnitLearning(String unit_id);
+
 }
 
src/main/java/com/takensoft/ai_lms/lms/unit_learning/dto/UnitLearningDTO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/unit_learning/dto/UnitLearningDTO.java
@@ -0,0 +1,19 @@
+package com.takensoft.ai_lms.lms.unit_learning.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author 구자현
+ * @since 2024.07.31
+ *
+ * 로드맵 조회용 DTO 클래스
+ */
+
+@Getter
+@Setter
+public class UnitLearningDTO {
+    private String book_id;
+    private String unit_id;
+}
+
src/main/java/com/takensoft/ai_lms/lms/unit_learning/service/Impl/UnitLearningServiceImpl.java
--- src/main/java/com/takensoft/ai_lms/lms/unit_learning/service/Impl/UnitLearningServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/unit_learning/service/Impl/UnitLearningServiceImpl.java
@@ -23,22 +23,11 @@
      * @author  : 구자현
      * @since   : 2024.07.26
      *
-     * 전체 로드맵 목록 출력
-     */
-    @Override
-    public List<UnitLearningVO> getAllUnitLearning() {
-        return unitLearningDAO.getAllUnitLearning();
-    };
-
-    /**
-     * @author  : 구자현
-     * @since   : 2024.07.26
-     *
      * 로드맵의 상세 정보
      */
     @Override
-    public UnitLearningVO getUnitLearningBySeq(int seq) {
-        return unitLearningDAO.getUnitLearningBySeq(seq);
+    public List<UnitLearningVO> getUnitLearning(String unit_id, String book_id) {
+        return unitLearningDAO.getUnitLearning(unit_id, book_id);
     };
 
     /**
@@ -48,9 +37,9 @@
      * 로드맵 등록
      */
     @Override
-    public void insertUnitLearning(UnitLearningVO unitLearningVO) {
-        unitLearningDAO.insertUnitLearning(unitLearningVO);
-    };
+    public int insertUnitLearning(List<UnitLearningVO> unitLearningVO) {
+        return unitLearningDAO.insertUnitLearning(unitLearningVO);
+    }
 
     /**
      * @author  : 구자현
@@ -59,8 +48,8 @@
      * 로드맵 순서 수정
      */
     @Override
-    public void updateUnitLearning(UnitLearningVO unitLearningVO) {
-        unitLearningDAO.updateUnitLearning(unitLearningVO);
+    public int updateUnitLearning(UnitLearningVO unitLearningVO) {
+        return unitLearningDAO.updateUnitLearning(unitLearningVO);
     };
 
     /**
@@ -70,7 +59,8 @@
      * 로드맵 삭제
      */
     @Override
-    public void deleteUnitLearning(int seq) {
-        unitLearningDAO.deleteUnitLearning(seq);
+    public int deleteUnitLearning(String unit_id) {
+        return unitLearningDAO.deleteUnitLearning(unit_id);
     };
+
 }
src/main/java/com/takensoft/ai_lms/lms/unit_learning/service/UnitLearningService.java
--- src/main/java/com/takensoft/ai_lms/lms/unit_learning/service/UnitLearningService.java
+++ src/main/java/com/takensoft/ai_lms/lms/unit_learning/service/UnitLearningService.java
@@ -16,17 +16,9 @@
      * @author  : 구자현
      * @since   : 2024.07.26
      *
-     * 전체 로드맵 목록 출력
-     */
-    List<UnitLearningVO> getAllUnitLearning();
-
-    /**
-     * @author  : 구자현
-     * @since   : 2024.07.26
-     *
      * 로드맵의 상세 정보
      */
-    UnitLearningVO getUnitLearningBySeq(int seq);
+    List<UnitLearningVO> getUnitLearning(String unit_id, String book_id);
 
     /**
      * @author  : 구자현
@@ -34,7 +26,7 @@
      *
      * 로드맵 등록
      */
-    void insertUnitLearning(UnitLearningVO unitLearningVO);
+    int insertUnitLearning(List<UnitLearningVO> unitLearningList);
 
     /**
      * @author  : 구자현
@@ -42,7 +34,7 @@
      *
      * 로드맵 순서 수정
      */
-    void updateUnitLearning(UnitLearningVO unitLearningVO);
+    int updateUnitLearning(UnitLearningVO unitLearningVO);
 
     /**
      * @author  : 구자현
@@ -50,5 +42,6 @@
      *
      * 로드맵 삭제
      */
-    void deleteUnitLearning(int seq);
+    int deleteUnitLearning(String unit_id);
+
 }
src/main/java/com/takensoft/ai_lms/lms/unit_learning/web/UnitLearningController.java
--- src/main/java/com/takensoft/ai_lms/lms/unit_learning/web/UnitLearningController.java
+++ src/main/java/com/takensoft/ai_lms/lms/unit_learning/web/UnitLearningController.java
@@ -1,8 +1,11 @@
 package com.takensoft.ai_lms.lms.unit_learning.web;
 
+import com.takensoft.ai_lms.lms.unit_learning.dto.UnitLearningDTO;
 import com.takensoft.ai_lms.lms.unit_learning.service.Impl.UnitLearningServiceImpl;
 import com.takensoft.ai_lms.lms.unit_learning.vo.UnitLearningVO;
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -18,22 +21,11 @@
      * @author  : 구자현
      * @since   : 2024.07.26
      *
-     * 전체 로드맵 목록 출력
-     */
-    @GetMapping("/findAll.json")
-    public List<UnitLearningVO> getAllUnitLearning(){
-        return unitLearningServiceImpl.getAllUnitLearning();
-    }
-
-    /**
-     * @author  : 구자현
-     * @since   : 2024.07.26
-     *
      * 로드맵의 상세 정보
      */
-    @GetMapping("/find.json")
-    public UnitLearningVO getUnitLearningBySeq(@RequestBody UnitLearningVO unitLearningVO){
-        return unitLearningServiceImpl.getUnitLearningBySeq(unitLearningVO.getSeq());
+    @PostMapping("/find.json")
+    public ResponseEntity<?> getUnitLearning(@RequestBody UnitLearningDTO unitLearningDTO){
+        return new ResponseEntity<>(unitLearningServiceImpl.getUnitLearning(unitLearningDTO.getUnit_id(), unitLearningDTO.getBook_id()), HttpStatus.OK);
     }
 
     /**
@@ -43,8 +35,8 @@
      * 로드맵 등록
      */
     @PostMapping("/insert.json")
-    public void insertUnitLearning(@RequestBody UnitLearningVO unitLearningVO) {
-        unitLearningServiceImpl.insertUnitLearning(unitLearningVO);
+    public ResponseEntity<?> insertUnitLearning(@RequestBody List<UnitLearningVO> unitLearning) {
+        return new ResponseEntity<>(unitLearningServiceImpl.insertUnitLearning(unitLearning), HttpStatus.OK);
     }
 
     /**
@@ -53,9 +45,9 @@
      *
      * 로드맵 순서 수정
      */
-    @PutMapping("/update.json")
-    public void updateUnitLearning(@RequestBody UnitLearningVO unitLearningVO) {
-        unitLearningServiceImpl.updateUnitLearning(unitLearningVO);
+    @PostMapping("/update.json")
+    public ResponseEntity<?> updateUnitLearning(@RequestBody UnitLearningVO unitLearningVO) {
+        return new ResponseEntity<>(unitLearningServiceImpl.updateUnitLearning(unitLearningVO), HttpStatus.OK);
     }
 
     /**
@@ -64,8 +56,9 @@
      *
      * 로드맵 삭제
      */
-    @DeleteMapping("/delete.json")
-    public void deleteUnitLearning(@RequestBody UnitLearningVO unitLearningVO) {
-        unitLearningServiceImpl.deleteUnitLearning(unitLearningVO.getSeq());
+    @PostMapping("/delete.json")
+    public ResponseEntity<?> deleteUnitLearning(@RequestBody UnitLearningVO unitLearningVO) {
+        return new ResponseEntity<>(unitLearningServiceImpl.deleteUnitLearning(unitLearningVO.getUnit_id()), HttpStatus.OK);
     }
+
 }
src/main/resources/mybatis/mapper/lms/book-SQL.xml
--- src/main/resources/mybatis/mapper/lms/book-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/book-SQL.xml
@@ -38,8 +38,9 @@
         내   용 : 교재 등록
     -->
     <insert id="insertBook" parameterType="bookVO">
-        INSERT INTO book (book_id, book_nm)
-             VALUES (#{book_id}, #{book_nm})
+        INSERT
+          INTO book (book_id, book_nm)
+        VALUES (#{book_id}, #{book_nm})
     </insert>
 
     <!--
@@ -59,7 +60,9 @@
         내   용 : 교재 삭제
     -->
     <delete id="deleteBook" parameterType="String">
-        DELETE FROM book
+        DELETE
+          FROM book
          WHERE book_id = #{book_id}
     </delete>
+
 </mapper>
(파일 끝에 줄바꿈 문자 없음)
src/main/resources/mybatis/mapper/lms/unit_learning-SQL.xml
--- src/main/resources/mybatis/mapper/lms/unit_learning-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/unit_learning-SQL.xml
@@ -14,60 +14,37 @@
     <!--
         작 성 자 : 구자현
         작 성 일 : 2024.07.26
-        내   용 : 전체 로드맵 목록 출력
-    -->
-    <select id="getAllUnitLearning" resultMap="unitLearningMap">
-        SELECT
-            unit_id,
-            prblm_id,
-            wd_book_id,
-            text_id,
-            eval_id,
-            seq
-         FROM unit_learning
-    </select>
-
-    <!--
-        작 성 자 : 구자현
-        작 성 일 : 2024.07.26
         내   용 : 로드맵의 상세 정보
     -->
-    <select id="getUnitLearningBySeq" parameterType="int" resultMap="unitLearningMap">
+    <select id="getUnitLearning" parameterType="String" resultMap="unitLearningMap">
         SELECT
-            unit_id,
-            prblm_id,
-            wd_book_id,
-            text_id,
-            eval_id,
-            seq
-         FROM unit_learning
-        WHERE seq = #{seq}
+            ul.unit_id,
+            ul.prblm_id,
+            ul.wd_book_id,
+            ul.text_id,
+            ul.eval_id,
+            ul.seq
+         FROM unit_learning ul
+         JOIN unit u
+           ON ul.unit_id = u.unit_id
+        WHERE ul.unit_id = #{unit_id} AND u.book_id = #{book_id}
     </select>
 
     <!--
         작 성 자 : 구자현
         작 성 일 : 2024.07.26
         내   용 : 로드맵 등록
+
     -->
-    <insert id="insertUnitLearning" parameterType="unitLearningVO">
-        INSERT INTO unit_learning
-            (
-            unit_id,
-            prblm_id,
-            wd_book_id,
-            text_id,
-            eval_id,
-            seq
-            )
-            VALUES
-            (
-            #{unit_id},
-            #{prblm_id},
-            #{wd_book_id},
-            #{text_id},
-            #{eval_id},
-            #{seq}
-            )
+    <insert id="insertUnitLearning" parameterType="list">
+        INSERT
+          INTO
+            unit_learning
+            (unit_id, prblm_id, wd_book_id, text_id, eval_id, seq)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (#{item.unit_id}, #{item.prblm_id}, #{item.wd_book_id}, #{item.text_id}, #{item.eval_id}, #{item.seq})
+        </foreach>
     </insert>
 
     <!--
@@ -75,14 +52,22 @@
         작 성 일 : 2024.07.26
         내   용 : 로드맵 수정
     -->
-    <update id="updateUnitLearning" parameterType="unitLearningVO">
+    <update id="updateUnitLearning"  parameterType="unitLearningVO">
         UPDATE unit_learning
            SET seq = #{seq}
          WHERE unit_id = #{unit_id}
-           AND prblm_id = #{prblm_id}
-           AND wd_book_id = #{wd_book_id}
-           AND text_id = #{text_id}
-           AND eval_id = #{eval_id}
+            <if test="prblm_id != null">
+                AND prblm_id = #{prblm_id}
+            </if>
+            <if test="wd_book_id != null">
+                AND wd_book_id = #{wd_book_id}
+            </if>
+            <if test="text_id != null">
+                AND text_id = #{text_id}
+            </if>
+            <if test="eval_id != null">
+                AND eval_id = #{eval_id}
+            </if>
     </update>
 
     <!--
@@ -90,8 +75,10 @@
         작 성 일 : 2024.07.26
         내   용 : 로드맵 삭제
     -->
-    <delete id="deleteUnitLearning" parameterType="int">
-        DELETE FROM unit_learning
-         WHERE seq = #{seq}
+    <delete id="deleteUnitLearning" parameterType="unitLearningVO">
+        DELETE
+          FROM unit_learning
+         WHERE unit_id = #{unit_id}
     </delete>
+
 </mapper>
(파일 끝에 줄바꿈 문자 없음)
Add a comment
List