23 lines
612 B
TypeScript
23 lines
612 B
TypeScript
import { http } from '@/lib'
|
|
import type { PageParams, Post, PostFormOutput } from '@/schemas'
|
|
|
|
export const listPosts = (params: PageParams) => {
|
|
return http.get<Post[], ApiPageResponse<Post>>('/posts', { params })
|
|
}
|
|
|
|
export const createPost = (data: PostFormOutput) => {
|
|
return http.post<{ post_id: number }>('/posts', data)
|
|
}
|
|
|
|
export const updatePost = (id: number, data: PostFormOutput) => {
|
|
return http.patch(`/posts/${id}`, data)
|
|
}
|
|
|
|
export const getPost = (id: number) => {
|
|
return http.get<Post>(`/posts/${id}`)
|
|
}
|
|
|
|
export const deletePost = (id: number) => {
|
|
return http.delete(`/posts/${id}`)
|
|
}
|