Browse Source

feat(公告): 添加删除公告接口和通用API响应类型

yz 2 weeks ago
parent
commit
e7f75b0186
2 changed files with 39 additions and 0 deletions
  1. 22 0
      src/api/announcement/index.js
  2. 17 0
      src/api/types/announcement.d.ts

+ 22 - 0
src/api/announcement/index.js

@@ -156,3 +156,25 @@ export const getCategoryList = () => {
     method: 'get'
   });
 };
+
+/**
+ * 删除公告
+ * @param {string} id - 公告ID(必填)
+ * @returns {Promise<NoticeOperationResponse>} 操作结果
+ * @throws {Error} 当请求失败或公告不存在时抛出错误
+ * @example
+ * // 删除公告
+ * const response = await deleteNotice('123');
+ * if (response.data.success) {
+ *   console.log('删除成功');
+ * } else {
+ *   console.error('删除失败:', response.data.msg);
+ * }
+ */
+export const deleteNotice = (id) => {
+  return request({
+    url: '/api/blade-factory/api/factory/notice/delete',
+    method: 'post',
+    params: { id }
+  });
+};

+ 17 - 0
src/api/types/announcement.d.ts

@@ -1,4 +1,21 @@
 import { AxiosResponse } from 'axios';
+import type { BaseQueryParams, PageResult } from './common';
+
+/**
+ * API响应接口
+ */
+export interface ApiResponse<T = any> {
+  /** 响应状态码 */
+  code: number;
+  /** 响应消息 */
+  message: string;
+  /** 响应数据 */
+  data: T;
+  /** 是否成功 */
+  success?: boolean;
+  /** 时间戳 */
+  timestamp?: number;
+}
 
 /**
  * 分类状态枚举