v0.8测试

This commit is contained in:
2026-04-16 07:55:46 +08:00
parent 7c743293be
commit c8262cf92e
16 changed files with 84 additions and 39 deletions

View File

@@ -32,7 +32,8 @@ class AttendanceService:
status: str,
reason: Optional[str],
apply_deduction: bool,
recorder_id: int
recorder_id: int,
custom_deduction: Optional[int] = None
) -> Dict[str, Any]:
"""添加考勤记录"""
# 检查权限
@@ -57,8 +58,10 @@ class AttendanceService:
# 应用扣分
if apply_deduction and status in ["absent", "late", "leave"]:
# 确定扣分数值
if status == "absent":
# 确定扣分数值(优先使用自定义扣分)
if custom_deduction is not None:
points_change = -custom_deduction
elif status == "absent":
points_change = -settings.DEDUCTION_ATTENDANCE_ABSENT
elif status == "late":
points_change = -settings.DEDUCTION_ATTENDANCE_LATE

View File

@@ -55,6 +55,10 @@ class ConductService:
# 劳动委员固定 ±1分
if points_change not in [settings.LABOR_POINTS_ADD, settings.LABOR_POINTS_SUBTRACT]:
return {"success": False, "message": "劳动委员只能进行±1分操作"}
elif role == "志愿委员":
# 志愿委员只能加分,不限制正分上限
if points_change < 0:
return {"success": False, "message": "志愿委员只能加分"}
elif role in ["学习委员", "考勤委员"]:
# 学习委员和考勤委员只能扣分
if points_change > 0:
@@ -147,8 +151,8 @@ class ConductService:
role = await PermissionChecker.get_user_role(user_id)
offset = (page - 1) * page_size
# 班主任/班长可查看全班
if role in ["班主任", "班长"]:
# 班主任/班长/志愿委员可查看全班
if role in ["班主任", "班长", "志愿委员"]:
records = await ConductModel.get_all_records(
limit=page_size,
offset=offset,