|
|
@ -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.advice.Gtw2Ctrl;
|
|
|
|
import au.com.royalpay.payment.manage.gateway.core.GatewayMerchantApply;
|
|
|
|
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.connections.attachment.core.AttachmentClient;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@ -19,6 +22,7 @@ import javax.annotation.Resource;
|
|
|
|
@RequestMapping("/api/v1.0/org_gateway/partners/{shortId}")
|
|
|
|
@RequestMapping("/api/v1.0/org_gateway/partners/{shortId}")
|
|
|
|
@Gtw2Ctrl
|
|
|
|
@Gtw2Ctrl
|
|
|
|
public class GtwPayController {
|
|
|
|
public class GtwPayController {
|
|
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private GatewayMerchantApply gatewayMerchantApply;
|
|
|
|
private GatewayMerchantApply gatewayMerchantApply;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
@ -41,12 +45,18 @@ public class GtwPayController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/attachment/files")
|
|
|
|
@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);
|
|
|
|
JSONObject org = gatewayMerchantApply.validOrgV200(shortId);
|
|
|
|
if (org == null) {
|
|
|
|
if (org == null) {
|
|
|
|
throw new InvalidShortIdException();
|
|
|
|
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.put("file_type", fileInfo.getString("filetype"));
|
|
|
|
fileInfo.remove("filepath");
|
|
|
|
fileInfo.remove("filepath");
|
|
|
|
fileInfo.remove("length");
|
|
|
|
fileInfo.remove("length");
|
|
|
|