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
... | ... | @@ -18,6 +18,9 @@ |
18 | 18 |
// 임시: 단어장 전체 목록 조회 |
19 | 19 |
List<WordBookVO> getAllWordBooks(); |
20 | 20 |
|
21 |
+ // 책에 소속된 단어장 목록 조회 |
|
22 |
+ List<WordBookVO> getWordBooksByBookId(String bookId); |
|
23 |
+ |
|
21 | 24 |
// 아이디에 해당하는 단어장 조회 |
22 | 25 |
WordBookVO getWordBookById(String wdBookId); |
23 | 26 |
|
--- 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 @@ |
30 | 30 |
} |
31 | 31 |
|
32 | 32 |
@Override |
33 |
+ public List<WordBookVO> getWordBooksByBookId(String bookId) { |
|
34 |
+ return wordBookDAO.getWordBooksByBookId(bookId); |
|
35 |
+ } |
|
36 |
+ |
|
37 |
+ @Override |
|
33 | 38 |
public WordBookVO getWordBookById(String wdBookId) { |
34 | 39 |
return wordBookDAO.getWordBookById(wdBookId); |
35 | 40 |
} |
--- 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 @@ |
16 | 16 |
// 임시: 단어장 전체 목록 조회 |
17 | 17 |
List<WordBookVO> getAllWordBooks(); |
18 | 18 |
|
19 |
+ // 책에 소속된 단어장 목록 조회 |
|
20 |
+ List<WordBookVO> getWordBooksByBookId(String bookId); |
|
21 |
+ |
|
19 | 22 |
// 아이디에 해당하는 단어장 조회 |
20 | 23 |
WordBookVO getWordBookById(String wdBookId); |
21 | 24 |
|
--- 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 @@ |
18 | 18 |
private String wdBookTypeId; |
19 | 19 |
private String textId; |
20 | 20 |
private String userId; |
21 |
+ private String bookId; |
|
21 | 22 |
|
22 | 23 |
} |
--- 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 @@ |
30 | 30 |
return wordBookService.getAllWordBooks(); |
31 | 31 |
} |
32 | 32 |
|
33 |
+ // 책에 소속된 단어장 목록 조회 |
|
34 |
+ @PostMapping("/findByBookId.json") |
|
35 |
+ public List<WordBookVO> getWordBooksByBookId(@RequestBody Map<String, String> request) { |
|
36 |
+ String bookId = request.get("bookId"); |
|
37 |
+ return wordBookService.getWordBooksByBookId(bookId); |
|
38 |
+ } |
|
39 |
+ |
|
33 | 40 |
// 아이디에 해당하는 단어장 조회 |
34 | 41 |
@PostMapping("/find.json") |
35 | 42 |
public WordBookVO getWordBookById(@RequestBody WordBookVO wordBook) { |
... | ... | @@ -43,6 +50,7 @@ |
43 | 50 |
wordBook.setWdBookTypeId(req.get("wdBookTypeId")); |
44 | 51 |
wordBook.setTextId(req.get("textId")); |
45 | 52 |
wordBook.setUserId(req.get("userId")); |
53 |
+ wordBook.setBookId(req.get("bookId")); |
|
46 | 54 |
wordBookService.insertWordBook(wordBook); |
47 | 55 |
} |
48 | 56 |
|
--- src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
... | ... | @@ -13,6 +13,7 @@ |
13 | 13 |
<result property="wdBookTypeId" column="wd_book_type_id"/> |
14 | 14 |
<result property="textId" column="text_id"/> |
15 | 15 |
<result property="userId" column="user_id"/> |
16 |
+ <result property="bookId" column="book_id"/> |
|
16 | 17 |
</resultMap> |
17 | 18 |
|
18 | 19 |
<select id="getAllWordBooks" resultMap="WordBookResultMap"> |
... | ... | @@ -20,8 +21,20 @@ |
20 | 21 |
wd_book_id, |
21 | 22 |
wd_book_type_id, |
22 | 23 |
text_id, |
23 |
- user_id |
|
24 |
+ user_id, |
|
25 |
+ book_id |
|
24 | 26 |
FROM ai_lms.wordbook |
27 |
+ </select> |
|
28 |
+ |
|
29 |
+ <select id="getWordBooksByBookId" resultMap="WordBookResultMap"> <!-- 수정됨 --> |
|
30 |
+ SELECT |
|
31 |
+ wd_book_id, |
|
32 |
+ wd_book_type_id, |
|
33 |
+ text_id, |
|
34 |
+ user_id, |
|
35 |
+ book_id |
|
36 |
+ FROM wordbook |
|
37 |
+ WHERE book_id = #{bookId} |
|
25 | 38 |
</select> |
26 | 39 |
|
27 | 40 |
<select id="getWordBookById" parameterType="string" resultMap="WordBookResultMap"> |
... | ... | @@ -29,7 +42,8 @@ |
29 | 42 |
wd_book_id, |
30 | 43 |
wd_book_type_id, |
31 | 44 |
text_id, |
32 |
- user_id |
|
45 |
+ user_id, |
|
46 |
+ book_id |
|
33 | 47 |
FROM ai_lms.wordbook |
34 | 48 |
WHERE wd_book_id = #{wdBookId} |
35 | 49 |
</select> |
... | ... | @@ -39,18 +53,21 @@ |
39 | 53 |
ai_lms.wordbook (wd_book_id, |
40 | 54 |
wd_book_type_id, |
41 | 55 |
text_id, |
42 |
- user_id) |
|
56 |
+ user_id, |
|
57 |
+ book_id) |
|
43 | 58 |
VALUES (#{wdBookId}, |
44 | 59 |
#{wdBookTypeId}, |
45 | 60 |
#{textId}, |
46 |
- #{userId}) |
|
61 |
+ #{userId}, |
|
62 |
+ #{bookId}) |
|
47 | 63 |
</insert> |
48 | 64 |
|
49 | 65 |
<update id="updateWordBook" parameterType="WordBookVO"> |
50 | 66 |
UPDATE ai_lms.wordbook |
51 | 67 |
SET wd_book_type_id = #{wdBookTypeId}, |
52 | 68 |
text_id = #{textId}, |
53 |
- user_id = #{userId} |
|
69 |
+ user_id = #{userId}, |
|
70 |
+ book_id = #{bookId} |
|
54 | 71 |
WHERE wd_book_id = #{wdBookId} |
55 | 72 |
</update> |
56 | 73 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?