修复bug,添加备案号悬挂功能
This commit is contained in:
@@ -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:
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user