From e2b9f5d751207c280bc1b0d781e656d7e25cdaf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E4=B8=BA=E4=B9=8B?= <560397@gree.com.cn> Date: Tue, 21 Nov 2023 11:31:32 +0800 Subject: [PATCH] Update project --- application/models/log.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/application/models/log.py b/application/models/log.py index c5e6185..1b89fd1 100644 --- a/application/models/log.py +++ b/application/models/log.py @@ -7,17 +7,25 @@ # @Email : StudentCWZ@outlook.com # @Date : 2023/11/19 14:59 # @File : log.py -# @Description : +# @Description : Defines the Log model for the application. """ +# Import built-in modules import os +# Import custom modules from application.extensions.init_sqlalchemy import db class Log(db.Model): - """Basic user model""" + """ + The Log model for the application. + + Each instance of this model represents a row in the 'logs' database table + which is defined by the 'TableName' environment variable or defaults to 'logs'. + """ + __tablename__ = os.environ.get('TableName', 'logs') id = db.Column(db.Integer, primary_key=True, autoincrement=True) @@ -55,14 +63,25 @@ class Log(db.Model): cost_time = db.Column(db.String(80)) def __repr__(self) -> str: + """ + Returns a string representation of a Log instance. + + Returns: + str: A string representation of a Log instance. + """ return f'' def to_dict(self) -> dict: - """object to dict""" + """ + Converts the Log instance to a dictionary. + + Returns: + dict: A dictionary representation of the Log instance. + """ _dic = {} for key, value in self.__dict__.items(): if str(key).startswith("_"): - # 前缀带下划线不要 + # Ignore attributes starting with an underscore continue _dic[key] = value return _dic -- GitLab