Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
practical_train
Commits
f11e9683
Commit
f11e9683
authored
Sep 20, 2026
by
wujipeng
Browse files
优化
parent
46eeeaaa
Changes
2
Hide whitespace changes
Inline
Side-by-side
practical-business/src/main/resources/com/platform/business/mapper/ExamStudentMapper.xml
View file @
f11e9683
...
@@ -108,8 +108,13 @@
...
@@ -108,8 +108,13 @@
left join user u on es.student_id = u.id
left join user u on es.student_id = u.id
left join class c on e.class_id = c.id
left join class c on e.class_id = c.id
where u.id = #{studentId}
where u.id = #{studentId}
order by es.start_time desc
<!--
limit 1
“最近考试”应以考试安排时间为准。考生尚未进入考试时,exam_student.start_time
通常为NULL,按该字段排序会退化为不确定顺序,并经常返回最早创建的记录。
exam.id用于考试时间相同时提供稳定的倒序结果。
-->
order by e.exam_time desc, e.id desc
limit 1
</select>
</select>
<select
id=
"theSameEvent"
resultType=
"com.platform.business.model.vo.ExamStudentVO"
>
<select
id=
"theSameEvent"
resultType=
"com.platform.business.model.vo.ExamStudentVO"
>
select es.student_id as studentId, u.nick_name as studentName
select es.student_id as studentId, u.nick_name as studentName
...
...
practical-business/src/test/java/com/platform/business/mapper/ExamStudentMapperXmlTest.java
View file @
f11e9683
...
@@ -72,5 +72,12 @@ class ExamStudentMapperXmlTest {
...
@@ -72,5 +72,12 @@ class ExamStudentMapperXmlTest {
assertTrue
(
sql
.
contains
(
"e.type"
));
assertTrue
(
sql
.
contains
(
"e.type"
));
assertFalse
(
sql
.
contains
(
"es.start_time as starttime"
));
assertFalse
(
sql
.
contains
(
"es.start_time as starttime"
));
assertFalse
(
sql
.
contains
(
"e.type = '实训考试'"
));
assertFalse
(
sql
.
contains
(
"e.type = '实训考试'"
));
/*
* 未开考时exam_student.start_time通常为NULL,不能用它判定“最近”。
* 按考试计划时间倒序取第一条,并在时间相同时用考试ID保证结果稳定。
*/
assertTrue
(
sql
.
contains
(
"order by e.exam_time desc, e.id desc limit 1"
));
assertFalse
(
sql
.
contains
(
"order by es.start_time"
));
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment