woals
07-26
240726 권민수 학생 정보 조회 api에 제일 최근 학습 3개까지 조회하는 기능 추가
@6614e06068a0dcb7acceeaeb725a580a84242deb
--- src/main/java/com/takensoft/ai_lms/lms/student/dao/StudentInfoDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/student/dao/StudentInfoDAO.java
... | ... | @@ -4,6 +4,8 @@ |
4 | 4 |
import org.apache.ibatis.annotations.Param; |
5 | 5 |
import org.egovframe.rte.psl.dataaccess.mapper.Mapper; |
6 | 6 |
|
7 |
+import java.util.List; |
|
8 |
+ |
|
7 | 9 |
/** |
8 | 10 |
* @author 권민수 |
9 | 11 |
* @since 2024.07.25 |
--- src/main/java/com/takensoft/ai_lms/lms/student/service/Impl/StudentInfoServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/student/service/Impl/StudentInfoServiceImpl.java
... | ... | @@ -6,6 +6,8 @@ |
6 | 6 |
import lombok.RequiredArgsConstructor; |
7 | 7 |
import org.springframework.stereotype.Service; |
8 | 8 |
|
9 |
+import java.util.List; |
|
10 |
+ |
|
9 | 11 |
/** |
10 | 12 |
* @author 권민수 |
11 | 13 |
* @since 2024.07.25 |
... | ... | @@ -21,6 +23,8 @@ |
21 | 23 |
|
22 | 24 |
@Override |
23 | 25 |
public StudentInfoVO getStudentInfo(String userId) { |
26 |
+// List<StudentInfoVO> studentInfos = studentInfoDAO.getStudentInfo(userId); |
|
27 |
+// return studentInfos.isEmpty() ? null : studentInfos.get(0); |
|
24 | 28 |
return studentInfoDAO.getStudentInfo(userId); |
25 | 29 |
} |
26 | 30 |
|
+++ src/main/java/com/takensoft/ai_lms/lms/student/vo/HistoryVO.java
... | ... | @@ -0,0 +1,23 @@ |
1 | +package com.takensoft.ai_lms.lms.student.vo; | |
2 | + | |
3 | +import lombok.Getter; | |
4 | +import lombok.Setter; | |
5 | + | |
6 | +import java.sql.Timestamp; | |
7 | + | |
8 | +/** | |
9 | + * @author 권민수 | |
10 | + * @since 2024.07.26 | |
11 | + * | |
12 | + * 학생 최근 학습 정보 VO 클래스 | |
13 | + */ | |
14 | + | |
15 | +@Getter | |
16 | +@Setter | |
17 | +public class HistoryVO { | |
18 | + | |
19 | + private String bookName; | |
20 | + private String unitName; | |
21 | + private Timestamp completionTime; | |
22 | + | |
23 | +} |
--- src/main/java/com/takensoft/ai_lms/lms/student/vo/StudentInfoVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/student/vo/StudentInfoVO.java
... | ... | @@ -3,6 +3,8 @@ |
3 | 3 |
import lombok.Getter; |
4 | 4 |
import lombok.Setter; |
5 | 5 |
|
6 |
+import java.util.List; |
|
7 |
+ |
|
6 | 8 |
/** |
7 | 9 |
* @author 권민수 |
8 | 10 |
* @since 2024.07.25 |
... | ... | @@ -13,11 +15,13 @@ |
13 | 15 |
@Setter |
14 | 16 |
@Getter |
15 | 17 |
public class StudentInfoVO { |
18 |
+ |
|
16 | 19 |
private String studentName; |
17 | 20 |
private String institutionName; |
18 |
- private String grade; |
|
21 |
+ private int grade; |
|
19 | 22 |
private String className; |
20 | 23 |
private String studentQuestion; |
24 |
+ private List<HistoryVO> history; |
|
21 | 25 |
|
22 | 26 |
} |
23 | 27 |
|
--- src/main/resources/mybatis/mapper/lms/student-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/student-SQL.xml
... | ... | @@ -14,19 +14,40 @@ |
14 | 14 |
<result property="grade" column="grade"/> |
15 | 15 |
<result property="className" column="className"/> |
16 | 16 |
<result property="studentQuestion" column="studentQuestion"/> |
17 |
+ <collection property="history" ofType="com.takensoft.ai_lms.lms.student.vo.HistoryVO"> |
|
18 |
+ <result property="bookName" column="bookName"/> |
|
19 |
+ <result property="unitName" column="unitName"/> |
|
20 |
+ <result property="completionTime" column="completionTime"/> |
|
21 |
+ </collection> |
|
17 | 22 |
</resultMap> |
18 | 23 |
|
19 |
- <select id="getStudentInfo" resultType="com.takensoft.ai_lms.lms.student.vo.StudentInfoVO"> |
|
24 |
+ <select id="getStudentInfo" resultMap="StudentInfoResultMap"> |
|
20 | 25 |
SELECT |
21 | 26 |
u.user_nm AS studentName, |
22 | 27 |
i.ednst_nm AS institutionName, |
23 | 28 |
ui.grd_no AS grade, |
24 | 29 |
ui.scls_nm AS className, |
25 |
- uc.stn_qna AS studentQuestion |
|
30 |
+ uc.stn_qna AS studentQuestion, |
|
31 |
+ hu.book_nm AS bookName, |
|
32 |
+ hu.unit_nm AS unitName, |
|
33 |
+ hu.cmptn_tm AS completionTime |
|
26 | 34 |
FROM users u |
27 | 35 |
JOIN user_institution ui ON u.user_id = ui.user_id |
28 | 36 |
JOIN institution i ON ui.ednst_id = i.ednst_id |
29 | 37 |
JOIN user_class uc ON u.user_id = uc.user_id |
38 |
+ LEFT JOIN ( |
|
39 |
+ SELECT |
|
40 |
+ uu.user_id, |
|
41 |
+ b.book_nm, |
|
42 |
+ un.unit_nm, |
|
43 |
+ uu.cmptn_tm |
|
44 |
+ FROM user_unit uu |
|
45 |
+ JOIN unit un ON uu.unit_id = un.unit_id |
|
46 |
+ JOIN book b ON un.book_id = b.book_id |
|
47 |
+ WHERE uu.user_id = #{userId} |
|
48 |
+ ORDER BY uu.cmptn_tm DESC |
|
49 |
+ LIMIT 3 |
|
50 |
+ ) hu ON u.user_id = hu.user_id |
|
30 | 51 |
WHERE u.user_id = #{userId} |
31 | 52 |
</select> |
32 | 53 |
|
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?