107 lines
2.7 KiB
Python
107 lines
2.7 KiB
Python
from pydantic import BaseModel, Field
|
|
|
|
from app.schemas.common import NaiveDatetime, NaiveDatetimeOptional
|
|
|
|
|
|
class CreditAdjustRequest(BaseModel):
|
|
amount: float = Field(..., ge=-9999999.99, le=9999999.99, multiple_of=0.01)
|
|
description: str = Field(..., max_length=256)
|
|
|
|
|
|
class ModelConfigCreate(BaseModel):
|
|
name: str = Field(..., max_length=64)
|
|
provider: str = Field(..., max_length=32)
|
|
api_base: str = Field(..., max_length=512)
|
|
api_key: str = Field(..., max_length=256)
|
|
model_name: str = Field(..., max_length=128)
|
|
weight: int = Field(default=1, ge=0)
|
|
max_tokens: int = Field(default=4096, ge=1)
|
|
temperature: float = Field(default=0.7, ge=0, le=2)
|
|
is_active: bool = True
|
|
priority: int = 0
|
|
|
|
|
|
class ModelConfigOut(ModelConfigCreate):
|
|
id: str
|
|
created_at: NaiveDatetime
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class SystemConfigUpdate(BaseModel):
|
|
value: str
|
|
|
|
|
|
class SystemConfigOut(BaseModel):
|
|
id: str
|
|
key: str
|
|
value: str
|
|
description: str | None = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class AdminUserOut(BaseModel):
|
|
id: str
|
|
username: str
|
|
email: str | None = None
|
|
phone: str | None = None
|
|
credits: float
|
|
is_active: bool
|
|
is_admin: bool
|
|
user_type: str = "frontend"
|
|
created_at: NaiveDatetime
|
|
last_login_at: NaiveDatetimeOptional = None
|
|
allowed_menus: list | None = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class CreateUserRequest(BaseModel):
|
|
username: str | None = Field(None, max_length=64)
|
|
password: str = Field(..., min_length=6, max_length=128)
|
|
email: str | None = None
|
|
phone: str | None = None
|
|
credits: float = 0.0
|
|
user_type: str = Field(default="frontend", pattern="^(frontend|admin)$")
|
|
allowed_menus: list | None = None
|
|
|
|
|
|
class UpdateMenusRequest(BaseModel):
|
|
allowed_menus: list | None = None
|
|
|
|
|
|
class ResetPasswordRequest(BaseModel):
|
|
new_password: str = Field(..., min_length=6, max_length=128)
|
|
|
|
|
|
class OperationLogOut(BaseModel):
|
|
id: str
|
|
user_id: str
|
|
username: str
|
|
action: str
|
|
method: str
|
|
path: str
|
|
detail: str | None = None
|
|
ip: str | None = None
|
|
created_at: NaiveDatetime
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class AdminStatsOut(BaseModel):
|
|
total_users: int
|
|
total_projects: int
|
|
total_generations: int
|
|
total_records: int
|
|
total_revenue: float
|
|
credits_consumed_today: float
|
|
today_alipay_revenue: float
|
|
today_wechat_revenue: float
|
|
last_period_users: int = 0
|
|
last_period_projects: int = 0
|
|
last_period_generations: int = 0
|
|
last_period_records: int = 0
|
|
last_period_revenue: float = 0.0
|
|
last_period_credits_consumed: float = 0.0
|