Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
崔为之
elp
Commits
e2b9f5d7
Commit
e2b9f5d7
authored
Nov 21, 2023
by
崔为之
💪🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project
parent
e3b4c279
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
application/models/log.py
application/models/log.py
+23
-4
No files found.
application/models/log.py
View file @
e2b9f5d7
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment