woals
08-07
240807 권민수 책별 단어장 조회 -> 단원별 단어장 조회로 구조 변경
@f2c543b7a2d9f9eddca585ae1a8fcbfa66efd50f
--- 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
... | ... | @@ -1,6 +1,7 @@ |
1 | 1 |
package com.takensoft.ai_lms.lms.word_book.dao; |
2 | 2 |
|
3 | 3 |
import com.takensoft.ai_lms.lms.word_book.vo.WordBookVO; |
4 |
+import org.apache.ibatis.annotations.Param; |
|
4 | 5 |
import org.egovframe.rte.psl.dataaccess.mapper.Mapper; |
5 | 6 |
|
6 | 7 |
import java.util.HashMap; |
... | ... | @@ -20,9 +21,9 @@ |
20 | 21 |
List<WordBookVO> getAllWordBooks(HashMap<String, Object> params) throws Exception; |
21 | 22 |
int getWordBooksCount() throws Exception; |
22 | 23 |
|
23 |
- // 책에 소속된 단어장 목록 조회 |
|
24 |
- List<WordBookVO> getWordBooksByBookId(HashMap<String, Object> params) throws Exception; |
|
25 |
- int getWordBooksByBookIdCount(String bookId) throws Exception; |
|
24 |
+ // 단원별로 단어장 목록 조회 |
|
25 |
+ List<WordBookVO> getWordBooksByUnitId(HashMap<String, Object> params) throws Exception; |
|
26 |
+ int getWordBooksByUnitIdCount(HashMap<String, Object> params) throws Exception; |
|
26 | 27 |
|
27 | 28 |
// 아이디에 해당하는 단어장 조회 |
28 | 29 |
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
... | ... | @@ -40,18 +40,20 @@ |
40 | 40 |
} |
41 | 41 |
|
42 | 42 |
@Override |
43 |
- public List<WordBookVO> getWordBooksByBookId(String bookId, int page, int pageSize) throws Exception { |
|
43 |
+ public List<WordBookVO> getWordBooksByUnitId(String unitId, int page, int pageSize) throws Exception { |
|
44 | 44 |
int startIndex = (page - 1) * pageSize; |
45 | 45 |
HashMap<String, Object> params = new HashMap<>(); |
46 |
- params.put("bookId", bookId); |
|
46 |
+ params.put("unitId", unitId); |
|
47 | 47 |
params.put("startIndex", startIndex); |
48 | 48 |
params.put("pageSize", pageSize); |
49 |
- return wordBookDAO.getWordBooksByBookId(params); |
|
49 |
+ return wordBookDAO.getWordBooksByUnitId(params); |
|
50 | 50 |
} |
51 | 51 |
|
52 | 52 |
@Override |
53 |
- public int getWordBooksByBookIdCount(String bookId) throws Exception { |
|
54 |
- return wordBookDAO.getWordBooksByBookIdCount(bookId); |
|
53 |
+ public int getWordBooksByUnitIdCount(String unitId) throws Exception { |
|
54 |
+ HashMap<String, Object> params = new HashMap<>(); |
|
55 |
+ params.put("unitId", unitId); |
|
56 |
+ return wordBookDAO.getWordBooksByUnitIdCount(params); |
|
55 | 57 |
} |
56 | 58 |
|
57 | 59 |
@Override |
... | ... | @@ -77,9 +79,10 @@ |
77 | 79 |
} |
78 | 80 |
|
79 | 81 |
@Override |
80 |
- public List<WordBookVO> getWordBooksByTextTitle(String textTitle, int page, int pageSize) throws Exception { |
|
82 |
+ public List<WordBookVO> getWordBooksByTextTitle(String unitId, String textTitle, int page, int pageSize) throws Exception { |
|
81 | 83 |
int startIndex = (page - 1) * pageSize; |
82 | 84 |
HashMap<String, Object> params = new HashMap<>(); |
85 |
+ params.put("unitId", unitId); |
|
83 | 86 |
params.put("textTitle", "%" + textTitle + "%"); |
84 | 87 |
params.put("startIndex", startIndex); |
85 | 88 |
params.put("pageSize", pageSize); |
... | ... | @@ -87,14 +90,18 @@ |
87 | 90 |
} |
88 | 91 |
|
89 | 92 |
@Override |
90 |
- public int getWordBooksByTextTitleCount(String textTitle) throws Exception { |
|
93 |
+ public int getWordBooksByTextTitleCount(String unitId, String textTitle) throws Exception { |
|
94 |
+ HashMap<String, Object> params = new HashMap<>(); |
|
95 |
+ params.put("unitId", unitId); |
|
96 |
+ params.put("textTitle", "%" + textTitle + "%"); |
|
91 | 97 |
return wordBookDAO.getWordBooksByTextTitleCount(textTitle); |
92 | 98 |
} |
93 | 99 |
|
94 | 100 |
@Override |
95 |
- public List<WordBookVO> getWordBooksByWord(String word, int page, int pageSize) throws Exception { |
|
101 |
+ public List<WordBookVO> getWordBooksByWord(String unitId, String word, int page, int pageSize) throws Exception { |
|
96 | 102 |
int startIndex = (page - 1) * pageSize; |
97 | 103 |
HashMap<String, Object> params = new HashMap<>(); |
104 |
+ params.put("unitId", unitId); |
|
98 | 105 |
params.put("word", word); |
99 | 106 |
params.put("startIndex", startIndex); |
100 | 107 |
params.put("pageSize", pageSize); |
... | ... | @@ -102,7 +109,10 @@ |
102 | 109 |
} |
103 | 110 |
|
104 | 111 |
@Override |
105 |
- public int getWordBooksByWordCount(String word) throws Exception { |
|
112 |
+ public int getWordBooksByWordCount(String unitId, String word) throws Exception { |
|
113 |
+ HashMap<String, Object> params = new HashMap<>(); |
|
114 |
+ params.put("unitId", unitId); |
|
115 |
+ params.put("word", word); |
|
106 | 116 |
return wordBookDAO.getWordBooksByWordCount(word); |
107 | 117 |
} |
108 | 118 |
|
--- 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
... | ... | @@ -18,8 +18,8 @@ |
18 | 18 |
int getWordBooksCount() throws Exception; |
19 | 19 |
|
20 | 20 |
// 책에 소속된 단어장 목록 조회 |
21 |
- List<WordBookVO> getWordBooksByBookId(String bookId, int page, int pageSize) throws Exception; |
|
22 |
- int getWordBooksByBookIdCount(String bookId) throws Exception; |
|
21 |
+ List<WordBookVO> getWordBooksByUnitId(String unitId, int page, int pageSize) throws Exception; |
|
22 |
+ int getWordBooksByUnitIdCount(String unitId) throws Exception; |
|
23 | 23 |
|
24 | 24 |
// 아이디에 해당하는 단어장 조회 |
25 | 25 |
WordBookVO getWordBookById(String wdBookId); |
... | ... | @@ -34,12 +34,12 @@ |
34 | 34 |
void deleteWordBook(String wdBookId); |
35 | 35 |
|
36 | 36 |
// 단어장 검색(지문 이름으로 검색) |
37 |
- List<WordBookVO> getWordBooksByTextTitle(String textTitle, int page, int pageSize) throws Exception; |
|
38 |
- int getWordBooksByTextTitleCount(String textTitle) throws Exception; |
|
37 |
+ List<WordBookVO> getWordBooksByTextTitle(String unitId, String textTitle, int page, int pageSize) throws Exception; |
|
38 |
+ int getWordBooksByTextTitleCount(String unitId, String textTitle) throws Exception; |
|
39 | 39 |
|
40 | 40 |
// 단어장 검색(단어로 검색) |
41 |
- List<WordBookVO> getWordBooksByWord(String word, int page, int pageSize) throws Exception; |
|
42 |
- int getWordBooksByWordCount(String word) throws Exception; |
|
41 |
+ List<WordBookVO> getWordBooksByWord(String unitId, String word, int page, int pageSize) throws Exception; |
|
42 |
+ int getWordBooksByWordCount(String unitId, String word) throws Exception; |
|
43 | 43 |
|
44 | 44 |
|
45 | 45 |
} |
--- 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
... | ... | @@ -19,5 +19,6 @@ |
19 | 19 |
private String textId; |
20 | 20 |
private String userId; |
21 | 21 |
private String bookId; |
22 |
+ private String unitId; |
|
22 | 23 |
|
23 | 24 |
} |
--- 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
... | ... | @@ -41,15 +41,15 @@ |
41 | 41 |
return result; |
42 | 42 |
} |
43 | 43 |
|
44 |
- // 책에 소속된 단어장 목록 조회 |
|
45 |
- @PostMapping("/findByBookId.json") |
|
46 |
- public HashMap<String, Object> getWordBooksByBookId(@RequestBody HashMap<String, Object> params) throws Exception { |
|
47 |
- String bookId = (String) params.get("bookId"); |
|
44 |
+ // 단원별 단어장 목록 조회 |
|
45 |
+ @PostMapping("/findByUnitId.json") |
|
46 |
+ public HashMap<String, Object> getWordBooksByUnitId(@RequestBody HashMap<String, Object> params) throws Exception { |
|
47 |
+ String unitId = (String) params.get("unitId"); |
|
48 | 48 |
int page = (int) params.get("page"); |
49 | 49 |
int pageSize = (int) params.get("pageSize"); |
50 | 50 |
|
51 |
- List<WordBookVO> wordBooks = wordBookService.getWordBooksByBookId(bookId, page, pageSize); |
|
52 |
- int totalWordBooks = wordBookService.getWordBooksByBookIdCount(bookId); |
|
51 |
+ List<WordBookVO> wordBooks = wordBookService.getWordBooksByUnitId(unitId, page, pageSize); |
|
52 |
+ int totalWordBooks = wordBookService.getWordBooksByUnitIdCount(unitId); |
|
53 | 53 |
|
54 | 54 |
HashMap<String, Object> result = new HashMap<>(); |
55 | 55 |
result.put("wordBooks", wordBooks); |
... | ... | @@ -90,12 +90,13 @@ |
90 | 90 |
// 단어장 검색(지문 이름으로 검색) |
91 | 91 |
@PostMapping("/findByTextTitle.json") |
92 | 92 |
public HashMap<String, Object> getWordBooksByTextTitle(@RequestBody HashMap<String, Object> params) throws Exception { |
93 |
+ String unitId = (String) params.get("unitId"); |
|
93 | 94 |
String textTitle = (String) params.get("textTitle"); |
94 | 95 |
int page = (int) params.get("page"); |
95 | 96 |
int pageSize = (int) params.get("pageSize"); |
96 | 97 |
|
97 |
- List<WordBookVO> wordBooks = wordBookService.getWordBooksByTextTitle(textTitle, page, pageSize); |
|
98 |
- int totalWordBooks = wordBookService.getWordBooksByTextTitleCount(textTitle); |
|
98 |
+ List<WordBookVO> wordBooks = wordBookService.getWordBooksByTextTitle(unitId, textTitle, page, pageSize); |
|
99 |
+ int totalWordBooks = wordBookService.getWordBooksByTextTitleCount(unitId, textTitle); |
|
99 | 100 |
|
100 | 101 |
HashMap<String, Object> result = new HashMap<>(); |
101 | 102 |
result.put("wordBooks", wordBooks); |
... | ... | @@ -107,12 +108,13 @@ |
107 | 108 |
// 단어장 검색(단어로 검색) |
108 | 109 |
@PostMapping("/findByWord.json") |
109 | 110 |
public HashMap<String, Object> getWordBooksByWord(@RequestBody HashMap<String, Object> params) throws Exception { |
111 |
+ String unitId = (String) params.get("unitId"); |
|
110 | 112 |
String word = (String) params.get("word"); |
111 | 113 |
int page = (int) params.get("page"); |
112 | 114 |
int pageSize = (int) params.get("pageSize"); |
113 | 115 |
|
114 |
- List<WordBookVO> wordBooks = wordBookService.getWordBooksByWord(word, page, pageSize); |
|
115 |
- int totalWordBooks = wordBookService.getWordBooksByWordCount(word); |
|
116 |
+ List<WordBookVO> wordBooks = wordBookService.getWordBooksByWord(unitId, word, page, pageSize); |
|
117 |
+ int totalWordBooks = wordBookService.getWordBooksByWordCount(unitId, word); |
|
116 | 118 |
|
117 | 119 |
HashMap<String, Object> result = new HashMap<>(); |
118 | 120 |
result.put("wordBooks", wordBooks); |
--- src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/word_book-SQL.xml
... | ... | @@ -13,7 +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 |
+ <result property="unitId" column="unit_id"/> |
|
17 | 17 |
</resultMap> |
18 | 18 |
|
19 | 19 |
<select id="getWordBooksCount" resultType="int"> |
... | ... | @@ -21,10 +21,10 @@ |
21 | 21 |
FROM ai_lms.wordbook |
22 | 22 |
</select> |
23 | 23 |
|
24 |
- <select id="getWordBooksByBookIdCount" resultType="int"> |
|
24 |
+ <select id="getWordBooksByUnitIdCount" resultType="int"> |
|
25 | 25 |
SELECT COUNT(*) |
26 | 26 |
FROM wordbook |
27 |
- WHERE book_id = #{bookId} |
|
27 |
+ WHERE unit_id = #{unitId} |
|
28 | 28 |
</select> |
29 | 29 |
|
30 | 30 |
<select id="getWordBooksByTextTitleCount" resultType="int"> |
... | ... | @@ -47,21 +47,23 @@ |
47 | 47 |
wd_book_type_id, |
48 | 48 |
text_id, |
49 | 49 |
user_id, |
50 |
- book_id |
|
50 |
+ book_id, |
|
51 |
+ unit_id |
|
51 | 52 |
FROM ai_lms.wordbook |
52 | 53 |
ORDER BY wd_book_id DESC |
53 | 54 |
LIMIT #{pageSize} OFFSET #{startIndex} |
54 | 55 |
</select> |
55 | 56 |
|
56 |
- <select id="getWordBooksByBookId" resultMap="WordBookResultMap"> |
|
57 |
+ <select id="getWordBooksByUnitId" resultMap="WordBookResultMap"> |
|
57 | 58 |
SELECT |
58 | 59 |
wd_book_id, |
59 | 60 |
wd_book_type_id, |
60 | 61 |
text_id, |
61 | 62 |
user_id, |
62 |
- book_id |
|
63 |
+ book_id, |
|
64 |
+ unit_id |
|
63 | 65 |
FROM wordbook |
64 |
- WHERE book_id = #{bookId} |
|
66 |
+ WHERE unit_id = #{unitId} |
|
65 | 67 |
ORDER BY wd_book_id DESC |
66 | 68 |
LIMIT #{pageSize} OFFSET #{startIndex} |
67 | 69 |
</select> |
... | ... | @@ -72,7 +74,8 @@ |
72 | 74 |
wd_book_type_id, |
73 | 75 |
text_id, |
74 | 76 |
user_id, |
75 |
- book_id |
|
77 |
+ book_id, |
|
78 |
+ unit_id |
|
76 | 79 |
FROM ai_lms.wordbook |
77 | 80 |
WHERE wd_book_id = #{wdBookId} |
78 | 81 |
</select> |
... | ... | @@ -83,12 +86,14 @@ |
83 | 86 |
wd_book_type_id, |
84 | 87 |
text_id, |
85 | 88 |
user_id, |
86 |
- book_id) |
|
89 |
+ book_id, |
|
90 |
+ unit_id) |
|
87 | 91 |
VALUES (#{wdBookId}, |
88 | 92 |
#{wdBookTypeId}, |
89 | 93 |
#{textId}, |
90 | 94 |
#{userId}, |
91 |
- #{bookId}) |
|
95 |
+ #{bookId}, |
|
96 |
+ #{unitId}) |
|
92 | 97 |
</insert> |
93 | 98 |
|
94 | 99 |
<update id="updateWordBook" parameterType="WordBookVO"> |
... | ... | @@ -96,7 +101,8 @@ |
96 | 101 |
SET wd_book_type_id = #{wdBookTypeId}, |
97 | 102 |
text_id = #{textId}, |
98 | 103 |
user_id = #{userId}, |
99 |
- book_id = #{bookId} |
|
104 |
+ book_id = #{bookId}, |
|
105 |
+ unit_id = #{unitId} |
|
100 | 106 |
WHERE wd_book_id = #{wdBookId} |
101 | 107 |
</update> |
102 | 108 |
|
... | ... | @@ -109,7 +115,8 @@ |
109 | 115 |
SELECT wb.* |
110 | 116 |
FROM wordbook wb |
111 | 117 |
JOIN text t ON wb.text_id = t.text_id |
112 |
- WHERE t.text_ttl LIKE #{textTitle} |
|
118 |
+ WHERE wb.unit_id = #{unitId} |
|
119 |
+ AND t.text_ttl LIKE #{textTitle} |
|
113 | 120 |
ORDER BY wd_book_id DESC |
114 | 121 |
LIMIT #{pageSize} OFFSET #{startIndex} |
115 | 122 |
</select> |
... | ... | @@ -118,7 +125,8 @@ |
118 | 125 |
SELECT DISTINCT wb.* |
119 | 126 |
FROM wordbook wb |
120 | 127 |
JOIN word w ON wb.wd_book_id = w.wd_book_id |
121 |
- WHERE w.wd_nm LIKE #{word} |
|
128 |
+ WHERE wb.unit_id = #{unitId} |
|
129 |
+ AND w.wd_nm LIKE #{word} |
|
122 | 130 |
ORDER BY wd_book_id DESC |
123 | 131 |
LIMIT #{pageSize} OFFSET #{startIndex} |
124 | 132 |
</select> |
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?