Browse Source

feat(api): 添加U9Cloud通用统一接口类型和函数

yz 1 month ago
parent
commit
e0f26ea78e
2 changed files with 25 additions and 0 deletions
  1. 18 0
      src/api/common/index.js
  2. 7 0
      src/api/types/common.d.ts

+ 18 - 0
src/api/common/index.js

@@ -11,6 +11,7 @@ import request from '@/router/axios';
  * @typedef {import('@/api/types/common').ItemListResponse} ItemListResponse
  * @typedef {import('@/api/types/common').CustomerInfoData} CustomerInfoData
  * @typedef {import('@/api/types/common').GetCustomerInfoResponse} GetCustomerInfoResponse
+ * @typedef {import('@/api/types/common').UnificationResponse} UnificationResponse
  */
 
 /**
@@ -87,3 +88,20 @@ export const getCustomerInfo = async () => {
     method: 'get'
   });
 };
+
+/**
+ * U9Cloud 通用统一接口
+ * @returns {Promise<UnificationResponse>} 接口响应
+ * @description GET 无参数,返回结构示例:{ code: 500, success: false, data: null, msg: string }
+ * @example
+ * const res = await getUnification();
+ * if (!res.data.success) {
+ *   console.warn(res.data.msg);
+ * }
+ */
+export const getUnification = async () => {
+  return request({
+    url: '/api/blade-u9cloud/api/common/unification',
+    method: 'get'
+  });
+};

+ 7 - 0
src/api/types/common.d.ts

@@ -243,3 +243,10 @@ export interface CustomerInfoData {
  * 获取客户信息API响应类型
  */
 export type GetCustomerInfoResponse = AxiosResponse<ApiResponseData<CustomerInfoData>>;
+
+/**
+ * U9Cloud 通用统一接口响应类型
+ * GET /api/blade-u9cloud/api/common/unification 无参数
+ * 返回示例:{"code":500,"success":false,"data":null,"msg":"..."}
+ */
+export type UnificationResponse = AxiosResponse<ApiResponseData<null>>;