Files
ez-api/internal/model/models.go
zenfun 58dfe5e9ac feat(server): initialize project skeleton with db and api setup
Establish the foundational structure for the ez-api server.

Key changes include:
- Set up main entry point with graceful shutdown and Gin router
- Configure database connections for PostgreSQL (GORM) and Redis
- Define core data models (User, Provider, Key, Model)
- Implement configuration loading and basic key creation handler
- Add Dockerfile for multi-stage builds and .gitignore
2025-12-02 13:35:17 +08:00

38 lines
744 B
Go

package model
import (
"gorm.io/gorm"
)
type User struct {
gorm.Model
Username string `gorm:"uniqueIndex;not null"`
Quota int64 `gorm:"default:0"`
Role string `gorm:"default:'user'"` // admin, user
}
type Provider struct {
gorm.Model
Name string `gorm:"not null"`
Type string `gorm:"not null"` // openai, anthropic, etc.
BaseURL string
APIKey string
}
type Key struct {
gorm.Model
ProviderID *uint
Provider *Provider
KeySecret string `gorm:"not null"`
Balance float64
Status string `gorm:"default:'active'"` // active, suspended
Weight int `gorm:"default:10"`
}
type Model struct {
gorm.Model
Name string `gorm:"uniqueIndex;not null"`
ContextWindow int
CostPerToken float64
}