This commit is contained in:
2021-09-09 18:39:18 +02:00
parent 6fcd785be0
commit 204d2a27f2
13 changed files with 438 additions and 4 deletions

View File

@ -1320,3 +1320,80 @@ SELECT
}
)
def get_notes(user, token_info):
return dbGetMany(user, token_info, {
"statement": """
SELECT
id
,created_at
,tenant
,note
FROM note_t
""",
"params": ()
}
)
def insert_note(user, token_info, **args):
try:
body = args["body"]
v_created_at = body["created_at"]
v_tenant = body["tenant"]
v_note = body["note"]
return dbInsert(user, token_info, {
"statement": """
INSERT INTO note_t
(
created_at
,tenant
,note
) VALUES (
%s
,%s
,%s
)
RETURNING *
""",
"params": [
v_created_at
,v_tenant
,v_note
]
})
except KeyError as e:
logger.warning("insert_note: parameter missing: {}".format(e))
raise werkzeug.exceptions.UnprocessableEntity("parameter missing: {}".format(e))
def get_note(user, token_info, noteId=None):
return dbGetOne(user, token_info, {
"statement": """
SELECT
id
,created_at
,tenant
,note
FROM note_t
WHERE id = %s
""",
"params": (noteId, )
}
)
def get_note_by_tenant(user, token_info, tenantId=None):
return dbGetMany(user, token_info, {
"statement": """
SELECT
id
,created_at
,tenant
,note
FROM note_t
WHERE tenant = %s
""",
"params": (tenantId, )
}
)

View File

@ -1256,6 +1256,87 @@ paths:
$ref: '#/components/schemas/account_entry'
security:
- jwt: ['secret']
/v1/notes:
get:
tags: [ "note" ]
summary: Return all normalized notes
operationId: methods.get_notes
responses:
'200':
description: notes response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/note'
security:
- jwt: ['secret']
post:
tags: [ "note" ]
summary: Insert a note
operationId: methods.insert_note
requestBody:
description: note
content:
application/json:
schema:
$ref: '#/components/schemas/note'
responses:
'200':
description: note successfully inserted
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/note'
security:
- jwt: ['secret']
/v1/notes/{noteId}:
get:
tags: [ "note" ]
summary: Return the normalized note with given id
operationId: methods.get_note
parameters:
- name: noteId
in: path
required: true
schema:
type: integer
responses:
'200':
description: note response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/note'
security:
- jwt: ['secret']
/v1/notes/tenant/{tenantId}:
get:
tags: [ "note", "tenant" ]
summary: Return note by $tenant
operationId: methods.get_note_by_tenant
parameters:
- name: tenantId
in: path
required: true
schema:
type: integer
responses:
'200':
description: note response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/note'
security:
- jwt: ['secret']
# -------------------------------------------------------------------
# ATTENTION: This file will not be parsed by Cheetah
@ -1511,3 +1592,15 @@ components:
type: string
amount:
type: number
note:
description: note
type: object
properties:
id:
type: integer
created_at:
type: string
tenant:
type: integer
note:
type: string