| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /**
- * Generated by orval v7.0.1 🍺
- * Do not edit manually.
- * OpenAPI definition
- * OpenAPI spec version: v0
- */
- import type {
- CategoryRequest,
- ResultListCategory,
- ResultLong,
- ResultVoid,
- StatusRequest,
- } from "../models";
- import { customAxiosInstance } from "../../util/axios-instance";
- export const getCategories = () => {
- /**
- * @summary 修改分类
- */
- const updateCategory = (id: number, categoryRequest: CategoryRequest) => {
- return customAxiosInstance<ResultVoid>({
- url: `/admin/categories/${id}`,
- method: "PUT",
- headers: { "Content-Type": "application/json" },
- data: categoryRequest,
- });
- };
- /**
- * @summary 启用/禁用分类
- */
- const toggleCategoryStatus = (id: number, statusRequest: StatusRequest) => {
- return customAxiosInstance<ResultVoid>({
- url: `/admin/categories/${id}/status`,
- method: "PUT",
- headers: { "Content-Type": "application/json" },
- data: statusRequest,
- });
- };
- /**
- * @summary 新增分类
- */
- const createCategory = (categoryRequest: CategoryRequest) => {
- return customAxiosInstance<ResultLong>({
- url: `/admin/categories`,
- method: "POST",
- headers: { "Content-Type": "application/json" },
- data: categoryRequest,
- });
- };
- /**
- * @summary 获取所有分类列表
- */
- const listCategories = () => {
- return customAxiosInstance<ResultListCategory>({
- url: `/categories`,
- method: "GET",
- });
- };
- return {
- updateCategory,
- toggleCategoryStatus,
- createCategory,
- listCategories,
- };
- };
- export type UpdateCategoryResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getCategories>["updateCategory"]>>
- >;
- export type ToggleCategoryStatusResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getCategories>["toggleCategoryStatus"]>>
- >;
- export type CreateCategoryResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getCategories>["createCategory"]>>
- >;
- export type ListCategoriesResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getCategories>["listCategories"]>>
- >;
|