+43
-24
@@ -172,31 +172,54 @@ ok(
|
||||
JSON.stringify(myTreeRows[0])
|
||||
);
|
||||
|
||||
// 9.7 绑定班级:class 档案 → BindClass/UnbindClass/BatchUnbind → 年级 Tab 过滤
|
||||
const clsNameA = `冒烟高一班${stamp}`;
|
||||
const clsNameB = `冒烟高二班${stamp}`;
|
||||
const clsAddA = await api("POST", "/api/class/Add", { form: { className: clsNameA, grade: 1, studentCount: 45, headTeacher: "王老师" } });
|
||||
ok("class Add(高一)", clsAddA.code === 0 && clsAddA.data > 0, clsAddA.msg);
|
||||
const clsAddB = await api("POST", "/api/class/Add", { form: { className: clsNameB, grade: 2, studentCount: 44, headTeacher: "陈老师" } });
|
||||
ok("class Add(高二)", clsAddB.code === 0 && clsAddB.data > 0, clsAddB.msg);
|
||||
ok("class Add 校内重名拒绝", (await api("POST", "/api/class/Add", { form: { className: clsNameA, grade: 1 } })).code !== 0);
|
||||
ok("class Add 非法年级拒绝", (await api("POST", "/api/class/Add", { form: { className: `冒烟班X${stamp}`, grade: 9 } })).code !== 0);
|
||||
// 9.7 绑定班级:班级数据源=班级管理平台接口(bschclass,本应用不落库、无 Add/Delete)
|
||||
// → BindClass/UnbindClass/BatchUnbind → 年级 Tab 过滤
|
||||
// 前置:dev 身份 schId=3(云海中学)在平台须有高一/高二班级
|
||||
const clsListAll = await api("GET", "/api/class/List");
|
||||
ok("class List code=0(平台班级)", clsListAll.code === 0 && Array.isArray(clsListAll.data), clsListAll.msg);
|
||||
ok(
|
||||
"class List 仅含高中学段(gradeId 10/11/12 之外的学段被过滤)",
|
||||
clsListAll.code === 0 && (clsListAll.data || []).every(c => [1, 2, 3].includes(c.grade)),
|
||||
JSON.stringify(clsListAll.data && clsListAll.data.find(c => ![1, 2, 3].includes(c.grade)))
|
||||
);
|
||||
const hs = (clsListAll.data || []).filter(c => c.grade === 1 || c.grade === 2);
|
||||
const clsA = hs.find(c => c.grade === 1 && c.classroomId == null);
|
||||
const clsB = hs.find(c => c.grade === 2 && c.classroomId == null);
|
||||
ok(
|
||||
"平台班级数据可用(高一/高二各有未绑定班级)",
|
||||
!!clsA && !!clsB,
|
||||
JSON.stringify(hs && hs.map(c => `${c.serID}:${c.className}:room${c.classroomId}`))
|
||||
);
|
||||
ok(
|
||||
"class List 行含 serID/className/studentCount(可空)/headTeacher",
|
||||
clsA && clsA.serID > 0 && !!clsA.className && (clsA.studentCount == null || Number.isInteger(clsA.studentCount)),
|
||||
JSON.stringify(clsA)
|
||||
);
|
||||
const clsListG1 = await api("GET", "/api/class/List", { params: { grade: 1 } });
|
||||
const clsA = clsListG1.data ? clsListG1.data.find(c => c.serID === clsAddA.data) : null;
|
||||
ok("class List grade=1 含新班级(未绑定 classroomId=null)", clsListG1.code === 0 && clsA && clsA.classroomId == null && clsA.headTeacher === "王老师", JSON.stringify(clsA));
|
||||
ok(
|
||||
"class List grade=1 只含高一且新班级未绑定(classroomId=null)",
|
||||
clsListG1.code === 0 && (clsListG1.data || []).length > 0 && (clsListG1.data || []).every(c => c.grade === 1)
|
||||
&& (clsListG1.data || []).find(c => c.serID === clsA.serID)?.classroomId == null,
|
||||
JSON.stringify(clsListG1.data && clsListG1.data.length)
|
||||
);
|
||||
|
||||
const bind = await api("POST", "/api/classroom/BindClass", { json: { serID: room1, classId: clsAddA.data } });
|
||||
ok("classroom BindClass 返回班级名", bind.code === 0 && bind.data && bind.data.className === clsNameA, bind.msg);
|
||||
const bindDup = await api("POST", "/api/classroom/BindClass", { json: { serID: rooms.data.list[1].serID, classId: clsAddA.data } });
|
||||
const bind = await api("POST", "/api/classroom/BindClass", { json: { serID: room1, classId: clsA.serID } });
|
||||
ok("classroom BindClass 返回班级名(平台展示名)", bind.code === 0 && bind.data && bind.data.className === clsA.className, bind.msg);
|
||||
const bindDup = await api("POST", "/api/classroom/BindClass", { json: { serID: rooms.data.list[1].serID, classId: clsA.serID } });
|
||||
ok("BindClass 班级已被其他教室占用拒绝", bindDup.code !== 0);
|
||||
ok("BindClass 缺参拒绝", (await api("POST", "/api/classroom/BindClass", { json: { serID: room1 } })).code !== 0);
|
||||
ok(
|
||||
"BindClass 班级不在平台列表拒绝",
|
||||
(await api("POST", "/api/classroom/BindClass", { json: { serID: rooms.data.list[2].serID, classId: 999999999 } })).code !== 0
|
||||
);
|
||||
|
||||
const roomsG1 = await api("GET", "/api/classroom/List", { params: { buildingId, grade: 1, page: 1, count: 20 } });
|
||||
const boundRow = roomsG1.data ? roomsG1.data.list.find(r => r.serID === room1) : null;
|
||||
ok(
|
||||
"List grade=1 含已绑教室且行含班级信息(名/人数/班主任)",
|
||||
roomsG1.code === 0 && roomsG1.data.total === 6 && boundRow && boundRow.classId === clsAddA.data &&
|
||||
boundRow.className === clsNameA && boundRow.studentCount === 45 && boundRow.headTeacher === "王老师",
|
||||
"List grade=1 含已绑教室且行含班级信息(名/人数/班主任同平台源)",
|
||||
roomsG1.code === 0 && roomsG1.data.total === 6 && boundRow && boundRow.classId === clsA.serID &&
|
||||
boundRow.className === clsA.className && (boundRow.studentCount ?? null) === (clsA.studentCount ?? null) &&
|
||||
boundRow.headTeacher === clsA.headTeacher,
|
||||
JSON.stringify(boundRow)
|
||||
);
|
||||
const roomsG2 = await api("GET", "/api/classroom/List", { params: { buildingId, grade: 2, page: 1, count: 20 } });
|
||||
@@ -208,14 +231,12 @@ ok(
|
||||
const roomsBoundOnly = await api("GET", "/api/classroom/List", { params: { buildingId, grade: 1, bindStatus: "bound", page: 1, count: 20 } });
|
||||
ok("List bindStatus=bound 只含已绑 1 间", roomsBoundOnly.code === 0 && roomsBoundOnly.data.total === 1);
|
||||
|
||||
ok("class Delete 绑定中拒绝", (await api("POST", "/api/class/Delete", { form: { serid: clsAddA.data } })).code !== 0);
|
||||
|
||||
ok("classroom UnbindClass", (await api("POST", "/api/classroom/UnbindClass", { form: { serid: room1 } })).code === 0);
|
||||
ok("UnbindClass 未绑定教室静默成功", (await api("POST", "/api/classroom/UnbindClass", { form: { serid: room1 } })).code === 0);
|
||||
|
||||
// 批量绑定两间 → 批量解绑 3 间(含 1 间未绑定 → skipped)
|
||||
await api("POST", "/api/classroom/BindClass", { json: { serID: room1, classId: clsAddA.data } });
|
||||
await api("POST", "/api/classroom/BindClass", { json: { serID: rooms.data.list[1].serID, classId: clsAddB.data } });
|
||||
// 批量绑定两间 → 批量解绑 3 间(含 1 间未绑定 → skipped);班级属平台数据,解绑即可、无需清理
|
||||
await api("POST", "/api/classroom/BindClass", { json: { serID: room1, classId: clsA.serID } });
|
||||
await api("POST", "/api/classroom/BindClass", { json: { serID: rooms.data.list[1].serID, classId: clsB.serID } });
|
||||
const bUnbind = await api("POST", "/api/classroom/BatchUnbind", { json: [room1, rooms.data.list[1].serID, rooms.data.list[2].serID] });
|
||||
ok(
|
||||
"BatchUnbind 3 间(updated=2, skipped=1)",
|
||||
@@ -223,8 +244,6 @@ ok(
|
||||
JSON.stringify(bUnbind.data)
|
||||
);
|
||||
ok("BatchUnbind 空集合拒绝", (await api("POST", "/api/classroom/BatchUnbind", { json: [] })).code !== 0);
|
||||
ok("class Delete 解绑后可删 A", (await api("POST", "/api/class/Delete", { form: { serid: clsAddA.data } })).code === 0);
|
||||
ok("class Delete 解绑后可删 B", (await api("POST", "/api/class/Delete", { form: { serid: clsAddB.data } })).code === 0);
|
||||
|
||||
// 菜单兜底(仅本地免 SSO 模式):绑定班级在第二位
|
||||
if (!COOKIE) {
|
||||
|
||||
Reference in New Issue
Block a user