From 3175dbc0fe7611e12de0b5ca46227ef2ddbebf33 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 2 May 2025 10:59:52 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=20=D0=BC=D0=B0=D1=80=D1=88=D1=80=D1=83=D1=82=D0=B0=20/v2/reqph?= =?UTF-8?q?oto=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D1=84=D0=BE=D1=82=D0=BE=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=84=D0=B8=D0=B9=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=BE=D0=B1?= =?UTF-8?q?=D0=B8=D0=BB=D1=8F=20=D0=BF=D0=BE=20VIN=20-=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D1=8B=20=D0=B2=20app.py=20=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20Swagger=20=D0=B4=D0=BB=D1=8F=20=D1=83=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D1=88=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=D0=B7=D0=B0=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81=D1=82=D0=B2=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=81=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/swagger.yaml | 60 +++++++++++++++++++++++++++++++++++++++++ app.py | 13 +++++---- templates/database.html | 4 +-- 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/api/swagger.yaml b/api/swagger.yaml index f138e0f..e4345ce 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -183,6 +183,66 @@ paths: type: string 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: get: summary: Check account balance diff --git a/app.py b/app.py index a786cb2..2dbbca1 100644 --- a/app.py +++ b/app.py @@ -701,7 +701,7 @@ def api_reqimage(): app.logger.debug(json.dumps(ret)) 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() img_count = int(res[0]) if img_count<1: @@ -715,19 +715,17 @@ def api_reqimage(): app.logger.debug(json.dumps(ret)) return response else: - #req_id = uuid.uuid4().hex - #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())) + cur.execute("""select GenImages('{}','{}') as ui from dual""".format(access_code, vin.upper())) res = cur.fetchall() - req_id = res[0] - cur.execute("""select fake_name from salvage_images_req where req_id = '{}}'""".format(req_id)) + req_id = res[0][0] + cur.execute('select fake_name from salvage_images_req where req_id = :p1', {'p1':req_id}) res = cur.fetchall() images = [] nm = 0 for it in res: images.append({ 'num':nm, - 'url':'https://salimages.salvagedb/{}/{}'.format(req_id, it) + 'url':'https://salimages.salvagedb/{}/{}'.format(req_id, it[0]) }) nm = nm + 1 ret = {'status': 'Image_found', 'Images':images} @@ -736,6 +734,7 @@ def api_reqimage(): status=200, mimetype='application/json' ) + return response diff --git a/templates/database.html b/templates/database.html index b099b79..a6a2cd2 100644 --- a/templates/database.html +++ b/templates/database.html @@ -14,11 +14,10 @@

-
+
- @@ -28,7 +27,6 @@ {% for row in pg %} -
# VIN Make Model
{{ row[0] }} {{ row[1] }} {{ row[2] }} {{ row[3] }}