v0.6测试
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user