135 lines
3.8 KiB
Plaintext
135 lines
3.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
// ==================== 管理员 ====================
|
|
|
|
model AdminUser {
|
|
id String @id @default(uuid())
|
|
username String @unique
|
|
password String // bcrypt hashed
|
|
name String
|
|
role String // SUPER_ADMIN, ADMIN, OPERATOR
|
|
status String @default("ACTIVE") // ACTIVE, DISABLED
|
|
lastLoginAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
auditLogs AuditLog[]
|
|
|
|
@@map("admin_users")
|
|
}
|
|
|
|
// ==================== 系统配置 ====================
|
|
|
|
model SystemConfig {
|
|
id String @id @default(uuid())
|
|
category String // MINING, TRADING, CONTRIBUTION, SYSTEM
|
|
key String
|
|
value String
|
|
description String?
|
|
isPublic Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([category, key])
|
|
@@map("system_configs")
|
|
}
|
|
|
|
// ==================== 系统账户(运营/省/市)====================
|
|
|
|
model SystemAccount {
|
|
id String @id @default(uuid())
|
|
accountType String @unique // OPERATION, PROVINCE, CITY
|
|
name String
|
|
description String?
|
|
totalContribution Decimal @db.Decimal(30, 8) @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("system_accounts")
|
|
}
|
|
|
|
// ==================== 初始化记录 ====================
|
|
|
|
model InitializationRecord {
|
|
id String @id @default(uuid())
|
|
type String // MINING_CONFIG, BLACK_HOLE, SYSTEM_ACCOUNTS
|
|
status String // PENDING, COMPLETED, FAILED
|
|
config Json
|
|
executedBy String
|
|
executedAt DateTime?
|
|
errorMessage String?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@map("initialization_records")
|
|
}
|
|
|
|
// ==================== 审计日志 ====================
|
|
|
|
model AuditLog {
|
|
id String @id @default(uuid())
|
|
adminId String
|
|
action String // CREATE, UPDATE, DELETE, LOGIN, LOGOUT, INIT
|
|
resource String // CONFIG, USER, SYSTEM_ACCOUNT, MINING
|
|
resourceId String?
|
|
oldValue Json?
|
|
newValue Json?
|
|
ipAddress String?
|
|
userAgent String?
|
|
createdAt DateTime @default(now())
|
|
|
|
admin AdminUser @relation(fields: [adminId], references: [id])
|
|
|
|
@@index([adminId])
|
|
@@index([action])
|
|
@@index([resource])
|
|
@@index([createdAt(sort: Desc)])
|
|
@@map("audit_logs")
|
|
}
|
|
|
|
// ==================== 报表快照 ====================
|
|
|
|
model DailyReport {
|
|
id String @id @default(uuid())
|
|
reportDate DateTime @unique @db.Date
|
|
|
|
// 用户统计
|
|
totalUsers Int @default(0)
|
|
newUsers Int @default(0)
|
|
activeUsers Int @default(0)
|
|
|
|
// 认种统计
|
|
totalAdoptions Int @default(0)
|
|
newAdoptions Int @default(0)
|
|
totalTrees Int @default(0)
|
|
|
|
// 算力统计
|
|
totalContribution Decimal @db.Decimal(30, 8) @default(0)
|
|
contributionGrowth Decimal @db.Decimal(30, 8) @default(0)
|
|
|
|
// 挖矿统计
|
|
totalDistributed Decimal @db.Decimal(30, 8) @default(0)
|
|
totalBurned Decimal @db.Decimal(30, 8) @default(0)
|
|
|
|
// 交易统计
|
|
tradingVolume Decimal @db.Decimal(30, 8) @default(0)
|
|
tradingAmount Decimal @db.Decimal(30, 8) @default(0)
|
|
tradeCount Int @default(0)
|
|
|
|
// 价格
|
|
openPrice Decimal @db.Decimal(30, 18) @default(1)
|
|
closePrice Decimal @db.Decimal(30, 18) @default(1)
|
|
highPrice Decimal @db.Decimal(30, 18) @default(1)
|
|
lowPrice Decimal @db.Decimal(30, 18) @default(1)
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
@@map("daily_reports")
|
|
}
|