
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
2024-07-31
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.takensoft.ai_lms.lms.student.dao.StudentInfoDAO">
<!--
작 성 자 : 권민수
작 성 일 : 2024.07.25
내 용 : 학생 정보 관련 sql 매핑 xml 문서
-->
<resultMap id="StudentInfoResultMap" type="com.takensoft.ai_lms.lms.student.vo.StudentInfoVO">
<result property="studentName" column="studentName"/>
<result property="institutionName" column="institutionName"/>
<result property="grade" column="grade"/>
<result property="className" column="className"/>
<result property="totalProblemsSolved" column="totalProblemsSolved"/>
<result property="studentQuestion" column="studentQuestion"/>
<collection property="history" ofType="com.takensoft.ai_lms.lms.student.vo.HistoryVO">
<result property="bookName" column="bookName"/>
<result property="bookId" column="bookId"/>
<result property="unitName" column="unitName"/>
<result property="unitId" column="unitId"/>
<result property="completionTime" column="completionTime"/>
</collection>
</resultMap>
<select id="getStudentInfo" resultMap="StudentInfoResultMap">
SELECT
u.user_nm AS studentName,
i.ednst_nm AS institutionName,
ui.grd_no AS grade,
ui.scls_nm AS className,
(SELECT COUNT(*) FROM problem_log pl WHERE pl.std_id = u.user_id) AS totalProblemsSolved,
uc.stn_qna AS studentQuestion,
hu.book_id AS bookId,
hu.book_nm AS bookName,
hu.unit_id AS unitId,
hu.unit_nm AS unitName,
hu.cmptn_tm AS completionTime
FROM users u
JOIN user_institution ui ON u.user_id = ui.user_id
JOIN institution i ON ui.ednst_id = i.ednst_id
JOIN user_class uc ON u.user_id = uc.user_id
LEFT JOIN (
SELECT
uu.user_id,
b.book_id,
b.book_nm,
un.unit_id,
un.unit_nm,
uu.cmptn_tm
FROM user_unit uu
JOIN unit un ON uu.unit_id = un.unit_id
JOIN book b ON un.book_id = b.book_id
WHERE uu.user_id = #{userId}
ORDER BY uu.cmptn_tm DESC
LIMIT 3
) hu ON u.user_id = hu.user_id
WHERE u.user_id = #{userId}
</select>
<update id="updateStudentQuestion">
UPDATE user_class
SET stn_qna = #{studentQuestion}
WHERE user_id = #{userId}
</update>
</mapper>