v0.6测试

This commit is contained in:
2026-04-14 19:18:11 +08:00
parent fd3535f884
commit a60ba8352f
23 changed files with 157 additions and 40 deletions

View File

@@ -226,6 +226,36 @@
### 阶段 10修复 500 Internal Server Error - SQL 引用不存在的 class_id 列
- [x] 10.1 修复代码与数据库 schema 不匹配问题13个文件
### 阶段 11修复 422 参数校验 + JS 变量重复声明 + RANK() 兼容性
- [x] 11.1 修复历史记录页 422 和 JS 变量声明问题
- [x] 11.2 修复首页 RANK() OVER 窗口函数兼容性
### 阶段 12全面项目审查 - 消灭潜在问题
- [x] 12.1 修复后端角色名"科代表"→"学习委员"3处+ 存储过程缺失 + 权限逻辑 + security工具类
【目标对象】`backend/services/conduct_service.py``backend/services/homework_service.py``backend/models/conduct.py``backend/middleware/permission.py``backend/utils/security.py`
【修改目的】1) "科代表"角色在数据库ENUM中不存在应为"学习委员"2) revoke_conduct_record存储过程在init.sql中不存在需替换为内联SQL3) get_user_subject_ids方法逻辑顺序有误4) validate_points_change返回类型不一致
【修改方式】
- conduct_service.py 第58行: `elif role in ["科代表", "考勤委员"]:``elif role in ["学习委员", "考勤委员"]:`
- homework_service.py 第35行: `elif role == "科代表":``elif role == "学习委员":`
- homework_service.py 第82行: `if role == "科代表":``if role == "学习委员":`
- conduct.py revoke_record方法: 替换 `call_procedure('revoke_conduct_record', ...)` 为内联SQL: `UPDATE conduct_records SET is_revoked=1, revoked_by=%s, revoked_at=NOW() WHERE record_id=%s`,使用 `execute_update` 执行
- permission.py get_user_subject_ids: 调整逻辑顺序先检查role_type是否为班主任再检查subject_id
- security.py 第126行: `return f"单次分值变动不能超过{max_abs}分"``return False, f"单次分值变动不能超过{max_abs}分"`
- [x] 12.2 修复前端学生端/家长端关键问题 + 管理端小问题 + 配置修复
【目标对象】`frontend/student/dashboard.php``frontend/api/save_session.php``frontend/index.php``frontend/student/attendance.php``frontend/admin/homework.php``frontend/config.php``frontend/student/conduct_history.php`
【修改目的】1) student/dashboard.php的common.js加载顺序错误导致API函数未定义2) save_session.php将user_id错误存储为student_id3) student/dashboard.php中hw.subject字段名错误4) homework.php重复调用loadStudents5) config.php中ICP_ENABLED逻辑反转6) conduct_history.php文件为空
【修改方式】
- student/dashboard.php: 将 `<script src="/assets/js/common.js"></script>` 移到内联script之前删除局部 `const API_BASE_URL``const JWT_STORAGE_KEY`/`USER_STORAGE_KEY`,改用 `window.API_BASE_URL = '<?php echo API_BASE_URL; ?>'` 等全局变量在common.js加载之前设置`hw.subject` 改为 `hw.subject_name`
- save_session.php: 第106行 `$_SESSION['student_id'] = $data['user_id'];` 改为从请求中获取实际student_id`$_SESSION['student_id'] = $data['student_id'] ?? $data['user_id'];`同时添加student_id到requiredFields验证仅学生时必须
- index.php: 登录成功后save_session调用中添加 `student_id: userData.student_id` 参数
- student/attendance.php: 第21行 `$student_id = $_SESSION['student_id'];` 保持不变修复save_session后此值会正确
- admin/homework.php: 删除第176行重复的 `loadStudents();` 调用
- config.php: 第61行 `define('ICP_ENABLED', $config['ICP_ENABLED'] === 'false');` 改为 `define('ICP_ENABLED', $config['ICP_ENABLED'] !== 'false');`
- student/conduct_history.php: 文件为空需要重定向到dashboard或创建基本页面。最简方案创建一个重定向到 /student/dashboard.php 的页面
【目标对象】`backend/models/attendance.py``backend/services/attendance_service.py``backend/models/conduct.py``backend/services/conduct_service.py``backend/models/homework.py``backend/services/homework_service.py``backend/models/student.py``backend/middleware/permission.py``backend/services/auth_service.py``backend/schemas/student.py``backend/schemas/admin.py``backend/services/student_service.py``backend/routes/student.py`
【修改目的】数据库 schema单班级系统`students``assignments` 表没有 `class_id` 列,但后端代码中大量 SQL 引用了该列,导致 MySQL 报错 → 500 Internal Server Error。同时 `PermissionChecker.get_user_subject_ids()``check_can_manage_student()` 方法不存在但被调用。
【修改方式】全面移除所有 `class_id` 引用(单班级系统不需要),添加缺失的方法
@@ -241,3 +271,36 @@
- auth_service.py: 移除 class_id 和 class_name 引用
- schemas/student.py 和 schemas/admin.py: 移除 class_id 和 class_name 字段
- student_service.py 和 routes/student.py: 移除 class_id 参数
- [x] 12.3 修复CRITICAL: total_points在所有Service中从未更新操行分系统完全失效
【目标对象】`backend/services/conduct_service.py``backend/services/attendance_service.py``backend/services/homework_service.py`
【修改目的】`StudentModel.update_total_points()` 方法已存在但从未被调用,导致 `students.total_points` 永远保持初始值60分排行榜、仪表盘、家长端显示的所有总分都是错误的
【修改方式】
- conduct_service.py add_points: 在 `ConductModel.create_record()` 后添加 `await StudentModel.update_total_points(student_id, points_change)`
- conduct_service.py revoke_record: 重写撤销逻辑,先获取原记录,撤销后调用 `await StudentModel.update_total_points(record["student_id"], -record["points_change"])` 反向恢复总分
- attendance_service.py add_attendance: 在 `ConductModel.create_record()` 后添加 `await StudentModel.update_total_points(student_id, points_change)`
- homework_service.py update_submission_status: 在 `ConductModel.create_record()` 后添加 `await StudentModel.update_total_points(submission["student_id"], points_change)`
- [x] 12.4 修复前端: student/homework.php字段名 + nav.php劳动委员 + parent/attendance.php死链
【目标对象】`frontend/student/homework.php``frontend/includes/nav.php``frontend/parent/attendance.php`
【修改目的】1) homework.php中hw.subject字段名与后端API不匹配2) 劳动委员无法在导航栏看到操行分管理入口README要求±1分权限3) parent/attendance.php有指向不存在的/parent/homework.php的死链接
【修改方式】
- student/homework.php 第56行: `hw.subject``hw.subject_name`
- nav.php 第4行: 添加 `|| $role === '劳动委员'` 到操行分管理导航条件
- parent/attendance.php: 删除指向不存在的 /parent/homework.php 的死链接,导航只保留"首页"和"考勤记录"
- [x] 12.5 修复学生端导航死链接: 3个页面的"操行分"链接指向不存在的/student/conduct.php
【目标对象】`frontend/student/homework.php``frontend/student/attendance.php``frontend/student/password.php`
【修改目的】学生端3个子页面导航栏中的"操行分"链接指向 `/student/conduct.php`,但实际文件名是 `conduct_history.php`导致404
【修改方式】
- password.php 第26行: `/student/conduct.php``/student/conduct_history.php`
- [x] 12.6 修复劳动委员页面级权限被拦截 + 仪表盘快捷操作缺失
【目标对象】`frontend/admin/conduct.php``frontend/admin/dashboard.php`
【修改目的】README规定劳动委员有操行分管理权限±1分但conduct.php页面级权限检查只允许班主任和班长访问劳动委员会被重定向到dashboarddashboard.php快捷操作也缺少劳动委员
【修改方式】
- conduct.php 第23行: `['班主任', '班长']``['班主任', '班长', '劳动委员']`
- conduct.php 第115行: 分数变动提示文字改为 if/elseif/else 结构,劳动委员显示"劳动委员仅限±1分"
- dashboard.php 第61行: 快捷操作条件添加劳动委员
- attendance.php 第27行: `/student/conduct.php``/student/conduct_history.php`
- password.php 第26行: `/student/conduct.php``/student/conduct_history.php`