You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
import 'package:dio/dio.dart';
|
|
import '../models/user_stats_bean.dart';
|
|
|
|
const String _LikesNumURL = 'http://8.210.250.29:10010/likes/user-like-num';
|
|
const String _CollectionsNumURL = 'http://8.210.250.29:10010/collections/user-collection-num';
|
|
const String _UploadsNumURL = 'http://8.210.250.29:10010/musics/upload-music-num';
|
|
|
|
class UserStatsApi {
|
|
final Dio dio = Dio();
|
|
|
|
/// 获取用户点赞数量
|
|
Future<UserStatsBean> getLikesNum({required String Authorization}) async {
|
|
try {
|
|
Response response = await dio.get(
|
|
_LikesNumURL,
|
|
options: Options(
|
|
headers: {
|
|
'Authorization': Authorization,
|
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
}
|
|
),
|
|
);
|
|
return UserStatsBean.fromMap(response.data);
|
|
} catch (e) {
|
|
print('获取点赞数量失败: $e');
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
/// 获取用户收藏数量
|
|
Future<UserStatsBean> getCollectionsNum({required String Authorization}) async {
|
|
try {
|
|
Response response = await dio.get(
|
|
_CollectionsNumURL,
|
|
options: Options(
|
|
headers: {
|
|
'Authorization': Authorization,
|
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
}
|
|
),
|
|
);
|
|
return UserStatsBean.fromMap(response.data);
|
|
} catch (e) {
|
|
print('获取收藏数量失败: $e');
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
/// 获取用户上传歌曲数量
|
|
Future<UserStatsBean> getUploadsNum({required String Authorization}) async {
|
|
try {
|
|
Response response = await dio.get(
|
|
_UploadsNumURL,
|
|
options: Options(
|
|
headers: {
|
|
'Authorization': Authorization,
|
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
}
|
|
),
|
|
);
|
|
return UserStatsBean.fromMap(response.data);
|
|
} catch (e) {
|
|
print('获取上传数量失败: $e');
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|