generator client { provider = "prisma-client-js" } datasource db { provider = "mysql" url = env("DATABASE_URL") } // 市场指数 model MarketIndex { id Int @id @default(autoincrement()) name String @unique code String @unique current Float change Float changePercent Float volume BigInt turnover BigInt updatedAt DateTime @updatedAt createdAt DateTime @default(now()) @@index([code]) @@map("market_indices") } // 版块信息 model Sector { id String @id @default(uuid()) name String @unique code String @unique stocks Stock[] quotes SectorQuote[] klines SectorKLine[] updatedAt DateTime @updatedAt createdAt DateTime @default(now()) @@index([code]) @@map("sectors") } // 版块行情 model SectorQuote { id Int @id @default(autoincrement()) sectorCode String @map("sector_code") sector Sector @relation(fields: [sectorCode], references: [code]) current Float change Float changePercent Float volume BigInt turnover BigInt momentumScore Float @default(50) rank Int @default(0) previousRank Int @default(0) @map("previous_rank") quoteTime DateTime @map("quote_time") @@index([sectorCode]) @@index([quoteTime]) @@map("sector_quotes") } // 版块K线数据 model SectorKLine { id Int @id @default(autoincrement()) sectorCode String @map("sector_code") sector Sector @relation(fields: [sectorCode], references: [code]) period String // day/week/month date DateTime open Float high Float low Float close Float volume BigInt @@unique([sectorCode, period, date]) @@index([sectorCode]) @@index([date]) @@map("sector_klines") } // 股票信息 model Stock { id String @id @default(uuid()) code String @unique name String sectorCode String? @map("sector_code") sector Sector? @relation(fields: [sectorCode], references: [code]) marketCap BigInt? @map("market_cap") pe Float? pb Float? quotes StockQuote[] klines StockKLine[] favorites UserFavorite[] updatedAt DateTime @updatedAt createdAt DateTime @default(now()) @@index([code]) @@index([sectorCode]) @@map("stocks") } // 股票行情 model StockQuote { id Int @id @default(autoincrement()) stockCode String @map("stock_code") stock Stock @relation(fields: [stockCode], references: [code]) price Float open Float high Float low Float preClose Float @map("pre_close") volume BigInt turnover BigInt changePercent Float @map("change_percent") turnoverRate Float? @map("turnover_rate") amplitude Float? quoteTime DateTime @map("quote_time") @@index([stockCode]) @@index([quoteTime]) @@map("stock_quotes") } // 股票K线数据 model StockKLine { id Int @id @default(autoincrement()) stockCode String @map("stock_code") stock Stock @relation(fields: [stockCode], references: [code]) period String // day/week/month date DateTime open Float high Float low Float close Float volume BigInt ma5 Float? ma10 Float? ma20 Float? ma30 Float? ma60 Float? @@unique([stockCode, period, date]) @@index([stockCode]) @@index([date]) @@map("stock_klines") } // 用户 model User { id String @id @default(uuid()) username String @unique email String @unique password String favorites UserFavorite[] createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@map("users") } // 用户自选股 model UserFavorite { id Int @id @default(autoincrement()) userId String @map("user_id") user User @relation(fields: [userId], references: [id], onDelete: Cascade) stockCode String @map("stock_code") stock Stock @relation(fields: [stockCode], references: [code]) createdAt DateTime @default(now()) @map("created_at") @@unique([userId, stockCode]) @@index([userId]) @@map("user_favorites") } // 新高新低股票记录 model HighLowStock { id Int @id @default(autoincrement()) stockCode String @map("stock_code") type String // high/low price Float date DateTime daysToHighLow Int @map("days_to_highlow") createdAt DateTime @default(now()) @map("created_at") @@index([stockCode]) @@index([type]) @@index([date]) @@map("high_low_stocks") } // 动量股票推荐 model MomentumStock { id Int @id @default(autoincrement()) stockCode String @map("stock_code") momentumScore Float @map("momentum_score") tags String? // JSON array volumeRatio Float @map("volume_ratio") breakThrough Boolean @default(false) @map("break_through") date DateTime createdAt DateTime @default(now()) @map("created_at") @@index([stockCode]) @@index([date]) @@map("momentum_stocks") }