主要变更: - 后端代码从根目录迁移到 app/ 目录 - 前端代码从 frontend/ 重命名为 WebUI/ - 更新所有导入路径以适配新结构 - 提取公共 API 响应函数到 app/api/common.py - 精简验证器服务代码 - 更新启动脚本和文档 测试: - 新增完整测试套件 (tests/) - 单元测试: 模型、仓库层 - 集成测试: 覆盖所有 22+ API 端点 - E2E 测试: 4个完整工作流场景 - 添加 pytest 配置和测试运行脚本
43 lines
966 B
Python
43 lines
966 B
Python
"""领域模型 - 纯数据结构,不依赖任何框架"""
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
|
|
@dataclass
|
|
class ProxyRaw:
|
|
"""爬虫爬取的原始代理数据"""
|
|
ip: str
|
|
port: int
|
|
protocol: str = "http"
|
|
|
|
def __post_init__(self):
|
|
self.protocol = self.protocol.lower().strip()
|
|
if self.protocol not in ("http", "https", "socks4", "socks5"):
|
|
self.protocol = "http"
|
|
|
|
|
|
@dataclass
|
|
class Proxy:
|
|
"""数据库中的代理实体"""
|
|
ip: str
|
|
port: int
|
|
protocol: str
|
|
score: int
|
|
response_time_ms: Optional[float] = None
|
|
last_check: Optional[datetime] = None
|
|
created_at: Optional[datetime] = None
|
|
|
|
|
|
@dataclass
|
|
class PluginInfo:
|
|
"""插件元数据"""
|
|
id: str
|
|
name: str
|
|
display_name: str
|
|
description: str
|
|
enabled: bool
|
|
last_run: Optional[datetime] = None
|
|
success_count: int = 0
|
|
failure_count: int = 0
|