feat(order-service): 重构分类资料收集与订单状态链路

This commit is contained in:
yml2213
2026-11-03 19:46:49 +08:00
parent 6e4758a3c7
commit 9f14e8de7a
59 changed files with 4866 additions and 1734 deletions
@@ -59,7 +59,12 @@ const ALLOWED_CONTENT_TYPES = new Set([
'video/webm',
])
const IMAGE_CONTENT_TYPES = new Set(['image/jpeg', 'image/png', 'image/webp'])
export const ORDER_SERVICE_SCREENSHOT_CONTENT_TYPES = new Set([
'image/jpeg',
'image/png',
'image/webp',
])
const IMAGE_CONTENT_TYPES = ORDER_SERVICE_SCREENSHOT_CONTENT_TYPES
export type UploadedFileDto = {
objectKey: string
@@ -78,6 +83,7 @@ type UploadFileAssetInput = {
scene: unknown
uploaderType: string
uploaderId: string
allowedContentTypes?: ReadonlySet<string>
/** 前端读取到的视频时长(秒),仅在容器里解析不到时作为兜底 */
durationSeconds?: unknown
}
@@ -92,11 +98,17 @@ export async function uploadFileAsset(input: UploadFileAssetInput) {
}
const contentType = normalizeContentType(file.mimetype, file.buffer)
if (!ALLOWED_CONTENT_TYPES.has(contentType)) {
throw createHttpError('文件不符合规则,仅支持 JPG、PNG、WebP、PDF 或 MP4/WebM 视频', {
statusCode: 400,
errorCode: 'upload_file_type_invalid',
})
const allowedContentTypes = input.allowedContentTypes || ALLOWED_CONTENT_TYPES
if (!allowedContentTypes.has(contentType)) {
throw createHttpError(
input.allowedContentTypes
? '文件不符合规则,仅支持 JPG、PNG、WebP 图片'
: '文件不符合规则,仅支持 JPG、PNG、WebP、PDF 或 MP4/WebM 视频',
{
statusCode: 400,
errorCode: 'upload_file_type_invalid',
},
)
}
const isVideo = VIDEO_CONTENT_TYPES.has(contentType)