From bcac5a7c12ccdfc8d5654aa299d80257ae3f884a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 22 Sep 2026 16:15:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E4=B8=AA=E6=8F=90=E4=BA=A4=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=E7=9A=84=E7=94=9F=E6=88=90=E9=80=89=E9=A1=B9=E6=98=A0?= =?UTF-8?q?=E5=B0=84=E6=94=B6=E6=95=9B=E4=B8=BA=E5=8D=95=E4=B8=80=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=B8=85=E5=8D=95=20-=20common::validation=20?= =?UTF-8?q?=E7=94=A8=20tripo=5Fgeneration=5Foptions=5Ffrom!=20=E7=94=B1?= =?UTF-8?q?=E4=B8=80=E4=BB=BD=E5=AD=97=E6=AE=B5=E6=B8=85=E5=8D=95=E6=B4=BE?= =?UTF-8?q?=E7=94=9F=E4=B8=89=E4=B8=AA=20From=20=E5=AE=9E=E7=8E=B0=20-=20m?= =?UTF-8?q?ultiview=20=E6=89=8B=E5=86=99=E7=9A=84=20TripoGenerationOptions?= =?UTF-8?q?=20=E6=98=A0=E5=B0=84=E6=94=B9=E4=B8=BA=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=E8=AF=A5=20From=20=E5=AE=9E=E7=8E=B0=20-=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=85=B1=E4=BA=AB=E5=AD=97=E6=AE=B5=E6=97=B6=E4=B8=89=E6=9D=A1?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=B8=80=E8=B5=B7=E8=B7=9F=E4=B8=8A=EF=BC=8C?= =?UTF-8?q?=E7=BC=BA=E5=AD=97=E6=AE=B5=E4=BC=9A=E5=9C=A8=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=9C=9F=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform-tripo/src/common/validation.rs | 71 ++++++++++--------- .../src/multiview_to_model/client.rs | 17 +---- 2 files changed, 41 insertions(+), 47 deletions(-) diff --git a/server-rs/crates/platform-tripo/src/common/validation.rs b/server-rs/crates/platform-tripo/src/common/validation.rs index ba6101458..6cb502b0c 100644 --- a/server-rs/crates/platform-tripo/src/common/validation.rs +++ b/server-rs/crates/platform-tripo/src/common/validation.rs @@ -3,6 +3,7 @@ use shared_contracts::model3d::common::{ Model3dTextureVersion, }; use shared_contracts::model3d::image_to_model::Model3dImageToModelParams; +use shared_contracts::model3d::multiview_to_model::Model3dMultiviewToModelRequest; use shared_contracts::model3d::text_to_model::Model3dTextToModelParams; use super::{TripoError, TripoField, TripoTaskHandle, TripoValidationReason}; @@ -22,42 +23,46 @@ pub(crate) struct TripoGenerationOptions { pub compress: Option, } -impl From<&Model3dTextToModelParams> for TripoGenerationOptions { - fn from(params: &Model3dTextToModelParams) -> Self { - Self { - model: params.model, - texture: params.texture, - pbr: params.pbr, - texture_quality: params.texture_quality, - texture_version: params.texture_version, - geometry_quality: params.geometry_quality, - face_limit: params.face_limit, - auto_size: params.auto_size, - quad: params.quad, - smart_low_poly: params.smart_low_poly, - generate_parts: params.generate_parts, - compress: params.compress, +/// 三个提交入口共享的生成选项字段清单:文本 / 图片 / 多视图三种请求到 +/// [`TripoGenerationOptions`] 的映射全部由这一份清单派生。 +/// +/// 新增共享字段时只改这份清单,三条路径会一起跟上;若某个请求结构缺少该字段, +/// 这里会直接编译失败,而不是在运行时静默漏校验。 +macro_rules! tripo_generation_options_from { + ($($field:ident),+ $(,)?) => { + impl From<&Model3dTextToModelParams> for TripoGenerationOptions { + fn from(params: &Model3dTextToModelParams) -> Self { + Self { $($field: params.$field,)+ } + } } - } + + impl From<&Model3dImageToModelParams> for TripoGenerationOptions { + fn from(params: &Model3dImageToModelParams) -> Self { + Self { $($field: params.$field,)+ } + } + } + + impl From<&Model3dMultiviewToModelRequest> for TripoGenerationOptions { + fn from(request: &Model3dMultiviewToModelRequest) -> Self { + Self { $($field: request.$field,)+ } + } + } + }; } -impl From<&Model3dImageToModelParams> for TripoGenerationOptions { - fn from(params: &Model3dImageToModelParams) -> Self { - Self { - model: params.model, - texture: params.texture, - pbr: params.pbr, - texture_quality: params.texture_quality, - texture_version: params.texture_version, - geometry_quality: params.geometry_quality, - face_limit: params.face_limit, - auto_size: params.auto_size, - quad: params.quad, - smart_low_poly: params.smart_low_poly, - generate_parts: params.generate_parts, - compress: params.compress, - } - } +tripo_generation_options_from! { + model, + texture, + pbr, + texture_quality, + texture_version, + geometry_quality, + face_limit, + auto_size, + quad, + smart_low_poly, + generate_parts, + compress, } pub(crate) fn validate_generation_options( diff --git a/server-rs/crates/platform-tripo/src/multiview_to_model/client.rs b/server-rs/crates/platform-tripo/src/multiview_to_model/client.rs index ac4866464..082d55459 100644 --- a/server-rs/crates/platform-tripo/src/multiview_to_model/client.rs +++ b/server-rs/crates/platform-tripo/src/multiview_to_model/client.rs @@ -43,20 +43,9 @@ impl TripoProviderClient { } Model3dMultiviewInputs::TaskId { task_id } => validate_task_id(task_id)?, } - validate_generation_options(&TripoGenerationOptions { - model: request.model, - texture: request.texture, - pbr: request.pbr, - texture_quality: request.texture_quality, - texture_version: request.texture_version, - geometry_quality: request.geometry_quality, - face_limit: request.face_limit, - auto_size: request.auto_size, - quad: request.quad, - smart_low_poly: request.smart_low_poly, - generate_parts: request.generate_parts, - compress: request.compress, - })?; + // 与 text / image 路径共用同一份字段映射(见 common::validation 的宏), + // 新增共享字段时三条路径一起跟上。 + validate_generation_options(&TripoGenerationOptions::from(request))?; let task_id = self .client .multiview_to_model(to_sdk_params(request)?)