mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
94 lines
2.5 KiB
Dart
94 lines
2.5 KiB
Dart
import 'package:PiliPlus/http/loading_state.dart';
|
|
|
|
import '../models/bangumi/list.dart';
|
|
import '../models/bangumi/pgc_index/condition.dart';
|
|
import 'index.dart';
|
|
|
|
class BangumiHttp {
|
|
static Future<LoadingState> pgcIndexResult({
|
|
required int page,
|
|
required Map<String, dynamic> params,
|
|
seasonType,
|
|
type,
|
|
indexType,
|
|
}) async {
|
|
dynamic res = await Request().get(
|
|
Api.pgcIndexResult,
|
|
queryParameters: {
|
|
...params,
|
|
if (seasonType != null) 'season_type': seasonType,
|
|
if (type != null) 'type': type,
|
|
if (indexType != null) 'index_type': indexType,
|
|
'page': page,
|
|
'pagesize': 21,
|
|
},
|
|
);
|
|
if (res.data['code'] == 0) {
|
|
return LoadingState.success(res.data['data']);
|
|
} else {
|
|
return LoadingState.error(res.data['message']);
|
|
}
|
|
}
|
|
|
|
static Future<LoadingState> pgcIndexCondition({
|
|
seasonType,
|
|
type,
|
|
indexType,
|
|
}) async {
|
|
dynamic res = await Request().get(
|
|
Api.pgcIndexCondition,
|
|
queryParameters: {
|
|
if (seasonType != null) 'season_type': seasonType,
|
|
if (type != null) 'type': type,
|
|
if (indexType != null) 'index_type': indexType,
|
|
},
|
|
);
|
|
if (res.data['code'] == 0) {
|
|
return LoadingState.success(Condition.fromJson(res.data['data']));
|
|
} else {
|
|
return LoadingState.error(res.data['message']);
|
|
}
|
|
}
|
|
|
|
static Future<LoadingState> bangumiList({
|
|
int? page,
|
|
int? indexType,
|
|
}) async {
|
|
var res = await Request().get(Api.bangumiList, queryParameters: {
|
|
'page': page,
|
|
if (indexType != null) 'index_type': indexType,
|
|
});
|
|
if (res.data['code'] == 0) {
|
|
BangumiListDataModel data =
|
|
BangumiListDataModel.fromJson(res.data['data']);
|
|
return LoadingState.success(data.list);
|
|
} else {
|
|
return LoadingState.error(res.data['message']);
|
|
}
|
|
}
|
|
|
|
static Future<LoadingState> bangumiFollowList({
|
|
required dynamic mid,
|
|
required int type,
|
|
required int pn,
|
|
int? followStatus,
|
|
}) async {
|
|
var res = await Request().get(Api.bangumiFollowList, queryParameters: {
|
|
'vmid': mid,
|
|
'type': type,
|
|
if (followStatus != null) 'follow_status': followStatus,
|
|
'pn': pn,
|
|
});
|
|
if (res.data['code'] == 0) {
|
|
BangumiListDataModel data =
|
|
BangumiListDataModel.fromJson(res.data['data']);
|
|
if (followStatus != null) {
|
|
return LoadingState.success(data.list);
|
|
}
|
|
return LoadingState.success(data);
|
|
} else {
|
|
return LoadingState.error(res.data['message']);
|
|
}
|
|
}
|
|
}
|