logo和名称替换
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:hgmj/hj_model/drama/drama_models.dart';
|
||||
import 'package:hgmj/hj_model/drama_media_info.dart';
|
||||
import 'package:hgmj/hj_model/list_base_model.dart';
|
||||
import 'package:hgmj/hj_model/media_content.dart';
|
||||
import 'package:hgmj/tools_base/net/base_resp_bean.dart';
|
||||
import 'package:hgmj/tools_base/net/http_manager.dart';
|
||||
import 'package:wydj/hj_model/drama/drama_models.dart';
|
||||
import 'package:wydj/hj_model/drama_media_info.dart';
|
||||
import 'package:wydj/hj_model/list_base_model.dart';
|
||||
import 'package:wydj/hj_model/media_content.dart';
|
||||
import 'package:wydj/tools_base/net/base_resp_bean.dart';
|
||||
import 'package:wydj/tools_base/net/http_manager.dart';
|
||||
|
||||
/// 短剧接口。金币解锁已并入 PayManager/BuyService,这里只剩读操作 + 两个计数型写操作:
|
||||
/// 信息流翻页去重、分享互动计数,都必须带 `X-Request-ID`——同一次业务的重试要复用同一个 id,
|
||||
/// 换新 id 就会重复计数。
|
||||
class DramaService {
|
||||
static Options _idempotent(String requestId) => Options(headers: {'X-Request-ID': requestId});
|
||||
static Options _idempotent(String requestId) =>
|
||||
Options(headers: {'X-Request-ID': requestId});
|
||||
|
||||
/// AI短剧信息流:一条 = 一部剧 + 该剧第 1 集。
|
||||
/// 排序、去重、已看沉底全在服务端,客户端不得二次排序,也不分页页码——每次请求都是下一批
|
||||
static Future<ListBaseModel<DramaFeedItem>?> fetchFeed({int size = 20, String? requestId}) async {
|
||||
static Future<ListBaseModel<DramaFeedItem>?> fetchFeed(
|
||||
{int size = 20, String? requestId}) async {
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/drama/feed',
|
||||
param: {'pageSize': size},
|
||||
@@ -29,7 +31,10 @@ class DramaService {
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/drama/topics',
|
||||
jsonTransformation: (json) =>
|
||||
(json['list'] as List?)?.map((e) => DramaTopic.fromJson(e)).toList() ?? <DramaTopic>[],
|
||||
(json['list'] as List?)
|
||||
?.map((e) => DramaTopic.fromJson(e))
|
||||
.toList() ??
|
||||
<DramaTopic>[],
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
@@ -48,7 +53,8 @@ class DramaService {
|
||||
'pageNumber': page,
|
||||
'pageSize': size,
|
||||
},
|
||||
jsonTransformation: (json) => ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
@@ -104,17 +110,24 @@ class DramaService {
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/media/library/search',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
/// 分集列表(选集面板用) [sortType] 0-正序 1-倒序
|
||||
static Future<ListBaseModel<MediaContent>?> fetchEpisodeList(String dramaId, int page, int size) async {
|
||||
static Future<ListBaseModel<MediaContent>?> fetchEpisodeList(
|
||||
String dramaId, int page, int size) async {
|
||||
if (dramaId.isEmpty) return null; // 与 fetchDetail 一致:没有剧 id 就别发空请求
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media_content/list',
|
||||
param: {'mediaId': dramaId, 'pageNumber': page, 'pageSize': size, 'sortType': 0},
|
||||
param: {
|
||||
'mediaId': dramaId,
|
||||
'pageNumber': page,
|
||||
'pageSize': size,
|
||||
'sortType': 0
|
||||
},
|
||||
jsonTransformation: (json) => ListBaseModel<MediaContent>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
@@ -133,31 +146,42 @@ class DramaService {
|
||||
}
|
||||
|
||||
/// 我的喜欢-短剧
|
||||
static Future<ListBaseModel<DramaMediaInfo>?> fetchLikes(int page, {int size = 20}) async {
|
||||
static Future<ListBaseModel<DramaMediaInfo>?> fetchLikes(int page,
|
||||
{int size = 20}) async {
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/mine/like',
|
||||
param: {'likeType': 'drama', 'pageNumber': page, 'pageSize': size},
|
||||
jsonTransformation: (json) => ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
/// 我的收藏-短剧 [sortType] 0-最新收藏 1-最近更新
|
||||
static Future<ListBaseModel<DramaMediaInfo>?> fetchFavorites(int page, {int size = 20, int sortType = 0}) async {
|
||||
static Future<ListBaseModel<DramaMediaInfo>?> fetchFavorites(int page,
|
||||
{int size = 20, int sortType = 0}) async {
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media_bookshelf/list',
|
||||
param: {'type': 'drama', 'sortType': sortType, 'pageNumber': page, 'pageSize': size},
|
||||
jsonTransformation: (json) => ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
param: {
|
||||
'type': 'drama',
|
||||
'sortType': sortType,
|
||||
'pageNumber': page,
|
||||
'pageSize': size
|
||||
},
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
/// 我的已购-短剧(按剧去重,点进去看每集的 hasBuy)
|
||||
static Future<ListBaseModel<DramaMediaInfo>?> fetchPurchased(int page, {int size = 20}) async {
|
||||
static Future<ListBaseModel<DramaMediaInfo>?> fetchPurchased(int page,
|
||||
{int size = 20}) async {
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/media/my_buy',
|
||||
param: {'mediaType': 'drama', 'pageNumber': page, 'pageSize': size},
|
||||
jsonTransformation: (json) => ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<DramaMediaInfo>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
@@ -198,6 +222,8 @@ class DramaService {
|
||||
},
|
||||
options: _idempotent(eventId),
|
||||
);
|
||||
return result.isSuccess ? (result.data is Map ? result.data['qrCode'] : null) : null;
|
||||
return result.isSuccess
|
||||
? (result.data is Map ? result.data['qrCode'] : null)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user