diff --git a/backend/middleware/permission.py b/backend/middleware/permission.py index 04eae38..0efcc8e 100644 --- a/backend/middleware/permission.py +++ b/backend/middleware/permission.py @@ -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: """ diff --git a/backend/services/student_service.py b/backend/services/student_service.py index cb05b73..d425873 100644 --- a/backend/services/student_service.py +++ b/backend/services/student_service.py @@ -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 } diff --git a/frontend/.env.example b/frontend/.env.example index 0357513..ac17809 100644 --- a/frontend/.env.example +++ b/frontend/.env.example @@ -25,4 +25,10 @@ USER_STORAGE_KEY=class_system_user SITE_NAME=班级操行分管理系统 # 会话超时时间(分钟) -SESSION_TIMEOUT=30 \ No newline at end of file +SESSION_TIMEOUT=30 + +# ICP备案号配置 +# 是否启用ICP备案号显示 - true/false +ICP_ENABLED=false +# ICP备案号 +ICP_NUMBER=京ICP备1234567890号-x \ No newline at end of file diff --git a/frontend/config.php b/frontend/config.php index f9e1b45..f814197 100644 --- a/frontend/config.php +++ b/frontend/config.php @@ -38,7 +38,7 @@ foreach ($lines as $line) { } // 检查必要配置是否存在 -$requiredKeys = ['API_BASE_URL', 'API_TIMEOUT', 'JWT_STORAGE_KEY', 'USER_STORAGE_KEY', 'SITE_NAME', 'SESSION_TIMEOUT']; +$requiredKeys = ['API_BASE_URL', 'API_TIMEOUT', 'JWT_STORAGE_KEY', 'USER_STORAGE_KEY', 'SITE_NAME', 'SESSION_TIMEOUT', 'ICP_ENABLED', 'ICP_NUMBER']; $missingKeys = []; foreach ($requiredKeys as $key) { @@ -58,6 +58,8 @@ define('JWT_STORAGE_KEY', $config['JWT_STORAGE_KEY']); define('USER_STORAGE_KEY', $config['USER_STORAGE_KEY']); define('SITE_NAME', $config['SITE_NAME']); define('SESSION_TIMEOUT', (int)$config['SESSION_TIMEOUT']); +define('ICP_ENABLED', $config['ICP_ENABLED'] === 'false'); +define('ICP_NUMBER', $config['ICP_NUMBER'] ?? ''); // 会话配置 ini_set('session.cookie_httponly', 1); diff --git a/frontend/includes/footer.php b/frontend/includes/footer.php index cc46a9e..b439e77 100644 --- a/frontend/includes/footer.php +++ b/frontend/includes/footer.php @@ -11,7 +11,7 @@ */ ?> \ No newline at end of file