2023-07-11 23:39:36 +08:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
|
|
|
|
import 'server.dart';
|
|
|
|
|
|
|
|
Future<Map<String, dynamic>> getMyProfile(String id) async {
|
|
|
|
Response response = await request.get(
|
|
|
|
'/user_profile/my',
|
|
|
|
queryParameters: {'id': id},
|
|
|
|
);
|
|
|
|
|
|
|
|
return response.data;
|
|
|
|
}
|
|
|
|
|
2023-10-21 21:25:09 +08:00
|
|
|
Future<Map<String, dynamic>> changeProfile(
|
2023-07-11 23:39:36 +08:00
|
|
|
String id,
|
2023-10-21 21:25:09 +08:00
|
|
|
String sign,
|
|
|
|
String status,
|
2023-07-11 23:39:36 +08:00
|
|
|
String nickname,
|
|
|
|
String birthday,
|
2023-10-21 21:25:09 +08:00
|
|
|
String location,
|
2023-07-11 23:39:36 +08:00
|
|
|
String gender,
|
|
|
|
) async {
|
2023-07-17 01:00:16 +08:00
|
|
|
Response response = await request.post('/user_profile/change/basic', data: {
|
2023-07-11 23:39:36 +08:00
|
|
|
'id': id,
|
2023-10-21 21:25:09 +08:00
|
|
|
'sign': sign,
|
|
|
|
'status': status,
|
2023-07-11 23:39:36 +08:00
|
|
|
'nickname': nickname,
|
|
|
|
'location': location,
|
|
|
|
'birthday': birthday,
|
|
|
|
'gender': gender,
|
|
|
|
});
|
|
|
|
return response.data;
|
|
|
|
}
|
|
|
|
|
2023-07-17 01:00:16 +08:00
|
|
|
Future<Map<String, dynamic>> changeSign(
|
2023-07-11 23:39:36 +08:00
|
|
|
String id,
|
|
|
|
String sign,
|
|
|
|
) async {
|
2023-10-06 16:43:51 +08:00
|
|
|
Response response = await request.post(
|
|
|
|
'/user_profile/change/sign',
|
|
|
|
data: {
|
|
|
|
'id': id,
|
|
|
|
'sign': sign,
|
|
|
|
},
|
|
|
|
);
|
2023-07-11 23:39:36 +08:00
|
|
|
return response.data;
|
|
|
|
}
|
|
|
|
|
2023-07-17 01:00:16 +08:00
|
|
|
Future<Map<String, dynamic>> changeAvatar(String id, Uint8List avatar) async {
|
2023-07-11 23:39:36 +08:00
|
|
|
Response response = await request.post(
|
2023-07-17 01:00:16 +08:00
|
|
|
'/user_profile/change/avatar',
|
2023-07-11 23:39:36 +08:00
|
|
|
data: {'file': avatar},
|
|
|
|
queryParameters: {
|
|
|
|
'id': id,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
return response.data;
|
|
|
|
}
|
|
|
|
|
2023-10-06 16:43:51 +08:00
|
|
|
Future<Map<String, dynamic>> changeStatus(String id, String status) async {
|
|
|
|
Response response = await request.post(
|
|
|
|
'/user_profile/change/status',
|
|
|
|
data: {
|
|
|
|
'id': id,
|
|
|
|
'status': status,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
return response.data;
|
|
|
|
}
|
|
|
|
|
2023-09-09 16:48:47 +08:00
|
|
|
Future<Uint8List> downloadUserAvatar(String avatarFilename) async {
|
2023-07-11 23:39:36 +08:00
|
|
|
Response response = await request.get(
|
2023-07-17 01:00:16 +08:00
|
|
|
'/user_profile/avatar',
|
|
|
|
queryParameters: {'avatar_filename': avatarFilename},
|
|
|
|
options: Options(responseType: ResponseType.bytes),
|
2023-07-11 23:39:36 +08:00
|
|
|
);
|
|
|
|
return response.data;
|
|
|
|
}
|
2023-07-27 18:17:52 +08:00
|
|
|
|
|
|
|
Future<Uint8List> downloadAvatars(List<String> avatars) async {
|
|
|
|
Response response = await request.get(
|
|
|
|
'/user_profile/avatars',
|
|
|
|
queryParameters: {'avatar_filename': avatars},
|
|
|
|
options: Options(responseType: ResponseType.bytes),
|
|
|
|
);
|
|
|
|
return response.data;
|
|
|
|
}
|