woals 07-31
240730 권민수 wordbook 테이블에 book_id 칼럼 추가에 따른 crud 로직 수정 및 책 별 단어장 조회 기능 추가
@6e3147d2a5f56ef624510838372e8a0abb99915b
src/main/java/com/takensoft/ai_lms/lms/word_book/dao/WordBookDAO.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/dao/WordBookDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/dao/WordBookDAO.java
@@ -18,6 +18,9 @@
     // 임시: 단어장 전체 목록 조회
     List<WordBookVO> getAllWordBooks();
 
+    // 책에 소속된 단어장 목록 조회
+    List<WordBookVO> getWordBooksByBookId(String bookId);
+
     // 아이디에 해당하는 단어장 조회
     WordBookVO getWordBookById(String wdBookId);
 
src/main/java/com/takensoft/ai_lms/lms/word_book/service/Impl/WordBookServiceImpl.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/service/Impl/WordBookServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/service/Impl/WordBookServiceImpl.java
@@ -30,6 +30,11 @@
     }
 
     @Override
+    public List<WordBookVO> getWordBooksByBookId(String bookId) {
+        return wordBookDAO.getWordBooksByBookId(bookId);
+    }
+
+    @Override
     public WordBookVO getWordBookById(String wdBookId) {
         return wordBookDAO.getWordBookById(wdBookId);
     }
src/main/java/com/takensoft/ai_lms/lms/word_book/service/WordBookService.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/service/WordBookService.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/service/WordBookService.java
@@ -16,6 +16,9 @@
     // 임시: 단어장 전체 목록 조회
     List<WordBookVO> getAllWordBooks();
 
+    // 책에 소속된 단어장 목록 조회
+    List<WordBookVO> getWordBooksByBookId(String bookId);
+
     // 아이디에 해당하는 단어장 조회
     WordBookVO getWordBookById(String wdBookId);
 
src/main/java/com/takensoft/ai_lms/lms/word_book/vo/WordBookVO.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/vo/WordBookVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/vo/WordBookVO.java
@@ -18,5 +18,6 @@
     private String wdBookTypeId;
     private String textId;
     private String userId;
+    private String bookId;
 
 }
src/main/java/com/takensoft/ai_lms/lms/word_book/web/WordBookController.java
--- src/main/java/com/takensoft/ai_lms/lms/word_book/web/WordBookController.java
+++ src/main/java/com/takensoft/ai_lms/lms/word_book/web/WordBookController.java
@@ -30,6 +30,13 @@
         return wordBookService.getAllWordBooks();
     }
 
+    // 책에 소속된 단어장 목록 조회
+    @PostMapping("/findByBookId.json")
+    public List<WordBookVO> getWordBooksByBookId(@RequestBody Map<String, String> request) {
+        String bookId = request.get("bookId");
+        return wordBookService.getWordBooksByBookId(bookId);
+    }
+
     // 아이디에 해당하는 단어장 조회
     @PostMapping("/find.json")
     public WordBookVO getWordBookById(@RequestBody WordBookVO wordBook) {
@@ -43,6 +50,7 @@
         wordBook.setWdBookTypeId(req.get("wdBookTypeId"));
         wordBook.setTextId(req.get("textId"));
         wordBook.setUserId(req.get("userId"));
+        wordBook.setBookId(req.get("bookId"));
         wordBookService.insertWordBook(wordBook);
     }
 
src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
--- src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
@@ -13,6 +13,7 @@
         <result property="wdBookTypeId" column="wd_book_type_id"/>
         <result property="textId" column="text_id"/>
         <result property="userId" column="user_id"/>
+        <result property="bookId" column="book_id"/>
     </resultMap>
 
     <select id="getAllWordBooks" resultMap="WordBookResultMap">
@@ -20,8 +21,20 @@
             wd_book_id,
             wd_book_type_id,
             text_id,
-            user_id
+            user_id,
+            book_id
         FROM ai_lms.wordbook
+    </select>
+
+    <select id="getWordBooksByBookId" resultMap="WordBookResultMap">  <!-- 수정됨 -->
+        SELECT
+        wd_book_id,
+        wd_book_type_id,
+        text_id,
+        user_id,
+        book_id
+        FROM wordbook
+        WHERE book_id = #{bookId}
     </select>
 
     <select id="getWordBookById" parameterType="string" resultMap="WordBookResultMap">
@@ -29,7 +42,8 @@
             wd_book_id,
             wd_book_type_id,
             text_id,
-            user_id
+            user_id,
+            book_id
         FROM ai_lms.wordbook
         WHERE wd_book_id = #{wdBookId}
     </select>
@@ -39,18 +53,21 @@
             ai_lms.wordbook (wd_book_id,
                              wd_book_type_id,
                              text_id,
-                             user_id)
+                             user_id,
+                             book_id)
         VALUES (#{wdBookId},
                 #{wdBookTypeId},
                 #{textId},
-                #{userId})
+                #{userId},
+                #{bookId})
     </insert>
 
     <update id="updateWordBook" parameterType="WordBookVO">
         UPDATE ai_lms.wordbook
         SET wd_book_type_id = #{wdBookTypeId},
             text_id = #{textId},
-            user_id = #{userId}
+            user_id = #{userId},
+            book_id = #{bookId}
         WHERE wd_book_id = #{wdBookId}
     </update>
 
Add a comment
List