95 lines
2.4 KiB
TypeScript
95 lines
2.4 KiB
TypeScript
import { cloudService } from './index'
|
|
import { IBlog, IBlogCategory, IBlogComment, IBlogStats, IBlogVisit, INewBlog } from '@/types/blog'
|
|
|
|
import { IPageRecord } from '@/types'
|
|
|
|
export const uploadBlogImageApi = (md5: string, form: FormData): Promise<string> =>
|
|
cloudService({
|
|
url: '/blog-api/blog/file/upload',
|
|
timeout: 10000,
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data'
|
|
},
|
|
method: 'post',
|
|
params: { md5 },
|
|
data: form
|
|
})
|
|
|
|
export const queryBlogApi = (currentPage: number, pageSize: number): Promise<IPageRecord<IBlog>> =>
|
|
cloudService({
|
|
url: '/blog-api/blog/all/page',
|
|
method: 'get',
|
|
params: { currentPage, pageSize }
|
|
})
|
|
|
|
export const queryUnapprovedBlogApi = (): Promise<IBlog[]> =>
|
|
cloudService({
|
|
url: '/blog-api/blog/unapproved',
|
|
method: 'get'
|
|
})
|
|
|
|
export const queryBlogByIdApi = (id: number): Promise<IBlog> =>
|
|
cloudService({
|
|
url: `/blog-api/blog/${id}/content`,
|
|
method: 'get'
|
|
})
|
|
|
|
export const queryBlogCategoryApi = (): Promise<IBlogCategory[]> =>
|
|
cloudService({
|
|
url: '/blog-api/blog/category',
|
|
method: 'get'
|
|
})
|
|
|
|
export const queryBlogStatsApi = (): Promise<IBlogStats> =>
|
|
cloudService({
|
|
url: '/blog-api/blog/stats',
|
|
method: 'get'
|
|
})
|
|
|
|
export const queryLatestBlogApi = (): Promise<IBlog[]> =>
|
|
cloudService({
|
|
url: '/blog-api/blog/latest',
|
|
method: 'get'
|
|
})
|
|
|
|
export const queryBlogCommentApi = (blogId: number): Promise<IBlogComment[]> =>
|
|
cloudService({
|
|
url: `/blog-api/blog/${blogId}/comment`,
|
|
method: 'get'
|
|
})
|
|
|
|
export const addBlogCommentApi = (blogComment: IBlogComment): Promise<boolean> =>
|
|
cloudService({
|
|
url: '/blog-api/blog/comment',
|
|
method: 'put',
|
|
data: blogComment
|
|
})
|
|
|
|
export const addBlogApi = (blog: INewBlog): Promise<boolean> =>
|
|
cloudService({
|
|
url: '/blog-api/blog',
|
|
method: 'post',
|
|
data: blog
|
|
})
|
|
|
|
export const updateBlogApi = (id: number, blog: INewBlog): Promise<boolean> =>
|
|
cloudService({
|
|
url: `/blog-api/blog/${id}`,
|
|
method: 'put',
|
|
data: blog
|
|
})
|
|
|
|
export const deleteBlogApi = (id: number): Promise<boolean> =>
|
|
cloudService({
|
|
url: `/blog-api/blog/${id}`,
|
|
method: 'DELETE'
|
|
})
|
|
|
|
export const queryBlogVisitApi = (currentPage: number,
|
|
pageSize: number): Promise<IPageRecord<IBlogVisit>> =>
|
|
cloudService({
|
|
url: '/blog-api/blog/visit',
|
|
method: 'get',
|
|
params: { currentPage, pageSize }
|
|
})
|