From c3e81c06e7e491902672cedb2d9683e8763d6330 Mon Sep 17 00:00:00 2001 From: luoyang Date: Mon, 30 Mar 2020 13:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96gateway=20=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../manage/gateway/web/GtwPayController.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index be6d056b7..57a345101 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.4.20 + 1.4.21 UTF-8 1.8.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/gateway/web/GtwPayController.java b/src/main/java/au/com/royalpay/payment/manage/gateway/web/GtwPayController.java index 5079ba76b..280863f6d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/gateway/web/GtwPayController.java +++ b/src/main/java/au/com/royalpay/payment/manage/gateway/web/GtwPayController.java @@ -5,7 +5,10 @@ import au.com.royalpay.payment.core.utils.PaymentValidUtils; import au.com.royalpay.payment.manage.gateway.advice.Gtw2Ctrl; import au.com.royalpay.payment.manage.gateway.core.GatewayMerchantApply; import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; import com.alibaba.fastjson.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -19,6 +22,7 @@ import javax.annotation.Resource; @RequestMapping("/api/v1.0/org_gateway/partners/{shortId}") @Gtw2Ctrl public class GtwPayController { + private Logger logger = LoggerFactory.getLogger(getClass()); @Resource private GatewayMerchantApply gatewayMerchantApply; @Resource @@ -41,12 +45,18 @@ public class GtwPayController { } @PostMapping("/attachment/files") - public JSONObject uploadFile(@PathVariable String shortId,@RequestParam MultipartFile file) throws Exception { + public JSONObject uploadFile(@PathVariable String shortId,@RequestParam MultipartFile file) { JSONObject org = gatewayMerchantApply.validOrgV200(shortId); if (org == null) { throw new InvalidShortIdException(); } - JSONObject fileInfo = attachmentClient.uploadFile(file, false); + JSONObject fileInfo = new JSONObject(); + try { + fileInfo = attachmentClient.uploadFile(file, false); + } catch (Exception e) { + logger.error("file upload fail :{}" , e.getMessage()); + throw new BadRequestException("File upload failed"); + } fileInfo.put("file_type", fileInfo.getString("filetype")); fileInfo.remove("filepath"); fileInfo.remove("length");