|
@@ -33,6 +33,8 @@ import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStreamReader;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -68,6 +70,9 @@ public class DocumentAuthServiceImpl implements DocumentAuthService {
|
|
|
@Value("${aliyun.endpoint}")
|
|
|
private String endpoint;
|
|
|
|
|
|
+ @Value("${spring.profiles.active}")
|
|
|
+ private String active;
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean getAuthorizationCookie(String authorizationMobile) {
|
|
|
if (!StringUtils.isEmpty(authorizationMobile)) {
|
|
@@ -198,9 +203,22 @@ public class DocumentAuthServiceImpl implements DocumentAuthService {
|
|
|
*/
|
|
|
private void setOssArchivePdfUrl(OssArchivePdf ossArchivePdf) {
|
|
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
|
+ String ossName = ossArchivePdf.getOssName();
|
|
|
// 设置URL过期时间为1个小时
|
|
|
Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
|
|
|
- String url = ossClient.generatePresignedUrl(bucketName, ossArchivePdf.getOssName(), expiration).toString();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = null;
|
|
|
+ try {
|
|
|
+ date = format.parse("2021-06-01 00:00:00");
|
|
|
+ if (ossArchivePdf.getUploadTime() != null && ossArchivePdf.getUploadTime().compareTo(date) > 0) {
|
|
|
+ //之后的文件都放在对应文件夹里
|
|
|
+ ossName = active + "/" + ossName;
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ log.info("格式化时间错误", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ String url = ossClient.generatePresignedUrl(bucketName, ossName, expiration).toString();
|
|
|
ossArchivePdf.setUrl(url);
|
|
|
ossClient.shutdown();
|
|
|
}
|