chore(contracts): 同步契约到 rest-api/data-models/model-formats 0.3.0、database 0.2.0(模型压缩包转换与默认模型规则)

This commit is contained in:
2026-09-15 13:55:59 +08:00
parent 8f303c0595
commit f4cf2c70de
5 changed files with 69 additions and 12 deletions
+28 -2
View File
@@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: OpenDance Studio Web 管理服务端 API
version: 0.2.0
version: 0.3.0
description: |
OpenDance Studio 的唯一数据源与契约权威。
契约版本见 contracts/VERSION。字段语义见 contracts/data-models.md。
@@ -317,7 +317,22 @@ paths:
schema: { $ref: '#/components/schemas/ModelPage' }
post:
tags: [models]
summary: 上传模型 + 来源信息(VRM 优先)
summary: 上传模型 + 来源信息(VRM 优先;支持 MMD 模型压缩包自动转换)
description: |
`file` 为单个文件:
- `.vrm` / `.glb` / `.gltf` / `.fbx`:直接入库,`format` 由扩展名决定
- `.zip`:视为 MMD 模型包。服务端解压 → 选取 `.pmx`
(优先 `MODEL_CONVERT_PMX` 指定的名字,默认 `Hatsune Miku.pmx`;
否则取目录最浅、文件最大者)→ 调 Assimp 导出 **FBX**,
导出后**回读校验**(Assimp 的 FBX 导出器对带蒙皮的大骨架模型会写出损坏文件),
失败自动回退 **GLB**,并把过程写入 `conversionNote`。
GLB 产物会把 Assimp 写成外部 URI 的贴图内嵌进二进制块,保证单文件可用。
压缩包原件作为 `model-archive` 资产留存以便溯源。
转换成功且 `autoDefault` 不为 false 时,该模型会被置为全局默认模型
(`isPrimary=1` + `status=published`),并把身份(名称/格式/产物 sha256)
写进源码 `web-server/src/config/default-model.ts`。
requestBody:
required: true
content:
@@ -329,6 +344,9 @@ paths:
file: { type: string, format: binary }
name: { type: string }
isPrimary: { type: boolean }
autoDefault:
type: boolean
description: 仅对 `.zip` 生效;转换成功后是否自动设为默认模型,默认 true
sourceType: { $ref: '#/components/schemas/SourceType' }
sourceName: { type: string }
sourceUrl: { type: string }
@@ -749,6 +767,14 @@ components:
fileUrl: { type: string, nullable: true }
fileSize: { type: integer, nullable: true }
thumbnailUrl: { type: string, nullable: true }
conversionNote:
type: string
nullable: true
description: 由压缩包转换而来时的说明;直传模型为 null
fileSha256:
type: string
nullable: true
description: 模型文件(转换产物)的 sha256,用于换库后定位默认模型
status: { $ref: '#/components/schemas/PublishStatus' }
createdAt: { type: string, format: date-time }
updatedAt: { type: string, format: date-time }