1. 月度分排行:管理端首页支持总分/月度分切换与月份选择,新增排行榜导出CSV 2. 数据报表:新增考勤/作业统计页(日期范围、汇总与每人明细、CSV导出) 3. 操作日志:新增查看页(操作类型/操作人/日期筛选,分页) 4. 系统设置:密码策略可配置(长度/字符种类),全站改密与重置统一校验、前端提示同步;策略通过公开配置下发 5. 学期归档对比:查看归档时展示与上一学期的分数变化与名次升降 6. 历史记录导出支持按学生分表(每人一段,便于发家长) 7. 移动端适配:导航横向滚动、表格触控滚动、字号与弹窗优化 8. 版本升级至4.4(无数据库结构变更)
140 lines
4.0 KiB
Python
140 lines
4.0 KiB
Python
# ===========================================
|
|
# 班级操行分管理系统 - 后端服务
|
|
#
|
|
# 开发者: Canglan
|
|
# 联系方式: admin@sea-studio.top
|
|
# 版权归属: Sea Network Technology Studio
|
|
# 许可证: MIT License
|
|
#
|
|
# 版权所有 © Sea Network Technology Studio
|
|
# ===========================================
|
|
|
|
from fastapi import APIRouter, Request, Query
|
|
from typing import Optional
|
|
|
|
from middleware.permission import get_current_user
|
|
from services.student_service import StudentService
|
|
from utils.response import success_response, error_response
|
|
from utils.logger import get_logger
|
|
|
|
router = APIRouter()
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
@router.get("/conduct/{student_id}")
|
|
async def get_conduct_history(
|
|
request: Request,
|
|
student_id: int,
|
|
limit: int = Query(50, ge=1, le=200),
|
|
offset: int = Query(0, ge=0)
|
|
):
|
|
"""
|
|
获取学生操行分历史
|
|
"""
|
|
try:
|
|
user = await get_current_user(request)
|
|
|
|
# 权限检查:只能查看自己的信息(学生)或同班(管理员)
|
|
if user["user_type"] == "student" and user["student_id"] != student_id:
|
|
return error_response(message="无权查看其他学生信息", code=403)
|
|
|
|
result = await StudentService.get_conduct_history(
|
|
student_id=student_id,
|
|
limit=limit,
|
|
offset=offset
|
|
)
|
|
|
|
return success_response(data=result)
|
|
except Exception as e:
|
|
logger.error(f"获取学生操行分失败: {e}", exc_info=True)
|
|
return error_response(message=f"获取学生操行分失败: {str(e)}")
|
|
|
|
|
|
@router.get("/homework/{student_id}")
|
|
async def get_homework_status(request: Request, student_id: int):
|
|
"""
|
|
获取学生作业情况
|
|
"""
|
|
user = await get_current_user(request)
|
|
|
|
# 权限检查
|
|
if user["user_type"] == "student" and user["student_id"] != student_id:
|
|
return error_response(message="无权查看其他学生信息", code=403)
|
|
|
|
result = await StudentService.get_homework_status(student_id)
|
|
|
|
return success_response(data=result)
|
|
|
|
|
|
@router.get("/attendance/{student_id}")
|
|
async def get_attendance_records(
|
|
request: Request,
|
|
student_id: int,
|
|
month: Optional[str] = None
|
|
):
|
|
"""
|
|
获取学生考勤记录
|
|
"""
|
|
user = await get_current_user(request)
|
|
|
|
# 权限检查
|
|
if user["user_type"] == "student" and user["student_id"] != student_id:
|
|
return error_response(message="无权查看其他学生信息", code=403)
|
|
|
|
result = await StudentService.get_attendance_records(
|
|
student_id=student_id,
|
|
month=month
|
|
)
|
|
|
|
return success_response(data=result)
|
|
|
|
|
|
@router.get("/ranking")
|
|
async def get_ranking(
|
|
request: Request,
|
|
limit: int = Query(50, ge=1, le=1000),
|
|
month: Optional[str] = Query(None, pattern=r'^\d{4}-\d{2}$')
|
|
):
|
|
"""
|
|
获取操行分排行榜(传 month=YYYY-MM 时为月度分排行)
|
|
"""
|
|
user = await get_current_user(request)
|
|
|
|
result = await StudentService.get_ranking(
|
|
user_id=user["user_id"],
|
|
limit=limit,
|
|
month=month
|
|
)
|
|
|
|
return success_response(data=result)
|
|
|
|
|
|
@router.get("/my-info")
|
|
async def get_my_info(request: Request):
|
|
"""
|
|
获取当前学生个人信息
|
|
"""
|
|
user = await get_current_user(request)
|
|
|
|
if user["user_type"] != "student":
|
|
return error_response(message="仅限学生访问", code=403)
|
|
|
|
result = await StudentService.get_student_info(user["student_id"])
|
|
|
|
return success_response(data=result)
|
|
|
|
|
|
@router.get("/semester-records")
|
|
async def get_student_semester_records(request: Request):
|
|
"""
|
|
获取当前学生的历史学期归档记录
|
|
"""
|
|
user = await get_current_user(request)
|
|
|
|
if user["user_type"] != "student":
|
|
return error_response(message="仅限学生访问", code=403)
|
|
|
|
from models.semester import SemesterArchiveModel
|
|
records = await SemesterArchiveModel.get_by_student(user["student_id"])
|
|
|
|
return success_response(data={"records": records}) |