1. 权限重构:自定义权限组(14项功能权限+允许加分/加分上限/允许扣分/扣分上限),管理员账号绑定权限组,预置六组且班主任组锁定;全站前后端改为权限驱动,权限变更60秒内自动生效 2. 新增班主任导出学生名单(导出前自选字段) 3. 加减分/考勤上限改为按权限组动态校验,弹窗实时提示并限制输入 4. 导出按学期隔离(默认当前学期,可选历史/全部),历史导出不再受1000条限制 5. 新增管理端个人查询:基础分/加分/扣分/月度分/月度理由汇总及明细导出 6. 版本升级至4.0(sql/upgrades/v4.0.sql)
122 lines
4.8 KiB
Python
122 lines
4.8 KiB
Python
# ===========================================
|
|
# 班级操行分管理系统 - 后端服务
|
|
#
|
|
# 开发者: Canglan
|
|
# 联系方式: admin@sea-studio.top
|
|
# 版权归属: Sea Network Technology Studio
|
|
# 许可证: MIT License
|
|
#
|
|
# 版权所有 © Sea Network Technology Studio
|
|
# ===========================================
|
|
|
|
from pydantic import BaseModel, Field
|
|
from typing import Optional, List
|
|
from datetime import date, datetime
|
|
|
|
|
|
class AddPointsRequest(BaseModel):
|
|
"""加减分请求"""
|
|
student_ids: List[int] = Field(..., min_length=1, max_length=200, description="学生ID列表")
|
|
points_change: int = Field(..., gt=-100, lt=100, description="分数变动")
|
|
reason: str = Field(..., min_length=1, max_length=255, description="原因")
|
|
related_type: Optional[str] = Field(default='manual', pattern=r'^(manual|homework|attendance)$', description="关联类型: manual/homework/attendance")
|
|
|
|
|
|
class AddPointsResponse(BaseModel):
|
|
"""加减分响应"""
|
|
success_count: int
|
|
fail_count: int
|
|
details: List[dict]
|
|
|
|
|
|
class RevokeRequest(BaseModel):
|
|
"""撤销请求"""
|
|
record_id: int = Field(..., description="记录ID")
|
|
|
|
|
|
class ImportStudentsRequest(BaseModel):
|
|
"""导入学生请求"""
|
|
students: List[dict] = Field(..., description="学生列表")
|
|
|
|
|
|
class ImportResult(BaseModel):
|
|
"""导入结果"""
|
|
total: int
|
|
success: int
|
|
failed: int
|
|
errors: List[str]
|
|
|
|
|
|
class AddAdminRequest(BaseModel):
|
|
"""添加管理员请求"""
|
|
username: str = Field(..., min_length=2, max_length=50, pattern=r'^[a-zA-Z0-9_\u4e00-\u9fa5]+$', description="登录账号")
|
|
real_name: str = Field(..., min_length=1, max_length=50, description="真实姓名")
|
|
password: Optional[str] = Field(None, min_length=6, max_length=50, description="密码(不填则自动生成)")
|
|
group_id: int = Field(..., gt=0, description="权限组ID")
|
|
subject_id: Optional[int] = Field(None, gt=0, description="科目ID(科代表需要)")
|
|
|
|
|
|
class AddAdminResponse(BaseModel):
|
|
"""添加管理员响应"""
|
|
success: bool
|
|
username: str
|
|
password: Optional[str] = None
|
|
message: str
|
|
|
|
|
|
class AddStudentRequest(BaseModel):
|
|
"""新增学生请求"""
|
|
student_no: str = Field(..., min_length=1, max_length=20, pattern=r'^[a-zA-Z0-9]+$', description="学号")
|
|
name: str = Field(..., min_length=1, max_length=50, description="姓名")
|
|
parent_phone: Optional[str] = Field(None, max_length=11, pattern=r'^\d{0,11}$', description="家长手机号")
|
|
dormitory_number: Optional[str] = Field(None, max_length=20, description="宿舍号")
|
|
|
|
|
|
class AddAttendanceRequest(BaseModel):
|
|
"""添加考勤请求"""
|
|
student_id: int = Field(..., gt=0, description="学生ID")
|
|
date: date
|
|
slot: str = Field(default="morning", pattern=r'^(morning|afternoon|evening)$', description="时段")
|
|
status: str = Field(..., pattern=r'^(present|absent|late|leave)$', description="考勤状态")
|
|
reason: Optional[str] = Field(None, max_length=255, description="原因")
|
|
apply_deduction: bool = True
|
|
custom_deduction: Optional[int] = Field(default=None, gt=0, le=20, description="自定义扣分值")
|
|
|
|
|
|
class UpdateAdminRequest(BaseModel):
|
|
"""更新管理员请求"""
|
|
real_name: str = Field(..., min_length=1, max_length=50, description="真实姓名")
|
|
group_id: int = Field(..., gt=0, description="权限组ID")
|
|
|
|
|
|
class PermissionGroupRequest(BaseModel):
|
|
"""权限组创建/编辑请求"""
|
|
group_name: str = Field(..., min_length=1, max_length=50, description="权限组名称")
|
|
description: Optional[str] = Field(None, max_length=255, description="说明")
|
|
permissions: List[str] = Field(default_factory=list, description="权限项列表")
|
|
can_add_points: bool = Field(True, description="是否允许加分")
|
|
max_add_points: Optional[int] = Field(None, ge=1, le=100, description="单次加分上限,不填为无限制")
|
|
can_subtract_points: bool = Field(True, description="是否允许扣分")
|
|
max_subtract_points: Optional[int] = Field(None, ge=1, le=100, description="单次扣分上限,不填为无限制")
|
|
|
|
|
|
class DeleteAdminRequest(BaseModel):
|
|
"""删除管理员请求"""
|
|
user_id: int = Field(..., description="用户ID")
|
|
|
|
|
|
class ResetPasswordRequest(BaseModel):
|
|
"""重置密码请求"""
|
|
new_password: str = Field(..., min_length=6, max_length=50, description="新密码")
|
|
|
|
|
|
class UpdateStudentRequest(BaseModel):
|
|
"""更新学生请求"""
|
|
name: Optional[str] = Field(None, min_length=1, max_length=50, description="姓名")
|
|
parent_phone: Optional[str] = Field(None, max_length=11, pattern=r'^\d{0,11}$', description="家长手机号")
|
|
dormitory_number: Optional[str] = Field(None, max_length=20, description="宿舍号")
|
|
|
|
|
|
class UnlockUserRequest(BaseModel):
|
|
"""解除用户登录锁定请求"""
|
|
username: str = Field(..., min_length=1, max_length=50, description="用户名") |