新增数字人版本管理
This commit is contained in:
157
frontend-vue/src/shared/api/digital-human.ts
Normal file
157
frontend-vue/src/shared/api/digital-human.ts
Normal file
@@ -0,0 +1,157 @@
|
||||
import { get, post, del, type JavaApiResponse, unwrapJavaResponse } from '@/shared/api/http'
|
||||
|
||||
const JAVA_API_PREFIX = '/newApi/api/digital-human/versions'
|
||||
|
||||
/**
|
||||
* 数字人版本信息
|
||||
*/
|
||||
export interface DigitalHumanVersion {
|
||||
id: number
|
||||
version: string
|
||||
ossObjectKey: string
|
||||
fileSize: number
|
||||
md5: string
|
||||
changelog: string | null
|
||||
minClientVersion: string | null
|
||||
isLatest: boolean
|
||||
status: 'DRAFT' | 'RELEASED' | 'DEPRECATED'
|
||||
createdBy: string | null
|
||||
createdAt: string
|
||||
releasedAt: string | null
|
||||
downloadUrl?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载链接信息
|
||||
*/
|
||||
export interface DownloadUrlVo {
|
||||
version: string
|
||||
downloadUrl: string
|
||||
expiresIn: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询参数
|
||||
*/
|
||||
export interface VersionListParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
status?: 'DRAFT' | 'RELEASED' | 'DEPRECATED'
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页结果
|
||||
*/
|
||||
export interface PageResult<T> {
|
||||
records: T[]
|
||||
total: number
|
||||
size: number
|
||||
current: number
|
||||
pages: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传新版本
|
||||
*/
|
||||
export function uploadDigitalHumanVersion(
|
||||
file: File,
|
||||
version: string,
|
||||
changelog?: string,
|
||||
minClientVersion?: string,
|
||||
) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
formData.append('version', version)
|
||||
if (changelog) formData.append('changelog', changelog)
|
||||
if (minClientVersion) formData.append('minClientVersion', minClientVersion)
|
||||
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<DigitalHumanVersion>>(
|
||||
`${JAVA_API_PREFIX}/upload`,
|
||||
formData,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询版本列表
|
||||
*/
|
||||
export function getDigitalHumanVersions(params?: VersionListParams) {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<PageResult<DigitalHumanVersion>>>(
|
||||
JAVA_API_PREFIX,
|
||||
{ params },
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新版本
|
||||
*/
|
||||
export function getLatestDigitalHumanVersion() {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<DigitalHumanVersion>>(
|
||||
`${JAVA_API_PREFIX}/latest`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定版本详情
|
||||
*/
|
||||
export function getDigitalHumanVersion(version: string) {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<DigitalHumanVersion>>(
|
||||
`${JAVA_API_PREFIX}/${version}`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布版本
|
||||
*/
|
||||
export function releaseDigitalHumanVersion(version: string) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<void>>(
|
||||
`${JAVA_API_PREFIX}/${version}/release`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设为最新版本
|
||||
*/
|
||||
export function setLatestDigitalHumanVersion(version: string) {
|
||||
return unwrapJavaResponse(
|
||||
post<JavaApiResponse<void>>(
|
||||
`${JAVA_API_PREFIX}/${version}/set-latest`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除版本
|
||||
*/
|
||||
export function deleteDigitalHumanVersion(version: string) {
|
||||
return unwrapJavaResponse(
|
||||
del<JavaApiResponse<void>>(
|
||||
`${JAVA_API_PREFIX}/${version}`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载链接
|
||||
*/
|
||||
export function getDigitalHumanVersionDownloadUrl(version: string) {
|
||||
return unwrapJavaResponse(
|
||||
get<JavaApiResponse<DownloadUrlVo>>(
|
||||
`${JAVA_API_PREFIX}/${version}/download-url`,
|
||||
),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user