feat: добавление нового маршрута /v2/reqphoto для получения фотографий автомобиля по VIN - обновлены запросы в app.py и документация Swagger для улучшения взаимодействия с API
This commit is contained in:
parent
0643d8173a
commit
3175dbc0fe
@ -183,6 +183,66 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
description: Error description
|
description: Error description
|
||||||
|
|
||||||
|
/v2/reqphoto:
|
||||||
|
post:
|
||||||
|
summary: Get vehicle photos
|
||||||
|
description: Get photos of the vehicle by VIN
|
||||||
|
parameters:
|
||||||
|
- name: access_code
|
||||||
|
in: query
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
description: API access code for authentication
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
vin:
|
||||||
|
type: string
|
||||||
|
description: Vehicle Identification Number
|
||||||
|
example: "1HGCM82633A123456"
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Successful photo retrieval
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
found:
|
||||||
|
type: boolean
|
||||||
|
description: Whether photos were found
|
||||||
|
photos:
|
||||||
|
type: array
|
||||||
|
description: List of photo information
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
url:
|
||||||
|
type: string
|
||||||
|
description: URL of the photo
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
description: Type of photo (FRONT, REAR, SIDE, INTERIOR, etc.)
|
||||||
|
date:
|
||||||
|
type: string
|
||||||
|
format: date
|
||||||
|
description: Date when photo was taken
|
||||||
|
'400':
|
||||||
|
description: Invalid VIN or access code
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
error:
|
||||||
|
type: string
|
||||||
|
description: Error description
|
||||||
|
|
||||||
/restfact:
|
/restfact:
|
||||||
get:
|
get:
|
||||||
summary: Check account balance
|
summary: Check account balance
|
||||||
|
|||||||
13
app.py
13
app.py
@ -701,7 +701,7 @@ def api_reqimage():
|
|||||||
app.logger.debug(json.dumps(ret))
|
app.logger.debug(json.dumps(ret))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
cur.execute('select count(*) from salvagedb.salvage_images where vin = :p1 and fnd = 1' , {'p1':vin.upper()})
|
cur.execute('select count(*) from salvagedb.salvage_images where vin = :p1 and fn = 1' , {'p1':vin.upper()})
|
||||||
res = cur.fetchone()
|
res = cur.fetchone()
|
||||||
img_count = int(res[0])
|
img_count = int(res[0])
|
||||||
if img_count<1:
|
if img_count<1:
|
||||||
@ -715,19 +715,17 @@ def api_reqimage():
|
|||||||
app.logger.debug(json.dumps(ret))
|
app.logger.debug(json.dumps(ret))
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
#req_id = uuid.uuid4().hex
|
cur.execute("""select GenImages('{}','{}') as ui from dual""".format(access_code, vin.upper()))
|
||||||
#cur.execute('select rownum,ipath from salvagedb.salvage_images where vin = :p1 and fnd = 1',{'p1':vin.upper()})
|
|
||||||
cur.execute("""select GenImages('{}','{}') uid from dual""".format(access_code, vin.upper()))
|
|
||||||
res = cur.fetchall()
|
res = cur.fetchall()
|
||||||
req_id = res[0]
|
req_id = res[0][0]
|
||||||
cur.execute("""select fake_name from salvage_images_req where req_id = '{}}'""".format(req_id))
|
cur.execute('select fake_name from salvage_images_req where req_id = :p1', {'p1':req_id})
|
||||||
res = cur.fetchall()
|
res = cur.fetchall()
|
||||||
images = []
|
images = []
|
||||||
nm = 0
|
nm = 0
|
||||||
for it in res:
|
for it in res:
|
||||||
images.append({
|
images.append({
|
||||||
'num':nm,
|
'num':nm,
|
||||||
'url':'https://salimages.salvagedb/{}/{}'.format(req_id, it)
|
'url':'https://salimages.salvagedb/{}/{}'.format(req_id, it[0])
|
||||||
})
|
})
|
||||||
nm = nm + 1
|
nm = nm + 1
|
||||||
ret = {'status': 'Image_found', 'Images':images}
|
ret = {'status': 'Image_found', 'Images':images}
|
||||||
@ -736,6 +734,7 @@ def api_reqimage():
|
|||||||
status=200,
|
status=200,
|
||||||
mimetype='application/json'
|
mimetype='application/json'
|
||||||
)
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,11 +14,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<div class="table-container">
|
<div class="table-container" style="display: flex; justify-content: center;">
|
||||||
<table id="hor-minimalist-a" summary="Salvage cars;Database page 1">
|
<table id="hor-minimalist-a" summary="Salvage cars;Database page 1">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
|
||||||
<th>VIN</th>
|
<th>VIN</th>
|
||||||
<th>Make</th>
|
<th>Make</th>
|
||||||
<th>Model</th>
|
<th>Model</th>
|
||||||
@ -28,7 +27,6 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for row in pg %}
|
{% for row in pg %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ row[0] }}</td>
|
|
||||||
<td><a href="/detail/{{ row[1] }}.html">{{ row[1] }}</a></td>
|
<td><a href="/detail/{{ row[1] }}.html">{{ row[1] }}</a></td>
|
||||||
<td>{{ row[2] }}</td>
|
<td>{{ row[2] }}</td>
|
||||||
<td>{{ row[3] }}</td>
|
<td>{{ row[3] }}</td>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user