cost.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. # app/schemas/cost.py
  2. from datetime import datetime
  3. from typing import Optional, Literal
  4. from pydantic import BaseModel, Field
  5. class VasCostCreate(BaseModel):
  6. category: Literal['vps', 'proxy_ip', 'captcha_api', 'sms_api', 'other'] = Field(
  7. ..., description="耗材类型: vps(海外服务器), proxy_ip(代理IP池), captcha_api(打码平台), sms_api(接码API), other(其他)"
  8. )
  9. amount: int = Field(..., gt=0, description="支出金额(单位:分)")
  10. currency: str = Field("CNY", description="币种")
  11. description: Optional[str] = Field(None, description="支出说明/用途")
  12. voucher_url: Optional[str] = Field(None, description="支付或充值截图凭证URL")
  13. paid_at: Optional[datetime] = Field(None, description="实际发生支出时间,默认当前时间")
  14. class VasCostOut(BaseModel):
  15. id: int
  16. period_id: Optional[str]
  17. category: str
  18. amount: int
  19. currency: str
  20. description: Optional[str]
  21. voucher_url: Optional[str]
  22. paid_at: datetime
  23. created_by: str
  24. created_at: datetime
  25. model_config = {"from_attributes": True}