forked from wangziqi/gongxue-base
feat: add taro tenant admin pages
This commit is contained in:
183
apps/taro/src/services/tenantAdmin.ts
Normal file
183
apps/taro/src/services/tenantAdmin.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
import { apiRequest } from './api';
|
||||
|
||||
export interface TenantDashboard {
|
||||
scope?: Record<string, unknown>;
|
||||
cards?: {
|
||||
students?: Record<string, number>;
|
||||
learning?: Record<string, number>;
|
||||
content?: Record<string, number>;
|
||||
activationCodes?: Record<string, number>;
|
||||
feedback?: Record<string, number>;
|
||||
};
|
||||
paymentStats?: Record<string, number>;
|
||||
trends?: Record<string, unknown>[];
|
||||
activeHours?: Record<string, unknown>[];
|
||||
questionDistribution?: Record<string, unknown>[];
|
||||
subjectTop?: Record<string, unknown>[];
|
||||
regionStats?: Record<string, unknown>[];
|
||||
planSales?: Record<string, unknown>[];
|
||||
recentActivities?: Record<string, unknown>[];
|
||||
}
|
||||
|
||||
export interface TenantClassItem {
|
||||
id: string;
|
||||
name: string;
|
||||
code?: string | null;
|
||||
status?: string;
|
||||
regionName?: string | null;
|
||||
studentCount?: number;
|
||||
teacherCount?: number;
|
||||
}
|
||||
|
||||
export interface TenantStudentItem {
|
||||
userId: string;
|
||||
name?: string | null;
|
||||
phone?: string | null;
|
||||
email?: string | null;
|
||||
status?: string;
|
||||
regionName?: string | null;
|
||||
selectedSchoolName?: string | null;
|
||||
selectedMajorName?: string | null;
|
||||
questionsAnsweredToday?: number;
|
||||
masteredWordsCount?: number;
|
||||
classes?: Record<string, unknown>[];
|
||||
}
|
||||
|
||||
export interface ImportJobItem {
|
||||
id: string;
|
||||
importType?: string;
|
||||
status?: string;
|
||||
sourceName?: string | null;
|
||||
totalCount?: number;
|
||||
successCount?: number;
|
||||
errorCount?: number;
|
||||
warningCount?: number;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface ContentEntryAdminItem {
|
||||
id: string;
|
||||
name: string;
|
||||
entryType?: string;
|
||||
visibility?: string;
|
||||
isActive?: boolean;
|
||||
regionName?: string | null;
|
||||
}
|
||||
|
||||
export interface PublicQuestionBankItem {
|
||||
grantId?: string;
|
||||
sourceQuestionBankId?: string;
|
||||
name?: string;
|
||||
regionName?: string | null;
|
||||
grantScope?: string;
|
||||
adoption?: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
export interface CouponItem {
|
||||
id: string;
|
||||
code: string;
|
||||
status?: string;
|
||||
discountType?: string | null;
|
||||
discountValue?: number | string | null;
|
||||
usedCount?: number;
|
||||
maxUses?: number | null;
|
||||
}
|
||||
|
||||
export interface CodeBatchItem {
|
||||
id: string;
|
||||
name?: string | null;
|
||||
batchNo?: string | null;
|
||||
totalCount?: number;
|
||||
usedCount?: number;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface TenantOverview {
|
||||
id?: string;
|
||||
name?: string;
|
||||
slug?: string;
|
||||
status?: string;
|
||||
brandName?: string;
|
||||
shortName?: string;
|
||||
slogan?: string | null;
|
||||
logoUrl?: string | null;
|
||||
theme?: Record<string, unknown>;
|
||||
featureFlags?: Record<string, unknown>;
|
||||
adminFeatureFlags?: Record<string, unknown>;
|
||||
publicConfig?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export async function loadTenantDashboard(timeRange = '30d') {
|
||||
return apiRequest<{ item?: TenantDashboard }>('/api/tenant-admin/dashboard', { query: { timeRange } });
|
||||
}
|
||||
|
||||
export async function loadTenantOverview() {
|
||||
return apiRequest<{ item?: TenantOverview }>('/api/tenant-admin/overview');
|
||||
}
|
||||
|
||||
export async function loadTenantPermissions() {
|
||||
return apiRequest<{ items?: Record<string, unknown>[]; modules?: Record<string, unknown>[] }>('/api/tenant-admin/permissions');
|
||||
}
|
||||
|
||||
export async function loadTenantClasses(limit = 50) {
|
||||
return apiRequest<{ items?: TenantClassItem[]; scoped?: boolean }>('/api/tenant-admin/classes', { query: { limit } });
|
||||
}
|
||||
|
||||
export async function loadTenantStudents(query: { keyword?: string; classId?: string; limit?: number } = {}) {
|
||||
return apiRequest<{ items?: TenantStudentItem[]; scoped?: boolean }>('/api/tenant-admin/students', {
|
||||
query: { ...query, limit: query.limit || 50 },
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadContentEntriesAdmin() {
|
||||
return apiRequest<{ items?: ContentEntryAdminItem[] }>('/api/tenant-content/content-entries');
|
||||
}
|
||||
|
||||
export async function loadImportJobs(limit = 20) {
|
||||
return apiRequest<{ items?: ImportJobItem[] }>('/api/tenant-content/imports', { query: { limit } });
|
||||
}
|
||||
|
||||
export async function loadImportIssues(jobId: string) {
|
||||
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/tenant-content/imports/issues', { query: { jobId } });
|
||||
}
|
||||
|
||||
export async function loadPublicQuestionBanks() {
|
||||
return apiRequest<{ items?: PublicQuestionBankItem[] }>('/api/tenant-content/public-question-banks');
|
||||
}
|
||||
|
||||
export async function loadCoupons() {
|
||||
return apiRequest<{ items?: CouponItem[] }>('/api/tenant-admin/coupons');
|
||||
}
|
||||
|
||||
export async function loadCodeBatches() {
|
||||
return apiRequest<{ items?: CodeBatchItem[] }>('/api/tenant-admin/code-batches');
|
||||
}
|
||||
|
||||
export async function loadActivationCodes(limit = 20) {
|
||||
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/tenant-admin/activation-codes', { query: { limit } });
|
||||
}
|
||||
|
||||
export async function loadTenantDomains() {
|
||||
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/tenant-admin/domains');
|
||||
}
|
||||
|
||||
export async function loadPaymentAccounts() {
|
||||
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/tenant-admin/payment-accounts');
|
||||
}
|
||||
|
||||
export async function loadAuthProviders() {
|
||||
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/tenant-admin/auth-providers');
|
||||
}
|
||||
|
||||
export async function loadRoleTemplates() {
|
||||
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/tenant-admin/role-templates');
|
||||
}
|
||||
|
||||
export async function loadCrmQueue(limit = 20) {
|
||||
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/crm/queue', { query: { limit } });
|
||||
}
|
||||
|
||||
export async function loadCommissionSummary() {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/commission/summary');
|
||||
}
|
||||
Reference in New Issue
Block a user