Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladislav Rykov
THSO.server
Commits
c0688580
Commit
c0688580
authored
May 12, 2020
by
Vladislav Rykov
Browse files
notification dao added
parent
e3daac7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/app/dao/notification/notification.py
0 → 100644
View file @
c0688580
from
app.helpers.misc
import
with_psql
@
with_psql
def
create
(
cur
,
nid
,
appkey
,
devid
,
name
,
desc
,
action_type
,
action
):
query
=
"""
INSERT INTO
notifications
VALUES
(%s, %s, %s, %s, %s, %s, %s)
"""
cur
.
execute
(
query
,
(
nid
,
appkey
,
devid
,
name
,
desc
,
action_type
,
action
))
return
(
True
,)
@
with_psql
def
delete
(
cur
,
appkey
,
nid
):
query
=
"""
DELETE FROM
notifications
WHERE
id = %s
AND
app_key = %s
"""
cur
.
execute
(
query
,
(
nid
,
appkey
))
return
(
True
,)
@
with_psql
def
get
(
cur
,
appkey
,
nid
):
query
=
"""
SELECT * FROM
notifications
WHERE
id = %s
AND
app_key = %s
"""
cur
.
execute
(
query
,
(
nid
,
appkey
))
app
=
cur
.
fetchone
()
if
app
is
None
:
return
(
False
,
'Notification with appkey {} and id {} does not exist'
.
format
(
appkey
,
nid
))
else
:
return
(
True
,
app
)
@
with_psql
def
get_list
(
cur
,
appkey
):
query
=
"""
SELECT * FROM
notifications
WHERE
app_key = %s
"""
cur
.
execute
(
query
,
(
appkey
,))
return
(
True
,
cur
.
fetchall
())
@
with_psql
def
get_count
(
cur
):
query
=
"""
SELECT COUNT(*) FROM
notifications
"""
cur
.
execute
(
query
,
())
return
(
True
,
cur
.
fetchone
())
Write
Preview
Supports
Markdown
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