| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- /**
- * Generated by orval v7.0.1 🍺
- * Do not edit manually.
- * Serve API
- * Serve应用接口文档
- * OpenAPI spec version: 0.0.1-SNAPSHOT
- */
- import type {
- ListPostsParams,
- ListPreviousPostsParams,
- PostDto,
- ResponseCreatePostVo,
- ResponsePageVoListPostVo,
- ResponsePostVo,
- ResponseVoid,
- UpdateHitStatusDto,
- UpdateViewCountDto,
- } from "./models";
- import { customAxiosInstance } from "../util/axios-instance";
- export const getPostController = () => {
- /**
- * @summary 获取帖子详情
- */
- const getPostDetail = (id: number) => {
- return customAxiosInstance<ResponsePostVo>({
- url: `/posts/${id}`,
- method: "GET",
- });
- };
- /**
- * @summary 更新帖子(管理员/本人)
- */
- const updatePost = (id: number, postDto: PostDto) => {
- return customAxiosInstance<ResponseVoid>({
- url: `/posts/${id}`,
- method: "PUT",
- headers: { "Content-Type": "application/json" },
- data: postDto,
- });
- };
- /**
- * @summary 删除帖子(管理员,逻辑删除)
- */
- const deletePost = (id: number) => {
- return customAxiosInstance<ResponseVoid>({
- url: `/posts/${id}`,
- method: "DELETE",
- });
- };
- /**
- * @summary 修改查看人数(管理员)
- */
- const updateViewCount = (
- id: number,
- updateViewCountDto: UpdateViewCountDto,
- ) => {
- return customAxiosInstance<ResponseVoid>({
- url: `/posts/${id}/view-count`,
- method: "PUT",
- headers: { "Content-Type": "application/json" },
- data: updateViewCountDto,
- });
- };
- /**
- * @summary 设置命中状态(管理员)
- */
- const updateHitStatus = (
- id: number,
- updateHitStatusDto: UpdateHitStatusDto,
- ) => {
- return customAxiosInstance<ResponseVoid>({
- url: `/posts/${id}/hit-status`,
- method: "PUT",
- headers: { "Content-Type": "application/json" },
- data: updateHitStatusDto,
- });
- };
- /**
- * @summary 获取帖子列表
- */
- const listPosts = (params?: ListPostsParams) => {
- return customAxiosInstance<ResponsePageVoListPostVo>({
- url: `/posts`,
- method: "GET",
- params,
- });
- };
- /**
- * @summary 创建帖子(仅专家/管理员)
- */
- const createPost = (postDto: PostDto) => {
- return customAxiosInstance<ResponseCreatePostVo>({
- url: `/posts`,
- method: "POST",
- headers: { "Content-Type": "application/json" },
- data: postDto,
- });
- };
- /**
- * @summary 获取专家往期帖子
- */
- const listPreviousPosts = (
- expertId: number,
- params?: ListPreviousPostsParams,
- ) => {
- return customAxiosInstance<ResponsePageVoListPostVo>({
- url: `/posts/expert/${expertId}/previous`,
- method: "GET",
- params,
- });
- };
- return {
- getPostDetail,
- updatePost,
- deletePost,
- updateViewCount,
- updateHitStatus,
- listPosts,
- createPost,
- listPreviousPosts,
- };
- };
- export type GetPostDetailResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getPostController>["getPostDetail"]>>
- >;
- export type UpdatePostResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getPostController>["updatePost"]>>
- >;
- export type DeletePostResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getPostController>["deletePost"]>>
- >;
- export type UpdateViewCountResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getPostController>["updateViewCount"]>>
- >;
- export type UpdateHitStatusResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getPostController>["updateHitStatus"]>>
- >;
- export type ListPostsResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getPostController>["listPosts"]>>
- >;
- export type CreatePostResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getPostController>["createPost"]>>
- >;
- export type ListPreviousPostsResult = NonNullable<
- Awaited<ReturnType<ReturnType<typeof getPostController>["listPreviousPosts"]>>
- >;
|