更新v1.4版本,修复了一些已知问题

This commit is contained in:
2026-04-28 03:16:17 +08:00
parent 76088b0dd4
commit 3aac2395a0
26 changed files with 342 additions and 151 deletions

View File

@@ -296,9 +296,8 @@ class AdminService:
if not user:
return {"success": False, "message": "未找到对应的用户账号"}
password_hash = security.sha1_md5_password(new_password)
result = await UserModel.update_password(user['user_id'], password_hash)
# UserModel.update_password 内部会进行哈希,无需预先哈希
result = await UserModel.update_password(user['user_id'], new_password)
if result:
await execute_update(
"UPDATE users SET need_change_password = 1 WHERE user_id = %s",

View File

@@ -89,14 +89,17 @@ class AttendanceService:
points_change = -settings.DEDUCTION_ATTENDANCE_LATE
else:
points_change = -settings.DEDUCTION_ATTENDANCE_LEAVE
# 创建扣分记录
# 扣分为0时跳过如请假不扣分
if points_change == 0:
logger.info(f"用户[{recorder_id}] 添加考勤记录[{attendance_id}] -> {status} (不扣分)")
return {"success": True, "message": "考勤记录添加成功(不扣分)"}
student = await StudentModel.get_by_id(student_id)
if student:
# 获取操作人姓名
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,

View File

@@ -115,8 +115,10 @@ class ConductService:
details.append({"student_id": student_id, "error": str(e)})
fail_count += 1
message = "操作成功" if fail_count == 0 else f"{success_count}人成功,{fail_count}人失败"
return {
"success": fail_count == 0,
"message": message,
"success_count": success_count,
"fail_count": fail_count,
"details": details
@@ -278,7 +280,7 @@ class ConductService:
limit=page_size,
offset=offset
)
total = len(await ConductModel.get_student_records(student_id, limit=10000))
total = await ConductModel.count_student_records(student_id)
else:
# 查看自己提交的记录
records = await ConductModel.get_records_by_recorder(
@@ -286,7 +288,7 @@ class ConductService:
limit=page_size,
offset=offset
)
total = len(await ConductModel.get_records_by_recorder(user_id, limit=10000))
total = await ConductModel.count_records_by_recorder(user_id)
return {
"records": records,

View File

@@ -135,9 +135,8 @@ class ParentService:
offset=offset
)
# 获取总数
all_records = await ConductModel.get_student_records(user["student_id"], limit=10000)
total = len(all_records)
# 使用 COUNT 查询获取总数(避免获取全部记录)
total = await ConductModel.count_student_records(user["student_id"])
return {
"student_id": student["student_id"],