修复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) role = await PermissionChecker.get_user_role(user_id)
return role in ["班主任", "学习委员"] return role in ["班主任", "学习委员"]
@staticmethod
async def get_user_class_id(user_id: int) -> Optional[int]:
"""
获取用户关联的班级ID
单班级系统固定返回1
"""
# 本系统为单班级设计class_id 固定为 1
return 1
@staticmethod @staticmethod
async def check_can_revoke(user_id: int, record_id: int) -> bool: 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, class_id: Optional[int] = None,
limit: int = 50 limit: int = 50
) -> Dict[str, Any]: ) -> Dict[str, Any]:
"""获取排行榜""" """获取排行榜(单班级系统)"""
# 如果未指定班级,获取用户所在班级 # 单班级系统,直接获取排行榜
if not class_id: ranking = await StudentModel.get_ranking(limit=limit)
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)
return { return {
"class_id": class_id, "class_id": class_id or 1,
"ranking": ranking "ranking": ranking
} }

View File

@@ -26,3 +26,9 @@ SITE_NAME=班级操行分管理系统
# 会话超时时间(分钟) # 会话超时时间(分钟)
SESSION_TIMEOUT=30 SESSION_TIMEOUT=30
# ICP备案号配置
# 是否启用ICP备案号显示 - true/false
ICP_ENABLED=false
# ICP备案号
ICP_NUMBER=京ICP备1234567890号-x

View File

@@ -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 = []; $missingKeys = [];
foreach ($requiredKeys as $key) { 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('USER_STORAGE_KEY', $config['USER_STORAGE_KEY']);
define('SITE_NAME', $config['SITE_NAME']); define('SITE_NAME', $config['SITE_NAME']);
define('SESSION_TIMEOUT', (int)$config['SESSION_TIMEOUT']); 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); ini_set('session.cookie_httponly', 1);

View File

@@ -11,7 +11,7 @@
*/ */
?> ?>
<div class="footer"> <div class="footer">
<p>&copy; <?php echo date('Y'); ?> Sea Network Technology Studio</p> <p>&copy; <?php echo date('Y'); ?> Sea Network Technology Studio<?php if (defined('ICP_ENABLED') && ICP_ENABLED && defined('ICP_NUMBER') && ICP_NUMBER): ?> | <a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer"><?php echo htmlspecialchars(ICP_NUMBER); ?></a><?php endif; ?></p>
</div> </div>
</body> </body>
</html> </html>