数据结构优化
This commit is contained in:
@@ -94,6 +94,8 @@ export interface Post {
|
||||
categoryName?: string // Display name
|
||||
categorySlug?: string
|
||||
category?: Category // Optional full object
|
||||
columnId?: number | null
|
||||
columnName?: string
|
||||
tags?: Tag[]
|
||||
date: string
|
||||
excerpt?: string
|
||||
@@ -515,13 +517,14 @@ export const getAdminPosts = async (): Promise<PaginationResponse<Post>> => {
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchPosts = async (query?: string, categoryId?: number, tagId?: number): Promise<Post[]> => {
|
||||
export const fetchPosts = async (query?: string, categoryId?: number, tagId?: number, columnId?: number): Promise<Post[]> => {
|
||||
try {
|
||||
let url = `${API_BASE}/posts`
|
||||
const params = new URLSearchParams()
|
||||
if (query) params.append('q', query)
|
||||
if (categoryId) params.append('category', categoryId.toString())
|
||||
if (tagId) params.append('tag', tagId.toString())
|
||||
if (columnId) params.append('column', columnId.toString())
|
||||
|
||||
if (params.toString()) {
|
||||
url += `?${params.toString()}`
|
||||
@@ -1440,6 +1443,21 @@ export interface Inquiry {
|
||||
createdAt?: string
|
||||
}
|
||||
|
||||
// OSS配置相关类型
|
||||
export interface OSSConfig {
|
||||
id: number
|
||||
name: string
|
||||
storageType: string // local/qcloud/aliyun/qiniu
|
||||
accessKey: string // 加密存储,返回时显示为 ***
|
||||
secretKey: string // 加密存储,返回时显示为 ***
|
||||
bucket: string
|
||||
region: string
|
||||
domain: string
|
||||
isActive: number
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface EmailSuffix {
|
||||
id: number
|
||||
suffix: string
|
||||
@@ -1500,3 +1518,75 @@ export const fetchInquiries = async (): Promise<Inquiry[]> => {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// OSS配置相关API
|
||||
export const getOSSConfigs = async (): Promise<OSSConfig[]> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/oss-configs`, {
|
||||
headers: getAuthHeaders()
|
||||
})
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.message || '获取OSS配置失败')
|
||||
}
|
||||
const data = await response.json()
|
||||
return data.result || []
|
||||
} catch (error) {
|
||||
console.error('Get OSS configs error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export const createOSSConfig = async (configData: Omit<OSSConfig, 'id' | 'createdAt' | 'updatedAt'>): Promise<OSSConfig> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/oss-configs`, {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders(),
|
||||
body: JSON.stringify(configData)
|
||||
})
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.message || '创建OSS配置失败')
|
||||
}
|
||||
const data = await response.json()
|
||||
return data.result
|
||||
} catch (error) {
|
||||
console.error('Create OSS config error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export const updateOSSConfig = async (id: number, configData: Partial<Omit<OSSConfig, 'id' | 'createdAt' | 'updatedAt'>>): Promise<OSSConfig> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/oss-configs/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: getAuthHeaders(),
|
||||
body: JSON.stringify(configData)
|
||||
})
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.message || '更新OSS配置失败')
|
||||
}
|
||||
const data = await response.json()
|
||||
return data.result
|
||||
} catch (error) {
|
||||
console.error('Update OSS config error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export const deleteOSSConfig = async (id: number): Promise<void> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/oss-configs/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: getAuthHeaders()
|
||||
})
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.message || '删除OSS配置失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Delete OSS config error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user