dajeong
08-07
240807 정다정 class 조회: 반 별 학생수 추가
@77051a156cfe57dd33e1d1b8e28e2b51f68a6a27
--- src/main/java/com/takensoft/ai_lms/lms/classes/vo/ClassVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/classes/vo/ClassVO.java
... | ... | @@ -17,4 +17,6 @@ |
17 | 17 |
public String userId; |
18 | 18 |
// 반 이름 |
19 | 19 |
public String sclsNm; |
20 |
+ // 반 총 인원 |
|
21 |
+ public int studentCount; |
|
20 | 22 |
} |
--- src/main/resources/mybatis/mapper/lms/classes-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/classes-SQL.xml
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 |
<result property="userId" column="user_id"/> |
8 | 8 |
<result property="sclsNm" column="scls_nm"/> |
9 | 9 |
<result property="useAt" column="use_at"/> |
10 |
+ <result property="studentCount" column="student_count"/> |
|
10 | 11 |
</resultMap> |
11 | 12 |
|
12 | 13 |
<!-- |
... | ... | @@ -15,14 +16,17 @@ |
15 | 16 |
내 용 : 반 조회 |
16 | 17 |
--> |
17 | 18 |
<select id="selectClass" parameterType="String" resultMap="classMap"> |
18 |
- SELECT scls_id |
|
19 |
- , user_id |
|
20 |
- , scls_nm |
|
21 |
- FROM |
|
22 |
- class |
|
23 |
- WHERE |
|
24 |
- user_id = #{userId} |
|
25 |
- AND use_at = 'Y' |
|
19 |
+ SELECT c.scls_id |
|
20 |
+ , c.user_id |
|
21 |
+ , c.scls_nm |
|
22 |
+ , COUNT(uc.std_id) AS student_count |
|
23 |
+ FROM class c |
|
24 |
+ LEFT JOIN user_class uc ON c.scls_id = uc.scls_id |
|
25 |
+ WHERE c.user_id = #{userId} AND c.use_at = 'Y' |
|
26 |
+ GROUP BY c.scls_id |
|
27 |
+ , c.user_id |
|
28 |
+ , c.scls_nm |
|
29 |
+ ORDER BY c.scls_id ASC; |
|
26 | 30 |
</select> |
27 | 31 |
|
28 | 32 |
<!-- |
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?