|
|
@@ -1,26 +1,9 @@
|
|
|
package me.zhengjie.application.bank.controller;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-
|
|
|
-import javax.servlet.ServletOutputStream;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-
|
|
|
-import cn.hutool.core.io.IoUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
|
|
import me.zhengjie.annotation.rest.AnonymousPostMapping;
|
|
|
import me.zhengjie.application.bank.service.BankNotarizeService;
|
|
|
import me.zhengjie.application.bank.service.UserAXQInfoService;
|
|
|
@@ -28,10 +11,15 @@ import me.zhengjie.base.ResponseDTO;
|
|
|
import me.zhengjie.base.ResultCode;
|
|
|
import me.zhengjie.base.config.TencentHumanFaceVerify;
|
|
|
import me.zhengjie.base.util.FileUploadUtil;
|
|
|
+import me.zhengjie.base.util.UUIDGenerator;
|
|
|
import me.zhengjie.base.util.tencent.h5face.SdkTest;
|
|
|
import me.zhengjie.dao.mybatis.OrderFileRepository;
|
|
|
import me.zhengjie.dao.mybatis.entity.OrderFileEntity;
|
|
|
-import me.zhengjie.exception.BadRequestException;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@Validated
|
|
|
@RestController
|
|
|
@@ -49,41 +37,20 @@ public class BankNotarizeController {
|
|
|
*
|
|
|
* @param json
|
|
|
* @return
|
|
|
- * @throws IOException
|
|
|
- * @throws ServletException
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
-// @RequestMapping("/getNotarization")
|
|
|
- @RequestMapping(value = "/getNotarization/{businessNo}")
|
|
|
- public void getNotarization(@PathVariable("businessNo") String businessNo, HttpServletRequest request,
|
|
|
- HttpServletResponse response) throws Exception {
|
|
|
-
|
|
|
+ @RequestMapping("/getNotarization")
|
|
|
+ public ResponseDTO<?> getNotarization(@RequestBody String json) throws Exception {
|
|
|
+ JSONObject jsonObj = JSONObject.parseObject(json);
|
|
|
+ String businessNo = jsonObj.getString("businessNo");
|
|
|
if (StringUtils.isEmpty(businessNo)) {
|
|
|
- throw new BadRequestException("参数错误");
|
|
|
+ return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
|
|
|
}
|
|
|
OrderFileEntity orderFile = orderFileRepository.getOrderNotarization(businessNo);
|
|
|
- ServletOutputStream outputStream = null;
|
|
|
- InputStream inputStream = null;
|
|
|
-
|
|
|
- try {
|
|
|
- inputStream = FileUploadUtil.getInputStream(orderFile.getSignedPdfUrl());
|
|
|
- response.setContentType("application/pdf");
|
|
|
- outputStream = response.getOutputStream();
|
|
|
-//
|
|
|
-// int len = 0;
|
|
|
-// byte[] buffer = new byte[4096];
|
|
|
-// while ((len = inputStream.read(buffer)) != -1) {
|
|
|
-// outputStream.write(buffer, 0, len);
|
|
|
-// }
|
|
|
- byte[] b = IoUtil.readBytes(inputStream);
|
|
|
- outputStream.write(b);
|
|
|
- outputStream.flush();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- outputStream.close();
|
|
|
- inputStream.close();
|
|
|
- }
|
|
|
-// return ResponseDTO.success();
|
|
|
+ // 下载到指定的目录
|
|
|
+ String filePath = "tmp/" + UUIDGenerator.uuid() + ".pdf";
|
|
|
+
|
|
|
+ return ResponseDTO.success(FileUploadUtil.getCustomUrl(orderFile.getSignedPdfUrl(),filePath));
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/axqRegister")
|
|
|
@@ -118,31 +85,6 @@ public class BankNotarizeController {
|
|
|
return bankNotarizeService.videoCall(json);
|
|
|
}
|
|
|
|
|
|
- @AnonymousGetMapping("/preview/{path}")
|
|
|
- public void preview(@PathVariable("path") String path, HttpServletRequest request, HttpServletResponse response)
|
|
|
- throws IOException {
|
|
|
- ServletOutputStream outputStream = null;
|
|
|
- InputStream inputStream = null;
|
|
|
- try {
|
|
|
- inputStream = FileUploadUtil.getInputStream(path);
|
|
|
- response.setContentType("application/pdf");
|
|
|
- outputStream = response.getOutputStream();
|
|
|
-
|
|
|
- int len = 0;
|
|
|
- byte[] buffer = new byte[4096];
|
|
|
- while ((len = inputStream.read(buffer)) != -1) {
|
|
|
- outputStream.write(buffer, 0, len);
|
|
|
- }
|
|
|
- outputStream.flush();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- outputStream.close();
|
|
|
- inputStream.close();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
@RequestMapping("/order/pdf")
|
|
|
public ResponseDTO<?> getOrderPDF(@RequestBody String json) {
|
|
|
|