REQ-3581: 备份
This commit is contained in:
parent
4c5b8177c7
commit
37184c7c39
@ -73,7 +73,7 @@ import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.axzo.nanopart.ess.server.ess.EssClient.Invocation.func;
|
||||
import static cn.axzo.nanopart.ess.server.ess.EssClient.Func.func;
|
||||
import static java.util.function.Function.identity;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
@ -196,7 +196,7 @@ public class EssClient implements InitializingBean {
|
||||
request.setAgent(agent(superAdmin));
|
||||
request.setFileInfos(files.toArray(new UploadFile[0]));
|
||||
request.setBusinessType(businessType.name());
|
||||
UploadFilesResponse response = call(Invocation.<UploadFilesResponse>func()
|
||||
UploadFilesResponse response = call(Func.<UploadFilesResponse>func()
|
||||
.context("UploadFiles")
|
||||
.subject("")
|
||||
.subject2(r -> r.getFileIds()[0])
|
||||
@ -254,7 +254,7 @@ public class EssClient implements InitializingBean {
|
||||
request.setCustomerData(customerData);
|
||||
if (contractInfo.getDeadlineMs() != null)
|
||||
request.setDeadline(contractInfo.getDeadlineMs() / 1000);
|
||||
ChannelCreateFlowByFilesResponse response = call(Invocation.<ChannelCreateFlowByFilesResponse>func()
|
||||
ChannelCreateFlowByFilesResponse response = call(Func.<ChannelCreateFlowByFilesResponse>func()
|
||||
.context("ChannelCreateFlowByFiles")
|
||||
.subject(contractInfo.getContractName())
|
||||
.subject2(ChannelCreateFlowByFilesResponse::getFlowId)
|
||||
@ -339,7 +339,7 @@ public class EssClient implements InitializingBean {
|
||||
return new EssbasicClient(cred, "", clientProfile);
|
||||
}
|
||||
|
||||
private <T> T exec(Invocation.InvocationBuilder<?> builder) {
|
||||
private <T> T exec(Func.FuncBuilder<?> builder) {
|
||||
try {
|
||||
return call(builder);
|
||||
} catch (TencentCloudSDKException e) {
|
||||
@ -347,24 +347,24 @@ public class EssClient implements InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T call(Invocation.InvocationBuilder<?> builder) throws TencentCloudSDKException {
|
||||
private <T> T call(Func.FuncBuilder<?> builder) throws TencentCloudSDKException {
|
||||
//noinspection unchecked
|
||||
Invocation<Object> invocation = (Invocation<Object>) builder.build();
|
||||
Func<Object> func = (Func<Object>) builder.build();
|
||||
EssLog essLog = new EssLog();
|
||||
essLog.setCreateAt(new Date());
|
||||
essLog.setUpdateAt(new Date());
|
||||
essLog.setContext(String.format("ess:api:%s", invocation.context));
|
||||
essLog.addLogContent("essRequest", invocation.request);
|
||||
essLog.setSubject(invocation.subject == null ? "" : invocation.subject);
|
||||
essLog.setContext(String.format("ess:api:%s", func.context));
|
||||
essLog.addLogContent("essRequest", func.request);
|
||||
essLog.setSubject(func.subject == null ? "" : func.subject);
|
||||
|
||||
T response = null;
|
||||
TencentCloudSDKException exception = null;
|
||||
try {
|
||||
//noinspection unchecked
|
||||
response = (T) invocation.command.exec();
|
||||
response = (T) func.command.exec();
|
||||
essLog.addLogContent("essResponse", response);
|
||||
if (invocation.subject2 != null) {
|
||||
String newSubject = invocation.subject2.apply(response);
|
||||
if (func.subject2 != null) {
|
||||
String newSubject = func.subject2.apply(response);
|
||||
if (newSubject != null) essLog.setSubject(newSubject);
|
||||
}
|
||||
if (response != null) {
|
||||
@ -411,15 +411,15 @@ public class EssClient implements InitializingBean {
|
||||
}
|
||||
|
||||
@Builder
|
||||
public static class Invocation<T> {
|
||||
public static class Func<T> {
|
||||
final String context;
|
||||
final String subject;
|
||||
final Function<T, String> subject2;
|
||||
final Object request;
|
||||
final TencentCloudFunc<T> command;
|
||||
|
||||
public static <T> InvocationBuilder<T> func() {
|
||||
return Invocation.builder();
|
||||
public static <T> Func.FuncBuilder<T> func() {
|
||||
return Func.builder();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user