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
2c66995a
Commit
2c66995a
authored
Sep 10, 2026
by
王蔡翾
Browse files
bug修复
parent
a8e84103
Changes
48
Hide whitespace changes
Inline
Side-by-side
practical-business/src/main/java/com/platform/business/service/impl/TheoreticalPaperAdminServiceImpl.java
View file @
2c66995a
...
...
@@ -652,11 +652,15 @@ public class TheoreticalPaperAdminServiceImpl implements TheoreticalPaperAdminSe
return
TheoreticalPaperAdminConstants
.
SEQUENCE_ORDERED
;
}
String
normalized
=
sequence
.
trim
();
if
(!
TheoreticalPaperAdminConstants
.
SEQUENCE_ORDERED
.
equals
(
normalized
)
&&
!
TheoreticalPaperAdminConstants
.
SEQUENCE_RANDOM
.
equals
(
normalized
))
{
throw
new
BusinessException
(
"试题顺序只支持顺序或乱序"
);
if
(
TheoreticalPaperAdminConstants
.
SEQUENCE_ORDERED
.
equals
(
normalized
)
||
TheoreticalPaperAdminConstants
.
LEGACY_SEQUENCE_RANDOM
.
equals
(
normalized
))
{
/*
* “乱序”是旧版的答题阶段随机标记。当前业务只在自动组卷时随机抽题,试卷
* 形成后顺序固定,因此兼容旧请求但统一落库为“顺序”。
*/
return
TheoreticalPaperAdminConstants
.
SEQUENCE_ORDERED
;
}
return
normalized
;
throw
new
BusinessException
(
"试卷生成后仅支持固定顺序"
)
;
}
private
String
normalizeCreateStatus
(
String
status
)
{
...
...
practical-business/src/main/java/com/platform/business/service/impl/TheoreticalPaperDetailServiceImpl.java
View file @
2c66995a
...
...
@@ -17,7 +17,7 @@ import java.util.List;
@Service
public
class
TheoreticalPaperDetailServiceImpl
extends
ServiceImpl
<
TheoreticalPaperDetailMapper
,
TheoreticalPaperDetailEntity
>
implements
TheoreticalPaperDetailService
{
@Override
public
List
<
TheoreticalPaperDetailEntity
>
select
Diso
rder
ly
(
String
paperId
)
{
return
baseMapper
.
select
Diso
rder
ly
(
paperId
);
public
List
<
TheoreticalPaperDetailEntity
>
select
InPaperO
rder
(
String
paperId
)
{
return
baseMapper
.
select
InPaperO
rder
(
paperId
);
}
}
practical-business/src/main/resources/bootstrap.yml
View file @
2c66995a
...
...
@@ -38,10 +38,12 @@ server:
tomcat
:
max-http-form-post-size
:
510MB
# 出勤签到配置。allowed-ip-cidrs 为空时
签到
会安全拒绝
,部署前请补充实际网段
。
# 出勤签到配置。allowed-ip-cidrs 为空时会安全拒绝
签到,当前按教学网络实际范围配置
。
attendance
:
verification-code-valid-minutes
:
15
allowed-ip-cidrs
:
[]
# 教学网络地址范围为192.168.10.0至192.168.10.255,对应CIDR前缀/24。
allowed-ip-cidrs
:
-
192.168.10.0/24
# 只有网关已清洗 X-Forwarded-For / X-Real-IP 时才开启。
trust-forwarded-headers
:
false
...
...
practical-business/src/main/resources/class-management-api.md
View file @
2c66995a
...
...
@@ -85,6 +85,7 @@
-
基础信息、计划/实际人数、培训自然日数和动态班级状态。
-
按课程名称、类型和授课教师聚合的课程列表,课时为全部排课课时之和。
-
聚合课程在最后一节排课的具体结束时刻到达后立即更新为
`ENDED / 已完成`
。
-
全班及个人出勤率;只有
`NORMAL/LATE`
计入出勤分子,
`ABSENT/LEAVE`
计入分母。
-
最近一场
`exam.mark_flag=true`
的考试,以及考生侧
`mark_flag=true`
的正式成绩。
-
最近考试中 60 分及以上人数占有效成绩人数的比例;没有正式成绩时通过率返回
`null`
。
...
...
practical-business/src/main/resources/com/platform/business/mapper/AdminHomeMapper.xml
View file @
2c66995a
...
...
@@ -10,7 +10,7 @@
from user u
inner join phone_role role_info on role_info.phone = u.phone_number
where role_info.role_name in ('学生', '学员')
and u.account_status = 'STUDYING'
<!-- “学员总数”统计全部未删除学员;在读人数另由活跃模块按STUDYING口径统计。 -->
and coalesce(u.del_flag, 0) = 0) as studentCount,
(select count(distinct u.id)
from user u
...
...
practical-business/src/main/resources/com/platform/business/mapper/ClassMapper.xml
View file @
2c66995a
...
...
@@ -129,7 +129,10 @@
where c.id = #{classId}
</select>
<!-- 同名、同类型且由同一教师授课的多次排课合并为详情页的一门逻辑课程。 -->
<!--
同名、同类型且由同一教师授课的多次排课合并为详情页的一门逻辑课程。
聚合后仍按首次日期、首次上课时段和首条ID排序,与课程管理列表的规则保持一致。
-->
<select
id=
"selectAdminCourses"
resultType=
"com.platform.business.model.vo.ClassAdminCourseVO"
>
select
subject.subject_name as subjectName,
...
...
@@ -138,12 +141,22 @@
subject.teacher_id as teacherId,
teacher.nick_name as teacherName,
min(subject.date) as firstDate,
max(subject.date) as lastDate
max(subject.date) as lastDate,
/*
time_frame最后一个“-”后的HH:mm就是该排课的最晚结束时刻;先拼接课程日期,
再在同一逻辑课程的全部排课中取最大值,使最后上课当天也能按具体时刻完成。
*/
str_to_date(max(concat(
date_format(subject.date, '%Y-%m-%d'), ' ',
trim(substring_index(
replace(replace(subject.time_frame, '—', '-'), '–', '-'), '-', -1
))
)), '%Y-%m-%d %H:%i') as lastEndTime
from class_subject subject
left join user teacher on teacher.id = subject.teacher_id
where subject.class_id = #{classId}
group by subject.subject_name, subject.type, subject.teacher_id, teacher.nick_name
order by min(subject.date) asc, subject.
subject_n
ame asc, subject.
teacher_
id asc
order by min(subject.date) asc,
min(
subject.
time_fr
ame
)
asc,
min(
subject.id
)
asc
</select>
<!--
...
...
practical-business/src/main/resources/com/platform/business/mapper/ClassSubjectAttendanceMapper.xml
View file @
2c66995a
...
...
@@ -195,7 +195,7 @@
</select>
<!--
管理端班级看板的口径:NORMAL
为正常签到;LATE、
ABSENT
、
LEAVE
均为异常
。
管理端班级看板的口径:NORMAL
和LATE都代表实际到课,
ABSENT
和
LEAVE
未实际到课
。
班级人数和课程数独立于出勤记录统计,确保无记录的在班学员和已排课程不会被遗漏。
-->
<select
id=
"querySummary"
resultType=
"com.platform.business.model.vo.AttendanceSummaryVO"
>
...
...
@@ -220,7 +220,7 @@
sum(case when a.status = 'LEAVE' then 1 else 0 end) as leaveCount,
sum(case when a.status in ('LATE', 'ABSENT', 'LEAVE') then 1 else 0 end) as abnormalCount,
case when count(a.id) = 0 then 0
else round(sum(case when a.status
=
'NORMAL' then 1 else 0 end) * 100.0 / count(a.id), 2)
else round(sum(case when a.status
in (
'NORMAL'
, 'LATE')
then 1 else 0 end) * 100.0 / count(a.id), 2)
end as attendanceRate
from class_subject_attendance a
inner join class_subject s on s.id = a.subject_id
...
...
@@ -234,7 +234,7 @@
</where>
</select>
<!-- 按学员汇总,使用与管理端总览相同的“
正常签到/应到”
出勤
率
口径。 -->
<!-- 按学员汇总,使用与管理端总览相同的“
实际出勤/应
出勤
”
口径。 -->
<select
id=
"queryStudentStatistics"
resultType=
"com.platform.business.model.vo.AttendanceStudentStatisticsVO"
>
select
a.user_id as studentId,
...
...
@@ -245,7 +245,7 @@
sum(case when a.status = 'LATE' then 1 else 0 end) as lateCount,
sum(case when a.status = 'ABSENT' then 1 else 0 end) as absentCount,
sum(case when a.status = 'LEAVE' then 1 else 0 end) as leaveCount,
round(sum(case when a.status
=
'NORMAL' then 1 else 0 end) * 100.0 / count(a.id), 2) as attendanceRate
round(sum(case when a.status
in (
'NORMAL'
, 'LATE')
then 1 else 0 end) * 100.0 / count(a.id), 2) as attendanceRate
from class_subject_attendance a
inner join class_subject s on s.id = a.subject_id
left join user student on student.id = a.user_id
...
...
@@ -278,7 +278,7 @@
sum(case when a.status = 'LATE' then 1 else 0 end) as lateCount,
sum(case when a.status = 'ABSENT' then 1 else 0 end) as absentCount,
sum(case when a.status = 'LEAVE' then 1 else 0 end) as leaveCount,
round(sum(case when a.status
=
'NORMAL' then 1 else 0 end) * 100.0 / count(a.id), 2) as attendanceRate
round(sum(case when a.status
in (
'NORMAL'
, 'LATE')
then 1 else 0 end) * 100.0 / count(a.id), 2) as attendanceRate
from class_subject_attendance a
inner join class_subject s on s.id = a.subject_id
left join class c on c.id = s.class_id
...
...
practical-business/src/main/resources/com/platform/business/mapper/NotificationMessageMapper.xml
View file @
2c66995a
...
...
@@ -20,9 +20,18 @@
<!-- 列表和详情复用同一字段映射,避免两个接口的命名或时间字段不一致。 -->
<sql
id=
"userMessageColumns"
>
m.id, m.event_id as eventId, m.message_type as messageType, m.title, m.summary, m.content,
m.id, m.event_id as eventId, m.message_type as messageType,
case when current_evaluation.status = 'REVOKED' then '课程评价任务已撤回'
else m.title end as title,
case when current_evaluation.status = 'REVOKED' then '当前新增评价任务已被撤回'
else m.summary end as summary,
case when current_evaluation.status = 'REVOKED' then '当前新增评价任务已被撤回'
else m.content end as content,
m.sender_id as senderId, m.sender_name as senderName, m.business_type as businessType,
m.business_id as businessId, m.action_url as actionUrl, m.priority,
m.business_id as businessId,
case when current_evaluation.status = 'REVOKED' then null
else m.action_url end as actionUrl,
m.priority,
r.read_flag as readFlag, r.read_at as readAt, m.created_at as createdAt, m.expires_at as expiresAt
</sql>
...
...
@@ -34,6 +43,12 @@
select
<include
refid=
"userMessageColumns"
/>
from notification_message_recipient r
inner join notification_message m on m.id = r.message_id
<!--
评议通知展示任务当前状态:未撤回时保持原消息,撤回后原通知与撤回通知返回同一文案,
同时清空已失效的任务跳转地址,避免学员进入不存在的待评价页面。
-->
left join evaluation_task current_evaluation
on m.business_type = 'EVALUATION' and current_evaluation.id = m.business_id
where r.user_id = #{userId}
and r.deleted_flag = 0
and (m.expires_at is null or m.expires_at
>
now())
...
...
@@ -52,6 +67,8 @@
select
<include
refid=
"userMessageColumns"
/>
from notification_message_recipient r
inner join notification_message m on m.id = r.message_id
left join evaluation_task current_evaluation
on m.business_type = 'EVALUATION' and current_evaluation.id = m.business_id
where r.user_id = #{userId} and r.message_id = #{messageId} and r.deleted_flag = 0
and (m.expires_at is null or m.expires_at
>
now())
limit 1
...
...
practical-business/src/main/resources/com/platform/business/mapper/StudentExamCenterMapper.xml
View file @
2c66995a
...
...
@@ -3,6 +3,21 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.platform.business.mapper.StudentExamCenterMapper"
>
<!--
历史个人试卷可能保留了分组前的原题号,因此答题页仍需按正式试卷相同的题型顺序
分组;服务层随后按返回位置生成连续展示题号,兼容已经开考的历史数据。
-->
<sql
id=
"groupedPaperQuestionOrder"
>
ORDER BY CASE type
WHEN '判断题' THEN 1
WHEN '单选题' THEN 2
WHEN '多选题' THEN 3
WHEN '主观题' THEN 4
ELSE 5
END,
CAST(sequence AS UNSIGNED), sequence, id
</sql>
<!-- 考试中心可展示全部个人应考关系,但只有双重发布标记均成立时才返回分数。 -->
<select
id=
"selectPage"
resultType=
"com.platform.business.model.vo.StudentExamCenterVO$ListItem"
>
SELECT
...
...
@@ -121,7 +136,7 @@
WHERE exam_id = #{examId}
AND student_id = #{studentId}
AND COALESCE(is_problem, 1) = 1
ORDER BY CAST(sequence AS UNSIGNED), sequence, id
<include
refid=
"groupedPaperQuestionOrder"
/>
</select>
<select
id=
"selectQuestionForUpdate"
...
...
practical-business/src/main/resources/com/platform/business/mapper/StudentHomeMapper.xml
View file @
2c66995a
...
...
@@ -142,9 +142,17 @@
subject.time_frame as timeFrame,
subject.subject_name as subjectName,
coalesce(nullif(teacher.nick_name, ''), teacher.username) as teacherName,
subject.location
subject.location,
attendance.status as attendanceStatus
from class_subject subject
left join user teacher on teacher.id = subject.teacher_id
<!--
首页课程状态必须按当前登录学员读取,不能只根据课程时间推断。
请假审批通过后出勤表会写入LEAVE,服务层据此优先展示“请假”。
-->
left join class_subject_attendance attendance
on attendance.subject_id = subject.id
and attendance.user_id = #{studentId}
where subject.class_id = #{classId}
and subject.date
>
= #{startDate}
and subject.date
<
#{endDate}
...
...
practical-business/src/main/resources/com/platform/business/mapper/TheoreticalPaperDetailMapper.xml
View file @
2c66995a
...
...
@@ -4,7 +4,11 @@
<mapper
namespace=
"com.platform.business.mapper.TheoreticalPaperDetailMapper"
>
<select
id=
"selectDisorderly"
resultType=
"com.platform.business.model.entity.TheoreticalPaperDetailEntity"
>
<!--
自动组卷已经在题库查询阶段随机抽题。这里读取的是已经形成的正式试卷,只按固定的
题型分组和数字题号排序,避免每名学员开考时再次RAND()而得到不同答题顺序。
-->
<select
id=
"selectInPaperOrder"
resultType=
"com.platform.business.model.entity.TheoreticalPaperDetailEntity"
>
SELECT id,
paper_id,
scope,
...
...
@@ -31,8 +35,10 @@
WHEN '判断题' THEN 1
WHEN '单选题' THEN 2
WHEN '多选题' THEN 3
ELSE 4
END, RAND()
WHEN '主观题' THEN 4
ELSE 5
END,
CAST(sequence AS UNSIGNED), sequence, id
</select>
</mapper>
practical-business/src/main/resources/home-api.md
View file @
2c66995a
...
...
@@ -52,7 +52,7 @@
`GET /home/student/courses/next-three-days`
固定返回今天、明天、后天三个分组,即使当天没有课程也会返回空
`courses`
。课程状态为
`IN_PROGRESS`
、
`UPCOMING`
或
`PENDING`
;距离首个时段开始不超过 60 分钟为
`UPCOMING`
。
固定返回今天、明天、后天三个分组,即使当天没有课程也会返回空
`courses`
。课程状态为
`LEAVE`
、
`IN_PROGRESS`
、
`UPCOMING`
或
`PENDING`
;
已审批请假优先返回
`LEAVE`
,
距离首个时段开始不超过 60 分钟为
`UPCOMING`
。
## 3. 教师首页
...
...
practical-business/src/main/resources/student-exam-center-api.md
View file @
2c66995a
...
...
@@ -26,6 +26,8 @@
-
`GET /{examStudentId}/instructions`
:考试信息与考试须知;实训考试只提供说明。
-
`POST /{examStudentId}/start`
:开始或恢复理论考试,重复调用返回同一应考记录ID。
-
`GET /attempts/{examStudentId}/paper`
:返回个人试卷和已保存答案,不返回正确答案。
题目沿用正式试卷的题型分组,组内顺序固定,并返回从1开始的连续题号;随机抽题只发生在
自动组卷阶段,学员开考时不会再次打乱。
-
`PUT /attempts/{examStudentId}/questions/{questionId}/answer`
:请求体
`{ "actualChoice": "A" }`
;
传
`null`
或空白表示清空本题答案。
-
`GET /attempts/{examStudentId}/submit-check`
:返回已答/未答数量和禁交状态。
...
...
practical-business/src/main/resources/templates/teaching-plan/B8-teaching-plan.docx
0 → 100644
View file @
2c66995a
File added
practical-business/src/main/resources/theoretical-paper-teacher-api.md
View file @
2c66995a
...
...
@@ -109,7 +109,7 @@ practical-business/src/main/resources/sql/theoretical_paper_management.sql
## 6. 旧页面兼容路径
-
`GET /theoretical/paper/auto`
等同规则预览接口
。
-
`GET /theoretical/paper/auto`
返回相同的公共规则配置,并保留给已登录学员的模拟考场兼容调用;教师端优先使用
`/auto-configuration`
。
-
`POST /theoretical/paper/create`
接收旧
`CombinationDTO`
,但忽略客户端
`num`
、
`sum`
、
`createUser`
、抽题分布和配分规则,服务端重新读取数据库规则;为保持历史行为固定创建
`PUBLISHED`
试卷,并继续返回布尔型
`data`
。
...
...
practical-business/src/test/java/com/platform/business/controller/TheoreticalPaperControllerTest.java
View file @
2c66995a
...
...
@@ -32,7 +32,7 @@ import static org.mockito.Mockito.times;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
教师
理论试卷控制器的角色鉴权、
可信身份、兼容转换
和分页边界测试。 */
/** 理论试卷控制器的角色鉴权、
学员只读兼容、可信身份
和分页边界测试。 */
@ExtendWith
(
MockitoExtension
.
class
)
class
TheoreticalPaperControllerTest
{
...
...
@@ -92,6 +92,20 @@ class TheoreticalPaperControllerTest {
verify
(
legacyPaperService
).
exportWithAnswer
(
"paper-1"
,
response
);
}
@Test
void
legacyAutoConfigurationShouldAllowAuthenticatedStudentReadOnlyAccess
()
{
MockHttpServletRequest
request
=
new
MockHttpServletRequest
();
UserEntity
student
=
new
UserEntity
();
student
.
setId
(
"student-1"
);
when
(
authenticatedUserService
.
current
(
request
)).
thenReturn
(
student
);
controller
.
legacyAutoConfiguration
(
"污水一级"
,
request
);
// 模拟考场只读取公共规则,不应触发教师角色校验或教师试卷写服务。
verify
(
legacyPaperService
).
auto
(
"污水一级"
);
verify
(
authenticatedUserService
,
org
.
mockito
.
Mockito
.
never
()).
requireTeacher
(
student
);
}
@Test
void
legacyCreateShouldIgnoreClientCalculatedAndIdentityFields
()
{
MockHttpServletRequest
request
=
new
MockHttpServletRequest
();
...
...
practical-business/src/test/java/com/platform/business/mapper/AttendanceStatisticsMapperXmlTest.java
View file @
2c66995a
...
...
@@ -13,11 +13,11 @@ import java.util.Date;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
/** 管理端出勤看板SQL口径的解析测试,防止迟到
再次被误计为正常签到
。 */
/** 管理端出勤看板SQL口径的解析测试,防止迟到
签到再次漏出实际出勤分子
。 */
class
AttendanceStatisticsMapperXmlTest
{
@Test
void
s
ummaryShouldExposeDashboardCountsAndUseNormalOnly
ForAttendanceRate
()
throws
Exception
{
void
s
tatisticsShouldUseActualAttendance
ForAttendanceRate
()
throws
Exception
{
Configuration
configuration
=
new
Configuration
();
parse
(
configuration
,
"com/platform/business/mapper/ClassSubjectAttendanceMapper.xml"
);
...
...
@@ -25,19 +25,31 @@ class AttendanceStatisticsMapperXmlTest {
query
.
setClassId
(
12
);
query
.
setStartDate
(
date
(
2026
,
Calendar
.
AUGUST
,
1
));
query
.
setEndDate
(
date
(
2026
,
Calendar
.
AUGUST
,
31
));
String
summarySql
=
statementSql
(
configuration
,
"querySummary"
,
query
);
// 班级人数来自成员关系、课程数来自排课,二者不依赖是否已经生成出勤记录。
assertTrue
(
summarySql
.
contains
(
"select count(*) from class_student member where member.class_id = ?"
));
assertTrue
(
summarySql
.
contains
(
"from class_subject scoped_subject"
));
assertTrue
(
summarySql
.
contains
(
"as studentCount"
));
assertTrue
(
summarySql
.
contains
(
"as courseCount"
));
// 迟到仍保留在异常人次展示中,但出勤率必须按NORMAL+LATE实际到课人次计算。
assertTrue
(
summarySql
.
contains
(
"a.status in ('LATE', 'ABSENT', 'LEAVE') then 1 else 0 end) as abnormalCount"
));
assertActualAttendanceRate
(
summarySql
);
assertActualAttendanceRate
(
statementSql
(
configuration
,
"queryStudentStatistics"
,
query
));
assertActualAttendanceRate
(
statementSql
(
configuration
,
"queryCourseStatistics"
,
query
));
}
private
static
String
statementSql
(
Configuration
configuration
,
String
statement
,
AttendanceQueryDTO
query
)
{
BoundSql
boundSql
=
configuration
.
getMappedStatement
(
"com.platform.business.mapper.ClassSubjectAttendanceMapper.
querySummary"
)
"com.platform.business.mapper.ClassSubjectAttendanceMapper.
"
+
statement
)
.
getBoundSql
(
query
);
String
sql
=
compact
(
boundSql
.
getSql
());
return
compact
(
boundSql
.
getSql
());
}
// 班级人数来自成员关系、课程数来自排课,二者不依赖是否已经生成出勤记录。
assertTrue
(
sql
.
contains
(
"select count(*) from class_student member where member.class_id = ?"
));
assertTrue
(
sql
.
contains
(
"from class_subject scoped_subject"
));
assertTrue
(
sql
.
contains
(
"as studentCount"
));
assertTrue
(
sql
.
contains
(
"as courseCount"
));
// 图片口径:仅NORMAL进入出勤率分子,其他三个状态组成异常人次。
assertTrue
(
sql
.
contains
(
"a.status in ('LATE', 'ABSENT', 'LEAVE') then 1 else 0 end) as abnormalCount"
));
assertTrue
(
sql
.
contains
(
"sum(case when a.status = 'NORMAL' then 1 else 0 end) * 100.0 / count(a.id)"
));
/** 三个统计维度必须共享同一实际出勤口径,避免总览与明细显示不同百分比。 */
private
static
void
assertActualAttendanceRate
(
String
sql
)
{
assertTrue
(
sql
.
contains
(
"sum(case when a.status in ('NORMAL', 'LATE') then 1 else 0 end) * 100.0 / count(a.id)"
));
}
private
static
void
parse
(
Configuration
configuration
,
String
resource
)
throws
Exception
{
...
...
practical-business/src/test/java/com/platform/business/mapper/ClassMapperXmlTest.java
View file @
2c66995a
...
...
@@ -18,12 +18,7 @@ class ClassMapperXmlTest {
@Test
void
adminClassQueryShouldUseTheOrderingRequestedByItsCaller
()
throws
Exception
{
String
resource
=
"com/platform/business/mapper/ClassMapper.xml"
;
Configuration
configuration
=
new
Configuration
();
try
(
InputStream
input
=
Resources
.
getResourceAsStream
(
resource
))
{
new
XMLMapperBuilder
(
input
,
configuration
,
resource
,
configuration
.
getSqlFragments
()).
parse
();
}
Configuration
configuration
=
parseMapper
();
// 模拟卡片分页调用,验证排序发生在数据库分页之前,并以ID作为稳定的第二排序键。
String
cardSql
=
compactSql
(
adminClassSql
(
configuration
,
true
));
...
...
@@ -37,6 +32,31 @@ class ClassMapperXmlTest {
assertFalse
(
treeSql
.
contains
(
"order by c.create_time desc"
));
}
@Test
void
adminClassCoursesShouldMatchCourseManagementOrdering
()
throws
Exception
{
Configuration
configuration
=
parseMapper
();
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"classId"
,
1
);
String
sql
=
compactSql
(
configuration
.
getMappedStatement
(
"com.platform.business.mapper.ClassMapper.selectAdminCourses"
)
.
getBoundSql
(
parameters
).
getSql
());
// 详情列表经过课程聚合,因此分别取每组最早值来对应课程管理的日期、时段、ID顺序。
assertTrue
(
sql
.
contains
(
"order by min(subject.date) asc, min(subject.time_frame) asc, min(subject.id) asc"
));
}
private
static
Configuration
parseMapper
()
throws
Exception
{
String
resource
=
"com/platform/business/mapper/ClassMapper.xml"
;
Configuration
configuration
=
new
Configuration
();
try
(
InputStream
input
=
Resources
.
getResourceAsStream
(
resource
))
{
new
XMLMapperBuilder
(
input
,
configuration
,
resource
,
configuration
.
getSqlFragments
()).
parse
();
}
return
configuration
;
}
private
static
String
adminClassSql
(
Configuration
configuration
,
boolean
orderByCreateTime
)
{
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
...
...
practical-business/src/test/java/com/platform/business/mapper/HomeMapperXmlTest.java
View file @
2c66995a
...
...
@@ -6,6 +6,7 @@ import org.apache.ibatis.session.Configuration;
import
org.junit.jupiter.api.Test
;
import
java.io.InputStream
;
import
java.util.HashMap
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
...
...
@@ -32,6 +33,14 @@ class HomeMapperXmlTest {
"com.platform.business.mapper.AdminHomeMapper.selectTodos"
)
.
getBoundSql
(
null
).
getSql
().
toUpperCase
();
assertFalse
(
adminTodoSql
.
contains
(
"EXAM_REVIEW"
));
String
statisticsSql
=
configuration
.
getMappedStatement
(
"com.platform.business.mapper.AdminHomeMapper.selectStatistics"
)
.
getBoundSql
(
new
HashMap
<
String
,
Object
>()).
getSql
()
.
replaceAll
(
"\\s+"
,
" "
).
toLowerCase
();
// 顶部“学员总数”必须覆盖待激活、在读和已结业等全部未删除学员,不能只统计在读状态。
assertTrue
(
statisticsSql
.
contains
(
"role_info.role_name in ('学生', '学员')"
));
assertFalse
(
statisticsSql
.
contains
(
"u.account_status = 'studying'"
));
}
private
static
void
parse
(
Configuration
configuration
,
String
resource
)
throws
Exception
{
...
...
practical-business/src/test/java/com/platform/business/mapper/NotificationMessageMapperXmlTest.java
0 → 100644
View file @
2c66995a
package
com.platform.business.mapper
;
import
com.platform.business.model.dto.NotificationMessageQueryDTO
;
import
org.apache.ibatis.builder.xml.XMLMapperBuilder
;
import
org.apache.ibatis.io.Resources
;
import
org.apache.ibatis.session.Configuration
;
import
org.junit.jupiter.api.Test
;
import
java.io.InputStream
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
/** 验证评议撤回后,消息列表和详情都会读取任务的当前状态。 */
class
NotificationMessageMapperXmlTest
{
@Test
void
evaluationMessagesShouldDisplayRevokedStateAndDisableStaleAction
()
throws
Exception
{
String
resource
=
"com/platform/business/mapper/NotificationMessageMapper.xml"
;
Configuration
configuration
=
new
Configuration
();
try
(
InputStream
input
=
Resources
.
getResourceAsStream
(
resource
))
{
new
XMLMapperBuilder
(
input
,
configuration
,
resource
,
configuration
.
getSqlFragments
()).
parse
();
}
NotificationMessageQueryDTO
query
=
new
NotificationMessageQueryDTO
();
query
.
setUserId
(
"S1"
);
query
.
setReadStatus
(
"ALL"
);
Map
<
String
,
Object
>
detailParameters
=
new
HashMap
<>();
detailParameters
.
put
(
"userId"
,
"S1"
);
detailParameters
.
put
(
"messageId"
,
"M1"
);
String
namespace
=
"com.platform.business.mapper.NotificationMessageMapper."
;
// 两个接口必须展开同一状态覆盖逻辑,确保历史发布通知和新增撤回通知展示一致。
for
(
String
sql
:
new
String
[]{
configuration
.
getMappedStatement
(
namespace
+
"queryUserMessages"
)
.
getBoundSql
(
query
).
getSql
(),
configuration
.
getMappedStatement
(
namespace
+
"selectUserMessage"
)
.
getBoundSql
(
detailParameters
).
getSql
()})
{
String
normalized
=
sql
.
replaceAll
(
"\\s+"
,
" "
).
toLowerCase
();
assertTrue
(
normalized
.
contains
(
"left join evaluation_task current_evaluation"
));
assertTrue
(
normalized
.
contains
(
"current_evaluation.status = 'revoked'"
));
assertTrue
(
normalized
.
contains
(
"当前新增评价任务已被撤回"
));
assertTrue
(
normalized
.
contains
(
"then null else m.action_url end as actionurl"
));
}
}
}
Prev
1
2
3
Next
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