mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
refa: query data (#659)
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -50,7 +50,7 @@ class BangumiHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> bangumiList({
|
||||
static Future<LoadingState<List<BangumiListItemModel>?>> bangumiList({
|
||||
int? page,
|
||||
int? indexType,
|
||||
}) async {
|
||||
@@ -67,7 +67,7 @@ class BangumiHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> bangumiFollowList({
|
||||
static Future<LoadingState<BangumiListDataModel>> bangumiFollowList({
|
||||
required dynamic mid,
|
||||
required int type,
|
||||
required int pn,
|
||||
@@ -80,12 +80,8 @@ class BangumiHttp {
|
||||
'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);
|
||||
return LoadingState.success(
|
||||
BangumiListDataModel.fromJson(res.data['data']));
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ import '../models/user/black.dart';
|
||||
import 'index.dart';
|
||||
|
||||
class BlackHttp {
|
||||
static Future<LoadingState> blackList({required int pn, int? ps}) async {
|
||||
static Future<LoadingState<BlackListDataModel>> blackList(
|
||||
{required int pn, int? ps}) async {
|
||||
var res = await Request().get(Api.blackLst, queryParameters: {
|
||||
'pn': pn,
|
||||
'ps': ps ?? 50,
|
||||
|
||||
@@ -8,7 +8,7 @@ import '../models/dynamics/up.dart';
|
||||
import 'index.dart';
|
||||
|
||||
class DynamicsHttp {
|
||||
static Future<LoadingState> followDynamic({
|
||||
static Future<LoadingState<DynamicsDataModel>> followDynamic({
|
||||
String? type,
|
||||
String? offset,
|
||||
int? mid,
|
||||
|
||||
@@ -4,7 +4,7 @@ import '../models/fans/result.dart';
|
||||
import 'index.dart';
|
||||
|
||||
class FanHttp {
|
||||
static Future<LoadingState> fans(
|
||||
static Future<LoadingState<FansDataModel>> fans(
|
||||
{int? vmid, int? pn, int? ps, String? orderType}) async {
|
||||
var res = await Request().get(Api.fans, queryParameters: {
|
||||
'vmid': vmid,
|
||||
|
||||
@@ -10,13 +10,13 @@ import 'api.dart';
|
||||
import 'init.dart';
|
||||
|
||||
class LiveHttp {
|
||||
static Future<LoadingState> liveList(
|
||||
static Future<LoadingState<List<LiveItemModel>?>> liveList(
|
||||
{int? vmid, int? pn, int? ps, String? orderType}) async {
|
||||
var res = await Request().get(Api.liveList,
|
||||
queryParameters: {'page': pn, 'page_size': 30, 'platform': 'web'});
|
||||
if (res.data['code'] == 0) {
|
||||
List<LiveItemModel> list = res.data['data']['list']
|
||||
.map<LiveItemModel>((e) => LiveItemModel.fromJson(e))
|
||||
List<LiveItemModel>? list = (res.data['data']?['list'] as List?)
|
||||
?.map<LiveItemModel>((e) => LiveItemModel.fromJson(e))
|
||||
.toList();
|
||||
return LoadingState.success(list);
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,9 @@ import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/space/data.dart';
|
||||
import 'package:PiliPlus/models/space_archive/data.dart' as space_archive;
|
||||
import 'package:PiliPlus/models/space_article/data.dart' as space_article;
|
||||
import 'package:PiliPlus/models/space/data.dart' as space_;
|
||||
import 'package:PiliPlus/models/space_fav/space_fav.dart';
|
||||
import 'package:PiliPlus/pages/member/new/content/member_contribute/member_contribute.dart'
|
||||
show ContributeType;
|
||||
@@ -62,7 +65,7 @@ class MemberHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> spaceArticle({
|
||||
static Future<LoadingState<space_article.Data>> spaceArticle({
|
||||
required int mid,
|
||||
required int page,
|
||||
}) async {
|
||||
@@ -138,13 +141,13 @@ class MemberHttp {
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']['items_lists']);
|
||||
return LoadingState.success(res.data['data']?['items_lists']);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> spaceArchive({
|
||||
static Future<LoadingState<space_archive.Data>> spaceArchive({
|
||||
required ContributeType type,
|
||||
required int? mid,
|
||||
String? aid,
|
||||
@@ -241,7 +244,7 @@ class MemberHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> space({
|
||||
static Future<LoadingState<space_.Data>> space({
|
||||
int? mid,
|
||||
dynamic fromViewAid,
|
||||
}) async {
|
||||
@@ -391,7 +394,7 @@ class MemberHttp {
|
||||
}
|
||||
|
||||
// 用户动态
|
||||
static Future<LoadingState> memberDynamic({
|
||||
static Future<LoadingState<DynamicsDataModel>> memberDynamic({
|
||||
String? offset,
|
||||
int? mid,
|
||||
}) async {
|
||||
@@ -601,7 +604,8 @@ class MemberHttp {
|
||||
}
|
||||
|
||||
// 最近投币
|
||||
static Future<LoadingState> getRecentCoinVideo({required int mid}) async {
|
||||
static Future<LoadingState<List<MemberCoinsDataModel>?>> getRecentCoinVideo(
|
||||
{required int mid}) async {
|
||||
Map params = await WbiSign.makSign({
|
||||
'mid': mid,
|
||||
'gaia_source': 'main_web',
|
||||
@@ -618,16 +622,18 @@ class MemberHttp {
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']
|
||||
.map<MemberCoinsDataModel>((e) => MemberCoinsDataModel.fromJson(e))
|
||||
.toList());
|
||||
List<MemberCoinsDataModel>? list = (res.data['data'] as List?)
|
||||
?.map<MemberCoinsDataModel>((e) => MemberCoinsDataModel.fromJson(e))
|
||||
.toList();
|
||||
return LoadingState.success(list);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
// 最近点赞
|
||||
static Future<LoadingState> getRecentLikeVideo({required int mid}) async {
|
||||
static Future<LoadingState<List<MemberCoinsDataModel>?>> getRecentLikeVideo(
|
||||
{required int mid}) async {
|
||||
Map params = await WbiSign.makSign({
|
||||
'mid': mid,
|
||||
'gaia_source': 'main_web',
|
||||
@@ -644,9 +650,10 @@ class MemberHttp {
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']['list']
|
||||
.map<MemberCoinsDataModel>((e) => MemberCoinsDataModel.fromJson(e))
|
||||
.toList());
|
||||
List<MemberCoinsDataModel>? list = (res.data['data']?['list'] as List?)
|
||||
?.map<MemberCoinsDataModel>((e) => MemberCoinsDataModel.fromJson(e))
|
||||
.toList();
|
||||
return LoadingState.success(list);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import 'api.dart';
|
||||
import 'init.dart';
|
||||
|
||||
class MsgHttp {
|
||||
static Future<LoadingState> msgFeedReplyMe(
|
||||
static Future<LoadingState<MsgFeedReplyMe>> msgFeedReplyMe(
|
||||
{int cursor = -1, int cursorTime = -1}) async {
|
||||
var res = await Request().get(Api.msgFeedReply, queryParameters: {
|
||||
'id': cursor == -1 ? null : cursor,
|
||||
@@ -34,7 +34,7 @@ class MsgHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> msgFeedAtMe(
|
||||
static Future<LoadingState<MsgFeedAtMe>> msgFeedAtMe(
|
||||
{int cursor = -1, int cursorTime = -1}) async {
|
||||
var res = await Request().get(Api.msgFeedAt, queryParameters: {
|
||||
'id': cursor == -1 ? null : cursor,
|
||||
@@ -51,7 +51,7 @@ class MsgHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> msgFeedLikeMe(
|
||||
static Future<LoadingState<MsgFeedLikeMe>> msgFeedLikeMe(
|
||||
{int cursor = -1, int cursorTime = -1}) async {
|
||||
var res = await Request().get(Api.msgFeedLike, queryParameters: {
|
||||
'id': cursor == -1 ? null : cursor,
|
||||
@@ -68,7 +68,7 @@ class MsgHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> msgFeedNotify(
|
||||
static Future<LoadingState<List<SystemNotifyList>?>> msgFeedNotify(
|
||||
{int cursor = -1, int pageSize = 20}) async {
|
||||
var res = await Request().get(Api.msgSysNotify, queryParameters: {
|
||||
'cursor': cursor == -1 ? null : cursor,
|
||||
|
||||
@@ -124,7 +124,7 @@ class ReplyHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> replyListGrpc({
|
||||
static Future<LoadingState<MainListReply>> replyListGrpc({
|
||||
int type = 1,
|
||||
required int oid,
|
||||
required CursorReq cursor,
|
||||
@@ -387,7 +387,8 @@ class ReplyHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> getEmoteList({String? business}) async {
|
||||
static Future<LoadingState<List<Packages>?>> getEmoteList(
|
||||
{String? business}) async {
|
||||
var res = await Request().get(Api.myEmote, queryParameters: {
|
||||
'business': business ?? 'reply',
|
||||
'web_location': '333.1245',
|
||||
|
||||
@@ -160,7 +160,8 @@ class SearchHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> bangumiInfoNew({int? seasonId, int? epId}) async {
|
||||
static Future<LoadingState<BangumiInfoModel>> bangumiInfoNew(
|
||||
{int? seasonId, int? epId}) async {
|
||||
final dynamic res = await Request().get(
|
||||
Api.bangumiInfo,
|
||||
queryParameters: {
|
||||
|
||||
@@ -46,7 +46,7 @@ class UserHttp {
|
||||
}
|
||||
|
||||
// 收藏夹
|
||||
static Future<LoadingState> userfavFolder({
|
||||
static Future<LoadingState<FavFolderData>> userfavFolder({
|
||||
required int pn,
|
||||
required int ps,
|
||||
required dynamic mid,
|
||||
@@ -170,7 +170,7 @@ class UserHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> userFavFolderDetail(
|
||||
static Future<LoadingState<FavDetailData>> userFavFolderDetail(
|
||||
{required int mediaId,
|
||||
required int pn,
|
||||
required int ps,
|
||||
@@ -195,7 +195,7 @@ class UserHttp {
|
||||
}
|
||||
|
||||
// 稍后再看
|
||||
static Future<LoadingState> seeYouLater() async {
|
||||
static Future<LoadingState<Map>> seeYouLater() async {
|
||||
var res = await Request().get(Api.seeYouLater);
|
||||
if (res.data['code'] == 0) {
|
||||
if (res.data['data']['count'] == 0) {
|
||||
@@ -220,7 +220,7 @@ class UserHttp {
|
||||
}
|
||||
|
||||
// 观看历史
|
||||
static Future<LoadingState> historyList({
|
||||
static Future<LoadingState<HistoryData>> historyList({
|
||||
required String type,
|
||||
int? max,
|
||||
int? viewAt,
|
||||
@@ -426,7 +426,7 @@ class UserHttp {
|
||||
}
|
||||
|
||||
// 我的订阅
|
||||
static Future<LoadingState> userSubFolder({
|
||||
static Future<LoadingState<List<SubFolderItemData>?>> userSubFolder({
|
||||
required int mid,
|
||||
required int pn,
|
||||
required int ps,
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:developer';
|
||||
import 'package:PiliPlus/grpc/app/card/v1/card.pb.dart' as card;
|
||||
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/member/article.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -145,7 +146,7 @@ class VideoHttp {
|
||||
}
|
||||
|
||||
// 最热视频
|
||||
static Future<LoadingState> hotVideoList(
|
||||
static Future<LoadingState<List<HotVideoItemModel>>> hotVideoList(
|
||||
{required int pn, required int ps}) async {
|
||||
var res = await Request().get(
|
||||
Api.hotList,
|
||||
@@ -345,15 +346,16 @@ class VideoHttp {
|
||||
}
|
||||
|
||||
// 相关视频
|
||||
static Future<LoadingState> relatedVideoList({required String bvid}) async {
|
||||
static Future<LoadingState<List<HotVideoItemModel>?>> relatedVideoList(
|
||||
{required String bvid}) async {
|
||||
var res =
|
||||
await Request().get(Api.relatedList, queryParameters: {'bvid': bvid});
|
||||
if (res.data['code'] == 0) {
|
||||
final items =
|
||||
(res.data['data'] as List).map((i) => HotVideoItemModel.fromJson(i));
|
||||
final items = (res.data['data'] as List?)
|
||||
?.map((i) => HotVideoItemModel.fromJson(i));
|
||||
final list = RecommendFilter.applyFilterToRelatedVideos
|
||||
? items.where((i) => !RecommendFilter.filterAll(i)).toList()
|
||||
: items.toList();
|
||||
? items?.where((i) => !RecommendFilter.filterAll(i)).toList()
|
||||
: items?.toList();
|
||||
return LoadingState.success(list);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
@@ -1046,7 +1048,8 @@ class VideoHttp {
|
||||
}
|
||||
|
||||
// 视频排行
|
||||
static Future<LoadingState> getRankVideoList(int rid) async {
|
||||
static Future<LoadingState<List<HotVideoItemModel>>> getRankVideoList(
|
||||
int rid) async {
|
||||
var rankApi = "${Api.getRankApi}?rid=$rid&type=all";
|
||||
var res = await Request().get(rankApi);
|
||||
if (res.data['code'] == 0) {
|
||||
@@ -1094,7 +1097,7 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> noteList({
|
||||
static Future<LoadingState<List<FavArticleModel>?>> noteList({
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
@@ -1106,13 +1109,16 @@ class VideoHttp {
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']?['list']);
|
||||
List<FavArticleModel>? list = (res.data['data']?['list'] as List?)
|
||||
?.map((e) => FavArticleModel.fromJson(e))
|
||||
.toList();
|
||||
return LoadingState.success(list);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> userNoteList({
|
||||
static Future<LoadingState<List<FavArticleModel>?>> userNoteList({
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
@@ -1124,7 +1130,10 @@ class VideoHttp {
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']?['list']);
|
||||
List<FavArticleModel>? list = (res.data['data']?['list'] as List?)
|
||||
?.map((e) => FavArticleModel.fromJson(e))
|
||||
.toList();
|
||||
return LoadingState.success(list);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user