rental objects

This commit is contained in:
2021-07-05 18:27:59 +02:00
parent 67c97ed4bc
commit b6c33534f1
2 changed files with 219 additions and 0 deletions

View File

@ -102,6 +102,120 @@ paths:
$ref: '#/components/schemas/Tenant' $ref: '#/components/schemas/Tenant'
security: security:
- jwt: ['secret'] - jwt: ['secret']
/v1/commercialPremises:
get:
tags: [ "CommercialPremise" ]
summary: Return all normalized commercial premises
operationId: rentalObjects.getCommercialPremises
responses:
'200':
description: commercial premise response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/CommercialPremise'
security:
- jwt: ['secret']
/v1/commercialPremises/{commercialPremiseId}:
get:
tags: [ "CommercialPremise" ]
summary: Return the normalized commercial premise with given id
operationId: rentalObjects.getCommercialPremise
parameters:
- name: commercialPremiseId
in: path
required: true
schema:
type: integer
responses:
'200':
description: commercial premise response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/CommercialPremise'
security:
- jwt: ['secret']
/v1/parkings:
get:
tags: [ "Parking" ]
summary: Return all normalized parkings
operationId: rentalObjects.getParkings
responses:
'200':
description: parkings response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/Parking'
security:
- jwt: ['secret']
/v1/parkings/{parkingId}:
get:
tags: [ "Parking" ]
summary: Return the normalized parking with given id
operationId: rentalObjects.getParking
parameters:
- name: parkingId
in: path
required: true
schema:
type: integer
responses:
'200':
description: parking response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/Parking'
security:
- jwt: ['secret']
/v1/flats:
get:
tags: [ "Flat" ]
summary: Return all normalized flats
operationId: rentalObjects.getFlats
responses:
'200':
description: flat response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/Flat'
security:
- jwt: ['secret']
/v1/flats/{flatId}:
get:
tags: [ "Flat" ]
summary: Return the normalized flat with given id
operationId: rentalObjects.getFlat
parameters:
- name: flatId
in: path
required: true
schema:
type: integer
responses:
'200':
description: flat response
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/schemas/Flat'
security:
- jwt: ['secret']
components: components:
securitySchemes: securitySchemes:
@ -157,3 +271,37 @@ components:
type: string type: string
account: account:
type: integer type: integer
CommercialPremise:
description: CommercialPremise
type: object
properties:
id:
type: integer
description:
type: string
premise:
type: integer
Parking:
description: Parking
type: object
properties:
id:
type: integer
description:
type: string
premise:
type: integer
Flat:
description: Flat
type: object
properties:
id:
type: integer
description:
type: string
premise:
type: integer
area:
type: number
flat_no:
type: integer

71
rentalObjects.py Normal file
View File

@ -0,0 +1,71 @@
from db import dbGetMany, dbGetOne
def getCommercialPremises(user, token_info):
return dbGetMany(user, token_info,
{
"statement": """
SELECT id, description, premise
FROM commercial_premise_t
""",
"params": ()
}
)
def getCommercialPremise(user, token_info, commercialPremiseId=None):
return dbGetOne(user, token_info,
{
"statement": """
SELECT id, description, premise
FROM commercial_premise_t
WHERE id = %s
""",
"params": (commercialPremiseId, )
}
)
def getFlats(user, token_info):
return dbGetMany(user, token_info,
{
"statement": """
SELECT id, description, premise, area, flat_no
FROM flat_t
""",
"params": ()
}
)
def getFlat(user, token_info, flatId=None):
return dbGetOne(user, token_info,
{
"statement": """
SELECT id, description, premise, area, flat_no
FROM flat_t
WHERE id = %s
""",
"params": (flatId, )
}
)
def getParking(user, token_info):
return dbGetMany(user, token_info,
{
"statement": """
SELECT id, description, premise
FROM parking_t
""",
"params": ()
}
)
def getParking(user, token_info, parkingId=None):
return dbGetOne(user, token_info,
{
"statement": """
SELECT id, description, premise
FROM parking_t
WHERE id = %s
""",
"params": (parkingId, )
}
)