合并字段

This commit is contained in:
散仙
2024-11-10 22:38:23 +08:00
parent 88aeec6388
commit 3259443c6d
3 changed files with 484 additions and 4 deletions

View File

@@ -55,12 +55,12 @@ def get_image_type_thumbnail(type:str, id:str, version:str, n:int, w:int, ext:st
if os.path.exists(img_path):
return Response(content=open(img_path, 'rb').read(), media_type=f"image/{ext}")
if type == 'ad' or type == 'article' or type == 'article_attribute':
count = cursor.execute(f"SELECT * FROM `web_{type}` WHERE `id`={id}")
count = cursor.execute(f"SELECT image FROM `web_{type}` WHERE `id`={id}")
img = cursor.fetchone()
if img is None:
print('图片不存在:', count)
return Response('图片不存在', status_code=404)
url = img['image']
url = img[0]
elif type == 'url':
id = unquote(id, 'utf-8')
id = id.replace(' ','+')
@@ -149,12 +149,12 @@ def get_image_thumbnail(id:int, version:str, n:int, w:int, ext:str):
if os.path.exists(img_path):
return Response(content=open(img_path, 'rb').read(), media_type=f"image/{ext}")
# 从数据库获取原图地址
cursor.execute(f"SELECT * FROM `web_images` WHERE `id`={id}")
cursor.execute(f"SELECT content FROM `web_images` WHERE `id`={id}")
img = cursor.fetchone()
if img is None:
print('图片不存在:', id)
return Response('图片不存在', status_code=404)
image = download_image(img['content'])
image = download_image(img[0])
if not image:
return Response('图片不存在', status_code=404)
image.thumbnail((n*w, image.size[1]))