fix(admin-app): fix dynamic→int type errors in service files
- notification_service: cast total/unreadCount in NotificationListResponse, cast count in getUnreadCount/getAnnouncementUnreadCount (Future<int>) - auth_service: fix unsafe (value ?? 300) as int → (value as int?) ?? 300 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
af5aba8efe
commit
89dbdb55b8
|
|
@ -28,7 +28,7 @@ class AuthService {
|
|||
});
|
||||
final data = response.data is Map<String, dynamic> ? response.data : {};
|
||||
final inner = data['data'] ?? data;
|
||||
return (inner is Map<String, dynamic>) ? (inner['expiresIn'] ?? 300) as int : 300;
|
||||
return (inner is Map<String, dynamic>) ? (inner['expiresIn'] as int?) ?? 300 : 300;
|
||||
} catch (e) {
|
||||
debugPrint('[AuthService] sendSmsCode 失败: $e');
|
||||
rethrow;
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ class NotificationListResponse {
|
|||
[];
|
||||
return NotificationListResponse(
|
||||
notifications: list,
|
||||
total: data['total'] ?? list.length,
|
||||
unreadCount: data['unreadCount'] ?? 0,
|
||||
total: (data['total'] as int?) ?? list.length,
|
||||
unreadCount: (data['unreadCount'] as int?) ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ class NotificationService {
|
|||
try {
|
||||
final response = await _apiClient.get('/api/v1/notifications/unread-count');
|
||||
final data = response.data is Map<String, dynamic> ? response.data : {};
|
||||
return data['data']?['count'] ?? data['count'] ?? 0;
|
||||
return (data['data']?['count'] as int?) ?? (data['count'] as int?) ?? 0;
|
||||
} catch (e) {
|
||||
debugPrint('[NotificationService] 获取未读数量失败: $e');
|
||||
return 0;
|
||||
|
|
@ -205,7 +205,7 @@ class NotificationService {
|
|||
try {
|
||||
final response = await _apiClient.get('/api/v1/announcements/unread-count');
|
||||
final data = response.data is Map<String, dynamic> ? response.data : {};
|
||||
return data['data']?['count'] ?? data['count'] ?? 0;
|
||||
return (data['data']?['count'] as int?) ?? (data['count'] as int?) ?? 0;
|
||||
} catch (e) {
|
||||
debugPrint('[NotificationService] 获取公告未读数失败: $e');
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue