|
|
@@ -7,6 +7,8 @@ import com.yingpaipay.business.domain.bo.AppletScanBo;
|
|
|
import com.yingpaipay.business.domain.dto.TextInR;
|
|
|
import com.yingpaipay.business.service.ITextInService;
|
|
|
import com.yingpaipay.common.file.config.TextInConfig;
|
|
|
+import com.yingpaipay.setting.domain.vo.TextinSettingVo;
|
|
|
+import com.yingpaipay.setting.service.ITextinSettingService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.dromara.common.core.exception.BusinessException;
|
|
|
import org.dromara.common.json.utils.JsonUtils;
|
|
|
@@ -15,11 +17,9 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.*;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.util.Base64;
|
|
|
-import java.util.List;
|
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
|
|
@@ -32,14 +32,22 @@ public class TextInServiceImpl implements ITextInService {
|
|
|
|
|
|
private final TextInConfig config;
|
|
|
|
|
|
+ private final ITextinSettingService settingService;
|
|
|
+
|
|
|
+ private HttpResponse getResponse(HttpRequest request) {
|
|
|
+ TextinSettingVo setting = settingService.query();
|
|
|
+ HttpResponse response = request.header("x-ti-app-id", setting.getAppId())
|
|
|
+ .header("x-ti-secret-code", setting.getSecretCode())
|
|
|
+ .execute();
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String imageToPdf(AppletScanBo bo) {
|
|
|
|
|
|
- HttpResponse response = HttpRequest.post(config.getImageToPdf())
|
|
|
- .header("x-ti-app-id", APP_ID)
|
|
|
- .header("x-ti-secret-code", SECRET_CODE)
|
|
|
- .body(JsonUtils.toJsonString(bo))
|
|
|
- .execute();
|
|
|
+ HttpResponse response = getResponse(
|
|
|
+ HttpRequest.post(config.getImageToPdf()).body(JsonUtils.toJsonString(bo))
|
|
|
+ );
|
|
|
|
|
|
TextInR result = getR(response);
|
|
|
|
|
|
@@ -66,12 +74,17 @@ public class TextInServiceImpl implements ITextInService {
|
|
|
@Override
|
|
|
public String imageToWord(String image) {
|
|
|
|
|
|
- HttpResponse response = HttpRequest.post(config.getImageToWord())
|
|
|
- .header("x-ti-app-id", APP_ID)
|
|
|
- .header("x-ti-secret-code", SECRET_CODE)
|
|
|
- .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
- .body(Base64.getDecoder().decode(image))
|
|
|
- .execute();
|
|
|
+// HttpResponse response = HttpRequest.post(config.getImageToWord())
|
|
|
+// .header("x-ti-app-id", APP_ID)
|
|
|
+// .header("x-ti-secret-code", SECRET_CODE)
|
|
|
+// .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+// .body(Base64.getDecoder().decode(image))
|
|
|
+// .execute();
|
|
|
+ HttpResponse response = getResponse(
|
|
|
+ HttpRequest.post(config.getImageToWord())
|
|
|
+ .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+ .body(Base64.getDecoder().decode(image))
|
|
|
+ );
|
|
|
|
|
|
TextInR result = getR(response);
|
|
|
|
|
|
@@ -81,12 +94,18 @@ public class TextInServiceImpl implements ITextInService {
|
|
|
@Override
|
|
|
public String wordToImage(String docx) {
|
|
|
|
|
|
- HttpResponse response = HttpRequest.post(config.getWordToImage())
|
|
|
- .header("x-ti-app-id", APP_ID)
|
|
|
- .header("x-ti-secret-code", SECRET_CODE)
|
|
|
- .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
- .body(docx)
|
|
|
- .execute();
|
|
|
+// HttpResponse response = HttpRequest.post(config.getWordToImage())
|
|
|
+// .header("x-ti-app-id", APP_ID)
|
|
|
+// .header("x-ti-secret-code", SECRET_CODE)
|
|
|
+// .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+// .body(docx)
|
|
|
+// .execute();
|
|
|
+
|
|
|
+ HttpResponse response = getResponse(
|
|
|
+ HttpRequest.post(config.getWordToImage())
|
|
|
+ .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+ .body(docx)
|
|
|
+ );
|
|
|
|
|
|
TextInR result = getR(response);
|
|
|
String zipBase64 = result.getResult().toString();
|
|
|
@@ -137,12 +156,17 @@ public class TextInServiceImpl implements ITextInService {
|
|
|
@Override
|
|
|
public String wordToPdf(String docx) {
|
|
|
|
|
|
- HttpResponse response = HttpRequest.post(config.getWordToPdf())
|
|
|
- .header("x-ti-app-id", APP_ID)
|
|
|
- .header("x-ti-secret-code", SECRET_CODE)
|
|
|
- .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
- .body(Base64.getDecoder().decode(docx))
|
|
|
- .execute();
|
|
|
+// HttpResponse response = HttpRequest.post(config.getWordToPdf())
|
|
|
+// .header("x-ti-app-id", APP_ID)
|
|
|
+// .header("x-ti-secret-code", SECRET_CODE)
|
|
|
+// .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+// .body(Base64.getDecoder().decode(docx))
|
|
|
+// .execute();
|
|
|
+ HttpResponse response = getResponse(
|
|
|
+ HttpRequest.post(config.getWordToPdf())
|
|
|
+ .header(Header.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
+ .body(Base64.getDecoder().decode(docx))
|
|
|
+ );
|
|
|
|
|
|
TextInR result = getR(response);
|
|
|
|