修复考勤管理bug并加强了信息保护
This commit is contained in:
@@ -82,11 +82,12 @@ class AttendanceService:
|
||||
user = await UserModel.get_by_user_id(recorder_id)
|
||||
recorder_name = user.get("real_name", "班主任") if user else "班主任"
|
||||
# 使用中文状态
|
||||
# 使用中文状态
|
||||
status_text = ATTENDANCE_STATUS_MAP.get(status, status)
|
||||
await ConductModel.create_record(
|
||||
student_id=student_id,
|
||||
points_change=points_change,
|
||||
reason=f"考勤异常: {status_text}",
|
||||
reason=f"考勤:{status_text}",
|
||||
recorder_id=recorder_id,
|
||||
recorder_name=recorder_name,
|
||||
related_type="attendance",
|
||||
@@ -98,8 +99,6 @@ class AttendanceService:
|
||||
|
||||
# 标记已应用扣分
|
||||
await AttendanceModel.mark_deduction_applied(attendance_id)
|
||||
await AttendanceModel.mark_deduction_applied(attendance_id)
|
||||
|
||||
logger.info(f"用户[{recorder_id}] 添加考勤记录[{attendance_id}] -> {status}")
|
||||
|
||||
return {"success": True, "message": "考勤记录添加成功"}
|
||||
|
||||
@@ -76,7 +76,8 @@ class AuthService:
|
||||
username=user["username"],
|
||||
user_type=user["user_type"],
|
||||
student_id=user["student_id"],
|
||||
role=role
|
||||
role=role,
|
||||
real_name=user["real_name"]
|
||||
)
|
||||
|
||||
# 存储Token到Redis
|
||||
|
||||
@@ -196,7 +196,8 @@ class ConductService:
|
||||
page_size: int = 20,
|
||||
start_date: Optional[str] = None,
|
||||
end_date: Optional[str] = None,
|
||||
grouped: bool = False
|
||||
grouped: bool = False,
|
||||
related_type: Optional[str] = None
|
||||
) -> Dict[str, Any]:
|
||||
"""获取历史记录"""
|
||||
# 空字符串转为None
|
||||
@@ -204,6 +205,8 @@ class ConductService:
|
||||
start_date = None
|
||||
if end_date == "":
|
||||
end_date = None
|
||||
if related_type == "":
|
||||
related_type = None
|
||||
|
||||
role = await PermissionChecker.get_user_role(user_id)
|
||||
offset = (page - 1) * page_size
|
||||
@@ -224,7 +227,8 @@ class ConductService:
|
||||
offset=offset,
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
student_id=student_id
|
||||
student_id=student_id,
|
||||
related_type=related_type
|
||||
)
|
||||
|
||||
# 获取总数
|
||||
@@ -240,6 +244,9 @@ class ConductService:
|
||||
if end_date:
|
||||
count_conditions.append("DATE(cr.created_at) <= %s")
|
||||
count_params.append(end_date)
|
||||
if related_type:
|
||||
count_conditions.append("cr.related_type = %s")
|
||||
count_params.append(related_type)
|
||||
count_where = " AND ".join(count_conditions)
|
||||
count_sql = f"""
|
||||
SELECT COUNT(*) as total FROM conduct_records cr
|
||||
|
||||
Reference in New Issue
Block a user