数据结构优化

This commit is contained in:
李琦
2026-01-19 20:21:09 +08:00
parent 68c4c6df1c
commit 7e918cedd4
39 changed files with 3703 additions and 824 deletions

View File

@@ -1445,6 +1445,40 @@ export interface Inquiry {
// OSS配置相关类型
export interface OSSConfig {
id: number
name: string
storageType: string
// 通用字段(向后兼容)
accessKey?: string
secretKey?: string
bucket?: string
region?: string
domain?: string
// 阿里云OSS专用字段
ossAccessKeyId?: string
ossAccessKeySecret?: string
ossEndpoint?: string
ossBucket?: string
ossDomain?: string
// 腾讯云COS专用字段
qcloudSecretId?: string
qcloudSecretKey?: string
qcloudRegion?: string
qcloudBucket?: string
qcloudDomain?: string
// 七牛云专用字段
qiniuAccessKey?: string
qiniuSecretKey?: string
qiniuBucket?: string
qiniuRegion?: string
qiniuDomain?: string
isActive: number
createdAt: string
updatedAt: string
}
// 向后兼容的旧接口定义(已废弃,保留用于类型兼容)
export interface OSSConfigOld {
id: number
name: string
storageType: string // local/qcloud/aliyun/qiniu
@@ -1590,3 +1624,122 @@ export const deleteOSSConfig = async (id: number): Promise<void> => {
throw error
}
}
// 附件相关类型
export interface Attachment {
id: number
categoryId?: number
category?: {
id: number
name: string
}
originalName: string
storedName: string
filePath: string
fileUrl: string
fileSize: number
fileType: string
mimeType: string
storageType: string
ossConfigId?: number
createdAt: string
updatedAt: string
}
// 附件分类相关类型
export interface AttachmentCategory {
id: number
name: string
description: string
sortOrder: number
createdAt: string
updatedAt: string
}
// 附件管理API
export const updateAttachment = async (id: number, data: { categoryId?: number | null }): Promise<Attachment> => {
try {
const response = await fetch(`${API_BASE}/admin/attachments/${id}`, {
method: 'PUT',
headers: getAuthHeaders(),
body: JSON.stringify(data)
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.message || '更新附件失败')
}
const responseData = await response.json()
return responseData.result
} catch (error) {
console.error('Update attachment error:', error)
throw error
}
}
// 附件分类管理API
export const getAttachmentCategories = async (): Promise<AttachmentCategory[]> => {
try {
const response = await fetch(`${API_BASE}/admin/attachment-categories`, {
headers: getAuthHeaders()
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.message || '获取附件分类列表失败')
}
const data = await response.json()
return data.result || []
} catch (error) {
console.error('Get attachment categories error:', error)
throw error
}
}
export const createAttachmentCategory = async (categoryData: Omit<AttachmentCategory, 'id' | 'createdAt' | 'updatedAt'>): Promise<void> => {
try {
const response = await fetch(`${API_BASE}/admin/attachment-categories`, {
method: 'POST',
headers: getAuthHeaders(),
body: JSON.stringify(categoryData)
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.message || '创建附件分类失败')
}
} catch (error) {
console.error('Create attachment category error:', error)
throw error
}
}
export const updateAttachmentCategory = async (id: number, categoryData: Partial<Omit<AttachmentCategory, 'id' | 'createdAt' | 'updatedAt'>>): Promise<void> => {
try {
const response = await fetch(`${API_BASE}/admin/attachment-categories/${id}`, {
method: 'PUT',
headers: getAuthHeaders(),
body: JSON.stringify(categoryData)
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.message || '更新附件分类失败')
}
} catch (error) {
console.error('Update attachment category error:', error)
throw error
}
}
export const deleteAttachmentCategory = async (id: number): Promise<void> => {
try {
const response = await fetch(`${API_BASE}/admin/attachment-categories/${id}`, {
method: 'DELETE',
headers: getAuthHeaders()
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.message || '删除附件分类失败')
}
} catch (error) {
console.error('Delete attachment category error:', error)
throw error
}
}