chore: initial commit
This commit is contained in:
22
src/api/blog/category.ts
Normal file
22
src/api/blog/category.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { http } from '@/lib'
|
||||
import type { Category, CategoryForm, PageParams } from '@/schemas'
|
||||
|
||||
export const getCategories = (params: PageParams) => {
|
||||
return http.get<Category[], ApiPageResponse<Category>>('/category', { params })
|
||||
}
|
||||
|
||||
export const createCategory = (data: CategoryForm) => {
|
||||
return http.post('/category', data)
|
||||
}
|
||||
|
||||
export const updateCategory = (id: number, data: CategoryForm) => {
|
||||
return http.patch(`/category/${id}`, data)
|
||||
}
|
||||
|
||||
export const deleteCategory = (id: number) => {
|
||||
return http.delete(`/category/${id}`)
|
||||
}
|
||||
|
||||
export const listAllCategories = () => {
|
||||
return http.get<Category[]>('/category/all')
|
||||
}
|
||||
22
src/api/blog/post.ts
Normal file
22
src/api/blog/post.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { http } from '@/lib'
|
||||
import type { PageParams, Post, PostFormOutput } from '@/schemas'
|
||||
|
||||
export const getPosts = (params: PageParams) => {
|
||||
return http.get<Post[], ApiPageResponse<Post>>('/post', { params })
|
||||
}
|
||||
|
||||
export const createPost = (data: PostFormOutput) => {
|
||||
return http.post<{ post_id: number }>('/post', data)
|
||||
}
|
||||
|
||||
export const updatePost = (id: number, data: PostFormOutput) => {
|
||||
return http.patch(`/post/${id}`, data)
|
||||
}
|
||||
|
||||
export const getPost = (id: number) => {
|
||||
return http.get<Post>(`/post/${id}`)
|
||||
}
|
||||
|
||||
export const deletePost = (id: number) => {
|
||||
return http.delete(`/post/${id}`)
|
||||
}
|
||||
Reference in New Issue
Block a user