Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
evm-store
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanli
evm-store
Commits
77e142d0
Commit
77e142d0
authored
Mar 22, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
c9c1da41
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
323 additions
and
0 deletions
+323
-0
backend/controller/app_logs_manager.py
backend/controller/app_logs_manager.py
+107
-0
backend/model/app_logs.py
backend/model/app_logs.py
+23
-0
backend/schema/app_logs.py
backend/schema/app_logs.py
+32
-0
backend/view/app_logs.py
backend/view/app_logs.py
+101
-0
frontend/src/components/GithubCorner/index.vue
frontend/src/components/GithubCorner/index.vue
+60
-0
No files found.
backend/controller/app_logs_manager.py
0 → 100644
View file @
77e142d0
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
copy
import
time
import
types
import
json
import
logging
import
traceback
from
datetime
import
datetime
from
pony.orm
import
*
from
model
import
fullStackDB
from
model.app_logs
import
AppLogs
from
model.user
import
User
from
utils
import
sql_filter
logger
=
logging
.
getLogger
(
"AppLogsManager"
)
class
AppLogsManager
(
object
):
def
__init__
(
self
):
super
(
AppLogsManager
,
self
)
.
__init__
()
def
add
(
self
,
user
,
data
):
# 判断角色名是否存在
result
=
AppLogs
.
get
(
name
=
data
.
get
(
"name"
))
if
result
:
return
False
,
"app logs name has been exists."
editor
=
User
.
get
(
id
=
user
)
if
not
editor
:
return
False
,
"current user is not exists"
data
.
update
({
'create_by'
:
editor
,
'create_at'
:
datetime
.
now
(),
})
result
=
fullStackDB
.
add
(
AppLogs
,
**
data
)
return
result
,
"add app logs {}."
.
format
(
"success"
if
result
else
"fail"
)
def
delete
(
self
,
user
,
uuid
):
with
db_session
:
editor
=
User
.
get
(
id
=
user
)
if
not
editor
:
return
False
,
"current user is not exists"
result
=
AppLogs
.
get
(
uuid
=
uuid
)
if
result
:
result
.
delete
()
return
result
,
"delete app logs {}."
.
format
(
"success"
if
result
else
"fail"
)
def
get
(
self
,
data
):
result
=
AppLogs
.
get
(
**
data
)
if
result
:
result
=
result
.
to_dict
(
with_collections
=
True
,
related_objects
=
True
,
only
=
[
"uuid"
,
"name"
,
"create_at"
,
"update_at"
,
"delete_at"
])
return
result
,
"get app logs {}."
.
format
(
"success"
if
result
else
"fail"
)
def
getList
(
self
,
user
,
data
):
if
not
data
or
len
(
data
)
<=
0
:
return
False
,
0
,
"parameters can not be null"
temp
=
copy
.
deepcopy
(
data
)
if
'pagenum'
in
temp
:
temp
.
pop
(
'pagenum'
)
if
'pagesize'
in
temp
:
temp
.
pop
(
'pagesize'
)
if
'scope_type'
in
temp
:
temp
.
pop
(
'scope_type'
)
with
db_session
:
if
"scope_type"
in
data
and
data
.
get
(
"scope_type"
)
==
"list"
:
result
=
AppLogs
.
select
()
.
where
(
**
temp
)
.
order_by
(
desc
(
AppLogs
.
create_at
))
temp
=
[]
for
item
in
result
:
temp
.
append
(
item
.
to_dict
(
only
=
[
"uuid"
,
"app_name"
]))
return
temp
,
len
(
temp
),
"get select {}."
.
format
(
"success"
if
temp
else
"no data"
)
result
=
AppLogs
.
select
()
.
where
(
**
temp
)
.
order_by
(
desc
(
AppLogs
.
create_at
))
.
page
(
data
.
get
(
"pagenum"
,
1
),
data
.
get
(
"pagesize"
,
10
))
count
=
AppLogs
.
select
()
.
where
(
**
temp
)
.
count
()
if
result
and
len
(
result
):
temp
=
[]
for
item
in
result
:
t
=
item
.
to_dict
(
with_collections
=
True
,
related_objects
=
True
)
t
.
update
({
"create_at"
:
item
.
create_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"create_by"
:
item
.
create_by
.
to_dict
(
only
=
[
"uuid"
,
"username"
]),
})
temp
.
append
(
t
)
result
=
temp
return
result
,
count
,
"get app logs {}."
.
format
(
"success"
if
result
else
"no data"
)
def
update
(
self
,
user
,
uuid
,
data
):
# 当参数为空时,直接返回错误
if
len
(
data
)
<=
0
or
(
len
(
data
.
keys
())
==
1
and
"id"
in
data
):
return
False
,
"parameters can not be null."
# 查询请求者是否存在
editor
=
User
.
get
(
id
=
user
)
if
not
editor
:
return
False
,
"current user is not exists"
return
True
,
"update app logs {}."
.
format
(
"success"
if
True
else
"fail"
)
appLogsManager
=
AppLogsManager
()
backend/model/app_logs.py
0 → 100644
View file @
77e142d0
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
uuid
from
datetime
import
datetime
from
pony.orm
import
PrimaryKey
,
Required
,
Optional
,
Set
,
Json
from
app
import
config
from
.
import
fullStackDB
db
=
fullStackDB
.
db
class
AppLogs
(
db
.
Entity
):
_table_
=
"{}"
.
format
(
config
[
'TABLE_PREFIX'
])
+
"app_logs"
id
=
PrimaryKey
(
int
,
auto
=
True
)
uuid
=
Required
(
uuid
.
UUID
,
unique
=
True
,
default
=
uuid
.
uuid1
,
index
=
True
)
app_name
=
Optional
(
str
)
app_path
=
Optional
(
str
,
default
=
""
)
app_version
=
Optional
(
str
,
default
=
""
)
app_info
=
Optional
(
Json
,
default
=
{})
create_at
=
Required
(
datetime
,
default
=
datetime
.
now
)
create_by
=
Optional
(
"User"
,
reverse
=
'app_logs_creater'
)
sort
=
Optional
(
int
,
size
=
32
,
default
=
0
)
remarks
=
Optional
(
str
,
max_len
=
255
,
default
=
""
,
nullable
=
True
)
backend/schema/app_logs.py
0 → 100644
View file @
77e142d0
from
datetime
import
datetime
from
.
import
BaseSchema
from
marshmallow
import
fields
,
validate
,
RAISE
,
INCLUDE
,
EXCLUDE
class
AddSchema
(
BaseSchema
):
class
Meta
:
unknown
=
EXCLUDE
class
UpdateSchema
(
BaseSchema
):
class
Meta
:
unknown
=
EXCLUDE
class
DeleteSchema
(
BaseSchema
):
class
Meta
:
unknown
=
EXCLUDE
class
QuerySchema
(
BaseSchema
):
uuid
=
fields
.
UUID
(
required
=
False
)
scope_type
=
fields
.
String
(
required
=
False
)
pagenum
=
fields
.
Int
(
required
=
False
)
pagesize
=
fields
.
Int
(
required
=
False
,
max
=
50
)
# 防止用户传特别大的数,导致数据库查询阻塞
class
Meta
:
unknown
=
EXCLUDE
class
ResponseSchema
(
BaseSchema
):
uuid
=
fields
.
UUID
(
required
=
True
)
create_at
=
fields
.
DateTime
(
required
=
False
,
default
=
datetime
.
now
)
update_at
=
fields
.
DateTime
(
required
=
False
,
default
=
datetime
.
now
)
class
Meta
:
unknown
=
INCLUDE
backend/view/app_logs.py
0 → 100644
View file @
77e142d0
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import
os
import
json
import
datetime
import
logging
import
traceback
from
flask
import
Blueprint
,
request
from
app
import
config
,
signalManager
from
fullstack.login
import
Auth
from
fullstack.validation
import
validate_schema
from
fullstack.response
import
ResponseCode
,
response_result
from
schema.app_logs
import
AddSchema
,
DeleteSchema
,
QuerySchema
,
UpdateSchema
,
ResponseSchema
logger
=
logging
.
getLogger
(
"appLogsApi"
)
appLogs_api
=
Blueprint
(
"appLogs_api"
,
__name__
,
url_prefix
=
"/api/v1/
%
s/appLogs"
%
config
[
'NAME'
])
@
appLogs_api
.
route
(
"/add"
,
methods
=
[
'POST'
])
@
validate_schema
(
AddSchema
)
@
Auth
.
auth_required
def
add
():
try
:
user
=
request
.
current_user
.
get
(
"id"
)
isSuccess
,
message
=
signalManager
.
actionAddAppLogs
.
emit
(
user
,
request
.
schema_data
)
if
isSuccess
:
return
response_result
(
ResponseCode
.
OK
,
msg
=
message
)
else
:
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
message
)
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
return
response_result
(
ResponseCode
.
SERVER_ERROR
,
msg
=
str
(
e
))
@
appLogs_api
.
route
(
"/delete/<uuid:id>"
,
methods
=
[
'POST'
])
@
validate_schema
(
DeleteSchema
)
@
Auth
.
auth_required
def
delete
(
id
):
try
:
user
=
request
.
current_user
.
get
(
"id"
)
isSuccess
,
message
=
signalManager
.
actionDeleteAppLogs
.
emit
(
user
,
id
)
if
isSuccess
:
return
response_result
(
ResponseCode
.
OK
,
msg
=
message
)
else
:
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
message
)
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
return
response_result
(
ResponseCode
.
SERVER_ERROR
)
@
appLogs_api
.
route
(
"/get"
,
methods
=
[
"POST"
])
@
validate_schema
(
QuerySchema
)
@
Auth
.
auth_required
def
get
():
try
:
user
=
request
.
current_user
.
get
(
"id"
)
result
,
message
=
signalManager
.
actionGetAppLogs
.
emit
(
user
,
request
.
schema_data
)
if
result
:
return
response_result
(
ResponseCode
.
OK
,
data
=
result
,
msg
=
message
)
else
:
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
message
)
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
return
response_result
(
ResponseCode
.
SERVER_ERROR
,
msg
=
str
(
e
))
@
appLogs_api
.
route
(
"/list"
,
methods
=
[
'POST'
])
@
validate_schema
(
QuerySchema
)
@
Auth
.
auth_required
def
get_list
():
try
:
user
=
request
.
current_user
.
get
(
"id"
)
result
,
count
,
message
=
signalManager
.
actionGetAppLogsList
.
emit
(
user
,
request
.
schema_data
)
if
result
:
return
response_result
(
ResponseCode
.
OK
,
data
=
result
,
msg
=
message
,
count
=
count
)
else
:
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
message
)
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
return
response_result
(
ResponseCode
.
SERVER_ERROR
)
@
appLogs_api
.
route
(
"/update/<uuid:id>"
,
methods
=
[
'POST'
])
@
validate_schema
(
UpdateSchema
)
@
Auth
.
auth_required
def
update
(
id
):
try
:
user
=
request
.
current_user
.
get
(
"id"
)
isSuccess
,
message
=
signalManager
.
actionUpdateAppLogs
.
emit
(
user
,
id
,
request
.
schema_data
)
if
isSuccess
:
return
response_result
(
ResponseCode
.
OK
,
msg
=
message
)
else
:
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
message
)
except
Exception
as
e
:
traceback
.
print_exc
()
logger
.
error
(
str
(
e
))
return
response_result
(
ResponseCode
.
SERVER_ERROR
)
frontend/src/components/GithubCorner/index.vue
0 → 100644
View file @
77e142d0
<
template
>
<a
href=
"https://gitee.com/scriptiot/evm"
target=
"_blank"
class=
"github-corner"
aria-label=
"View source on Github"
>
<svg
width=
"80"
height=
"80"
viewBox=
"0 0 250 250"
style=
"fill:#40c9c6; color:#fff;"
aria-hidden=
"true"
>
<path
d=
"M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"
/>
<path
d=
"M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill=
"currentColor"
style=
"transform-origin: 130px 106px;"
class=
"octo-arm"
/>
<path
d=
"M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill=
"currentColor"
class=
"octo-body"
/>
</svg>
</a>
</
template
>
<
style
scoped
>
.github-corner
{
top
:
0px
;
right
:
0px
;
position
:
absolute
;
margin
:
0px
;
}
.github-corner
:hover
.octo-arm
{
animation
:
octocat-wave
560ms
ease-in-out
}
@keyframes
octocat-wave
{
0
%,
100
%
{
transform
:
rotate
(
0
)
}
20
%,
60
%
{
transform
:
rotate
(
-25deg
)
}
40
%,
80
%
{
transform
:
rotate
(
10deg
)
}
}
@media
(
max-width
:
500px
)
{
.github-corner
:hover
.octo-arm
{
animation
:
none
}
.github-corner
.octo-arm
{
animation
:
octocat-wave
560ms
ease-in-out
}
}
</
style
>
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