提交正式官网
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import request from '@/utils/request'
|
||||
import type { ICommonPageResponse, ICommonResponse } from '@/types/common'
|
||||
|
||||
export type MediaType = 'article' | 'video'
|
||||
|
||||
export interface INewsItem {
|
||||
id: string
|
||||
locale: 'en' | 'zh'
|
||||
mediaType: MediaType
|
||||
title: string
|
||||
summary: string
|
||||
thumbnail: string
|
||||
thumbnailAlt?: string
|
||||
url?: string
|
||||
youtubeUrl?: string
|
||||
tiktokUrl?: string
|
||||
sortOrder: number
|
||||
status: 'published' | 'draft'
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface INewsListParams {
|
||||
page: number
|
||||
pageSize: number
|
||||
locale?: '' | 'en' | 'zh'
|
||||
mediaType?: '' | MediaType
|
||||
keyword?: string
|
||||
status?: '' | 'published' | 'draft'
|
||||
}
|
||||
|
||||
export interface INewsInput {
|
||||
id?: string
|
||||
locale: 'en' | 'zh'
|
||||
mediaType: MediaType
|
||||
title: string
|
||||
summary: string
|
||||
thumbnail: string
|
||||
thumbnailAlt?: string
|
||||
url?: string
|
||||
youtubeUrl?: string
|
||||
tiktokUrl?: string
|
||||
sortOrder?: number
|
||||
status?: 'published' | 'draft'
|
||||
}
|
||||
|
||||
export const newsPage = (params?: INewsListParams) => {
|
||||
return request.get<ICommonPageResponse<INewsItem[]>>('/news', { params })
|
||||
}
|
||||
|
||||
export const createNews = (data: INewsInput) => {
|
||||
return request.post<ICommonResponse<INewsItem>>('/news', data)
|
||||
}
|
||||
|
||||
export const updateNews = (data: INewsInput & { id: string }) => {
|
||||
return request.put<ICommonResponse<INewsItem>>('/news', data)
|
||||
}
|
||||
|
||||
export const deleteNews = (ids: string[]) => {
|
||||
return request.delete<ICommonResponse<unknown>>('/news', { data: ids })
|
||||
}
|
||||
Reference in New Issue
Block a user