Commit e2b9f5d7 authored by 崔为之's avatar 崔为之 💪🏽

Update project

parent e3b4c279
...@@ -7,17 +7,25 @@ ...@@ -7,17 +7,25 @@
# @Email : StudentCWZ@outlook.com # @Email : StudentCWZ@outlook.com
# @Date : 2023/11/19 14:59 # @Date : 2023/11/19 14:59
# @File : log.py # @File : log.py
# @Description : # @Description : Defines the Log model for the application.
""" """
# Import built-in modules
import os import os
# Import custom modules
from application.extensions.init_sqlalchemy import db from application.extensions.init_sqlalchemy import db
class Log(db.Model): 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') __tablename__ = os.environ.get('TableName', 'logs')
id = db.Column(db.Integer, primary_key=True, autoincrement=True) id = db.Column(db.Integer, primary_key=True, autoincrement=True)
...@@ -55,14 +63,25 @@ class Log(db.Model): ...@@ -55,14 +63,25 @@ class Log(db.Model):
cost_time = db.Column(db.String(80)) cost_time = db.Column(db.String(80))
def __repr__(self) -> str: def __repr__(self) -> str:
"""
Returns a string representation of a Log instance.
Returns:
str: A string representation of a Log instance.
"""
return f'<Log {self.uuid}>' return f'<Log {self.uuid}>'
def to_dict(self) -> dict: 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 = {} _dic = {}
for key, value in self.__dict__.items(): for key, value in self.__dict__.items():
if str(key).startswith("_"): if str(key).startswith("_"):
# 前缀带下划线不要 # Ignore attributes starting with an underscore
continue continue
_dic[key] = value _dic[key] = value
return _dic return _dic
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment