diff --git a/backend/app/admin/api/v1/wxpay.py b/backend/app/admin/api/v1/wxpay.py index 5273901..d9c51bc 100644 --- a/backend/app/admin/api/v1/wxpay.py +++ b/backend/app/admin/api/v1/wxpay.py @@ -75,7 +75,7 @@ async def query_refund(out_refund_no: str) -> ResponseSchemaModel[QueryRefundRes @router.post('/notify', summary='支付回调通知') async def pay_notify(request: Request) -> ResponseSchemaModel[dict]: raw = await request.body() - print(raw) + print('pay_notify raw: ',raw) timestamp = request.headers.get('Wechatpay-Timestamp', '') nonce = request.headers.get('Wechatpay-Nonce', '') signature = request.headers.get('Wechatpay-Signature', '') diff --git a/backend/app/admin/service/file_service.py b/backend/app/admin/service/file_service.py index e240a0b..158daef 100755 --- a/backend/app/admin/service/file_service.py +++ b/backend/app/admin/service/file_service.py @@ -703,6 +703,7 @@ class FileService: 'image/bmp': 'bmp', 'image/svg+xml': 'svg', 'audio/mpeg': 'mp3', + 'audio/mp3': 'mp3', 'audio/wav': 'wav', 'video/mp4': 'mp4', 'video/quicktime': 'mov', @@ -794,7 +795,11 @@ class FileService: final_size = content_length or 0 final_content_type = "image/avif" expired_seconds = 30 * 24 * 60 * 60 - url = cos.get_presigned_download_url(final_key, expired_seconds) + params = { + 'response-content-disposition': f'attachment; filename={file_id}.avif', + 'response-content-type': final_content_type, + } + url = cos.get_presigned_download_url(final_key, expired_seconds, params=params) from datetime import datetime, timezone as dt_tz now_ts = int(datetime.now(dt_tz.utc).timestamp()) expire_ts = now_ts + expired_seconds - 60 @@ -829,7 +834,13 @@ class FileService: } else: expired_seconds = 30 * 24 * 60 * 60 - url = cos.get_presigned_download_url(cos_key, expired_seconds) + ext = FileService._mime_to_ext(content_type, None) + filename = f"{file_id}.{ext}" + params = { + 'response-content-disposition': f'attachment; filename={filename}', + 'response-content-type': content_type or 'application/octet-stream', + } + url = cos.get_presigned_download_url(cos_key, expired_seconds, params=params) from datetime import datetime, timezone as dt_tz now_ts = int(datetime.now(dt_tz.utc).timestamp()) expire_ts = now_ts + expired_seconds - 60 @@ -884,7 +895,14 @@ class FileService: now_ts = int(datetime.now(dt_tz.utc).timestamp()) if (not url) or (now_ts >= expire_ts): expired_seconds = 30 * 24 * 60 * 60 - url = cos.get_presigned_download_url(cos_key, expired_seconds) + ctype = db_file.content_type or 'application/octet-stream' + ext = FileService._mime_to_ext(ctype, None) + filename = f"{file_id}.{ext}" + params = { + 'response-content-disposition': f'attachment; filename={filename}', + 'response-content-type': ctype, + } + url = cos.get_presigned_download_url(cos_key, expired_seconds, params=params) expire_ts = now_ts + expired_seconds - 60 async with async_db_session.begin() as wdb: await file_dao.update( diff --git a/backend/app/admin/service/wxpay_service.py b/backend/app/admin/service/wxpay_service.py index 045cb37..cf584a4 100755 --- a/backend/app/admin/service/wxpay_service.py +++ b/backend/app/admin/service/wxpay_service.py @@ -142,7 +142,7 @@ class WxPayService: # notify_url = f"https://app.xhzone.cn:{settings.SERVER_PORT}{settings.FASTAPI_API_V1_PATH}/wxpay/notify" wxpay = WxPayService._build_wxpay_instance(notify_url) result = WxPayService._safe_call(wxpay.query, out_trade_no=out_trade_no) - print(result) + # print(result) data = WxPayService._parse_result(result) trade_state = data.get('trade_state', 'NOTPAY') transaction_id = data.get('transaction_id') diff --git a/backend/app/ai/service/image_service.py b/backend/app/ai/service/image_service.py index 76fe659..b9ecca3 100755 --- a/backend/app/ai/service/image_service.py +++ b/backend/app/ai/service/image_service.py @@ -433,12 +433,6 @@ class ImageService: logger.error(f"Failed to update task {task_id} status to {status}: {str(e)}") raise - @staticmethod - async def _process_image(task_id: int) -> None: - # This method is no longer used as we've moved the logic to _process_image_with_limiting - # Keeping it for backward compatibility - pass - @staticmethod async def _process_image_recognition(task_id: int) -> None: """后台处理图片识别任务 - compatible version for task processor""" @@ -471,7 +465,6 @@ class ImageService: # 下载文件(在数据库事务外执行) file_content, file_name, content_type = await file_service.download_image_file(task.file_id) - print(len(file_content)) image_format = image_service.detect_image_format(file_content) image_format_str = image_format.value base64_image = base64.b64encode(file_content).decode('utf-8') diff --git a/backend/middleware/cos_client.py b/backend/middleware/cos_client.py index 17aaba3..72317d3 100644 --- a/backend/middleware/cos_client.py +++ b/backend/middleware/cos_client.py @@ -48,7 +48,7 @@ class CosClient: Key=key, PicOperations=json.dumps(pic_operations) ) - print(json.dumps(resp)) + # print(json.dumps(resp)) return resp except Exception as e: logger.error(f"cos upload_image failed: {e}") @@ -110,12 +110,13 @@ class CosClient: except Exception: return False - def get_presigned_download_url(self, key: str, expired_seconds: int) -> str: + def get_presigned_download_url(self, key: str, expired_seconds: int, params: dict | None = None) -> str: try: return self.client.get_presigned_download_url( Bucket=self.bucket, Key=key, Expired=expired_seconds, + Params=params, ) except Exception as e: logger.error(f"cos presigned_download_url failed: {e}") @@ -129,7 +130,7 @@ class CosClient: Key=key, PicOperations=ops ) - print(json.dumps(response)) + # print(json.dumps(response)) return response except Exception as e: logger.error(f"cos process_image failed: {e}")