refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import '../../core/network/i_api_client.dart';
|
||||
import 'models/user_summary.dart';
|
||||
|
||||
abstract class UserRepository {
|
||||
Future<UserSummary> getById(String userId);
|
||||
Future<UserSummary> getMe();
|
||||
}
|
||||
|
||||
class UserRepositoryImpl implements UserRepository {
|
||||
final IApiClient _apiClient;
|
||||
static const _prefix = '/api/v1/users';
|
||||
|
||||
UserRepositoryImpl(this._apiClient);
|
||||
|
||||
@override
|
||||
Future<UserSummary> getById(String userId) async {
|
||||
final response = await _apiClient.get<Map<String, dynamic>>(
|
||||
'$_prefix/$userId',
|
||||
);
|
||||
final user = response.data;
|
||||
if (user == null) {
|
||||
throw StateError('Invalid getById response: empty payload');
|
||||
}
|
||||
return UserSummary.fromJson(user);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UserSummary> getMe() async {
|
||||
final response = await _apiClient.get<Map<String, dynamic>>('$_prefix/me');
|
||||
final user = response.data;
|
||||
if (user == null) {
|
||||
throw StateError('Invalid getMe response: empty payload');
|
||||
}
|
||||
return UserSummary.fromJson(user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user