feat(system): 新增学生心理评级查询功能
- 添加了 StudentMentalRatingVo 类用于查询结果封装 - 在 StudentMentalRatingMapper 中新增了两个查询方法: - selectLatestByTeacherIdWithConditions:查询辅导员负责的每个学生的最新心理评级记录 - selectLatestAllWithConditions:查询所有学生的最新心理评级记录 - 更新了 WeChatMentalAlertController,添加了新的查询接口 - 优化了查询逻辑,支持条件查询和分页功能
This commit is contained in:
@@ -21,25 +21,76 @@
|
||||
WHERE student_id = #{studentId}
|
||||
</update>
|
||||
|
||||
<!-- 心理查询全部:知无涯 -->
|
||||
<select id="selectAll" resultType="com.srs.system.domain.StudentMentalRating">
|
||||
SELECT id,
|
||||
student_id AS studentId,
|
||||
rating,
|
||||
created_time AS createdTime,
|
||||
updated_time AS updatedTime
|
||||
|
||||
<!-- 查询辅导员负责的每个学生的最新心理评级记录(带条件查询) -->
|
||||
<select id="selectLatestByTeacherIdWithConditions" resultType="com.srs.system.domain.vo.StudentMentalRatingVo">
|
||||
SELECT
|
||||
a.stu_no,
|
||||
a.stu_name,
|
||||
a.class_name,
|
||||
smr.rating,
|
||||
smr.created_time
|
||||
FROM view_stu_info a
|
||||
LEFT JOIN student_mental_rating smr ON a.stu_no = smr.student_id
|
||||
INNER JOIN (
|
||||
SELECT student_id, MAX(created_time) as max_time
|
||||
FROM student_mental_rating
|
||||
ORDER BY created_time DESC
|
||||
WHERE rating IS NOT NULL
|
||||
GROUP BY student_id
|
||||
) latest ON smr.student_id = latest.student_id AND smr.created_time = latest.max_time
|
||||
WHERE a.t_no = #{teacherId}
|
||||
AND smr.rating IS NOT NULL
|
||||
AND smr.student_id IS NOT NULL
|
||||
<if test="stuNo != null and stuNo != ''">
|
||||
AND a.stu_no = #{stuNo}
|
||||
</if>
|
||||
<if test="stuName != null and stuName != ''">
|
||||
AND a.stu_name LIKE CONCAT('%', #{stuName}, '%')
|
||||
</if>
|
||||
ORDER BY smr.created_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据学号查询心理:知无涯 -->
|
||||
<select id="selectByStuNo" resultType="com.srs.system.domain.StudentMentalRating">
|
||||
SELECT id,
|
||||
student_id AS studentId,
|
||||
rating,
|
||||
created_time AS createdTime,
|
||||
updated_time AS updatedTime
|
||||
<!-- 查询所有学生的最新心理评级记录(带条件查询) -->
|
||||
<select id="selectLatestAllWithConditions" resultType="com.srs.system.domain.vo.StudentMentalRatingVo">
|
||||
SELECT
|
||||
a.stu_no,
|
||||
a.stu_name,
|
||||
a.class_name,
|
||||
smr.rating,
|
||||
smr.created_time
|
||||
FROM view_stu_info a
|
||||
LEFT JOIN student_mental_rating smr ON a.stu_no = smr.student_id
|
||||
INNER JOIN (
|
||||
SELECT student_id, MAX(created_time) as max_time
|
||||
FROM student_mental_rating
|
||||
WHERE rating IS NOT NULL
|
||||
GROUP BY student_id
|
||||
) latest ON smr.student_id = latest.student_id AND smr.created_time = latest.max_time
|
||||
WHERE smr.rating IS NOT NULL
|
||||
AND smr.student_id IS NOT NULL
|
||||
<if test="stuNo != null and stuNo != ''">
|
||||
AND a.stu_no = #{stuNo}
|
||||
</if>
|
||||
<if test="stuName != null and stuName != ''">
|
||||
AND a.stu_name LIKE CONCAT('%', #{stuName}, '%')
|
||||
</if>
|
||||
ORDER BY smr.created_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 根据学号查询心理:知无涯 -->
|
||||
<select id="selectByStuNo" parameterType="string" resultType="com.srs.system.domain.vo.StudentMentalRatingVo">
|
||||
SELECT
|
||||
a.stu_no,
|
||||
a.stu_name,
|
||||
a.class_name,
|
||||
smr.rating,
|
||||
smr.created_time
|
||||
FROM view_stu_info a
|
||||
LEFT JOIN student_mental_rating smr ON a.stu_no = smr.student_id
|
||||
WHERE student_id = #{stuNo}
|
||||
ORDER BY created_time DESC
|
||||
</select>
|
||||
|
Reference in New Issue
Block a user