修复bug,添加备案号悬挂功能

This commit is contained in:
2026-04-14 07:53:29 +08:00
parent 72bf0c32b8
commit 4b545ddcf9
5 changed files with 24 additions and 16 deletions

View File

@@ -82,6 +82,15 @@ class PermissionChecker:
role = await PermissionChecker.get_user_role(user_id)
return role in ["班主任", "学习委员"]
@staticmethod
async def get_user_class_id(user_id: int) -> Optional[int]:
"""
获取用户关联的班级ID
单班级系统固定返回1
"""
# 本系统为单班级设计class_id 固定为 1
return 1
@staticmethod
async def check_can_revoke(user_id: int, record_id: int) -> bool:
"""

View File

@@ -122,21 +122,12 @@ class StudentService:
class_id: Optional[int] = None,
limit: int = 50
) -> Dict[str, Any]:
"""获取排行榜"""
# 如果未指定班级,获取用户所在班级
if not class_id:
user = await StudentModel.get_by_id(user_id) if user_id else None
if user:
class_id = user["class_id"]
else:
admin_class = await PermissionChecker.get_user_class_id(user_id)
if admin_class:
class_id = admin_class
ranking = await StudentModel.get_ranking(class_id=class_id, limit=limit)
"""获取排行榜(单班级系统)"""
# 单班级系统,直接获取排行榜
ranking = await StudentModel.get_ranking(limit=limit)
return {
"class_id": class_id,
"class_id": class_id or 1,
"ranking": ranking
}