add tenant

This commit is contained in:
Wolfgang Hottgenroth 2021-07-05 12:03:56 +02:00
parent 1e9d22483c
commit 81ba2655b3
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
2 changed files with 67 additions and 3 deletions

View File

@ -64,6 +64,44 @@ paths:
$ref: '#/components/schemas/Account'
security:
- jwt: ['secret']
/v1/tenants:
get:
tags: [ "Tenant" ]
summary: Return all normalized tenants
operationId: account.getTenants
responses:
'200':
description: tenant response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/Tenant'
security:
- jwt: ['secret']
/v1/tenants/{tenantId}:
get:
tags: [ "Tenant" ]
summary: Return the normalized tenant with given id
operationId: account.getTenant
parameters:
- name: tenantId
in: path
required: true
schema:
type: integer
responses:
'200':
description: tenants response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/Tenant'
security:
- jwt: ['secret']
components:
securitySchemes:
@ -119,6 +157,3 @@ components:
type: string
account:
type: integer
TenantJoint:
description: TenantJoint
type: object

29
tenant.py Normal file
View File

@ -0,0 +1,29 @@
from db import dbGetMany, dbGetOne
def getTenants(user, token_info):
return dbGetMany(user, token_info,
{
"statement": """
SELECT id, salutation, firstname, lastname,
address1, address2, address3, zip, city,
phone1, phone2, iban, account
FROM tenant_t
""",
"params": ()
}
)
def getTenant(user, token_info, tenantId=None):
return dbGetOne(user, token_info,
{
"statement": """
SELECT id, salutation, firstname, lastname,
address1, address2, address3, zip, city,
phone1, phone2, iban, account
FROM tenant_t
WHERE id = %s
""",
"params": (tenantId, )
}
)