mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
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
This commit is contained in:
37
internal/model/models.go
Normal file
37
internal/model/models.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user