简道云V2.0
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
"""
|
||||
Pydantic 数据模型定义
|
||||
用于 FastAPI 请求和响应的数据验证
|
||||
"""
|
||||
from typing import Optional, Dict, Any, List
|
||||
from pydantic import BaseModel, Field
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ActionType(str, Enum):
|
||||
"""支持的操作类型枚举"""
|
||||
LOGIN_IN = "login_in"
|
||||
GET_COMPANY_INFORMATION = "get_company_information"
|
||||
GET_STORE_INFORMATION = "get_store_information"
|
||||
KEEP_ALIVE = "keep_alive"
|
||||
CHECK_FILE = "check_file"
|
||||
CREATE_BRAND = "create_brand"
|
||||
DELETE_HISTORY = "delete_history"
|
||||
DELETE_CUSTOMER = "delete_customer"
|
||||
DELETE_CARS = "delete_cars"
|
||||
SMS_SIGNATURE_STATUS = "sms_signature_status"
|
||||
MODIFY_CUSTOMER_INFO = "modify_customer_info"
|
||||
F6_PLUGIN = "F6_Plugin"
|
||||
|
||||
|
||||
class WebhookRequest(BaseModel):
|
||||
"""Webhook 请求体数据模型"""
|
||||
# 通用字段
|
||||
api_key: Optional[str] = Field(None, description="简道云应用ID")
|
||||
entry_id: Optional[str] = Field(None, description="简道云表单ID")
|
||||
data_id: Optional[str] = Field(None, description="简道云数据ID")
|
||||
Action: Optional[str] = Field(None, description="操作类型")
|
||||
|
||||
# 登录相关字段
|
||||
username: Optional[str] = Field(None, description="用户名")
|
||||
password: Optional[str] = Field(None, description="密码")
|
||||
company_name: Optional[str] = Field(None, description="公司名称")
|
||||
|
||||
# 文件相关字段
|
||||
file_path: Optional[str] = Field(None, description="文件保存路径")
|
||||
|
||||
# 其他字段(允许任意额外字段)
|
||||
class Config:
|
||||
extra = "allow" # 允许额外字段,因为简道云可能传递其他字段
|
||||
|
||||
|
||||
class WebhookHeader(BaseModel):
|
||||
"""Webhook 请求头数据模型"""
|
||||
Action: Optional[str] = Field(None, description="操作类型")
|
||||
Check: Optional[str] = Field(None, description="检查标志(是/否)")
|
||||
|
||||
class Config:
|
||||
extra = "allow" # 允许额外请求头
|
||||
|
||||
|
||||
class WebhookResponse(BaseModel):
|
||||
"""Webhook 响应数据模型"""
|
||||
msg: str = Field(..., description="响应消息")
|
||||
msg_details: Optional[str] = Field(None, description="详细信息")
|
||||
check: Optional[str] = Field(None, description="检查结果")
|
||||
status: Optional[str] = Field(None, description="状态")
|
||||
|
||||
class Config:
|
||||
extra = "allow" # 允许额外字段
|
||||
|
||||
|
||||
class HealthResponse(BaseModel):
|
||||
"""健康检查响应模型"""
|
||||
status: str = Field("ok", description="服务状态")
|
||||
version: Optional[str] = Field(None, description="服务版本")
|
||||
|
||||
|
||||
class ErrorResponse(BaseModel):
|
||||
"""错误响应模型"""
|
||||
detail: str = Field(..., description="错误详情")
|
||||
error_code: Optional[str] = Field(None, description="错误代码")
|
||||
|
||||
Reference in New Issue
Block a user