初始化
This commit is contained in:
@@ -0,0 +1,398 @@
|
||||
//AI相关接口
|
||||
|
||||
import 'package:hgdj/hj_model/list_base_model.dart';
|
||||
import 'package:hgdj/hj_page/ai/ai_sub_type/ai_function_logic.dart';
|
||||
import 'package:hgdj/tools_base/debug_log.dart';
|
||||
import 'package:hgdj/tools_base/net/http_manager.dart';
|
||||
|
||||
import '../../hj_page/ai/models/ai_girl_resp_model.dart';
|
||||
import '../../hj_page/ai/models/ai_mod_list_model.dart';
|
||||
import '../../hj_page/ai/models/ai_record_model.dart';
|
||||
import '../../hj_page/ai/models/ai_square_model.dart';
|
||||
|
||||
class AIService {
|
||||
// 获取AI脱衣记录列表
|
||||
//status 1、进行中 2、生成成功 3、生成失败
|
||||
static Future<ListBaseModel<AiRecordModel>?> getUndressList(
|
||||
int? pageNumber,
|
||||
int? pageSize,
|
||||
int? status,
|
||||
) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'status': status
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/ai/undress/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<AiRecordModel>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
/// 获取AI照片换脸记录列表
|
||||
// 1、进行中 2、生成成功 3、生成失败
|
||||
static Future<ListBaseModel<AiRecordModel>?> getImgList(
|
||||
int? pageNumber,
|
||||
int? pageSize,
|
||||
int? status,
|
||||
) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'status': status,
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/ai/img/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<AiRecordModel>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
/// 获取AI视频换脸记录列表
|
||||
// 1、进行中 2、生成成功 3、生成失败
|
||||
static Future<ListBaseModel<AiRecordModel>?> getChangeFaceList(
|
||||
int? pageNumber,
|
||||
int? pageSize,
|
||||
int? status,
|
||||
) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'status': status,
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/ai/changeface/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<AiRecordModel>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//生成AI脱衣记录
|
||||
static Future<bool> generateUndress(
|
||||
List<String>? originPics, bool shareStatus, String? shareTitle) async {
|
||||
final param = {
|
||||
'originPic': originPics,
|
||||
'shareStatus': shareStatus ? 1 : 0,
|
||||
'shareTitle': shareTitle
|
||||
}..removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/ai/undress/generate',
|
||||
param: param,
|
||||
);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
//生成AI视频换脸
|
||||
static Future<bool> generateChangeFace(
|
||||
List<String>? picture,
|
||||
String? vidModId,
|
||||
String? discountId,
|
||||
bool shareStatus,
|
||||
String? shareTitle,
|
||||
) async {
|
||||
final param = {
|
||||
'picture': picture,
|
||||
'vidModId': vidModId,
|
||||
'discount': discountId?.isNotEmpty == true ? [discountId!] : null,
|
||||
'shareStatus': shareStatus ? 1 : 0,
|
||||
'shareTitle': shareTitle
|
||||
}..removeWhere((k, v) => v == null);
|
||||
|
||||
final result = await httpManager
|
||||
.fetchResponseByPOST('/ai/changeface/generate', param: param);
|
||||
return result.isSuccess && result.data == 'success';
|
||||
}
|
||||
|
||||
//生成图片AI换脸
|
||||
static Future<bool> generateImg(
|
||||
String picture, String imgModId, bool shareStatus, String? shareTitle,
|
||||
{String? discount}) async {
|
||||
final param = {
|
||||
'originPic': picture,
|
||||
'mId': imgModId,
|
||||
'discount': discount,
|
||||
'shareStatus': shareStatus ? 1 : 0,
|
||||
'shareTitle': shareTitle
|
||||
};
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/ai/img/generate',
|
||||
param: param,
|
||||
);
|
||||
return result.isSuccess && result.data == 'success';
|
||||
}
|
||||
|
||||
//ai脱衣
|
||||
static Future<AiModList?> getModelList() async {
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/ai/mod/list',
|
||||
param: {},
|
||||
jsonTransformation: (json) => AiModList.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
//ai换脸 新版本
|
||||
static Future<AiChangeModList?> getModelListV2({
|
||||
AiType type = AiType.imageChangeFace, //只认图片换脸/视频换脸两种
|
||||
String? categoryId, //模版分类id,如果为空,则默认第一个模版分类
|
||||
}) async {
|
||||
//接口只认 type=0/1,枚举在这一层换回去
|
||||
final param = {'type': type.isVideoFace ? 1 : 0, 'categoryId': categoryId}
|
||||
..removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/ai/mod/v2/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) => AiChangeModList.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
///删除AI订单脱衣
|
||||
static Future<bool> deleteUndress(String? id) async {
|
||||
final param = {'id': id};
|
||||
final result =
|
||||
await httpManager.fetchResponseByPOST('/ai/undress/hide', param: param);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
///删除AI换脸Video订单
|
||||
static Future<bool> deleteChangeFace(String? id) async {
|
||||
final param = {'id': id};
|
||||
final result = await httpManager.fetchResponseByPOST('/ai/changeface/hide',
|
||||
param: param);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
///删除AI换脸 Img订单
|
||||
static Future<bool> deleteImg(String? id) async {
|
||||
final param = {'id': id};
|
||||
final result =
|
||||
await httpManager.fetchResponseByPOST('/ai/img/hide', param: param);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
//ai女友用户余额查询
|
||||
static Future<AIGirlFriendBalanceModel> getBalance(data) async {
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/aimate/getBalance',
|
||||
param: {},
|
||||
jsonTransformation: (value) => AIGirlFriendBalanceModel.fromJson(value),
|
||||
);
|
||||
//返回类型非空,给不了 null:失败时这里抛,由调用方 try/catch 兜底(改可空要连调用方一起改)
|
||||
return result.data;
|
||||
}
|
||||
|
||||
/// 获取 AI 女友 H5 链接(v2,点击入口时请求)
|
||||
static Future<AIGirlFriendUrlModel?> getMateUrl([dynamic data]) async {
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/aimatev2/url',
|
||||
jsonTransformation: (value) => AIGirlFriendUrlModel.fromJson(value),
|
||||
);
|
||||
return result.isSuccess ? result.data as AIGirlFriendUrlModel? : null;
|
||||
}
|
||||
|
||||
//获取AI女友货币列表
|
||||
static Future<AIGirlFriendCurrencys> getMateCurrencies() async {
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/aimate/currencys',
|
||||
param: {},
|
||||
jsonTransformation: (value) => AIGirlFriendCurrencys.fromJson(value),
|
||||
);
|
||||
//返回类型非空,给不了 null:失败时这里抛,由调用方 try/catch 兜底(改可空要连调用方一起改)
|
||||
return result.data;
|
||||
}
|
||||
|
||||
//AI女友积分兑换
|
||||
static Future<dynamic> exchangeMate(data) async {
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/aimate/exchange',
|
||||
param: data,
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
///获取AI广场列表
|
||||
static Future<ListBaseModel<AISquareItemModel>?> getPlazaList(int pageNumber,
|
||||
{int pageSize = 10}) async {
|
||||
final result = await httpManager.fetchResponseByGET('/aiplaza/list',
|
||||
param: {'pageNumber': pageNumber, 'pageSize': pageSize},
|
||||
jsonTransformation: (json) =>
|
||||
ListBaseModel<AISquareItemModel>.fromJson(json));
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
///Ai模版是否还存在
|
||||
static Future<TemplateModel?> getModelInfo(String? id, int? type) async {
|
||||
final param = {'id': id, 'type': type};
|
||||
param.removeWhere((k, v) => v == null);
|
||||
final resultData =
|
||||
await httpManager.fetchResponseByGET('/ai/mod/info', param: param);
|
||||
if (resultData.isSuccess) {
|
||||
final data = resultData.data;
|
||||
if (data is Map) {
|
||||
try {
|
||||
//模版被下架时 aiChangeFaceMod 为 null,要回 null 让调用方走「已下架」分支
|
||||
final mod = data['aiChangeFaceMod'];
|
||||
resultData.data = mod == null ? null : TemplateModel.fromJson(mod);
|
||||
} catch (e) {
|
||||
debugLog('AIService', 'getModelInfo 解析失败: $e');
|
||||
resultData.data = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultData.data;
|
||||
}
|
||||
|
||||
// 获取文字绘图记录
|
||||
//status 1、进行中 2、生成成功 3、生成失败
|
||||
static Future<ListBaseModel<AiRecordModel>?> getTextToImageList(
|
||||
int? pageNumber,
|
||||
int? pageSize,
|
||||
int? status,
|
||||
) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'status': status
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/ai/text_to_image/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<AiRecordModel>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
///删除文字绘图
|
||||
static Future<bool> deleteTextToImage(String? id) async {
|
||||
final param = {'id': id};
|
||||
final result = await httpManager
|
||||
.fetchResponseByPOST('/ai/text_to_image/hide', param: param);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
// 获取AI图生视频记录列表
|
||||
//status 1、进行中 2、生成成功 3、生成失败
|
||||
static Future<ListBaseModel<AiRecordModel>?> getImgVideoList(
|
||||
int? pageNumber,
|
||||
int? pageSize,
|
||||
int? status,
|
||||
) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'status': status
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/ai/imagetovideo/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<AiRecordModel>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
///删除AI图生视频
|
||||
static Future<bool> deleteImgVideo(String? id) async {
|
||||
final param = {'id': id};
|
||||
final result = await httpManager
|
||||
.fetchResponseByPOST('/ai/imagetovideo/hide', param: param);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
/// ai 生成小说
|
||||
static Future<bool> generateNovel(
|
||||
String description, {
|
||||
//剧情描述/故事情节
|
||||
String? characterSetting, //人物设定
|
||||
String? details, //细节说明/其他要求
|
||||
String? locationScene, //地点场景
|
||||
int modelType = 1, //1:AI小艺 2:AI小萌
|
||||
}) async {
|
||||
final param = {
|
||||
'details': details,
|
||||
"locationScene": locationScene,
|
||||
"modelType": modelType,
|
||||
'description': description,
|
||||
'characterSetting': characterSetting
|
||||
}..removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/ai_text_to_novel/generate',
|
||||
param: param,
|
||||
);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
///生成AI图生视频记录
|
||||
static Future<bool> generateImgVideo(
|
||||
String originPic, {
|
||||
bool shareStatus = true,
|
||||
String? shareTitle,
|
||||
String? mid,
|
||||
}) async {
|
||||
final param = {
|
||||
'originPic': originPic,
|
||||
'shareStatus': shareStatus ? 1 : 0,
|
||||
'shareTitle': shareTitle,
|
||||
'mid': mid,
|
||||
}..removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/ai/imagetovideo/generate',
|
||||
param: param,
|
||||
);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
/// ai文生图
|
||||
static Future<bool> generateTextToImage(
|
||||
String aspectRatio,
|
||||
int styleType,
|
||||
String text, {
|
||||
bool shareStatus = true,
|
||||
String? shareTitle,
|
||||
}) async {
|
||||
final param = {
|
||||
'aspectRatio': aspectRatio,
|
||||
"styleType": styleType,
|
||||
"text": text,
|
||||
'shareStatus': shareStatus ? 1 : 0,
|
||||
'shareTitle': shareTitle
|
||||
}..removeWhere((k, v) => v == null);
|
||||
final result = await httpManager.fetchResponseByPOST(
|
||||
'/ai/text_to_image/generate',
|
||||
param: param,
|
||||
);
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
// 获取AI生成小说记录列表
|
||||
//status 1、进行中 2、生成成功 3、生成失败
|
||||
static Future<ListBaseModel<AiRecordModel>?> getNovelList(
|
||||
int? pageNumber,
|
||||
int? pageSize,
|
||||
int? status,
|
||||
) async {
|
||||
final param = {
|
||||
'pageNumber': pageNumber,
|
||||
'pageSize': pageSize,
|
||||
'status': status
|
||||
};
|
||||
final result = await httpManager.fetchResponseByGET(
|
||||
'/ai_text_to_novel/list',
|
||||
param: param,
|
||||
jsonTransformation: (json) => ListBaseModel<AiRecordModel>.fromJson(json),
|
||||
);
|
||||
return result.isSuccess ? result.data : null;
|
||||
}
|
||||
|
||||
///删除AI文生图
|
||||
static Future<bool> deleteNovel(String? id) async {
|
||||
final param = {'id': id};
|
||||
final result = await httpManager
|
||||
.fetchResponseByPOST('/ai_text_to_novel/hide', param: param);
|
||||
return result.isSuccess;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user