notification-controller.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Generated by orval v7.0.1 🍺
  3. * Do not edit manually.
  4. * Serve API
  5. * Serve应用接口文档
  6. * OpenAPI spec version: 0.0.1-SNAPSHOT
  7. */
  8. import type {
  9. ResponseListNotificationVo,
  10. ResponseUnreadCountVo,
  11. ResponseVoid,
  12. } from "./models";
  13. import { customAxiosInstance } from "../util/axios-instance";
  14. export const getNotificationController = () => {
  15. /**
  16. * @summary 标记已读
  17. */
  18. const markRead = (id: number) => {
  19. return customAxiosInstance<ResponseVoid>({
  20. url: `/notifications/${id}/read`,
  21. method: "PUT",
  22. });
  23. };
  24. /**
  25. * @summary 获取通知列表
  26. */
  27. const listNotifications = () => {
  28. return customAxiosInstance<ResponseListNotificationVo>({
  29. url: `/notifications`,
  30. method: "GET",
  31. });
  32. };
  33. /**
  34. * @summary 获取未读数
  35. */
  36. const getUnreadCount = () => {
  37. return customAxiosInstance<ResponseUnreadCountVo>({
  38. url: `/notifications/unread-count`,
  39. method: "GET",
  40. });
  41. };
  42. return { markRead, listNotifications, getUnreadCount };
  43. };
  44. export type MarkReadResult = NonNullable<
  45. Awaited<ReturnType<ReturnType<typeof getNotificationController>["markRead"]>>
  46. >;
  47. export type ListNotificationsResult = NonNullable<
  48. Awaited<
  49. ReturnType<
  50. ReturnType<typeof getNotificationController>["listNotifications"]
  51. >
  52. >
  53. >;
  54. export type GetUnreadCountResult = NonNullable<
  55. Awaited<
  56. ReturnType<ReturnType<typeof getNotificationController>["getUnreadCount"]>
  57. >
  58. >;