From c6dccf1c04bc29fc6be5557c11b29e1255285484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BE=B7=E8=BE=89?= Date: Wed, 2 Jul 2025 13:51:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- scripts/generate-api.js | 85 +++- src/api/index.ts | 87 ++-- ...bg_v3_api_v3_local_batch_change_bg_post.ts | 13 + ...bg_v3_api_v3_cloud_batch_change_bg_post.ts | 13 + ..._v3_api_v3_cloud_batch_edit_images_post.ts | 20 + ..._v3_api_v3_local_batch_edit_images_post.ts | 20 + .../Body_upload_image_api_upload_post.ts | 8 - src/api/models/UploadResponse.ts | 10 - src/api/models/index.ts | 6 +- ...bg_v3_api_v3_local_batch_change_bg_post.ts | 29 ++ ...bg_v3_api_v3_cloud_batch_change_bg_post.ts | 29 ++ ..._v3_api_v3_cloud_batch_edit_images_post.ts | 34 ++ ..._v3_api_v3_local_batch_edit_images_post.ts | 34 ++ .../$Body_upload_image_api_upload_post.ts | 13 - src/api/schemas/$UploadResponse.ts | 20 - src/api/services/DataQueryService.ts | 97 +++++ ...aultService.ts => ImageGenerateService.ts} | 171 ++++---- src/api/services/ModelService.ts | 235 +++++++++++ src/api/services/Service.ts | 371 ------------------ src/api/services/TagService.ts | 42 ++ src/api/services/VideoGenerateService.ts | 112 ++++++ src/api/services/WebhookWebhookService.ts | 21 + src/api/services/index.ts | 9 +- src/lib/api.ts | 7 +- src/pages/ChangeBgPage/index.tsx | 7 +- src/pages/ModelPage/components/ModelForm.tsx | 4 +- src/pages/ModelPage/index.tsx | 10 +- src/pages/TryOnPage/index.tsx | 8 +- src/pages/TryOnTasksPage/index.tsx | 7 +- src/pages/TryOnVideoTaskPage/index.tsx | 4 +- 31 files changed, 927 insertions(+), 601 deletions(-) create mode 100644 src/api/models/Body_async_change_bg_v3_api_v3_local_batch_change_bg_post.ts create mode 100644 src/api/models/Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post.ts create mode 100644 src/api/models/Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post.ts create mode 100644 src/api/models/Body_local_gen_images_v3_api_v3_local_batch_edit_images_post.ts delete mode 100644 src/api/models/Body_upload_image_api_upload_post.ts delete mode 100644 src/api/models/UploadResponse.ts create mode 100644 src/api/schemas/$Body_async_change_bg_v3_api_v3_local_batch_change_bg_post.ts create mode 100644 src/api/schemas/$Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post.ts create mode 100644 src/api/schemas/$Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post.ts create mode 100644 src/api/schemas/$Body_local_gen_images_v3_api_v3_local_batch_edit_images_post.ts delete mode 100644 src/api/schemas/$Body_upload_image_api_upload_post.ts delete mode 100644 src/api/schemas/$UploadResponse.ts create mode 100644 src/api/services/DataQueryService.ts rename src/api/services/{DefaultService.ts => ImageGenerateService.ts} (65%) create mode 100644 src/api/services/ModelService.ts delete mode 100644 src/api/services/Service.ts create mode 100644 src/api/services/TagService.ts create mode 100644 src/api/services/VideoGenerateService.ts create mode 100644 src/api/services/WebhookWebhookService.ts diff --git a/package.json b/package.json index 090cb96..77366ca 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "lint": "eslint .", "preview": "vite preview", "api": "node scripts/generate-api.js", - "api:dev": "OPENAPI_URL=http://localhost:3000/openapi.json node scripts/generate-api.js", + "api:dev": "OPENAPI_URL=http://192.168.0.127:8010/openapi.json node scripts/generate-api.js", "api:prod": "OPENAPI_URL=https://your-api-domain.com/openapi.json node scripts/generate-api.js" }, "dependencies": { diff --git a/scripts/generate-api.js b/scripts/generate-api.js index c3a4ddc..d05f4c1 100644 --- a/scripts/generate-api.js +++ b/scripts/generate-api.js @@ -5,7 +5,8 @@ import axios from 'axios'; // 配置 const config = { - input: process.env.OPENAPI_URL || 'https://bowongai--glam-api-fastapi-app.modal.run/openapi.json', // OpenAPI规范URL + // input: process.env.OPENAPI_URL || 'https://bowongai--glam-api-fastapi-app.modal.run/openapi.json', // OpenAPI规范URL + input: process.env.OPENAPI_URL || 'http://192.168.0.127:8010/openapi.json', // OpenAPI规范URL output: './src/api', // 生成的API代码输出目录 client: 'axios', // 使用axios作为HTTP客户端 useOptions: true, @@ -30,44 +31,91 @@ async function fetchOpenApiSpec(url) { function createIndexFiles() { const apiDir = config.output; - + // 创建services/index.ts const servicesDir = join(apiDir, 'services'); if (existsSync(servicesDir)) { const serviceFiles = readdirSync(servicesDir) .filter(file => file.endsWith('.ts') && file !== 'index.ts' && file !== 'Service.ts') .map(file => file.replace('.ts', '')); - - const servicesIndexContent = serviceFiles - .map(service => `export * from './${service}';`) - .join('\n'); - + + const servicesIndexContent = serviceFiles.map(service => `export * from './${service}';`).join('\n'); + writeFileSync(join(servicesDir, 'index.ts'), servicesIndexContent); console.log('📝 创建services/index.ts完成'); } - + // 创建models/index.ts const modelsDir = join(apiDir, 'models'); if (existsSync(modelsDir)) { const modelFiles = readdirSync(modelsDir) .filter(file => file.endsWith('.ts') && file !== 'index.ts') .map(file => file.replace('.ts', '')); - - const modelsIndexContent = modelFiles - .map(model => `export * from './${model}';`) - .join('\n'); - + + const modelsIndexContent = modelFiles.map(model => `export * from './${model}';`).join('\n'); + writeFileSync(join(modelsDir, 'index.ts'), modelsIndexContent); console.log('📝 创建models/index.ts完成'); } } +function createApiEntry() { + const servicesDir = join(config.output, 'services'); + const modelsDir = join(config.output, 'models'); + const apiDir = join('src', 'api'); + const apiFile = join(apiDir, 'index.ts'); + + // 读取 service 文件 + let serviceFiles = []; + if (existsSync(servicesDir)) { + serviceFiles = readdirSync(servicesDir) + .filter(file => file.endsWith('.ts') && file !== 'index.ts' && file !== 'Service.ts') + .map(file => file.replace('.ts', '')); + } + + // 读取 model 文件 + let modelFiles = []; + if (existsSync(modelsDir)) { + modelFiles = readdirSync(modelsDir) + .filter(file => file.endsWith('.ts') && file !== 'index.ts') + .map(file => file.replace('.ts', '')); + } + + // 生成 import 语句 + const importStatements = [ + `import { OpenAPI } from '@/api/core/OpenAPI';`, + ...serviceFiles.map(name => `import * as ${name} from '@/api/services/${name}';`), + ].join('\n'); + + // 生成 api 对象 + const apiObject = ['export const api = {', ...serviceFiles.map(name => ` ...${name},`), ' OpenAPI,', '};'].join('\n'); + + // 生成 baseURL 逻辑 + const baseUrlLogic = `\nconst baseURL = (() => {\n const url = import.meta.env.VITE_API_BASE_URL || ''; + return url;\n})();\nOpenAPI.BASE = baseURL;\n`; + + // 生成类型 re-export + const typeExports = modelFiles.map(name => `export type { ${name} } from '@/api/models/${name}';`).join('\n'); + + // 合成文件内容 + const content = `${importStatements}\n${baseUrlLogic}\n${apiObject}\n\n${typeExports}\n`; + + // 确保 api 目录存在 + if (!existsSync(apiDir)) { + require('fs').mkdirSync(apiDir, { recursive: true }); + } + + // 写入文件 + writeFileSync(apiFile, content); + console.log('📝 自动生成 src/api/index.ts 完成'); +} + async function generateApi() { try { console.log('🚀 开始生成API代码...'); - + let openApiSpec; - + // 检查输入是URL还是本地文件 if (config.input.startsWith('http://') || config.input.startsWith('https://')) { // 从URL获取OpenAPI规范 @@ -98,14 +146,15 @@ async function generateApi() { console.log('✅ API代码生成完成!'); console.log(`📁 输出目录: ${config.output}`); - + // 创建索引文件 createIndexFiles(); - + // 自动生成 api/index.ts(包含 api 和 ApiModel) + createApiEntry(); } catch (error) { console.error('❌ 生成API代码时出错:', error); } } // 运行生成器 -generateApi(); \ No newline at end of file +generateApi(); diff --git a/src/api/index.ts b/src/api/index.ts index da857f3..0943e60 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,48 +1,45 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export { ApiError } from './core/ApiError'; -export { CancelablePromise, CancelError } from './core/CancelablePromise'; -export { OpenAPI } from './core/OpenAPI'; -export type { OpenAPIConfig } from './core/OpenAPI'; +import { OpenAPI } from '@/api/core/OpenAPI'; +import * as DataQueryService from '@/api/services/DataQueryService'; +import * as ImageGenerateService from '@/api/services/ImageGenerateService'; +import * as ModelService from '@/api/services/ModelService'; +import * as TagService from '@/api/services/TagService'; +import * as VideoGenerateService from '@/api/services/VideoGenerateService'; +import * as WebhookService from '@/api/services/WebhookService'; +import * as WebhookWebhookService from '@/api/services/WebhookWebhookService'; -export type { BatchVideoTaskRequest } from './models/BatchVideoTaskRequest'; -export type { Body_create_model_api_models_create_post } from './models/Body_create_model_api_models_create_post'; -export type { Body_local_async_change_bg_api_v2_local_batch_change_bg_post } from './models/Body_local_async_change_bg_api_v2_local_batch_change_bg_post'; -export type { Body_local_async_gen_images_api_v2_local_batch_edit_images_post } from './models/Body_local_async_gen_images_api_v2_local_batch_edit_images_post'; -export type { Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post } from './models/Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post'; -export type { Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post } from './models/Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post'; -export type { Body_update_model_api_models__model_id__put } from './models/Body_update_model_api_models__model_id__put'; -export type { Body_upload_image_api_upload_post } from './models/Body_upload_image_api_upload_post'; -export type { HTTPValidationError } from './models/HTTPValidationError'; -export type { PaginationResponse } from './models/PaginationResponse'; -export type { TaskQueryRequest } from './models/TaskQueryRequest'; -export type { UploadResponse } from './models/UploadResponse'; -export type { ValidationError } from './models/ValidationError'; -export type { VideoDataPaginationRequest } from './models/VideoDataPaginationRequest'; -export type { VideoDataResponse } from './models/VideoDataResponse'; -export type { VideoTaskRequest } from './models/VideoTaskRequest'; -export type { VideoTaskStatus } from './models/VideoTaskStatus'; +const baseURL = (() => { + const url = import.meta.env.VITE_API_BASE_URL || ''; + return url; +})(); +OpenAPI.BASE = baseURL; -export { $BatchVideoTaskRequest } from './schemas/$BatchVideoTaskRequest'; -export { $Body_create_model_api_models_create_post } from './schemas/$Body_create_model_api_models_create_post'; -export { $Body_local_async_change_bg_api_v2_local_batch_change_bg_post } from './schemas/$Body_local_async_change_bg_api_v2_local_batch_change_bg_post'; -export { $Body_local_async_gen_images_api_v2_local_batch_edit_images_post } from './schemas/$Body_local_async_gen_images_api_v2_local_batch_edit_images_post'; -export { $Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post } from './schemas/$Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post'; -export { $Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post } from './schemas/$Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post'; -export { $Body_update_model_api_models__model_id__put } from './schemas/$Body_update_model_api_models__model_id__put'; -export { $Body_upload_image_api_upload_post } from './schemas/$Body_upload_image_api_upload_post'; -export { $HTTPValidationError } from './schemas/$HTTPValidationError'; -export { $PaginationResponse } from './schemas/$PaginationResponse'; -export { $TaskQueryRequest } from './schemas/$TaskQueryRequest'; -export { $UploadResponse } from './schemas/$UploadResponse'; -export { $ValidationError } from './schemas/$ValidationError'; -export { $VideoDataPaginationRequest } from './schemas/$VideoDataPaginationRequest'; -export { $VideoDataResponse } from './schemas/$VideoDataResponse'; -export { $VideoTaskRequest } from './schemas/$VideoTaskRequest'; -export { $VideoTaskStatus } from './schemas/$VideoTaskStatus'; +export const api = { + ...DataQueryService, + ...ImageGenerateService, + ...ModelService, + ...TagService, + ...VideoGenerateService, + ...WebhookService, + ...WebhookWebhookService, + OpenAPI, +}; -export { Service } from './services/Service'; -export { DefaultService } from './services/DefaultService'; -export { WebhookService } from './services/WebhookService'; +export type { BatchVideoTaskRequest } from '@/api/models/BatchVideoTaskRequest'; +export type { Body_async_change_bg_v3_api_v3_local_batch_change_bg_post } from '@/api/models/Body_async_change_bg_v3_api_v3_local_batch_change_bg_post'; +export type { Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post } from '@/api/models/Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post'; +export type { Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post } from '@/api/models/Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post'; +export type { Body_create_model_api_models_create_post } from '@/api/models/Body_create_model_api_models_create_post'; +export type { Body_local_async_change_bg_api_v2_local_batch_change_bg_post } from '@/api/models/Body_local_async_change_bg_api_v2_local_batch_change_bg_post'; +export type { Body_local_async_gen_images_api_v2_local_batch_edit_images_post } from '@/api/models/Body_local_async_gen_images_api_v2_local_batch_edit_images_post'; +export type { Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post } from '@/api/models/Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post'; +export type { Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post } from '@/api/models/Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post'; +export type { Body_local_gen_images_v3_api_v3_local_batch_edit_images_post } from '@/api/models/Body_local_gen_images_v3_api_v3_local_batch_edit_images_post'; +export type { Body_update_model_api_models__model_id__put } from '@/api/models/Body_update_model_api_models__model_id__put'; +export type { HTTPValidationError } from '@/api/models/HTTPValidationError'; +export type { PaginationResponse } from '@/api/models/PaginationResponse'; +export type { TaskQueryRequest } from '@/api/models/TaskQueryRequest'; +export type { ValidationError } from '@/api/models/ValidationError'; +export type { VideoDataPaginationRequest } from '@/api/models/VideoDataPaginationRequest'; +export type { VideoDataResponse } from '@/api/models/VideoDataResponse'; +export type { VideoTaskRequest } from '@/api/models/VideoTaskRequest'; +export type { VideoTaskStatus } from '@/api/models/VideoTaskStatus'; diff --git a/src/api/models/Body_async_change_bg_v3_api_v3_local_batch_change_bg_post.ts b/src/api/models/Body_async_change_bg_v3_api_v3_local_batch_change_bg_post.ts new file mode 100644 index 0000000..f3096ed --- /dev/null +++ b/src/api/models/Body_async_change_bg_v3_api_v3_local_batch_change_bg_post.ts @@ -0,0 +1,13 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type Body_async_change_bg_v3_api_v3_local_batch_change_bg_post = { + clothing_images: Array; + padding_images: Array; + /** + * 背景提示词,用 || 分隔多个提示词 + */ + bg_prompts: string; +}; + diff --git a/src/api/models/Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post.ts b/src/api/models/Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post.ts new file mode 100644 index 0000000..7845dbd --- /dev/null +++ b/src/api/models/Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post.ts @@ -0,0 +1,13 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post = { + clothing_images: Array; + padding_images: Array; + /** + * 背景提示词,用 || 分隔多个提示词 + */ + bg_prompts: string; +}; + diff --git a/src/api/models/Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post.ts b/src/api/models/Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post.ts new file mode 100644 index 0000000..ca63e48 --- /dev/null +++ b/src/api/models/Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post.ts @@ -0,0 +1,20 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post = { + clothing_images: Array; + /** + * 标签列表,用||分隔多个标签,如:女_下衣_长款_牛仔_白 + */ + tag_list: string; + /** + * 垫图列表,文件名格式:前缀_背景描述.jpg + */ + padding_clothes: Array; + /** + * 背景提示词,用 || 分隔多个提示词 + */ + bg_prompts: string; +}; + diff --git a/src/api/models/Body_local_gen_images_v3_api_v3_local_batch_edit_images_post.ts b/src/api/models/Body_local_gen_images_v3_api_v3_local_batch_edit_images_post.ts new file mode 100644 index 0000000..790c640 --- /dev/null +++ b/src/api/models/Body_local_gen_images_v3_api_v3_local_batch_edit_images_post.ts @@ -0,0 +1,20 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type Body_local_gen_images_v3_api_v3_local_batch_edit_images_post = { + clothing_images: Array; + /** + * 标签列表,用||分隔多个标签,如:女_下衣_长款_牛仔_白 + */ + tag_list: string; + /** + * 垫图列表,文件名格式:前缀_背景描述.jpg + */ + padding_clothes: Array; + /** + * 背景提示词,用 || 分隔多个提示词 + */ + bg_prompts: string; +}; + diff --git a/src/api/models/Body_upload_image_api_upload_post.ts b/src/api/models/Body_upload_image_api_upload_post.ts deleted file mode 100644 index 393b09e..0000000 --- a/src/api/models/Body_upload_image_api_upload_post.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export type Body_upload_image_api_upload_post = { - image: Blob; -}; - diff --git a/src/api/models/UploadResponse.ts b/src/api/models/UploadResponse.ts deleted file mode 100644 index 063755c..0000000 --- a/src/api/models/UploadResponse.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export type UploadResponse = { - success: boolean; - filename: string; - path: string; -}; - diff --git a/src/api/models/index.ts b/src/api/models/index.ts index 15fae34..4724ebf 100644 --- a/src/api/models/index.ts +++ b/src/api/models/index.ts @@ -1,15 +1,17 @@ export * from './BatchVideoTaskRequest'; +export * from './Body_async_change_bg_v3_api_v3_local_batch_change_bg_post'; +export * from './Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post'; +export * from './Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post'; export * from './Body_create_model_api_models_create_post'; export * from './Body_local_async_change_bg_api_v2_local_batch_change_bg_post'; export * from './Body_local_async_gen_images_api_v2_local_batch_edit_images_post'; export * from './Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post'; export * from './Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post'; +export * from './Body_local_gen_images_v3_api_v3_local_batch_edit_images_post'; export * from './Body_update_model_api_models__model_id__put'; -export * from './Body_upload_image_api_upload_post'; export * from './HTTPValidationError'; export * from './PaginationResponse'; export * from './TaskQueryRequest'; -export * from './UploadResponse'; export * from './ValidationError'; export * from './VideoDataPaginationRequest'; export * from './VideoDataResponse'; diff --git a/src/api/schemas/$Body_async_change_bg_v3_api_v3_local_batch_change_bg_post.ts b/src/api/schemas/$Body_async_change_bg_v3_api_v3_local_batch_change_bg_post.ts new file mode 100644 index 0000000..c6390d7 --- /dev/null +++ b/src/api/schemas/$Body_async_change_bg_v3_api_v3_local_batch_change_bg_post.ts @@ -0,0 +1,29 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $Body_async_change_bg_v3_api_v3_local_batch_change_bg_post = { + properties: { + clothing_images: { + type: 'array', + contains: { + type: 'binary', + format: 'binary', + }, + isRequired: true, + }, + padding_images: { + type: 'array', + contains: { + type: 'binary', + format: 'binary', + }, + isRequired: true, + }, + bg_prompts: { + type: 'string', + description: `背景提示词,用 || 分隔多个提示词`, + isRequired: true, + }, + }, +} as const; diff --git a/src/api/schemas/$Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post.ts b/src/api/schemas/$Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post.ts new file mode 100644 index 0000000..e403523 --- /dev/null +++ b/src/api/schemas/$Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post.ts @@ -0,0 +1,29 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post = { + properties: { + clothing_images: { + type: 'array', + contains: { + type: 'binary', + format: 'binary', + }, + isRequired: true, + }, + padding_images: { + type: 'array', + contains: { + type: 'binary', + format: 'binary', + }, + isRequired: true, + }, + bg_prompts: { + type: 'string', + description: `背景提示词,用 || 分隔多个提示词`, + isRequired: true, + }, + }, +} as const; diff --git a/src/api/schemas/$Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post.ts b/src/api/schemas/$Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post.ts new file mode 100644 index 0000000..8acaaa1 --- /dev/null +++ b/src/api/schemas/$Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post.ts @@ -0,0 +1,34 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post = { + properties: { + clothing_images: { + type: 'array', + contains: { + type: 'binary', + format: 'binary', + }, + isRequired: true, + }, + tag_list: { + type: 'string', + description: `标签列表,用||分隔多个标签,如:女_下衣_长款_牛仔_白`, + isRequired: true, + }, + padding_clothes: { + type: 'array', + contains: { + type: 'binary', + format: 'binary', + }, + isRequired: true, + }, + bg_prompts: { + type: 'string', + description: `背景提示词,用 || 分隔多个提示词`, + isRequired: true, + }, + }, +} as const; diff --git a/src/api/schemas/$Body_local_gen_images_v3_api_v3_local_batch_edit_images_post.ts b/src/api/schemas/$Body_local_gen_images_v3_api_v3_local_batch_edit_images_post.ts new file mode 100644 index 0000000..f34bc4a --- /dev/null +++ b/src/api/schemas/$Body_local_gen_images_v3_api_v3_local_batch_edit_images_post.ts @@ -0,0 +1,34 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $Body_local_gen_images_v3_api_v3_local_batch_edit_images_post = { + properties: { + clothing_images: { + type: 'array', + contains: { + type: 'binary', + format: 'binary', + }, + isRequired: true, + }, + tag_list: { + type: 'string', + description: `标签列表,用||分隔多个标签,如:女_下衣_长款_牛仔_白`, + isRequired: true, + }, + padding_clothes: { + type: 'array', + contains: { + type: 'binary', + format: 'binary', + }, + isRequired: true, + }, + bg_prompts: { + type: 'string', + description: `背景提示词,用 || 分隔多个提示词`, + isRequired: true, + }, + }, +} as const; diff --git a/src/api/schemas/$Body_upload_image_api_upload_post.ts b/src/api/schemas/$Body_upload_image_api_upload_post.ts deleted file mode 100644 index 3f25d24..0000000 --- a/src/api/schemas/$Body_upload_image_api_upload_post.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $Body_upload_image_api_upload_post = { - properties: { - image: { - type: 'binary', - isRequired: true, - format: 'binary', - }, - }, -} as const; diff --git a/src/api/schemas/$UploadResponse.ts b/src/api/schemas/$UploadResponse.ts deleted file mode 100644 index 15b4628..0000000 --- a/src/api/schemas/$UploadResponse.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export const $UploadResponse = { - properties: { - success: { - type: 'boolean', - isRequired: true, - }, - filename: { - type: 'string', - isRequired: true, - }, - path: { - type: 'string', - isRequired: true, - }, - }, -} as const; diff --git a/src/api/services/DataQueryService.ts b/src/api/services/DataQueryService.ts new file mode 100644 index 0000000..09531aa --- /dev/null +++ b/src/api/services/DataQueryService.ts @@ -0,0 +1,97 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { PaginationResponse } from '../models/PaginationResponse'; +import type { TaskQueryRequest } from '../models/TaskQueryRequest'; +import type { VideoDataPaginationRequest } from '../models/VideoDataPaginationRequest'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class DataQueryService { + /** + * 批量查询任务结果 + * 批量查询任务结果 + * + * Args: + * request: 包含任务ID列表的请求 + * db: 数据库会话 + * + * Returns: + * dict: 查询结果 + * @returns any Successful Response + * @throws ApiError + */ + public static localSyncQueryTaskResultApiV2LocalBatchQueryTaskResultPost({ + requestBody, + }: { + requestBody: TaskQueryRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/v2/local/batch/query/task/result', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 分页查询视频生成数据 + * 分页查询视频生成数据,按创建时间降序排列 + * + * Args: + * request: 分页查询请求参数 + * db: 数据库会话 + * + * Returns: + * PaginationResponse: 分页查询结果 + * @returns PaginationResponse Successful Response + * @throws ApiError + */ + public static getImageDataListApiImageDataListPost({ + requestBody, + }: { + requestBody: VideoDataPaginationRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/image/data/list', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 根据ID查询单条视频生成数据 + * 根据ID查询单条视频生成数据 + * + * Args: + * data_id: 数据ID + * db: 数据库会话 + * + * Returns: + * dict: 查询结果 + * @returns any Successful Response + * @throws ApiError + */ + public static getVideoDataByIdApiVideoDataDataIdGet({ + dataId, + }: { + dataId: number, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/api/video/data/{data_id}', + path: { + 'data_id': dataId, + }, + errors: { + 422: `Validation Error`, + }, + }); + } +} diff --git a/src/api/services/DefaultService.ts b/src/api/services/ImageGenerateService.ts similarity index 65% rename from src/api/services/DefaultService.ts rename to src/api/services/ImageGenerateService.ts index dad4752..0b444ee 100644 --- a/src/api/services/DefaultService.ts +++ b/src/api/services/ImageGenerateService.ts @@ -2,39 +2,18 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { Body_async_change_bg_v3_api_v3_local_batch_change_bg_post } from '../models/Body_async_change_bg_v3_api_v3_local_batch_change_bg_post'; +import type { Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post } from '../models/Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post'; +import type { Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post } from '../models/Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post'; import type { Body_local_async_change_bg_api_v2_local_batch_change_bg_post } from '../models/Body_local_async_change_bg_api_v2_local_batch_change_bg_post'; import type { Body_local_async_gen_images_api_v2_local_batch_edit_images_post } from '../models/Body_local_async_gen_images_api_v2_local_batch_edit_images_post'; import type { Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post } from '../models/Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post'; import type { Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post } from '../models/Body_local_cloud_async_gen_images_api_v2_cloud_batch_edit_images_post'; -import type { Body_upload_image_api_upload_post } from '../models/Body_upload_image_api_upload_post'; -import type { PaginationResponse } from '../models/PaginationResponse'; -import type { TaskQueryRequest } from '../models/TaskQueryRequest'; -import type { UploadResponse } from '../models/UploadResponse'; -import type { VideoDataPaginationRequest } from '../models/VideoDataPaginationRequest'; +import type { Body_local_gen_images_v3_api_v3_local_batch_edit_images_post } from '../models/Body_local_gen_images_v3_api_v3_local_batch_edit_images_post'; import type { CancelablePromise } from '../core/CancelablePromise'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; -export class DefaultService { - /** - * Upload Image - * @returns UploadResponse Successful Response - * @throws ApiError - */ - public static uploadImageApiUploadPost({ - formData, - }: { - formData: Body_upload_image_api_upload_post, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/upload', - formData: formData, - mediaType: 'multipart/form-data', - errors: { - 422: `Validation Error`, - }, - }); - } +export class ImageGenerateService { /** * 本地新版异步图片生成接口 * 本地新版异步图片生成接口 @@ -66,6 +45,68 @@ export class DefaultService { }, }); } + /** + * 本地新版异步图片生成接口,支持垫图 + * 本地新版异步图片生成接口,支持垫图 + * + * Args: + * clothing_images: 服装图片文件列表 + * tag_list: 标签列表JSON字符串,格式:["男_上衣_长款_牛仔_红", "xxxx"] + * padding_clothes: 垫图列表,用作模特图片,文件名格式:前缀_背景描述.jpg (如:model_室内客厅.jpg) + * db: 数据库会话 + * + * Returns: + * dict: 异步任务提交结果 + * @returns any Successful Response + * @throws ApiError + */ + public static localGenImagesV3ApiV3LocalBatchEditImagesPost({ + formData, + }: { + formData: Body_local_gen_images_v3_api_v3_local_batch_edit_images_post, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/v3/local/batch/edit/images', + formData: formData, + mediaType: 'multipart/form-data', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 云端V3智能负载均衡异步图片生成接口,支持垫图 + * 云端V3智能负载均衡异步图片生成接口,支持垫图 + * 🧠 与V3本地版本逻辑完全相同,但使用智能负载均衡选择最优ComfyUI节点 + * + * Args: + * clothing_images: 服装图片文件列表 + * tag_list: 标签列表,用||分隔多个标签,格式:女_下衣_长款_牛仔_白||xxxx + * padding_clothes: 垫图列表,用作模特图片,文件名格式:前缀_背景描述.jpg (如:model_室内客厅.jpg) + * bg_prompts: 背景提示词,用 || 分隔多个提示词 + * db: 数据库会话 + * + * Returns: + * dict: 异步任务提交结果 + * @returns any Successful Response + * @throws ApiError + */ + public static asyncCloudGenImagesV3ApiV3CloudBatchEditImagesPost({ + formData, + }: { + formData: Body_async_cloud_gen_images_v3_api_v3_cloud_batch_edit_images_post, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/v3/cloud/batch/edit/images', + formData: formData, + mediaType: 'multipart/form-data', + errors: { + 422: `Validation Error`, + }, + }); + } /** * 本地新版异步换背景接口 * @returns any Successful Response @@ -87,85 +128,43 @@ export class DefaultService { }); } /** - * 批量查询任务结果 - * 批量查询任务结果 - * - * Args: - * request: 包含任务ID列表的请求 - * db: 数据库会话 - * - * Returns: - * dict: 查询结果 + * 带垫图的换背景 + * 带垫图的换背景接口(简化版) * @returns any Successful Response * @throws ApiError */ - public static localSyncQueryTaskResultApiV2LocalBatchQueryTaskResultPost({ - requestBody, + public static asyncChangeBgV3ApiV3LocalBatchChangeBgPost({ + formData, }: { - requestBody: TaskQueryRequest, + formData: Body_async_change_bg_v3_api_v3_local_batch_change_bg_post, }): CancelablePromise { return __request(OpenAPI, { method: 'POST', - url: '/api/v2/local/batch/query/task/result', - body: requestBody, - mediaType: 'application/json', + url: '/api/v3/local/batch/change/bg', + formData: formData, + mediaType: 'multipart/form-data', errors: { 422: `Validation Error`, }, }); } /** - * 分页查询视频生成数据 - * 分页查询视频生成数据,按创建时间降序排列 - * - * Args: - * request: 分页查询请求参数 - * db: 数据库会话 - * - * Returns: - * PaginationResponse: 分页查询结果 - * @returns PaginationResponse Successful Response - * @throws ApiError - */ - public static getImageDataListApiImageDataListPost({ - requestBody, - }: { - requestBody: VideoDataPaginationRequest, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/image/data/list', - body: requestBody, - mediaType: 'application/json', - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 根据ID查询单条视频生成数据 - * 根据ID查询单条视频生成数据 - * - * Args: - * data_id: 数据ID - * db: 数据库会话 - * - * Returns: - * dict: 查询结果 + * V3智能负载均衡带垫图的换背景 + * 智能负载均衡版本:带垫图的换背景接口 + * 🧠 与V3本地版本逻辑完全相同,但使用智能负载均衡选择最优ComfyUI节点 * @returns any Successful Response * @throws ApiError */ - public static getVideoDataByIdApiVideoDataDataIdGet({ - dataId, + public static asyncCloudChangeBgV3ApiV3CloudBatchChangeBgPost({ + formData, }: { - dataId: number, + formData: Body_async_cloud_change_bg_v3_api_v3_cloud_batch_change_bg_post, }): CancelablePromise { return __request(OpenAPI, { - method: 'GET', - url: '/api/video/data/{data_id}', - path: { - 'data_id': dataId, - }, + method: 'POST', + url: '/api/v3/cloud/batch/change/bg', + formData: formData, + mediaType: 'multipart/form-data', errors: { 422: `Validation Error`, }, diff --git a/src/api/services/ModelService.ts b/src/api/services/ModelService.ts new file mode 100644 index 0000000..a20a1fe --- /dev/null +++ b/src/api/services/ModelService.ts @@ -0,0 +1,235 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { Body_create_model_api_models_create_post } from '../models/Body_create_model_api_models_create_post'; +import type { Body_update_model_api_models__model_id__put } from '../models/Body_update_model_api_models__model_id__put'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class ModelService { + /** + * 创建模型 + * 创建模型 + * + * Args: + * tags: 模型标签,格式:性别_类别_尺寸_材质_颜色 + * cover_image: 封面图片文件 + * status: 状态,默认为1 + * db: 数据库会话 + * + * Returns: + * dict: 包含创建结果的响应 + * { + * 'status': 创建状态, + * 'data': { + * 'id': 模型ID, + * 'tag': {'sex': '性别', 'category': '类别', 'size': '尺寸', 'material': '材质', 'color': '颜色'}, + * 'cover_url': '封面URL', + * 'status': 状态, + * 'create_time': '创建时间' + * }, + * 'msg': '提示信息' + * } + * @returns any Successful Response + * @throws ApiError + */ + public static createModelApiModelsCreatePost({ + formData, + }: { + formData: Body_create_model_api_models_create_post, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/models/create', + formData: formData, + mediaType: 'multipart/form-data', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 获取模特列表 + * 获取模型列表 + * + * Args: + * status: 状态筛选,1启用,0禁用,为空时获取所有 + * db: 数据库会话 + * + * Returns: + * dict: 包含模型列表的响应 + * { + * 'status': 查询状态, + * 'data': [模型信息列表], + * 'msg': '提示信息' + * } + * @returns any Successful Response + * @throws ApiError + */ + public static getModelsListApiModelsListGet({ + status, + }: { + /** + * 状态筛选,1启用,0禁用 + */ + status?: (number | null), + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/api/models/list', + query: { + 'status': status, + }, + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 更新模型 + * 更新模型信息 + * + * Args: + * model_id: 模型ID + * tags: 更新的标签,格式:性别_类别_尺寸_材质_颜色(可选) + * cover_image: 更新的封面图片文件(可选) + * status: 更新的状态(可选) + * db: 数据库会话 + * + * Returns: + * dict: 包含更新结果的响应 + * @returns any Successful Response + * @throws ApiError + */ + public static updateModelApiModelsModelIdPut({ + modelId, + formData, + }: { + modelId: number, + formData?: Body_update_model_api_models__model_id__put, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/api/models/{model_id}', + path: { + 'model_id': modelId, + }, + formData: formData, + mediaType: 'multipart/form-data', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 删除单个模型 + * 删除单个模型(软删除) + * + * Args: + * model_id: 模型ID + * db: 数据库会话 + * + * Returns: + * dict: 删除结果 + * @returns any Successful Response + * @throws ApiError + */ + public static deleteModelApiModelsModelIdDelete({ + modelId, + }: { + modelId: number, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/api/models/{model_id}', + path: { + 'model_id': modelId, + }, + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 删除模型,支持批量 + * 批量删除模型(软删除) + * + * Args: + * model_ids: 模型ID列表 + * db: 数据库会话 + * + * Returns: + * dict: 删除结果 + * { + * 'status': 删除状态, + * 'data': { + * 'total': 总数, + * 'success': 成功数, + * 'failed': 失败数 + * }, + * 'msg': '提示信息' + * } + * @returns any Successful Response + * @throws ApiError + */ + public static removeModelsApiModelsRemovePost({ + requestBody, + }: { + requestBody: Array, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/models/remove', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 根据标签筛选模型列表 + * 根据标签筛选模型列表 + * 支持格式:性别_类别_尺寸_材质_颜色,使用特殊匹配规则 + * + * 匹配规则: + * - sex(性别)和 category(类别):等值匹配(必须完全相同,AND逻辑) + * - size(尺寸)、material(材质)、color(颜色):非等值匹配(所有字段都必须不同,AND逻辑) + * + * Args: + * tags: 标签字符串,格式:性别_类别_尺寸_材质_颜色 + * status: 状态筛选,默认为1 + * db: 数据库会话 + * + * Returns: + * dict: 包含筛选结果的响应 + * @returns any Successful Response + * @throws ApiError + */ + public static getModelsByTagApiModelsByTagsGet({ + tags, + status, + }: { + /** + * 标签,格式:性别_类别_尺寸_材质_颜色。例如: '女_上衣_长款_牛仔_红' + */ + tags: string, + /** + * 状态筛选,1启用,0禁用 + */ + status?: (number | null), + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/api/models/by/tags', + query: { + 'tags': tags, + 'status': status, + }, + errors: { + 422: `Validation Error`, + }, + }); + } + } diff --git a/src/api/services/Service.ts b/src/api/services/Service.ts deleted file mode 100644 index 60fef26..0000000 --- a/src/api/services/Service.ts +++ /dev/null @@ -1,371 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { BatchVideoTaskRequest } from '../models/BatchVideoTaskRequest'; -import type { Body_create_model_api_models_create_post } from '../models/Body_create_model_api_models_create_post'; -import type { Body_update_model_api_models__model_id__put } from '../models/Body_update_model_api_models__model_id__put'; -import type { VideoTaskStatus } from '../models/VideoTaskStatus'; -import type { CancelablePromise } from '../core/CancelablePromise'; -import { OpenAPI } from '../core/OpenAPI'; -import { request as __request } from '../core/request'; -export class Service { - /** - * 异步批量提交任务 - * @returns any Successful Response - * @throws ApiError - */ - public static submitVideoTaskApiJmSubmitTaskPost({ - requestBody, - }: { - requestBody: BatchVideoTaskRequest, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/jm/submit/task', - body: requestBody, - mediaType: 'application/json', - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 查询视频生成任务状态 - * @returns any Successful Response - * @throws ApiError - */ - public static queryVideoTaskApiJmQueryStatusGet({ - jobId, - }: { - jobId: string, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/jm/query/status', - query: { - 'job_id': jobId, - }, - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 批量查询视频生成任务状态 - * 批量查询视频生成任务状态 - * - * Args: - * data: VideoTaskStatus对象,包含job_ids列表 - * - * Returns: - * dict: 按状态分类的任务信息 - * { - * 'data': { - * 'finished': [{'job_id': 'xxx', 'video_url': 'xxx'}], - * 'failed': ['失败的job_id'], - * 'running': ['处理中的job_id'] - * }, - * 'status': True, - * 'msg': '' - * } - * @returns any Successful Response - * @throws ApiError - */ - public static batchQueryVideoStatusApiJmBatchQueryStatusPost({ - requestBody, - }: { - requestBody: VideoTaskStatus, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/jm/batch/query/status', - body: requestBody, - mediaType: 'application/json', - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 获取Modal配置信息 - * 获取当前Modal服务配置信息 - * @returns any Successful Response - * @throws ApiError - */ - public static getModalConfigApiJmModalConfigGet(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/jm/modal/config', - }); - } - /** - * 刷新Modal配置 - * 刷新Modal配置,重新自动发现端点URL - * @returns any Successful Response - * @throws ApiError - */ - public static refreshModalConfigApiJmModalConfigRefreshPost(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/jm/modal/config/refresh', - }); - } - /** - * 创建模型 - * 创建模型 - * - * Args: - * tags: 模型标签,格式:性别_类别_尺寸_材质_颜色 - * cover_image: 封面图片文件 - * status: 状态,默认为1 - * db: 数据库会话 - * - * Returns: - * dict: 包含创建结果的响应 - * { - * 'status': 创建状态, - * 'data': { - * 'id': 模型ID, - * 'tag': {'sex': '性别', 'category': '类别', 'size': '尺寸', 'material': '材质', 'color': '颜色'}, - * 'cover_url': '封面URL', - * 'status': 状态, - * 'create_time': '创建时间' - * }, - * 'msg': '提示信息' - * } - * @returns any Successful Response - * @throws ApiError - */ - public static createModelApiModelsCreatePost({ - formData, - }: { - formData: Body_create_model_api_models_create_post, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/models/create', - formData: formData, - mediaType: 'multipart/form-data', - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 获取模特列表 - * 获取模型列表 - * - * Args: - * status: 状态筛选,1启用,0禁用,为空时获取所有 - * db: 数据库会话 - * - * Returns: - * dict: 包含模型列表的响应 - * { - * 'status': 查询状态, - * 'data': [模型信息列表], - * 'msg': '提示信息' - * } - * @returns any Successful Response - * @throws ApiError - */ - public static getModelsListApiModelsListGet({ - status, - }: { - /** - * 状态筛选,1启用,0禁用 - */ - status?: (number | null), - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/models/list', - query: { - 'status': status, - }, - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 更新模型 - * 更新模型信息 - * - * Args: - * model_id: 模型ID - * tags: 更新的标签,格式:性别_类别_尺寸_材质_颜色(可选) - * cover_image: 更新的封面图片文件(可选) - * status: 更新的状态(可选) - * db: 数据库会话 - * - * Returns: - * dict: 包含更新结果的响应 - * @returns any Successful Response - * @throws ApiError - */ - public static updateModelApiModelsModelIdPut({ - modelId, - formData, - }: { - modelId: number, - formData?: Body_update_model_api_models__model_id__put, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'PUT', - url: '/api/models/{model_id}', - path: { - 'model_id': modelId, - }, - formData: formData, - mediaType: 'multipart/form-data', - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 删除单个模型 - * 删除单个模型(软删除) - * - * Args: - * model_id: 模型ID - * db: 数据库会话 - * - * Returns: - * dict: 删除结果 - * @returns any Successful Response - * @throws ApiError - */ - public static deleteModelApiModelsModelIdDelete({ - modelId, - }: { - modelId: number, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/api/models/{model_id}', - path: { - 'model_id': modelId, - }, - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 删除模型,支持批量 - * 批量删除模型(软删除) - * - * Args: - * model_ids: 模型ID列表 - * db: 数据库会话 - * - * Returns: - * dict: 删除结果 - * { - * 'status': 删除状态, - * 'data': { - * 'total': 总数, - * 'success': 成功数, - * 'failed': 失败数 - * }, - * 'msg': '提示信息' - * } - * @returns any Successful Response - * @throws ApiError - */ - public static removeModelsApiModelsRemovePost({ - requestBody, - }: { - requestBody: Array, - }): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/api/models/remove', - body: requestBody, - mediaType: 'application/json', - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 根据标签筛选模型列表 - * 根据标签筛选模型列表 - * 支持格式:性别_类别_尺寸_材质_颜色,使用特殊匹配规则 - * - * 匹配规则: - * - sex(性别)和 category(类别):等值匹配(必须完全相同,AND逻辑) - * - size(尺寸)、material(材质)、color(颜色):非等值匹配(所有字段都必须不同,AND逻辑) - * - * Args: - * tags: 标签字符串,格式:性别_类别_尺寸_材质_颜色 - * status: 状态筛选,默认为1 - * db: 数据库会话 - * - * Returns: - * dict: 包含筛选结果的响应 - * @returns any Successful Response - * @throws ApiError - */ - public static getModelsByTagApiModelsByTagsGet({ - tags, - status, - }: { - /** - * 标签,格式:性别_类别_尺寸_材质_颜色。例如: '女_上衣_长款_牛仔_红' - */ - tags: string, - /** - * 状态筛选,1启用,0禁用 - */ - status?: (number | null), - }): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/models/by/tags', - query: { - 'tags': tags, - 'status': status, - }, - errors: { - 422: `Validation Error`, - }, - }); - } - /** - * 获取换背景标签 - * @returns any Successful Response - * @throws ApiError - */ - public static fetchStyleAvailableTagsApiTagStyleTagListGet(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/tag/style/tag_list', - }); - } - /** - * 获取模特标签列表 - * @returns any Successful Response - * @throws ApiError - */ - public static fetchModelTagsApiTagModelTagListGet(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/tag/model/tag_list', - }); - } - /** - * 获取jm生成视频的提示词 - * @returns any Successful Response - * @throws ApiError - */ - public static fetchJmPromptApiConfigJmPromptGet(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/api/config/jm/prompt', - }); - } - } diff --git a/src/api/services/TagService.ts b/src/api/services/TagService.ts new file mode 100644 index 0000000..9e89da7 --- /dev/null +++ b/src/api/services/TagService.ts @@ -0,0 +1,42 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class TagService { + /** + * 获取换背景标签 + * @returns any Successful Response + * @throws ApiError + */ + public static fetchStyleAvailableTagsApiTagStyleTagListGet(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/api/tag/style/tag_list', + }); + } + /** + * 获取模特标签列表 + * @returns any Successful Response + * @throws ApiError + */ + public static fetchModelTagsApiTagModelTagListGet(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/api/tag/model/tag_list', + }); + } + /** + * 获取jm生成视频的提示词 + * @returns any Successful Response + * @throws ApiError + */ + public static fetchJmPromptApiConfigJmPromptGet(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/api/config/jm/prompt', + }); + } +} diff --git a/src/api/services/VideoGenerateService.ts b/src/api/services/VideoGenerateService.ts new file mode 100644 index 0000000..a25c06c --- /dev/null +++ b/src/api/services/VideoGenerateService.ts @@ -0,0 +1,112 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { BatchVideoTaskRequest } from '../models/BatchVideoTaskRequest'; +import type { VideoTaskStatus } from '../models/VideoTaskStatus'; +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class VideoGenerateService { + /** + * 异步批量提交任务 + * @returns any Successful Response + * @throws ApiError + */ + public static submitVideoTaskApiJmSubmitTaskPost({ + requestBody, + }: { + requestBody: BatchVideoTaskRequest, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/jm/submit/task', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 查询视频生成任务状态 + * @returns any Successful Response + * @throws ApiError + */ + public static queryVideoTaskApiJmQueryStatusGet({ + jobId, + }: { + jobId: string, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/api/jm/query/status', + query: { + 'job_id': jobId, + }, + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 批量查询视频生成任务状态 + * 批量查询视频生成任务状态 + * + * Args: + * data: VideoTaskStatus对象,包含job_ids列表 + * + * Returns: + * dict: 按状态分类的任务信息 + * { + * 'data': { + * 'finished': [{'job_id': 'xxx', 'video_url': 'xxx'}], + * 'failed': ['失败的job_id'], + * 'running': ['处理中的job_id'] + * }, + * 'status': True, + * 'msg': '' + * } + * @returns any Successful Response + * @throws ApiError + */ + public static batchQueryVideoStatusApiJmBatchQueryStatusPost({ + requestBody, + }: { + requestBody: VideoTaskStatus, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/jm/batch/query/status', + body: requestBody, + mediaType: 'application/json', + errors: { + 422: `Validation Error`, + }, + }); + } + /** + * 获取Modal配置信息 + * 获取当前Modal服务配置信息 + * @returns any Successful Response + * @throws ApiError + */ + public static getModalConfigApiJmModalConfigGet(): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/api/jm/modal/config', + }); + } + /** + * 刷新Modal配置 + * 刷新Modal配置,重新自动发现端点URL + * @returns any Successful Response + * @throws ApiError + */ + public static refreshModalConfigApiJmModalConfigRefreshPost(): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/jm/modal/config/refresh', + }); + } + } diff --git a/src/api/services/WebhookWebhookService.ts b/src/api/services/WebhookWebhookService.ts new file mode 100644 index 0000000..4874bb2 --- /dev/null +++ b/src/api/services/WebhookWebhookService.ts @@ -0,0 +1,21 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; +export class WebhookWebhookService { + /** + * @deprecated + * 异步数据处理 + * @returns any Successful Response + * @throws ApiError + */ + public static asyncWebhookSlotApiAsyncWebhookReceiverPost(): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/api/async/webhook/receiver', + }); + } +} diff --git a/src/api/services/index.ts b/src/api/services/index.ts index 51cb6d9..7d1232d 100644 --- a/src/api/services/index.ts +++ b/src/api/services/index.ts @@ -1,2 +1,7 @@ -export * from './DefaultService'; -export * from './WebhookService'; \ No newline at end of file +export * from './DataQueryService'; +export * from './ImageGenerateService'; +export * from './ModelService'; +export * from './TagService'; +export * from './VideoGenerateService'; +export * from './WebhookService'; +export * from './WebhookWebhookService'; \ No newline at end of file diff --git a/src/lib/api.ts b/src/lib/api.ts index ae21395..c05058a 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,6 +1,5 @@ import { OpenAPI } from '@/api/core/OpenAPI'; -import * as Service from '@/api/services/Service'; -import * as DefaultService from '@/api/services/DefaultService'; +import * as TagService from '@/api/services/TagService'; import * as WebhookService from '@/api/services/WebhookService'; const baseURL = (() => { @@ -12,8 +11,8 @@ OpenAPI.BASE = baseURL; // 统一导出 api 实例(同步导入,保证 api 是同步对象) export const api = { - ...Service, - ...DefaultService, + ...TagService, ...WebhookService, OpenAPI, }; + diff --git a/src/pages/ChangeBgPage/index.tsx b/src/pages/ChangeBgPage/index.tsx index 3c6434c..489ab2b 100644 --- a/src/pages/ChangeBgPage/index.tsx +++ b/src/pages/ChangeBgPage/index.tsx @@ -1,12 +1,11 @@ import { Button } from '@/components/ui/button'; import { Form } from '@/components/ui/form'; -import { api } from '@/lib/api'; import { zodResolver } from '@hookform/resolvers/zod'; import React, { useEffect, useRef, useState } from 'react'; import { useForm } from 'react-hook-form'; import { z } from 'zod'; import ClothingCard from './components/ClothingCard'; -import type { Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post } from '@/api'; +import { api, type Body_local_cloud_async_change_bg_api_v2_cloud_batch_change_bg_post } from '@/api'; // 五级联动的 tag schema const tagSchema = z.object({ @@ -50,7 +49,7 @@ const TryOnPage: React.FC = () => { // 拉取标签数据 useEffect(() => { - api.Service.fetchStyleAvailableTagsApiTagStyleTagListGet().then(data => setScenesOptions(data.data || [])); + api.TagService.fetchStyleAvailableTagsApiTagStyleTagListGet().then(data => setScenesOptions(data.data || [])); }, []); const tags = form.watch('tags'); @@ -126,7 +125,7 @@ const TryOnPage: React.FC = () => { scenes_list: JSON.stringify([{ title: scene.title, prompt: scene.prompt }]), }; // eslint-disable-next-line no-await-in-loop - const res = await api.DefaultService.localCloudAsyncChangeBgApiV2CloudBatchChangeBgPost({ formData }); + const res = await api.ImageGenerateService.localCloudAsyncChangeBgApiV2CloudBatchChangeBgPost({ formData }); results.push(res); } } diff --git a/src/pages/ModelPage/components/ModelForm.tsx b/src/pages/ModelPage/components/ModelForm.tsx index 31f57ad..12aeae0 100644 --- a/src/pages/ModelPage/components/ModelForm.tsx +++ b/src/pages/ModelPage/components/ModelForm.tsx @@ -6,7 +6,7 @@ import { Form, FormField, FormItem, FormLabel, FormControl, FormMessage } from ' import { useForm } from 'react-hook-form'; import { z } from 'zod'; import { zodResolver } from '@hookform/resolvers/zod'; -import { api } from '@/lib/api'; +import { api } from '@/api'; interface ModelFormProps { initialData?: any; @@ -87,7 +87,7 @@ const ModelForm: React.FC = ({ initialData, onSubmit, onCancel, // 拉取标签数据 useEffect(() => { - api.Service.fetchModelTagsApiTagModelTagListGet().then(data => setTagOptions(data.data || [])); + api.TagService.fetchModelTagsApiTagModelTagListGet().then(data => setTagOptions(data.data || [])); }, []); // 提交 diff --git a/src/pages/ModelPage/index.tsx b/src/pages/ModelPage/index.tsx index 2167f3d..43f76cf 100644 --- a/src/pages/ModelPage/index.tsx +++ b/src/pages/ModelPage/index.tsx @@ -4,8 +4,8 @@ import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog'; import type { Body_create_model_api_models_create_post } from '@/api/models/Body_create_model_api_models_create_post'; import type { Body_update_model_api_models__model_id__put } from '@/api/models/Body_update_model_api_models__model_id__put'; import ModelForm from './components/ModelForm'; -import { api } from '@/lib/api'; import { ConfirmDialog } from '@/components/block/confirm-dialog'; +import { api } from '@/api'; interface ModelItem { id: number; @@ -25,7 +25,7 @@ const ModelPage: React.FC = () => { const fetchModels = async () => { setLoading(true); try { - const res = await api.Service.getModelsListApiModelsListGet({}); + const res = await api.ModelService.getModelsListApiModelsListGet({}); setModels(res.data || []); } finally { setLoading(false); @@ -52,7 +52,7 @@ const ModelPage: React.FC = () => { ConfirmDialog.confirm({ content: '确定要删除该模特吗?', onConfirm: async () => { - await api.Service.deleteModelApiModelsModelIdDelete({ modelId: id }); + await api.ModelService.deleteModelApiModelsModelIdDelete({ modelId: id }); fetchModels(); }, }); @@ -60,9 +60,9 @@ const ModelPage: React.FC = () => { const handleFormSubmit = async (data: Body_create_model_api_models_create_post | Body_update_model_api_models__model_id__put, id?: number) => { if (editMode && id) { - await api.Service.updateModelApiModelsModelIdPut({ modelId: id, formData: data as Body_update_model_api_models__model_id__put }); + await api.ModelService.updateModelApiModelsModelIdPut({ modelId: id, formData: data as Body_update_model_api_models__model_id__put }); } else { - await api.Service.createModelApiModelsCreatePost({ formData: data as Body_create_model_api_models_create_post }); + await api.ModelService.createModelApiModelsCreatePost({ formData: data as Body_create_model_api_models_create_post }); } setOpen(false); fetchModels(); diff --git a/src/pages/TryOnPage/index.tsx b/src/pages/TryOnPage/index.tsx index 9b3a6b2..92103d2 100644 --- a/src/pages/TryOnPage/index.tsx +++ b/src/pages/TryOnPage/index.tsx @@ -1,12 +1,12 @@ import type { Body_local_async_gen_images_api_v2_local_batch_edit_images_post } from '@/api/models/Body_local_async_gen_images_api_v2_local_batch_edit_images_post'; import { Button } from '@/components/ui/button'; import { Form } from '@/components/ui/form'; -import { api } from '@/lib/api'; import { zodResolver } from '@hookform/resolvers/zod'; import React, { useEffect, useRef, useState } from 'react'; import { useForm } from 'react-hook-form'; import { z } from 'zod'; import ClothingCard from './components/ClothingCard'; +import { api } from '@/api'; // 五级联动的 tag schema const tagSchema = z.object({ @@ -61,8 +61,8 @@ const TryOnPage: React.FC = () => { // 拉取标签数据 useEffect(() => { - api.Service.fetchModelTagsApiTagModelTagListGet().then(data => setTagOptions(data.data || [])); - api.Service.fetchStyleAvailableTagsApiTagStyleTagListGet().then(data => setScenesOptions(data.data || [])); + api.TagService.fetchModelTagsApiTagModelTagListGet().then(data => setTagOptions(data.data || [])); + api.TagService.fetchStyleAvailableTagsApiTagStyleTagListGet().then(data => setScenesOptions(data.data || [])); }, []); const tags = form.watch('tags'); @@ -176,7 +176,7 @@ const TryOnPage: React.FC = () => { mode: 'both', }; // eslint-disable-next-line no-await-in-loop - const res = await api.DefaultService.localAsyncGenImagesApiV2LocalBatchEditImagesPost({ formData }); + const res = await api.ImageGenerateService.localAsyncGenImagesApiV2LocalBatchEditImagesPost({ formData }); results.push(res); } } diff --git a/src/pages/TryOnTasksPage/index.tsx b/src/pages/TryOnTasksPage/index.tsx index c3a2f3f..bcdab73 100644 --- a/src/pages/TryOnTasksPage/index.tsx +++ b/src/pages/TryOnTasksPage/index.tsx @@ -1,6 +1,5 @@ import React, { useCallback, useEffect, useState } from 'react'; import { useApi } from '@/hooks/useApi'; -import { api } from '@/lib/api'; import type { VideoDataPaginationRequest } from '@/api/models/VideoDataPaginationRequest'; import type { PaginationResponse } from '@/api/models/PaginationResponse'; import { Table, TableHeader, TableBody, TableHead, TableRow, TableCell } from '@/components/ui/table'; @@ -11,7 +10,7 @@ import { Checkbox } from '@/components/ui/checkbox'; import { ACTION_PROMPTS } from '@/lib/prompt'; import { toast } from 'sonner'; import { addVideoTasks } from '@/lib/indexeddb'; -import type { BatchVideoTaskRequest } from '@/api'; +import { api, type BatchVideoTaskRequest } from '@/api'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; @@ -37,7 +36,7 @@ const TryOnTasksPage: React.FC = () => { const [creating, setCreating] = useState(false); const r = useCallback(async (params: VideoDataPaginationRequest) => { - const res = await api.DefaultService.getImageDataListApiImageDataListPost({ requestBody: params }); + const res = await api.DataQueryService.getImageDataListApiImageDataListPost({ requestBody: params }); return res; }, []); @@ -91,7 +90,7 @@ const TryOnTasksPage: React.FC = () => { img_url: row.img_url, task_id: row.task_id, })); - const res = (await api.Service.submitVideoTaskApiJmSubmitTaskPost({ requestBody: { tasks } })) as { + const res = (await api.VideoGenerateService.submitVideoTaskApiJmSubmitTaskPost({ requestBody: { tasks } })) as { status: boolean; data: { success: { task_id: string; img_url: string }[]; failed: string[] }; msg: string; diff --git a/src/pages/TryOnVideoTaskPage/index.tsx b/src/pages/TryOnVideoTaskPage/index.tsx index 5eabe39..6659b4b 100644 --- a/src/pages/TryOnVideoTaskPage/index.tsx +++ b/src/pages/TryOnVideoTaskPage/index.tsx @@ -2,12 +2,12 @@ import React, { useEffect, useState } from 'react'; import { getAllVideoTasks, updateVideoTask } from '@/lib/indexeddb'; import { Dialog, DialogContent } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; -import { api } from '@/lib/api'; import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from '@/components/ui/table'; import { Checkbox } from '@/components/ui/checkbox'; import { toast } from 'sonner'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; +import { api } from '@/api'; dayjs.extend(utc); @@ -68,7 +68,7 @@ const TryOnVideoTaskPage: React.FC = () => { .filter(Boolean); if (!job_ids.length) return; setStatusLoading(true); - api.Service.batchQueryVideoStatusApiJmBatchQueryStatusPost({ requestBody: { job_ids } }) + api.VideoGenerateService.batchQueryVideoStatusApiJmBatchQueryStatusPost({ requestBody: { job_ids } }) .then(res => { // 后端返回格式:{ data: { finished: [{job_id, video_url}], running: [job_id], failed: [job_id] }, ... } const map: TaskStatusMap = {};