feat: 统一函数命名

This commit is contained in:
2026-08-02 12:02:17 +08:00
parent 97235386ca
commit 99d5392a68
64 changed files with 331 additions and 1459 deletions

View File

@@ -1,22 +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 listCategories = (params: PageParams) => {
return http.get<Category[], ApiPageResponse<Category>>('/categories', { params })
}
export const createCategory = (data: CategoryForm) => {
return http.post('/category', data)
return http.post('/categories', data)
}
export const updateCategory = (id: number, data: CategoryForm) => {
return http.patch(`/category/${id}`, data)
return http.patch(`/categories/${id}`, data)
}
export const deleteCategory = (id: number) => {
return http.delete(`/category/${id}`)
return http.delete(`/categories/${id}`)
}
export const listAllCategories = () => {
return http.get<Category[]>('/category/all')
return http.get<Category[]>('/categories/all')
}

View File

@@ -1,22 +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 listPosts = (params: PageParams) => {
return http.get<Post[], ApiPageResponse<Post>>('/posts', { params })
}
export const createPost = (data: PostFormOutput) => {
return http.post<{ post_id: number }>('/post', data)
return http.post<{ post_id: number }>('/posts', data)
}
export const updatePost = (id: number, data: PostFormOutput) => {
return http.patch(`/post/${id}`, data)
return http.patch(`/posts/${id}`, data)
}
export const getPost = (id: number) => {
return http.get<Post>(`/post/${id}`)
return http.get<Post>(`/posts/${id}`)
}
export const deletePost = (id: number) => {
return http.delete(`/post/${id}`)
return http.delete(`/posts/${id}`)
}

View File

@@ -1,22 +1,22 @@
import { http } from '@/lib'
import type { PageParams, Tag, TagForm } from '@/schemas'
export const getTags = (params: PageParams) => {
return http.get<Tag[], ApiPageResponse<Tag>>('/tag', { params })
export const listTags = (params: PageParams) => {
return http.get<Tag[], ApiPageResponse<Tag>>('/tags', { params })
}
export const createTag = (data: TagForm) => {
return http.post('/tag', data)
return http.post('/tags', data)
}
export const updateTag = (id: number, data: TagForm) => {
return http.patch(`/tag/${id}`, data)
return http.patch(`/tags/${id}`, data)
}
export const deleteTag = (id: number) => {
return http.delete(`/tag/${id}`)
return http.delete(`/tags/${id}`)
}
export const listAllTags = () => {
return http.get<Tag[]>('/tag/all')
return http.get<Tag[]>('/tags/all')
}