feat(交易记录): 新增交易记录管理页面与API接口 feat(上传): 添加统一上传接口支持自动识别文件类型 feat(用户管理): 为用户模型添加备注字段并更新相关接口 feat(邮件): 实现SMTP邮件发送功能并添加测试脚本 feat(短信): 增强短信服务配置灵活性与日志记录 fix(发票): 修复发票列表时间筛选功能 fix(nginx): 调整上传大小限制与超时配置 docs: 添加多个功能模块的说明文档 docs(估值): 补充估值计算流程与API提交数据说明 chore: 更新依赖与Docker镜像版本
116 lines
3.4 KiB
Python
116 lines
3.4 KiB
Python
from pydantic import BaseModel, Field, validator
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
import re
|
|
|
|
|
|
class AppUserRegisterSchema(BaseModel):
|
|
"""AppUser注册Schema - 只需要手机号"""
|
|
phone: str = Field(..., description="手机号")
|
|
|
|
@validator('phone')
|
|
def validate_phone(cls, v):
|
|
if not re.match(r'^1[3-9]\d{9}$', v):
|
|
raise ValueError('手机号格式不正确')
|
|
return v
|
|
|
|
|
|
class AppUserLoginSchema(BaseModel):
|
|
"""AppUser登录Schema"""
|
|
phone: str = Field(..., description="手机号")
|
|
password: str = Field(..., description="密码")
|
|
|
|
|
|
class AppUserJWTPayload(BaseModel):
|
|
"""AppUser JWT载荷"""
|
|
user_id: int
|
|
phone: str
|
|
exp: datetime
|
|
|
|
|
|
class AppUserJWTOut(BaseModel):
|
|
"""AppUser JWT输出"""
|
|
access_token: str
|
|
token_type: str = "bearer"
|
|
expires_in: int
|
|
|
|
|
|
class AppUserInfoOut(BaseModel):
|
|
"""AppUser信息输出"""
|
|
id: int
|
|
phone: str
|
|
nickname: Optional[str] = None
|
|
avatar: Optional[str] = None
|
|
company_name: Optional[str] = None
|
|
company_address: Optional[str] = None
|
|
company_contact: Optional[str] = None
|
|
company_phone: Optional[str] = None
|
|
company_email: Optional[str] = None
|
|
is_active: bool
|
|
last_login: Optional[datetime] = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
remaining_quota: int
|
|
|
|
|
|
class AppUserUpdateSchema(BaseModel):
|
|
"""AppUser更新Schema"""
|
|
nickname: Optional[str] = Field(None, description="昵称")
|
|
avatar: Optional[str] = Field(None, description="头像")
|
|
company_name: Optional[str] = Field(None, description="公司名称")
|
|
company_address: Optional[str] = Field(None, description="公司地址")
|
|
company_contact: Optional[str] = Field(None, description="公司联系人")
|
|
company_phone: Optional[str] = Field(None, description="公司电话")
|
|
company_email: Optional[str] = Field(None, description="公司邮箱")
|
|
|
|
|
|
class AppUserChangePasswordSchema(BaseModel):
|
|
"""AppUser修改密码Schema"""
|
|
old_password: str = Field(..., description="原密码")
|
|
new_password: str = Field(..., description="新密码")
|
|
|
|
|
|
class AppUserDashboardOut(BaseModel):
|
|
"""AppUser首页摘要输出"""
|
|
remaining_quota: int
|
|
latest_valuation: Optional[dict] = None
|
|
pending_invoices: int
|
|
|
|
|
|
class AppUserQuotaOut(BaseModel):
|
|
"""AppUser剩余估值次数输出"""
|
|
remaining_count: int
|
|
user_type: Optional[str] = None
|
|
|
|
|
|
class AppUserQuotaUpdateSchema(BaseModel):
|
|
user_id: int = Field(..., description="用户ID")
|
|
target_count: Optional[int] = Field(None, description="目标次数")
|
|
delta: Optional[int] = Field(None, description="增减次数")
|
|
op_type: str = Field(..., description="操作类型")
|
|
remark: Optional[str] = Field(None, description="备注")
|
|
|
|
|
|
class AppUserQuotaLogOut(BaseModel):
|
|
id: int
|
|
app_user_id: int
|
|
operator_id: int
|
|
operator_name: str
|
|
before_count: int
|
|
after_count: int
|
|
op_type: str
|
|
remark: Optional[str] = None
|
|
created_at: str
|
|
|
|
|
|
class AppUserRegisterOut(BaseModel):
|
|
"""App 用户注册结果"""
|
|
user_id: int = Field(..., description="用户ID")
|
|
phone: str = Field(..., description="手机号")
|
|
default_password: str = Field(..., description="默认密码(手机号后六位)")
|
|
|
|
|
|
class TokenValidateOut(BaseModel):
|
|
"""Token 校验结果"""
|
|
user_id: int = Field(..., description="用户ID")
|
|
phone: str = Field(..., description="手机号") |