国外MOSE官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
3.5 KiB

3 months ago
  1. import request from '@/utils/http/request';
  2. import type { ApiResponse } from '@/utils/http/types';
  3. // 定义PageParams接口
  4. export interface PageParams {
  5. pageNo?: number;
  6. pageSize?: number;
  7. }
  8. // 社交媒体账号接口
  9. export interface OfficialMediaItem {
  10. id: string;
  11. title: string;
  12. description?: string;
  13. image: string;
  14. link: string;
  15. createBy?: string;
  16. createTime?: string;
  17. updateBy?: string;
  18. updateTime?: string;
  19. }
  20. // 论坛信息接口
  21. export interface ForumItem {
  22. id: string;
  23. title: string;
  24. content: string;
  25. image?: string;
  26. createBy?: string;
  27. createTime?: string;
  28. updateBy?: string;
  29. updateTime?: string;
  30. }
  31. // 评论信息接口
  32. export interface CommentItem {
  33. id?: string;
  34. content: string;
  35. forumId: string;
  36. createBy?: string;
  37. createTime?: string;
  38. updateBy?: string;
  39. updateTime?: string;
  40. }
  41. // 信息公示接口
  42. export interface MessageItem {
  43. id: string;
  44. title: string;
  45. content: string;
  46. image?: string;
  47. createBy?: string;
  48. createTime?: string;
  49. updateBy?: string;
  50. updateTime?: string;
  51. }
  52. // 社区信息接口
  53. export interface CommunityItem {
  54. id: string;
  55. title: string;
  56. content: string;
  57. image?: string;
  58. createBy?: string;
  59. createTime?: string;
  60. updateBy?: string;
  61. updateTime?: string;
  62. }
  63. // 处理API响应
  64. function handleResponse<T>(response: any): T[] {
  65. if (!response) return [];
  66. // 检查响应结构
  67. if (response.result && response.result.records) {
  68. return response.result.records as T[];
  69. } else if (response.records) {
  70. return response.records as T[];
  71. } else if (Array.isArray(response.result)) {
  72. return response.result as T[];
  73. } else if (Array.isArray(response)) {
  74. return response as T[];
  75. }
  76. return [];
  77. }
  78. /**
  79. *
  80. * @param params
  81. * @returns
  82. */
  83. export function queryOfficialMediaList(params?: PageParams & Partial<OfficialMediaItem>) {
  84. return request.get<any>('/mose-admin/mose/community/queryOfficialMediaList', params)
  85. .then(response => handleResponse<OfficialMediaItem>(response));
  86. }
  87. /**
  88. *
  89. * @param params
  90. * @returns
  91. */
  92. export function queryForumList(params?: PageParams & Partial<ForumItem>) {
  93. return request.get<any>('/mose-admin/mose/community/queryForumList', params)
  94. .then(response => handleResponse<ForumItem>(response));
  95. }
  96. /**
  97. *
  98. * @param params
  99. * @returns
  100. */
  101. export function queryCommentsList(params?: PageParams & Partial<CommentItem>) {
  102. return request.get<any>('/mose-admin/mose/community/queryCommentsList', params)
  103. .then(response => handleResponse<CommentItem>(response));
  104. }
  105. /**
  106. *
  107. * @param params
  108. * @returns
  109. */
  110. export function queryMessageList(params?: PageParams & Partial<MessageItem>) {
  111. return request.get<any>('/mose-admin/mose/community/queryMessageList', params)
  112. .then(response => handleResponse<MessageItem>(response));
  113. }
  114. /**
  115. *
  116. * @param params
  117. * @returns
  118. */
  119. export function queryCommunityList(params?: PageParams & Partial<CommunityItem>) {
  120. return request.get<any>('/mose-admin/mose/community/queryCommunityList', params)
  121. .then(response => handleResponse<CommunityItem>(response));
  122. }
  123. /**
  124. *
  125. * @param params
  126. * @returns
  127. */
  128. export function addComments(params: Partial<CommentItem>) {
  129. return request.get<any>('/mose-admin/mose/community/addComments', params);
  130. }