forked from wangziqi/gongxue-base
feat: add platform admin operations
This commit is contained in:
@@ -113,6 +113,73 @@ export interface PlatformQuestionBankGrant {
|
||||
expiresAt?: string | null;
|
||||
}
|
||||
|
||||
export interface CreatePlatformTenantInput {
|
||||
slug: string;
|
||||
name: string;
|
||||
legalName?: string;
|
||||
brandName?: string;
|
||||
shortName?: string;
|
||||
primaryHost?: string;
|
||||
planCode?: string;
|
||||
status?: string;
|
||||
billingStatus?: string;
|
||||
amountCents?: number;
|
||||
}
|
||||
|
||||
export interface UpdatePlatformTenantStatusInput {
|
||||
tenantId: string;
|
||||
status?: string;
|
||||
billingStatus?: string;
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export interface CreatePlatformSubscriptionInput {
|
||||
tenantId: string;
|
||||
planCode: string;
|
||||
status?: string;
|
||||
startsAt?: string;
|
||||
expiresAt?: string;
|
||||
amountCents?: number;
|
||||
}
|
||||
|
||||
export interface CreatePlatformInvoiceFromSubscriptionInput {
|
||||
tenantId: string;
|
||||
subscriptionId?: string;
|
||||
status?: string;
|
||||
dueDate?: string;
|
||||
note?: string;
|
||||
}
|
||||
|
||||
export interface ConfirmPlatformInvoicePaymentInput {
|
||||
tenantId: string;
|
||||
invoiceId: string;
|
||||
amountCents: number;
|
||||
provider?: string;
|
||||
method?: string;
|
||||
providerTradeNo?: string;
|
||||
}
|
||||
|
||||
export interface RecordPlatformUsageInput {
|
||||
tenantId: string;
|
||||
metricKey: string;
|
||||
metricValue: number;
|
||||
periodStart: string;
|
||||
periodEnd: string;
|
||||
}
|
||||
|
||||
export interface UpsertPlatformQuestionBankGrantInput {
|
||||
id?: string;
|
||||
sourceQuestionBankId: string;
|
||||
grantScope: string;
|
||||
allowedPlanCodes?: string[];
|
||||
allowedTenantIds?: string[];
|
||||
allowedRegionIds?: string[];
|
||||
allowedSubjectIds?: string[];
|
||||
status?: string;
|
||||
startsAt?: string;
|
||||
expiresAt?: string;
|
||||
}
|
||||
|
||||
export async function loadPlatformOverview() {
|
||||
return apiRequest<{ item?: PlatformOverview }>('/api/platform-admin/overview', { tenantId: null });
|
||||
}
|
||||
@@ -158,3 +225,59 @@ export async function loadPlatformQuestionBankGrants(query: { questionBankId?: s
|
||||
tenantId: null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createPlatformTenant(input: CreatePlatformTenantInput) {
|
||||
return apiRequest<{ item?: PlatformTenantItem }>('/api/platform-admin/tenants', {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
tenantId: null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function updatePlatformTenantStatus(input: UpdatePlatformTenantStatusInput) {
|
||||
return apiRequest<{ item?: PlatformTenantItem }>('/api/platform-admin/tenants/status', {
|
||||
method: 'PATCH',
|
||||
body: input,
|
||||
tenantId: null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createPlatformSubscription(input: CreatePlatformSubscriptionInput) {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/platform-admin/subscriptions', {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
tenantId: null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createPlatformInvoiceFromSubscription(input: CreatePlatformInvoiceFromSubscriptionInput) {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/platform-admin/invoices/from-subscription', {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
tenantId: null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function confirmPlatformInvoicePayment(input: ConfirmPlatformInvoicePaymentInput) {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/platform-admin/invoices/payments/manual-confirm', {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
tenantId: null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function recordPlatformUsage(input: RecordPlatformUsageInput) {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/platform-admin/usage', {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
tenantId: null,
|
||||
});
|
||||
}
|
||||
|
||||
export async function upsertPlatformQuestionBankGrant(input: UpsertPlatformQuestionBankGrantInput) {
|
||||
return apiRequest<{ item?: PlatformQuestionBankGrant }>('/api/platform-admin/question-bank-grants', {
|
||||
method: 'PUT',
|
||||
body: input,
|
||||
tenantId: null,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user