上传素材
continuous-integration/drone/push Build is passing Details

yxy/生成PDF
YXY 1 year ago
parent 2c8d0490e2
commit c510d7a00d

@ -1,10 +1,8 @@
package com.ruoyi.flyingbook.LarkHelper;
import com.lark.oapi.service.drive.v1.enums.ParentTypeEnum;
import com.lark.oapi.service.drive.v1.model.UploadAllFileReq;
import com.lark.oapi.service.drive.v1.model.UploadAllFileReqBody;
import com.lark.oapi.service.drive.v1.model.UploadAllFileResp;
import com.lark.oapi.service.drive.v1.model.UploadAllFileRespBody;
import com.lark.oapi.service.drive.v1.enums.UploadAllMediaParentTypeEnum;
import com.lark.oapi.service.drive.v1.model.*;
import com.ruoyi.flyingbook.domain.lark.LarkException;
import com.ruoyi.flyingbook.domain.lark.LarkFileRequest;
import lombok.extern.slf4j.Slf4j;
@ -60,4 +58,33 @@ public class LarkFileHelper extends LarkHelper {
throw new RuntimeException(new LarkException("LarkFileHelper.uploadFile",uploadAllFileResp.getMsg(),request).getErrorMessageBody());
}
}
public UploadAllMediaRespBody uploadMediaFile(LarkFileRequest request) {
UploadAllMediaResp uploadAllFileResp = null;
try {
uploadAllFileResp = buildClient(request)
.drive()
.media()
.uploadAll(
UploadAllMediaReq.newBuilder()
.uploadAllMediaReqBody(
UploadAllMediaReqBody.newBuilder()
.file(request.getFile())
.fileName(request.getFileName())
.parentType(UploadAllMediaParentTypeEnum.BITABLE_FILE)
.parentNode(request.getParentNode())
.size(request.getFileSize())
.build()
)
.build()
);
} catch (Exception e) {
throw new RuntimeException(new LarkException("LarkFileHelper.uploadFile",e.getMessage(),request).getErrorMessageBody());
}
if (uploadAllFileResp!= null && uploadAllFileResp.getCode() == 0){
return uploadAllFileResp.getData();
}else {
throw new RuntimeException(new LarkException("LarkFileHelper.uploadFile",uploadAllFileResp.getMsg(),request).getErrorMessageBody());
}
}
}

@ -3,6 +3,7 @@ package com.ruoyi.flyingbook.LarkHelper.script;
import com.lark.oapi.service.bitable.v1.model.AppTableRecord;
import com.lark.oapi.service.bitable.v1.model.GetAppTableRecordResp;
import com.lark.oapi.service.drive.v1.model.UploadAllFileRespBody;
import com.lark.oapi.service.drive.v1.model.UploadAllMediaRespBody;
import com.ruoyi.common.core.domain.PdfEntity;
import com.ruoyi.common.enums.ConfigurationSubTypeEnum;
import com.ruoyi.common.enums.ConfigurationTypeEnum;
@ -24,10 +25,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author yuxiangyong
@ -94,10 +92,12 @@ public class LarkCreatePdfHelper {
File file = new File(pdfWatermarkingAllPath);
Long length = file.length();
LarkFileRequest fileRequest = new LarkFileRequest(request.getAppId(),request.getAppSecret(),
file,file.getName(),length.intValue(),folderToken);
UploadAllFileRespBody uploadAllFileRespBody = larkFileHelper.uploadFile(fileRequest);
String fileToken = uploadAllFileRespBody.getFileToken();
fields.put("file_token", fileToken);
file,file.getName(),length.intValue(),tableRelation.getFromTableId());
UploadAllMediaRespBody uploadAllMediaRespBody = larkFileHelper.uploadMediaFile(fileRequest);
String fileToken = uploadAllMediaRespBody.getFileToken();
Map<String,Object> fileMap = new HashMap<>();
fileMap.put("file_token",fileToken);
fields.put("附件", Arrays.asList(fileMap));
LarkTableRequest updateRequest = new LarkTableRequest(request.getAppId(),request.getAppSecret(),
tableRelation.getFromAppToken(),tableRelation.getFromTableId(),record.getRecordId(),fields);
larkTableHelper.updateTableRecord(updateRequest);

@ -1,6 +1,7 @@
package com.ruoyi.flyingbook.controller;
import com.lark.oapi.service.drive.v1.model.UploadAllFileRespBody;
import com.lark.oapi.service.drive.v1.model.UploadAllMediaRespBody;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PdfEntity;
import com.ruoyi.common.utils.PdfUtils;
@ -73,9 +74,11 @@ public class EdiController extends BaseController {
File file = new File(pdfWatermarkingAllPath);
Long length = file.length();
LarkFileRequest fileRequest = new LarkFileRequest("cli_a482a8572cbc9013","lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos",
file,file.getName(),length.intValue(),"fldcnLt2RyUgDDD6rgC6K9gIWlM");
UploadAllFileRespBody uploadAllFileRespBody = larkFileHelper.uploadFile(fileRequest);
String fileToken = uploadAllFileRespBody.getFileToken();
file,file.getName(),length.intValue(),"Efl5bXdHHavfR0sAGMMcQZEinvc");
// UploadAllFileRespBody uploadAllFileRespBody = larkFileHelper.uploadFile(fileRequest);
// String fileToken = uploadAllFileRespBody.getFileToken();
UploadAllMediaRespBody uploadAllMediaRespBody = larkFileHelper.uploadMediaFile(fileRequest);
String fileToken = uploadAllMediaRespBody.getFileToken();
int i = 0;
Map<String,Object> map = new HashMap<>();

Loading…
Cancel
Save