import { request } from '../request' import { ApiResponse, PaginatedResponse, QueryRequest } from '../types' // 中心配置相关类型 export interface Tenant { id: string name: string code: string type: 'individual' | 'enterprise' | 'cooperative' status: 'active' | 'inactive' | 'suspended' contactPerson: string contactPhone: string contactEmail: string address: string maxUsers: number currentUsers: number subscriptionPlan: 'basic' | 'standard' | 'premium' subscriptionExpiry?: string settings: { timezone: string language: string currency: string dateFormat: string numberFormat: string } features: string[] createdAt: string updatedAt: string } export interface User { id: string username: string email: string phone: string realName: string avatar?: string role: 'admin' | 'manager' | 'operator' | 'viewer' tenantId: string status: 'active' | 'inactive' | 'locked' lastLoginAt?: string permissions: string[] preferences: { language: string theme: 'light' | 'dark' | 'auto' notifications: { email: boolean sms: boolean push: boolean } } createdAt: string updatedAt: string } export interface SystemParameter { id: string category: 'system' | 'business' | 'notification' | 'security' | 'integration' key: string value: string type: 'string' | 'number' | 'boolean' | 'json' description: string isEditable: boolean requiresRestart: boolean validationRules?: { required?: boolean min?: number max?: number pattern?: string options?: string[] } tenantId?: string createdAt: string updatedAt: string } export interface SystemLog { id: string level: 'debug' | 'info' | 'warn' | 'error' | 'fatal' category: 'system' | 'business' | 'security' | 'performance' message: string details?: any userId?: string tenantId?: string ip?: string userAgent?: string timestamp: string duration?: number stackTrace?: string } export interface Message { id: string type: 'system' | 'business' | 'notification' | 'alert' category: 'info' | 'warning' | 'error' | 'success' title: string content: string senderId?: string recipientId?: string recipientRole?: string tenantId?: string status: 'unread' | 'read' | 'archived' priority: 'low' | 'medium' | 'high' | 'urgent' expiresAt?: string metadata?: Record createdAt: string readAt?: string } export const configApi = { // 租户管理 getTenantList: (params: QueryRequest): Promise>> => { return request.get('/config/tenants', params) }, getTenantDetail: (id: string): Promise> => { return request.get(`/config/tenants/${id}`) }, createTenant: (data: Omit): Promise> => { return request.post('/config/tenants', data) }, updateTenant: (id: string, data: Partial): Promise> => { return request.put(`/config/tenants/${id}`, data) }, deleteTenant: (id: string): Promise> => { return request.delete(`/config/tenants/${id}`) }, suspendTenant: (id: string): Promise> => { return request.post(`/config/tenants/${id}/suspend`) }, activateTenant: (id: string): Promise> => { return request.post(`/config/tenants/${id}/activate`) }, // 用户管理 getUserList: (params: QueryRequest): Promise>> => { return request.get('/config/users', params) }, getUserDetail: (id: string): Promise> => { return request.get(`/config/users/${id}`) }, createUser: (data: Omit): Promise> => { return request.post('/config/users', data) }, updateUser: (id: string, data: Partial): Promise> => { return request.put(`/config/users/${id}`, data) }, deleteUser: (id: string): Promise> => { return request.delete(`/config/users/${id}`) }, resetPassword: (id: string, newPassword: string): Promise> => { return request.post(`/config/users/${id}/reset-password`, { newPassword }) }, lockUser: (id: string): Promise> => { return request.post(`/config/users/${id}/lock`) }, unlockUser: (id: string): Promise> => { return request.post(`/config/users/${id}/unlock`) }, // 系统参数 getParameterList: (params: QueryRequest): Promise>> => { return request.get('/config/parameters', params) }, getParameterDetail: (id: string): Promise> => { return request.get(`/config/parameters/${id}`) }, createParameter: (data: Omit): Promise> => { return request.post('/config/parameters', data) }, updateParameter: (id: string, data: Partial): Promise> => { return request.put(`/config/parameters/${id}`, data) }, deleteParameter: (id: string): Promise> => { return request.delete(`/config/parameters/${id}`) }, getParametersByCategory: (category: string): Promise> => { return request.get(`/config/parameters/category/${category}`) }, // 系统监控 getSystemLogs: (params: QueryRequest & { level?: string; category?: string }): Promise>> => { return request.get('/config/logs', params) }, getSystemMetrics: (): Promise> => { return request.get('/config/metrics') }, getSystemHealth: (): Promise issues: Array<{ type: 'error' | 'warning' message: string timestamp: string }> }>> => { return request.get('/config/health') }, // 消息中心 getMessageList: (params: QueryRequest): Promise>> => { return request.get('/config/messages', params) }, getMessageDetail: (id: string): Promise> => { return request.get(`/config/messages/${id}`) }, createMessage: (data: Omit): Promise> => { return request.post('/config/messages', data) }, markMessageAsRead: (id: string): Promise> => { return request.put(`/config/messages/${id}/read`) }, archiveMessage: (id: string): Promise> => { return request.put(`/config/messages/${id}/archive`) }, deleteMessage: (id: string): Promise> => { return request.delete(`/config/messages/${id}`) }, getUnreadCount: (): Promise> => { return request.get('/config/messages/unread/count') } }