2025-02-15 23:36:20 +08:00
|
|
|
|
# _*_ coding : UTF-8 _*_
|
|
|
|
|
# @Time : 2025/02/13 21:23
|
|
|
|
|
# @UpdateTime : 2025/02/13 21:23
|
|
|
|
|
# @Author : sonder
|
|
|
|
|
# @File : code.py
|
|
|
|
|
# @Software : PyCharm
|
|
|
|
|
# @Comment : 本程序
|
|
|
|
|
from tortoise import fields
|
|
|
|
|
|
|
|
|
|
from models.common import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Code(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
编码模型
|
|
|
|
|
"""
|
|
|
|
|
code = fields.CharField(
|
|
|
|
|
max_length=255,
|
|
|
|
|
description="编码",
|
|
|
|
|
source_field="code"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
description = fields.TextField(
|
|
|
|
|
description="描述",
|
|
|
|
|
source_field="description"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
table = "code"
|
|
|
|
|
table_description = "编码表"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QueryCodeLog(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
查询编码日志模型
|
|
|
|
|
"""
|
|
|
|
|
request_params = fields.TextField(
|
|
|
|
|
null=True,
|
|
|
|
|
description="请求参数",
|
|
|
|
|
source_field="request_params" # 映射到数据库字段 request_params
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
请求参数。
|
|
|
|
|
- 记录用户请求的参数(任意格式,如字符串、JSON、XML 等)。
|
|
|
|
|
- 允许为空。
|
|
|
|
|
- 映射到数据库字段 request_params。
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
response_result = fields.TextField(
|
|
|
|
|
null=True,
|
|
|
|
|
description="返回结果",
|
|
|
|
|
source_field="response_result" # 映射到数据库字段 response_result
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
返回结果。
|
|
|
|
|
- 记录操作的返回结果(任意格式,如字符串、JSON、XML 等)。
|
|
|
|
|
- 允许为空。
|
|
|
|
|
- 映射到数据库字段 response_result。
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
status = fields.SmallIntField(
|
|
|
|
|
default=1,
|
|
|
|
|
description="操作状态(1成功,0失败)",
|
|
|
|
|
source_field="status" # 映射到数据库字段 status
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
操作状态。
|
|
|
|
|
- 1:成功
|
|
|
|
|
- 0:失败
|
|
|
|
|
- 默认为 1。
|
|
|
|
|
- 映射到数据库字段 status。
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
operation_time = fields.DatetimeField(
|
|
|
|
|
auto_now_add=True,
|
|
|
|
|
description="操作时间",
|
|
|
|
|
source_field="operation_time" # 映射到数据库字段 operation_time
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
操作时间。
|
|
|
|
|
- 自动设置为当前时间。
|
|
|
|
|
- 映射到数据库字段 operation_time。
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
cost_time = fields.FloatField(
|
|
|
|
|
default=0,
|
|
|
|
|
description="消耗时间(毫秒)",
|
|
|
|
|
source_field="cost_time" # 映射到数据库字段 cost_time
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
消耗时间。
|
|
|
|
|
- 记录操作消耗的时间(单位:毫秒)。
|
|
|
|
|
- 默认为 0。
|
|
|
|
|
- 映射到数据库字段 cost_time。
|
|
|
|
|
"""
|
|
|
|
|
query_count = fields.IntField(
|
|
|
|
|
default=0,
|
|
|
|
|
description="查询统计",
|
|
|
|
|
source_field="query_count" # 映射到数据库字段 query_count
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
查询统计。
|
|
|
|
|
- 记录查询文本的数量。
|
|
|
|
|
- 默认为 0。
|
|
|
|
|
- 映射到数据库字段 query_count。
|
|
|
|
|
"""
|
|
|
|
|
result_count = fields.IntField(
|
|
|
|
|
default=0,
|
|
|
|
|
description="结果统计",
|
|
|
|
|
source_field="result_count" # 映射到数据库字段 result_count
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
结果统计。
|
|
|
|
|
- 记录查询结果的数量。
|
|
|
|
|
- 默认为 0。
|
|
|
|
|
- 映射到数据库字段 result_count。
|
|
|
|
|
"""
|
|
|
|
|
operator = fields.ForeignKeyField(
|
|
|
|
|
"models.User",
|
|
|
|
|
related_name="query_code_logs",
|
|
|
|
|
description="操作人员",
|
|
|
|
|
source_field="operator_id" # 映射到数据库字段 operator_id
|
|
|
|
|
)
|
|
|
|
|
"""
|
|
|
|
|
操作人员。
|
|
|
|
|
- 外键关联到 User 表。
|
|
|
|
|
- 允许为空。
|
|
|
|
|
- 映射到数据库字段 operator_id。
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
table = "query_code_log"
|
|
|
|
|
table_description = "查询编码日志表"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QueryCode(BaseModel):
|
|
|
|
|
"""
|
|
|
|
|
查询编码模型
|
|
|
|
|
"""
|
|
|
|
|
session = fields.ForeignKeyField(
|
|
|
|
|
"models.QueryCodeLog",
|
|
|
|
|
related_name="query_code",
|
|
|
|
|
description="会话ID",
|
|
|
|
|
source_field="session_id"
|
|
|
|
|
)
|
|
|
|
|
query_text = fields.TextField(
|
|
|
|
|
description="查询文本",
|
|
|
|
|
source_field="query_text" # 映射到数据库字段 query_text
|
|
|
|
|
)
|
|
|
|
|
result_text = fields.TextField(
|
|
|
|
|
description="结果文本",
|
|
|
|
|
source_field="result_text" # 映射到数据库字段 result_text
|
|
|
|
|
)
|
2025-02-19 01:20:04 +08:00
|
|
|
|
status = fields.SmallIntField(
|
|
|
|
|
default=1,
|
|
|
|
|
description="操作状态(1成功,0失败)",
|
|
|
|
|
source_field="status" # 映射到数据库字段 status
|
|
|
|
|
)
|
2025-02-15 23:36:20 +08:00
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
table = "query_code"
|
|
|
|
|
table_description = "查询编码表"
|