You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

"""
测试日志模型
"""
from datetime import datetime
from sqlalchemy import Column, BigInteger, String, Integer, Boolean, Text, DateTime, JSON, TypeDecorator, String as SQLString
import json
class JSONField(TypeDecorator):
impl = SQLString
def process_bind_param(self, value, dialect):
if value is None:
return None
return json.dumps(value)
def process_result_value(self, value, dialect):
if value is None:
return None
return json.loads(value)
from app.db.base import Base
class APITestLog(Base):
"""API测试日志表"""
__tablename__ = "api_test_logs"
id = Column(BigInteger, primary_key=True, index=True)
test_name = Column(String(200), nullable=False)
api_category = Column(String(50), nullable=False, index=True)
api_endpoint = Column(String(200), nullable=False, index=True)
request_method = Column(String(10), nullable=False)
request_params = Column(JSONField)
response_data = Column(JSONField)
status_code = Column(Integer)
execution_time_ms = Column(Integer)
is_success = Column(Boolean, default=False)
error_message = Column(Text)
created_at = Column(DateTime(timezone=True), default=datetime.utcnow, index=True)