Procházet zdrojové kódy

feat: API的type.d

lvkun před 2 roky
rodič
revize
280b26fed6
2 změnil soubory, kde provedl 26 přidání a 43 odebrání
  1. 18 8
      src/api/datacenter/apiCenter.ts
  2. 8 35
      src/type/dc.d.ts

+ 18 - 8
src/api/datacenter/apiCenter.ts

@@ -3,8 +3,8 @@ import request from '@/service/request'
 /**
  * API列表分页查询
  * */
-export function getApiTableList (params) {
-  return request({
+export function getApiTableList (params: COMMON.API.QueryParams) {
+  return request<DC.API.Api[]>({
     url: '/apiCenter/page',
     method: 'GET',
     params
@@ -14,8 +14,8 @@ export function getApiTableList (params) {
 /**
  * API列表编辑弹框修改
  */
-export async function updateApiTableItem (data) {
-  return request({
+export async function updateApiTableItem (data: DC.API.Api) {
+  return request<string>({
     url: '/apiCenter',
     method: 'PUT',
     data
@@ -27,7 +27,7 @@ export async function updateApiTableItem (data) {
  * 用appId获取
  */
 export async function getDetailById (data) {
-  return request({
+  return request<DC.API.Api>({
     url: `/apiCenter?id=${data.id}&serviceId=${data.serviceId}${data.vid ? ('&vId=' + data.vid) : ''}`,
     method: 'GET'
   })
@@ -37,7 +37,7 @@ export async function getDetailById (data) {
  * 根据id删除api
  */
 export function delDataById (id: string) {
-  return request({
+  return request<string>({
     url: `/apiCenter/${id}`,
     method: 'DELETE'
   })
@@ -46,14 +46,24 @@ export function delDataById (id: string) {
 /**
  * API新增
  */
-export function addApi (data) {
-  return request({
+export function addApi (data: DC.API.Api) {
+  return request<string>({
     url: '/apiCenter',
     method: 'POST',
     data
   })
 }
 
+/**
+ * 将api按分组查询树结构
+ */
+export function getApiByTree (id: string) {
+  return request<string>({
+    url: `/apiCenter/tree?id=${id}`,
+    method: 'GET'
+  })
+}
+
 /**
  * 根据serviceId获取api使用情况
  */

+ 8 - 35
src/type/dc.d.ts

@@ -1,46 +1,19 @@
 
 declare namespace DC {
   namespace API {
-    interface Detail {
+    interface Api {
       serviceName: string,
       serviceId: string,
       serviceDesc: string,
-      requestMethod: string,
-      permanentToken: string,
-      groupKey: string,
-      serviceType: string,
-      sourceName: string,
-      targetName: string,
-      title: string,
-      url: string,
-      method: 'GET' | 'POST' | 'PUT' | 'DELETE',
-      contentType: 'JSON',
-      retry: number,
-      authType: string,
-      basicUsername: string,
-      basicPassword: string,
-      jwtMethod: 'HS256',
-      jwtKey: string,
-      enableCustomInput: boolean,
-      customInputMerge: boolean,
-      inputMap: [],
-      enableCustomQuery: boolean,
-      customQueryMerge: boolean,
-      queryMap: [],
-      enableCustomHeader: boolean,
-      customHeaderMerge: boolean,
-      headerMap: [],
-      isDownload: boolean,
-      transformMerge: boolean,
-      enableCustomOutput: boolean,
-      outputTransform: [],
-      enableResponseAdaptor: boolean,
-      responseAdaptor: string,
-      enableCustomCa: boolean,
-      httpsKey: string,
-      httpsCert: string,
+      serviceState: null | 0 | 1 // 状态 0 正 常,1 禁⽤
+      groupKey: string
+      serviceType: null | 1 | 2// 类型1 单接口 2 聚合接口
+      versionId: string
+      defaultConfig: any // api 配置项
       reqParam: [],
       respParam: [],
+      headers: ''
+      requestMethod: string
     }
   }