cmc-web/packages/api/system/tenant.ts

167 lines
4.7 KiB
TypeScript
Raw Normal View History

2024-08-20 12:11:31 +00:00
/**
* Created by HaijunZhang on 2019/7/23.
*/
import { request } from '@cmp/cmp-element'
import { wrapperParams, downloadFile } from 'utils/index'
const baseUrl = '/sms/v1/tenants'
2024-08-21 01:17:14 +00:00
export function getTenant(params: any) {
2024-08-20 12:11:31 +00:00
return request.get(baseUrl, {
params
})
}
2024-08-21 01:17:14 +00:00
export function checkedTenant(account: string) {
2024-08-20 12:11:31 +00:00
return request.get(`${baseUrl}/${account}/exist`)
}
2024-08-21 01:17:14 +00:00
export function getTenantTree(params: any) {
2024-08-20 12:11:31 +00:00
return request.get(`${baseUrl}`, {
params: {
condition: JSON.stringify({ condition: 'children' }),
...params
}
})
}
2024-08-21 01:17:14 +00:00
export function getTenantDetail(id: number) {
2024-08-20 12:11:31 +00:00
return request.get(`${baseUrl}/${id}/quotas`)
}
// 租户信息
2024-08-21 01:17:14 +00:00
export function getTenantInfo(id: number) {
2024-08-20 12:11:31 +00:00
return request.get(`${baseUrl}/${id}`)
}
// 租户下用户列表
2024-08-21 01:17:14 +00:00
export function getTenantUserTrans(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.get(`${baseUrl}/${id}/users`, { params })
}
// 租户下服务列表
2024-08-21 01:17:14 +00:00
export function getTenantService(id: number) {
2024-08-20 12:11:31 +00:00
return request.get(`/cos/v1/services/tenants/${id}/services`)
}
2024-08-21 01:17:14 +00:00
export function createTenant(params: any) {
2024-08-20 12:11:31 +00:00
return request.post(baseUrl, wrapperParams(params))
}
2024-08-21 01:17:14 +00:00
export function modifyTenant(params: any) {
2024-08-20 12:11:31 +00:00
return request.put(`${baseUrl}/${params.id}`, wrapperParams(params))
}
2024-08-21 01:17:14 +00:00
export function removeTenant(id: number) {
2024-08-20 12:11:31 +00:00
return request.delete(`${baseUrl}/${id}`)
}
2024-08-21 01:17:14 +00:00
export function getTenantStats(params: any) {
2024-08-20 12:11:31 +00:00
return request.get(`${baseUrl}/stats`, {
params: wrapperParams(params)
})
}
2024-08-21 01:17:14 +00:00
export function getTenantPool(id: number) {
2024-08-20 12:11:31 +00:00
return request.get(`${baseUrl}/${id}/pools`)
}
2024-08-21 01:17:14 +00:00
export function assignTenantPools(params: any) {
2024-08-20 12:11:31 +00:00
return request.post(`${baseUrl}/${params.id}/pools`, JSON.stringify(params.poolIds))
}
2024-08-21 01:17:14 +00:00
export function resetTenantPsw(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.patch(`${baseUrl}/${id}/reset`, {
...wrapperParams(params)
})
}
/*
* action
* lock active reset accredit change
*/
2024-08-21 01:17:14 +00:00
export function operateTenant(id: number, action: string, params: any) {
2024-08-20 12:11:31 +00:00
return request.patch(`${baseUrl}/${id}`, {
action,
...wrapperParams(params)
})
}
// 租户配额
2024-08-21 01:17:14 +00:00
export function getQuotaTenant(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.get(`/cos/v1/tenants/${id}/quotas`, { params })
}
2024-08-21 01:17:14 +00:00
export function getCscQuotaTenant(params: any) {
2024-08-20 12:11:31 +00:00
return request.get(`/cos/v1/tenants/${params.tenantId ? params.tenantId : params.target}/quotas`, { params: wrapperParams(params) })
}
2024-08-21 01:17:14 +00:00
export function createQuotaTenant(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.post(`/cos/v1/tenants/${id}/quotas`, wrapperParams(params))
}
2024-08-21 01:17:14 +00:00
export function getTenantBus(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.get(`/sms/v1/tenants/${id}/businesses`, { params })
}
2024-08-21 01:17:14 +00:00
export function createTenantBus(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.post(`/sms/v1/tenants/${id}/businesses`, params)
}
2024-08-21 01:17:14 +00:00
export function createTenantPool(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.post(`/sms/v1/tenants/${id}/pools`, params)
}
2024-08-21 01:17:14 +00:00
export function getOsTenant(params: any) {
2024-08-20 12:11:31 +00:00
return request.get('/cmp/v1/ostenants', {
params
})
}
2024-08-21 01:17:14 +00:00
export function createOsTenantt(params: any) {
2024-08-20 12:11:31 +00:00
return request.post('/cmp/v1/ostenants', wrapperParams(params))
}
2024-08-21 01:17:14 +00:00
export function modifyOsTenant(params: any) {
2024-08-20 12:11:31 +00:00
return request.put(`/cmp/v1/ostenants/${params.id}`, wrapperParams(params))
}
2024-08-21 01:17:14 +00:00
export function removeOsTenant(id: number) {
2024-08-20 12:11:31 +00:00
return request.delete(`/cmp/v1/ostenants/${id}`)
}
2024-08-21 01:17:14 +00:00
export function getTrack(params: any) {
2024-08-20 12:11:31 +00:00
return request.get(`${baseUrl}/track`, {
params: params
})
}
2024-08-21 01:17:14 +00:00
export function getUser(params: any) {
2024-08-20 12:11:31 +00:00
return request.get('/sms/v1/users', { params })
}
// 获取授信
2024-08-21 01:17:14 +00:00
export function getTenantAccount(id: number) {
2024-08-20 12:11:31 +00:00
return request.get(`/cos/v1/tenants/${id}/account`)
}
// 授信修改
2024-08-21 01:17:14 +00:00
export function createTenantAccount(params: any) {
2024-08-20 12:11:31 +00:00
return request.post('/cos/v1/tenants/account', wrapperParams(params))
}
2024-08-21 01:17:14 +00:00
export function getApiById(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.get(`/sms/v1/tenants/${id}/apis`, {
params: params
})
}
2024-08-21 01:17:14 +00:00
export function updateApi(id: number, params: any) {
2024-08-20 12:11:31 +00:00
return request.patch(`/sms/v1/tenants/${id}/apis`, params)
}
// 配额
export function getBaseQuotas() {
return request.get('/cos/v1/quotas/metas')
}
2024-08-21 01:17:14 +00:00
export function getTenantBaseQuotas(id: number) {
2024-08-20 12:11:31 +00:00
return request.get(`/cos/v1/tenants/${id}/quotas/metas`)
}
// 租户配置用户
2024-08-21 01:17:14 +00:00
export function tenantCongigUser(params: any) {
2024-08-20 12:11:31 +00:00
return request.post(`/sms/v1/tenants/${params.id}/users`, params.ids)
}
// 租户移除用户
2024-08-21 01:17:14 +00:00
export function tenantRemoveUser(id: number) {
2024-08-20 12:11:31 +00:00
return request.patch(`/sms/v1/users/${id}/tenants`)
}
// /sms/v1/tenants
// 租户移除用户
export function lockTenant(params: any) {
return request.patch('/sms/v1/tenants', params)
}
// 导出租户列表
export function exportTenantList() {
downloadFile('/sms/v1/tenants/export')
}