11
This commit is contained in:
26
app/schemas/card_key.py
Normal file
26
app/schemas/card_key.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from datetime import datetime
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
CardKeyType = Literal["时长", "点数"]
|
||||
|
||||
|
||||
class CardKeyActivateRequest(BaseModel):
|
||||
serial_number: str = Field(min_length=1, max_length=64)
|
||||
|
||||
@field_validator("serial_number")
|
||||
@classmethod
|
||||
def normalize_serial(cls, value: str) -> str:
|
||||
stripped = value.strip().upper()
|
||||
if not stripped:
|
||||
raise ValueError("请输入卡密")
|
||||
return stripped
|
||||
|
||||
|
||||
class CardKeyActivateResponse(BaseModel):
|
||||
card_type: CardKeyType
|
||||
vip_end_time: datetime | None = None
|
||||
points: float | None = None
|
||||
added_days: int | None = None
|
||||
added_points: float | None = None
|
||||
Reference in New Issue
Block a user