PsHooN7979
07-29
240726 박세훈 반에 등록 된 교재 조회기능 추가
@81e774ea4de33822c75de9eab28f841a85454194
--- 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
... | ... | @@ -4,9 +4,12 @@ |
4 | 4 |
import com.takensoft.ai_lms.lms.class_book.vo.ClassBookVO; |
5 | 5 |
import org.egovframe.rte.psl.dataaccess.mapper.Mapper; |
6 | 6 |
|
7 |
+import java.util.HashMap; |
|
8 |
+import java.util.List; |
|
9 |
+ |
|
7 | 10 |
/** |
8 | 11 |
* @author : 박세훈 |
9 |
- * since : 2024.07.20 |
|
12 |
+ * since : 2024.07.29 |
|
10 | 13 |
* |
11 | 14 |
* class - book관련 Mapper |
12 | 15 |
*/ |
... | ... | @@ -14,9 +17,12 @@ |
14 | 17 |
@Mapper("classBookDAO") |
15 | 18 |
public interface ClassBookDAO { |
16 | 19 |
|
17 |
- // 책 등록 |
|
20 |
+ // 교재 등록 |
|
18 | 21 |
int registerBook(ClassBookVO classBookVO) throws Exception; |
19 | 22 |
|
20 |
- // 책 삭제 |
|
23 |
+ // 교재 삭제 |
|
21 | 24 |
int deleteClassBook(ClassBookVO classBookVO) throws Exception; |
25 |
+ |
|
26 |
+ // 교재 조회 |
|
27 |
+ List<HashMap<String, Object>> findByBookId(HashMap<String, Object> params) throws Exception; |
|
22 | 28 |
} |
--- 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
... | ... | @@ -2,19 +2,25 @@ |
2 | 2 |
|
3 | 3 |
import com.takensoft.ai_lms.lms.class_book.vo.ClassBookVO; |
4 | 4 |
|
5 |
+import java.util.HashMap; |
|
6 |
+import java.util.List; |
|
7 |
+ |
|
5 | 8 |
|
6 | 9 |
/** |
7 | 10 |
* @author : 박세훈 |
8 |
- * since : 2024.07.20 |
|
11 |
+ * since : 2024.07.29 |
|
9 | 12 |
* |
10 | 13 |
* class - book관련 Service |
11 | 14 |
*/ |
12 | 15 |
|
13 | 16 |
public interface ClassBookService { |
14 | 17 |
|
15 |
- // 책 등록 |
|
18 |
+ // 교재 등록 |
|
16 | 19 |
int registerBook(ClassBookVO classBookVO) throws Exception; |
17 | 20 |
|
18 |
- // 책 삭제 |
|
21 |
+ // 교재 삭제 |
|
19 | 22 |
int deleteClassBook(ClassBookVO classBookVO) throws Exception; |
23 |
+ |
|
24 |
+ // 교재 조회 |
|
25 |
+ List<HashMap<String, Object>> findByBookId(HashMap<String, Object> params) throws Exception; |
|
20 | 26 |
} |
--- 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
... | ... | @@ -8,10 +8,13 @@ |
8 | 8 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
9 | 9 |
import org.springframework.stereotype.Service; |
10 | 10 |
|
11 |
+import java.util.HashMap; |
|
12 |
+import java.util.List; |
|
13 |
+ |
|
11 | 14 |
|
12 | 15 |
/** |
13 | 16 |
* @author : 박세훈 |
14 |
- * since : 2024.07.20 |
|
17 |
+ * since : 2024.07.29 |
|
15 | 18 |
* |
16 | 19 |
* class - book관련 ServiceImpl |
17 | 20 |
*/ |
... | ... | @@ -21,12 +24,21 @@ |
21 | 24 |
|
22 | 25 |
private final ClassBookDAO classBookDAO; |
23 | 26 |
|
27 |
+ // 교재 등록 |
|
24 | 28 |
@Override |
25 | 29 |
public int registerBook(ClassBookVO classBookVO) throws Exception { |
26 | 30 |
return classBookDAO.registerBook(classBookVO); |
27 | 31 |
} |
32 |
+ |
|
33 |
+ // 교재 삭제 |
|
28 | 34 |
@Override |
29 | 35 |
public int deleteClassBook(ClassBookVO classBookVO) throws Exception { |
30 | 36 |
return classBookDAO.deleteClassBook(classBookVO); |
31 | 37 |
} |
38 |
+ |
|
39 |
+ // 등록된 교재 조회 |
|
40 |
+ @Override |
|
41 |
+ public List<HashMap<String, Object>> findByBookId(HashMap<String, Object> params) throws Exception { |
|
42 |
+ return classBookDAO.findByBookId(params); |
|
43 |
+ } |
|
32 | 44 |
} |
--- src/main/java/com/takensoft/ai_lms/lms/class_book/vo/ClassBookVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/class_book/vo/ClassBookVO.java
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 |
// 반 아이디 |
15 | 15 |
private String sclsId; |
16 | 16 |
|
17 |
- // 책 아이디 |
|
17 |
+ // 교재 아이디 |
|
18 | 18 |
private String bookId; |
19 | 19 |
|
20 | 20 |
} |
--- 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
... | ... | @@ -3,6 +3,8 @@ |
3 | 3 |
import com.takensoft.ai_lms.lms.class_book.service.ClassBookService; |
4 | 4 |
import com.takensoft.ai_lms.lms.class_book.vo.ClassBookVO; |
5 | 5 |
import lombok.RequiredArgsConstructor; |
6 |
+import org.springframework.http.HttpStatus; |
|
7 |
+import org.springframework.http.ResponseEntity; |
|
6 | 8 |
import org.springframework.web.bind.annotation.*; |
7 | 9 |
|
8 | 10 |
import java.util.HashMap; |
... | ... | @@ -21,7 +23,7 @@ |
21 | 23 |
* @return |
22 | 24 |
* @throws Exception |
23 | 25 |
* |
24 |
- * 반 책 등록 |
|
26 |
+ * 반 교재 등록 |
|
25 | 27 |
*/ |
26 | 28 |
@PostMapping("/register.json") |
27 | 29 |
public String registerBook(@RequestBody ClassBookVO classBookVO) throws Exception { |
... | ... | @@ -46,7 +48,26 @@ |
46 | 48 |
* @return |
47 | 49 |
* @throws Exception |
48 | 50 |
* |
49 |
- * 반 책 삭제 |
|
51 |
+ * 반에 등록된 교재 조회 |
|
52 |
+ */ |
|
53 |
+ @PostMapping("/findAll.json") |
|
54 |
+ public ResponseEntity<?> findByBookId(@RequestBody HashMap<String, Object> params) throws Exception { |
|
55 |
+ HashMap<String, Object> result = new HashMap<>(); |
|
56 |
+ |
|
57 |
+ result.put("list", classBookService.findByBookId(params)); |
|
58 |
+ |
|
59 |
+ return new ResponseEntity<>(result, HttpStatus.OK); |
|
60 |
+ } |
|
61 |
+ |
|
62 |
+ |
|
63 |
+ /** |
|
64 |
+ * @author 박세훈 |
|
65 |
+ * @since 2024.07.29 |
|
66 |
+ * param ClassBookDAO |
|
67 |
+ * @return |
|
68 |
+ * @throws Exception |
|
69 |
+ * |
|
70 |
+ * 반 교재 삭제 |
|
50 | 71 |
*/ |
51 | 72 |
@DeleteMapping("/deleteClassBook.json") |
52 | 73 |
public String deleteClassBook(@RequestBody ClassBookVO classBookVO) throws Exception { |
--- src/main/resources/mybatis/mapper/lms/class_book-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/class_book-SQL.xml
... | ... | @@ -3,15 +3,13 @@ |
3 | 3 |
<mapper namespace="com.takensoft.ai_lms.lms.class_book.dao.ClassBookDAO"> |
4 | 4 |
|
5 | 5 |
|
6 |
- <resultMap id="classBookMap" type="ClassBookVO" > |
|
7 |
- <result property="sclsId" column="scls_id"/> |
|
8 |
- <result property="sclsNm" column="scls_nm"/> |
|
9 |
- </resultMap> |
|
6 |
+ |
|
7 |
+ |
|
10 | 8 |
|
11 | 9 |
<!-- |
12 | 10 |
작성자 : 박세훈 |
13 | 11 |
작성일 : 2024.07.26 |
14 |
- 내 용 : 반에 책 등록 |
|
12 |
+ 내 용 : 반에 교재 등록 |
|
15 | 13 |
--> |
16 | 14 |
<insert id="registerBook" parameterType="String" > |
17 | 15 |
INSERT INTO class_book( book_id, |
... | ... | @@ -21,16 +19,32 @@ |
21 | 19 |
); |
22 | 20 |
</insert> |
23 | 21 |
|
22 |
+ |
|
24 | 23 |
<!-- |
25 | 24 |
작성자 : 박세훈 |
26 | 25 |
작성일 : 2024.07.26 |
27 |
- 내 용 : 반에 등록 된 책 삭제 |
|
26 |
+ 내 용 : 반에 등록 된 교재 삭제 |
|
28 | 27 |
--> |
29 | 28 |
<delete id="deleteClassBook" parameterType="String"> |
30 | 29 |
DELETE FROM class_book |
31 | 30 |
WHERE |
32 |
- book_id = #{bookId} AND |
|
31 |
+ book_id = #{bookId} AND |
|
33 | 32 |
scls_id = #{sclsId} |
34 | 33 |
</delete> |
35 | 34 |
|
35 |
+ |
|
36 |
+ <!-- |
|
37 |
+ 작성자 : 박세훈 |
|
38 |
+ 작성일 : 2024.07.29 |
|
39 |
+ 내 용 : 반에 등록 된 교재 조회 |
|
40 |
+ --> |
|
41 |
+ |
|
42 |
+ <select id="findByBookId" parameterType="String"> |
|
43 |
+ SELECT b.book_id, b.book_nm |
|
44 |
+ FROM book b |
|
45 |
+ JOIN class_book cb ON b.book_id = cb.book_id |
|
46 |
+ JOIN class c ON cb.scls_id = c.scls_id |
|
47 |
+ WHERE c.scls_id = #{sclsId}; |
|
48 |
+ </select> |
|
49 |
+ |
|
36 | 50 |
</mapper>(파일 끝에 줄바꿈 문자 없음) |
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?