|
| 1 | +import { Result } from '@/request/Result' |
| 2 | +import { get, post, del, put } from '@/request/index' |
| 3 | + |
| 4 | +import { type Ref } from 'vue' |
| 5 | + |
| 6 | +const prefix = '/workspace/' + localStorage.getItem('workspace_id') + '/application' |
| 7 | + |
| 8 | +/** |
| 9 | + * API_KEY列表 |
| 10 | + * @param 参数 application_id |
| 11 | + */ |
| 12 | +const getAPIKey: (application_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = ( |
| 13 | + application_id, |
| 14 | + loading, |
| 15 | +) => { |
| 16 | + return get(`${prefix}/${application_id}/application`, undefined, loading) |
| 17 | +} |
| 18 | + |
| 19 | +/** |
| 20 | + * 新增API_KEY |
| 21 | + * @param 参数 application_id |
| 22 | + */ |
| 23 | +const postAPIKey: (application_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = ( |
| 24 | + application_id, |
| 25 | + loading, |
| 26 | +) => { |
| 27 | + return post(`${prefix}/${application_id}/application`, {}, undefined, loading) |
| 28 | +} |
| 29 | + |
| 30 | +/** |
| 31 | + * 删除API_KEY |
| 32 | + * @param 参数 application_id api_key_id |
| 33 | + */ |
| 34 | +const delAPIKey: ( |
| 35 | + application_id: string, |
| 36 | + api_key_id: string, |
| 37 | + loading?: Ref<boolean>, |
| 38 | +) => Promise<Result<boolean>> = (application_id, api_key_id, loading) => { |
| 39 | + return del(`${prefix}/${application_id}/application/${api_key_id}`, undefined, undefined, loading) |
| 40 | +} |
| 41 | + |
| 42 | +/** |
| 43 | + * 修改API_KEY |
| 44 | + * @param 参数 application_id,api_key_id |
| 45 | + * data { |
| 46 | + * is_active: boolean |
| 47 | + * } |
| 48 | + */ |
| 49 | +const putAPIKey: ( |
| 50 | + application_id: string, |
| 51 | + api_key_id: string, |
| 52 | + data: any, |
| 53 | + loading?: Ref<boolean>, |
| 54 | +) => Promise<Result<any>> = (application_id, api_key_id, data, loading) => { |
| 55 | + return put(`${prefix}/${application_id}/application/${api_key_id}`, data, undefined, loading) |
| 56 | +} |
| 57 | + |
| 58 | +export default { |
| 59 | + getAPIKey, |
| 60 | + postAPIKey, |
| 61 | + delAPIKey, |
| 62 | + putAPIKey, |
| 63 | +} |
0 commit comments