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
a36d5206
Commit
a36d5206
authored
Mar 24, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
6a858248
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
0 deletions
+133
-0
backend/controller/login_logs_manager.py
backend/controller/login_logs_manager.py
+112
-0
backend/model/login_logs.py
backend/model/login_logs.py
+21
-0
No files found.
backend/controller/login_logs_manager.py
0 → 100644
View file @
a36d5206
#!/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.login_logs
import
LoginLogs
from
model.user
import
User
from
utils
import
sql_filter
logger
=
logging
.
getLogger
(
"LoginLogsManager"
)
class
LoginLogsManager
(
object
):
def
__init__
(
self
):
super
(
LoginLogsManager
,
self
)
.
__init__
()
def
add
(
self
,
user
,
data
):
# 判断角色名是否存在
result
=
LoginLogs
.
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
(
LoginLogs
,
**
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
=
LoginLogs
.
get
(
uuid
=
uuid
)
if
result
:
result
.
delete
()
return
result
,
"delete app logs {}."
.
format
(
"success"
if
result
else
"fail"
)
def
get
(
self
,
data
):
result
=
LoginLogs
.
get
(
**
data
)
if
result
:
result
=
result
.
to_dict
(
with_collections
=
True
,
related_objects
=
True
)
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
:
editor
=
User
.
get
(
id
=
user
)
if
not
editor
:
return
False
,
"current user is not exists"
temp
.
update
({
'create_by'
:
editor
})
if
"scope_type"
in
data
and
data
.
get
(
"scope_type"
)
==
"list"
:
result
=
LoginLogs
.
select
()
.
where
(
**
temp
)
.
order_by
(
desc
(
LoginLogs
.
create_at
))
temp
=
[]
for
item
in
result
:
temp
.
append
(
item
.
to_dict
(
only
=
[
"uuid"
]))
return
temp
,
len
(
temp
),
"get select {}."
.
format
(
"success"
if
temp
else
"no data"
)
result
=
LoginLogs
.
select
()
.
where
(
**
temp
)
.
order_by
(
desc
(
LoginLogs
.
create_at
))
.
page
(
data
.
get
(
"pagenum"
,
1
),
data
.
get
(
"pagesize"
,
10
))
count
=
LoginLogs
.
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"
)
loginLogsManager
=
LoginLogsManager
()
backend/model/login_logs.py
0 → 100644
View file @
a36d5206
#!/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
LoginLogs
(
db
.
Entity
):
_table_
=
"{}"
.
format
(
config
[
'TABLE_PREFIX'
])
+
"login_logs"
id
=
PrimaryKey
(
int
,
auto
=
True
)
uuid
=
Required
(
uuid
.
UUID
,
unique
=
True
,
default
=
uuid
.
uuid1
,
index
=
True
)
username
=
Optional
(
str
)
address
=
Optional
(
str
)
create_at
=
Required
(
datetime
,
default
=
datetime
.
now
)
create_by
=
Optional
(
"User"
,
reverse
=
'login_logs_creater'
)
sort
=
Optional
(
int
,
size
=
32
,
default
=
0
)
remarks
=
Optional
(
str
,
default
=
""
,
nullable
=
True
)
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