Browse Source

模版修改

licailing 4 years ago
parent
commit
9a1389b7f6

+ 5 - 0
pom.xml

@@ -311,6 +311,11 @@
             <artifactId>junrar</artifactId>
             <version>4.0.0</version>
         </dependency>
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>3.11.2</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 4 - 0
src/main/java/com/izouma/wenlvju/service/RateService.java

@@ -265,6 +265,10 @@ public class RateService {
 
             //单位概况
             dataMap.put("introduction", rate.getIntroduction());
+
+            //等级
+            dataMap.put("grade", rate.getGrade().getDesc());
+
             //Configuration 用于读取ftl文件
             Configuration configuration = new Configuration(new Version("2.3.0"));
 

+ 30 - 0
src/main/java/com/izouma/wenlvju/service/storage/AliStorageService.java

@@ -1,6 +1,10 @@
 package com.izouma.wenlvju.service.storage;
 
+import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.model.CopyObjectRequest;
+import com.aliyun.oss.model.CopyObjectResult;
 import com.aliyun.oss.model.ObjectMetadata;
 import com.izouma.wenlvju.exception.BusinessException;
 import lombok.Data;
@@ -67,4 +71,30 @@ public class AliStorageService implements StorageService {
         return ossDomain + "/" + path;
     }
 
+    public void rename(String sourceKey, String destinationKey) {
+        // 填写源Object的完整路径。Object完整路径中不能包含Bucket名称。
+//        String sourceKey = "application.txt";
+
+        // 填写目标Object的完整路径。Object完整路径中不能包含Bucket名称。
+//        String destinationKey = sourceKey;
+
+        // 创建OSSClient实例。
+        OSS ossClient = new OSSClientBuilder().build(ossEndPoint, accessKeyId, accessKeySecret);
+
+        // 创建CopyObjectRequest对象。
+        CopyObjectRequest copyObjectRequest = new CopyObjectRequest(ossBucketName, sourceKey, ossBucketName, destinationKey);
+
+        // 设置新的文件元信息。
+        ObjectMetadata meta = new ObjectMetadata();
+//        meta.setContentType("text/txt");
+        copyObjectRequest.setNewObjectMetadata(meta);
+
+        // 复制文件。
+        CopyObjectResult result = ossClient.copyObject(copyObjectRequest);
+        System.out.println("ETag: " + result.getETag() + " LastModified: " + result.getLastModified());
+
+        // 关闭OSSClient。
+        ossClient.shutdown();
+    }
+
 }

File diff suppressed because it is too large
+ 0 - 0
src/main/resources/templates/RateTemplate.ftl


+ 26 - 0
src/test/java/com/izouma/wenlvju/service/storage/AliStorageServiceTest.java

@@ -0,0 +1,26 @@
+package com.izouma.wenlvju.service.storage;
+
+import com.izouma.wenlvju.ApplicationTests;
+import com.izouma.wenlvju.domain.Rate;
+import com.izouma.wenlvju.exception.BusinessException;
+import com.izouma.wenlvju.repo.RateRepo;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+public class AliStorageServiceTest extends ApplicationTests {
+
+    @Autowired
+    private AliStorageService aliStorageService;
+    @Autowired
+    private RateRepo          rateRepo;
+
+    @Test
+    public void rename() {
+        Rate wu = rateRepo.findById(12696L).orElseThrow(new BusinessException("wu"));
+        wu.getPrivacyPolicy().forEach(img -> {
+            img.lastIndexOf("/");
+        });
+//        aliStorageService.rename("application/2021-08-30-18-18-18DKdQtyCS.", "application/2021-08-30-18-18-18DKdQtyCS.jpg");
+    }
+}

Some files were not shown because too many files changed in this diff