1. 考勤记录查询关联 users 表返回记录人姓名(修复记录人为空) 2. 默认出勤生成的记录原因写为"默认出勤";整天请假未填原因时默认"请假(整天)" 3. "假前下午上课"属于偶发情况,默认不做:移除 pre_holiday 校历类型,需要时按正常考勤流程单独补录下午记录 4. 已确认:默认出勤记录可被异常考勤覆盖(覆盖时按异常状态正常扣分)
141 lines
6.6 KiB
Python
141 lines
6.6 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
|
|
|
|
|
|
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 RevokeRequest(BaseModel):
|
|
"""撤销请求"""
|
|
record_id: int = Field(..., description="记录ID")
|
|
|
|
|
|
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")
|
|
email: Optional[str] = Field(None, max_length=100, description="绑定邮箱(用于找回密码)")
|
|
subject_id: Optional[int] = Field(None, gt=0, description="科目ID(科代表需要)")
|
|
|
|
|
|
class UpdateAdminRequest(BaseModel):
|
|
"""更新管理员请求"""
|
|
real_name: str = Field(..., min_length=1, max_length=50, description="真实姓名")
|
|
group_id: int = Field(..., gt=0, description="权限组ID")
|
|
email: Optional[str] = Field(None, max_length=100, description="绑定邮箱(留空解除绑定)")
|
|
|
|
|
|
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 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 DefaultAttendanceRequest(BaseModel):
|
|
"""批量默认出勤请求"""
|
|
start_date: date
|
|
end_date: date
|
|
slots: Optional[List[str]] = Field(None, description="时段列表(morning/afternoon/evening),默认全部")
|
|
|
|
|
|
class FullDayLeaveRequest(BaseModel):
|
|
"""整天请假请求"""
|
|
date: date
|
|
student_ids: List[int] = Field(..., min_length=1, max_length=200, description="请假学生ID列表")
|
|
reason: Optional[str] = Field(None, max_length=255, description="原因")
|
|
|
|
|
|
class CalendarDayRequest(BaseModel):
|
|
"""校历手动设置请求"""
|
|
date: date
|
|
day_type: str = Field(..., pattern=r'^(holiday|makeup)$', description="类型: holiday=放假, makeup=补课")
|
|
note: Optional[str] = Field(None, max_length=100, description="备注")
|
|
|
|
|
|
class HomeworkRegisterItem(BaseModel):
|
|
"""按次登记-缺交学生"""
|
|
student_id: int = Field(..., gt=0, description="学生ID")
|
|
miss_count: int = Field(..., ge=1, le=99, description="缺交次数")
|
|
|
|
|
|
class HomeworkRegisterRequest(BaseModel):
|
|
"""作业按次登记请求"""
|
|
subject_id: int = Field(..., gt=0, description="科目ID")
|
|
title: Optional[str] = Field(None, max_length=100, description="作业名称/批次名")
|
|
deadline: date = Field(..., description="缴交/截止日期(用于统计归属)")
|
|
total_times: int = Field(..., ge=1, le=99, description="总提交次数")
|
|
per_deduction: Optional[int] = Field(None, ge=1, le=20, description="单次缺交扣分(默认取系统配置)")
|
|
note: Optional[str] = Field(None, max_length=100, description="备注")
|
|
records: List[HomeworkRegisterItem] = Field(default_factory=list, max_length=200, description="缺交学生与缺交次数(可为空,空=全班已交)")
|
|
|
|
|
|
class ResetPasswordRequest(BaseModel):
|
|
"""重置密码请求"""
|
|
new_password: str = Field(..., min_length=1, max_length=100, 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="用户名")
|
|
|
|
|
|
class EmailTestRequest(BaseModel):
|
|
"""邮件测试请求"""
|
|
email: str = Field(..., min_length=3, max_length=100, description="接收测试邮件的邮箱")
|
|
|
|
|
|
class PasswordPolicyRequest(BaseModel):
|
|
"""密码策略请求"""
|
|
min_length: int = Field(..., ge=4, le=64, description="密码最小长度")
|
|
max_length: int = Field(..., ge=8, le=100, description="密码最大长度")
|
|
min_types: int = Field(..., ge=1, le=4, description="最少字符种类数") |