v0.6测试
This commit is contained in:
@@ -77,6 +77,9 @@ class AttendanceService:
|
||||
related_id=attendance_id
|
||||
)
|
||||
|
||||
# 更新学生总分
|
||||
await StudentModel.update_total_points(student_id, points_change)
|
||||
|
||||
# 标记已应用扣分
|
||||
await AttendanceModel.mark_deduction_applied(attendance_id)
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ class ConductService:
|
||||
# 劳动委员固定 ±1分
|
||||
if points_change not in [settings.LABOR_POINTS_ADD, settings.LABOR_POINTS_SUBTRACT]:
|
||||
return {"success": False, "message": "劳动委员只能进行±1分操作"}
|
||||
elif role in ["科代表", "考勤委员"]:
|
||||
# 科代表和考勤委员只能扣分
|
||||
elif role in ["学习委员", "考勤委员"]:
|
||||
# 学习委员和考勤委员只能扣分
|
||||
if points_change > 0:
|
||||
return {"success": False, "message": "该角色只能进行扣分操作"}
|
||||
else:
|
||||
@@ -85,6 +85,9 @@ class ConductService:
|
||||
recorder_name=recorder_name
|
||||
)
|
||||
|
||||
# 更新学生总分
|
||||
await StudentModel.update_total_points(student_id, points_change)
|
||||
|
||||
details.append({"student_id": student_id, "success": True, "record_id": record_id})
|
||||
success_count += 1
|
||||
|
||||
@@ -109,10 +112,17 @@ class ConductService:
|
||||
if not can_revoke:
|
||||
return {"success": False, "message": "无权撤销此记录"}
|
||||
|
||||
# 先获取原记录信息(用于恢复分数)
|
||||
record = await ConductModel.get_record_by_id(record_id)
|
||||
if not record:
|
||||
return {"success": False, "message": "记录不存在"}
|
||||
|
||||
# 撤销记录
|
||||
result = await ConductModel.revoke_record(record_id, revoker_id)
|
||||
|
||||
if result:
|
||||
# 反向恢复学生总分
|
||||
await StudentModel.update_total_points(record["student_id"], -record["points_change"])
|
||||
logger.info(f"用户[{revoker_id}] 撤销了记录[{record_id}]")
|
||||
return {"success": True, "message": "撤销成功"}
|
||||
else:
|
||||
|
||||
@@ -32,7 +32,7 @@ class HomeworkService:
|
||||
|
||||
if role == "班主任":
|
||||
assignments = await HomeworkModel.get_all_assignments()
|
||||
elif role == "科代表":
|
||||
elif role == "学习委员":
|
||||
subject_ids = await PermissionChecker.get_user_subject_ids(user_id)
|
||||
assignments = await HomeworkModel.get_assignments_by_subjects(subject_ids)
|
||||
else:
|
||||
@@ -79,7 +79,7 @@ class HomeworkService:
|
||||
|
||||
# 检查权限
|
||||
role = await PermissionChecker.get_user_role(operator_id)
|
||||
if role == "科代表":
|
||||
if role == "学习委员":
|
||||
# 检查是否管理该科目
|
||||
subject_ids = await PermissionChecker.get_user_subject_ids(operator_id)
|
||||
if submission["subject_id"] not in subject_ids:
|
||||
@@ -118,6 +118,9 @@ class HomeworkService:
|
||||
related_id=submission["assignment_id"]
|
||||
)
|
||||
|
||||
# 更新学生总分
|
||||
await StudentModel.update_total_points(submission["student_id"], points_change)
|
||||
|
||||
# 标记已应用扣分
|
||||
await HomeworkModel.mark_deduction_applied(submission_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user