初始化
This commit is contained in:
@@ -0,0 +1,271 @@
|
||||
//acg模块网络请求
|
||||
|
||||
import 'package:hgdj/hj_model/acg/comic_chapters_model.dart';
|
||||
import 'package:hgdj/hj_model/list_base_model.dart';
|
||||
import 'package:hgdj/hj_model/video_model.dart';
|
||||
import 'package:hgdj/tools_base/net/http_manager.dart';
|
||||
|
||||
import '../../hj_model/acg/cartoon_more_list.dart';
|
||||
import '../../hj_model/cartoon_media_info.dart';
|
||||
import '../../hj_model/media_content.dart';
|
||||
|
||||
class ACGService {
|
||||
//获取动漫详情 种类 1、动漫,2、漫画
|
||||
static Future<CartoonMediaInfo?> getMediaInfo(String id) async {
|
||||
final param = {'id': id};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/info',
|
||||
param: param,
|
||||
jsonTransformation: (json) => CartoonMediaInfo.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
///动漫更多数据
|
||||
static Future<ListBaseModel<CartoonMediaInfo>?> getMoreCartoon(
|
||||
int pageNumber,
|
||||
int pageSize,
|
||||
int sortType, //排序 1最多播放,2、最新,3、 最多收藏 "
|
||||
String? tagID,
|
||||
) async {
|
||||
final param = {
|
||||
'tagID': tagID,
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'sortType': sortType,
|
||||
};
|
||||
param.removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
"/tag/media/list",
|
||||
param: param,
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<CartoonMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//加入书架
|
||||
static Future<bool> addBookshelf(String id) async {
|
||||
final param = {'id': id};
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/media_bookshelf/add',
|
||||
param: param,
|
||||
);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
/// 获取标签详情
|
||||
static Future<TagsBean?> fetchMediaTag(String tagId) async {
|
||||
final param = {'id': tagId};
|
||||
final result = await httpManager.fetchResponseByGET('/media_tag/info',
|
||||
param: param, jsonTransformation: (json) => TagsBean.fromMap(json));
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//移除书架
|
||||
static Future<bool> deleteBookshelf(String id) async {
|
||||
final param = {'id': id};
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/media_bookshelf/del',
|
||||
param: param,
|
||||
);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
//acg热门推荐 0-最新热播 1-本月最热 2-上月最热
|
||||
static Future<ListBaseModel<CartoonMediaInfo>?> fetchRecommend(
|
||||
int pageNumber,
|
||||
int pageSize, {
|
||||
String? mediaType = 'video',
|
||||
int? type = 0,
|
||||
}) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'mediaType': mediaType,
|
||||
'type': type,
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/hot',
|
||||
param: param,
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<CartoonMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//获取媒体书架列表 //排序 0、最新收藏 1.最近更新
|
||||
static Future<ListBaseModel<T>?> fetchAcgBooklib<T>(
|
||||
String type, {
|
||||
int page = 1,
|
||||
int size = 20,
|
||||
}) async {
|
||||
final param = {
|
||||
'pageNumber': page,
|
||||
'pageSize': size,
|
||||
'type': type,
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media_bookshelf/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<T>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
static Future<ListBaseModel<T>?> fetchAcgBuyData<T>(
|
||||
int pageNumber,
|
||||
int pageSize, {
|
||||
String? mediaType = 'video',
|
||||
}) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'mediaType': mediaType,
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/my_buy',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<T>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//acg日/周/人气等榜单 1-日榜 2-周榜 3-人气榜 4-热度榜 5-钻石榜 6-连载榜
|
||||
|
||||
static Future<ListBaseModel<CartoonMediaInfo>?> getRanking(
|
||||
int pageNumber,
|
||||
int pageSize, {
|
||||
String? mediaType = 'video', //video 动画 image 漫画 text 小说
|
||||
int? type = 1,
|
||||
}) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'mediaType': mediaType,
|
||||
'type': type,
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/ranking',
|
||||
param: param,
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<CartoonMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//获取动漫内容章节列表 sortType: 0-正序 1-倒序
|
||||
|
||||
static Future<ListBaseModel<ComicChapterInfo>?> getChapterList(
|
||||
String mediaId, int pageNumber, int pageSize,
|
||||
{int? sortType = 0}) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'mediaId': mediaId,
|
||||
'sortType': sortType,
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media_content/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<ComicChapterInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//动漫详情-推荐列表,相似作品
|
||||
static Future<ListBaseModel<CartoonMediaInfo>?> comicsRecommendList(
|
||||
int pageNumber,
|
||||
int pageSize, {
|
||||
String? tagId, //标签id
|
||||
String? mediaType, // 视频播放页时-必传 ACG类型: image, video
|
||||
String? mediaId, //标签id
|
||||
}) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'tagId': tagId,
|
||||
'mediaType': mediaType,
|
||||
'mediaId': mediaId,
|
||||
};
|
||||
param.removeWhere((k, v) => v == null); //去掉 null,避免发出 tagId=null 等脏参数
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/recommend',
|
||||
param: param,
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<CartoonMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//kind:1动漫 2漫画 3小说 4短剧
|
||||
//sortType:1-最新上架 2-最多观看
|
||||
static Future<MediaSearchListModel?> mediaSearch(
|
||||
{int page = 1,
|
||||
int size = 20,
|
||||
int? kind,
|
||||
String? tagName,
|
||||
int? sortType,
|
||||
String? keyword}) async {
|
||||
final param = {
|
||||
'pageNumber': page,
|
||||
'pageSize': size,
|
||||
'kind': kind,
|
||||
'tagName': tagName,
|
||||
'sortType': sortType,
|
||||
'keyword': keyword
|
||||
};
|
||||
param.removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/search',
|
||||
param: param,
|
||||
jsonTransformation: (json) => MediaSearchListModel.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//获取子集详情
|
||||
static Future<MediaContent?> getMediaDetail({
|
||||
String? id,
|
||||
int? episodeNumber,
|
||||
String? mediaId,
|
||||
}) async {
|
||||
final param = {
|
||||
'id': id,
|
||||
'episodeNumber': episodeNumber,
|
||||
'mediaId': mediaId,
|
||||
}..removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media_content/info',
|
||||
param: param,
|
||||
jsonTransformation: (json) => MediaContent.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
///动漫更多数据
|
||||
static Future<ListBaseModel<CartoonMediaInfo>?> getPreferences(
|
||||
int pageNumber,
|
||||
int pageSize, {
|
||||
String sId = '',
|
||||
int? sortType = 0, //排序 1-最新 2-最多观看 3-最多喜欢(收藏)
|
||||
int? type = 1, //0-默认专题这些页面获取 1-首页获取(猜你喜欢)
|
||||
}) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'sId': sId,
|
||||
'sortType': sortType,
|
||||
'type': type,
|
||||
};
|
||||
param.removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/topic',
|
||||
param: param,
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<CartoonMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user