REQ-3540: 解决依赖问题
This commit is contained in:
parent
59ff764e29
commit
94948ef38b
@ -0,0 +1,27 @@
|
||||
|
||||
package cn.axzo.nanopart.doc.file;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import cn.axzo.nanopart.doc.integration.OssClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/doc/private")
|
||||
public class DocPrivateController {
|
||||
|
||||
private final OssClient ossClient;
|
||||
|
||||
@GetMapping("/ossFileUrl")
|
||||
public String getOssFileUrl(@RequestParam("key") String ossFileKey) {
|
||||
return ossClient.getOssUrl(ossFileKey);
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,6 +21,8 @@ import cn.axzo.nanopart.doc.api.util.UUIDUtil;
|
||||
import cn.axzo.nanopart.doc.config.DocProps;
|
||||
import cn.axzo.nanopart.doc.dao.DocLogDao;
|
||||
import cn.axzo.oss.http.api.ServerFileServiceApi;
|
||||
import cn.axzo.oss.http.model.ApiSignUrlDownloadRequest;
|
||||
import cn.axzo.oss.http.model.ApiSignUrlDownloadResponse;
|
||||
import cn.axzo.oss.http.model.copyobject.ServerFileBatchCopyObjectRequest;
|
||||
import cn.axzo.oss.http.model.copyobject.ServerFileBatchCopyObjectRequest.ServerFileCopyObjectRequest;
|
||||
import cn.axzo.oss.http.model.copyobject.ServerFileBatchCopyObjectResponse;
|
||||
@ -134,6 +136,16 @@ public class OssClient {
|
||||
}
|
||||
}
|
||||
|
||||
public String getOssUrl(String ossFileKey) {
|
||||
ApiSignUrlDownloadRequest request = new ApiSignUrlDownloadRequest();
|
||||
request.setAppCode(docProps.getOssAppCode());
|
||||
request.setBizScene(docProps.getOssBizScene());
|
||||
List<ApiSignUrlDownloadResponse> responses = BizAssertions.assertResponse(
|
||||
serverFileServiceApi.signUrlFetchDownload(request));
|
||||
request.setFileKeys(Collections.singletonList(ossFileKey));
|
||||
return CollectionUtils.isEmpty(responses) ? null : responses.get(0).getSignUrl();
|
||||
}
|
||||
|
||||
private void log(String context, Object subject, Object... logContents) {
|
||||
docLogDao.log(context, subject, logContents);
|
||||
}
|
||||
|
||||
@ -16,12 +16,10 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
@ -104,13 +102,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@RequiredArgsConstructor
|
||||
public class EssClient implements InitializingBean {
|
||||
|
||||
private static final String NEW_TRANSACTION = "essLogTransactionTemplate";
|
||||
private static final Pattern ESS_ERROR_REQUEST_ID_PATTERN = Pattern.compile("RequestId:([a-f0-9\\-]+)");
|
||||
|
||||
private final EssProps props;
|
||||
private final EssLogDao essLogDao;
|
||||
private final EssSupport essSupport;
|
||||
@Resource(name = NEW_TRANSACTION)
|
||||
private final PlatformTransactionManager transactionManager;
|
||||
private TransactionTemplate newTransaction;
|
||||
private EssbasicClient manage;
|
||||
private EssbasicClient file;
|
||||
@ -470,6 +467,8 @@ public class EssClient implements InitializingBean {
|
||||
public void afterPropertiesSet() {
|
||||
manage = createEssbasicClient(props.getApiEndPoint());
|
||||
file = createEssbasicClient(props.getFileEndPoint());
|
||||
newTransaction = new TransactionTemplate(transactionManager);
|
||||
newTransaction.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
}
|
||||
|
||||
private EssbasicClient createEssbasicClient(String apiEndPoint) {
|
||||
@ -560,11 +559,4 @@ public class EssClient implements InitializingBean {
|
||||
T exec() throws TencentCloudSDKException;
|
||||
}
|
||||
|
||||
@Bean(NEW_TRANSACTION)
|
||||
public TransactionTemplate transactionTemplate(PlatformTransactionManager transactionManager) {
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
return transactionTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user