e4e995854d
- 新增忘记密码页面与重置密码确认流程(前端+后端) - 修复注册验证码页登录跳转路由 - 新增用户搜索API(按邮箱查询) - 简化infra脚本,统一为app.sh - 补充密码重置与用户API测试覆盖 - 更新runtime文档与AGENTS配置
29 lines
842 B
Dart
29 lines
842 B
Dart
import 'package:social_app/core/api/api_client.dart';
|
|
import 'models/user_response.dart';
|
|
|
|
class UsersApi {
|
|
final ApiClient _client;
|
|
static const _prefix = '/api/v1/users';
|
|
|
|
UsersApi(this._client);
|
|
|
|
Future<UserResponse> getMe() async {
|
|
final response = await _client.get('$_prefix/me');
|
|
return UserResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<UserResponse> updateMe(UserUpdateRequest request) async {
|
|
final response = await _client.patch('$_prefix/me', data: request.toJson());
|
|
return UserResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<List<UserResponse>> searchUsers(String query) async {
|
|
final response = await _client.post(
|
|
'$_prefix/search',
|
|
data: {'query': query},
|
|
);
|
|
final List<dynamic> data = response.data;
|
|
return data.map((json) => UserResponse.fromJson(json)).toList();
|
|
}
|
|
}
|