Prechádzať zdrojové kódy

feat(临考突击报告): 暴露PDF页面复用配置

金逸霄 5 dní pred
rodič
commit
3d4c94331a

+ 2 - 0
ability-center-runtime/src/main/resources/application-prod.yml

@@ -13,6 +13,8 @@ ability:
         borrow-timeout: 60s
         launch-timeout: 45s
         render-timeout: 60s
+        page-reuse-enabled: ${ABILITY_EXAM_SPRINT_REPORT_PDF_PAGE_REUSE_ENABLED:true}
+        page-max-render-count: ${ABILITY_EXAM_SPRINT_REPORT_PDF_PAGE_MAX_RENDER_COUNT:200}
       storage:
         type: azure
         connection-string: "${AZURE_BLOB_CONNECTION_STRING:DefaultEndpointsProtocol=https;AccountName=dcjxb;AccountKey=+Bg9srieVxwemxcE2b+icL3t3hp8m04PuYanTl6fwB/Cx1SF49qimBpYvXQjcvatgDDDgxjqYDP/0DCFTSQcgg==;EndpointSuffix=core.chinacloudapi.cn;}"

+ 2 - 0
ability-center-runtime/src/main/resources/application-test.yml

@@ -13,6 +13,8 @@ ability:
         borrow-timeout: 60s
         launch-timeout: 45s
         render-timeout: 60s
+        page-reuse-enabled: true
+        page-max-render-count: 200
       storage:
         type: azure
         connection-string: "DefaultEndpointsProtocol=https;AccountName=dcjxbtest;AccountKey=CoOzFKq3/aecqY8JehnW+oV3XYe8dN8772NQbhT5VzYO5fdrx+Ps/LhmPqv9U/M28BtqSrgN13pjJqPvIRdI2w==;EndpointSuffix=core.chinacloudapi.cn"

+ 3 - 0
ability-center-runtime/src/main/resources/application.yml

@@ -4,6 +4,9 @@ ability:
       retention: 1d
       download-expiry: 15m
       cleanup-interval-ms: 600000
+      pdf:
+        page-reuse-enabled: true
+        page-max-render-count: 200
       storage:
         type: memory
         container-name: report

+ 20 - 0
ability-center-runtime/src/test/java/cn/yunzhixue/ability/center/examsprint/configuration/ExamSprintReportRuntimeConfigurationTest.java

@@ -13,10 +13,15 @@ import cn.yunzhixue.ability.center.examsprint.infrastructure.report.rendering.ou
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.boot.env.YamlPropertySourceLoader;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Import;
+import org.springframework.core.env.StandardEnvironment;
+import org.springframework.core.io.ClassPathResource;
 
+import java.io.IOException;
 import java.time.Duration;
 import java.time.Instant;
 
@@ -59,6 +64,21 @@ class ExamSprintReportRuntimeConfigurationTest {
         assertThat(properties.getPdf().getPageMaxRenderCount()).isEqualTo(123);
     }
 
+    @Test
+    void productionYamlExposesPdfPageReuseSettingsForOperationsOverride() throws IOException {
+        StandardEnvironment environment = new StandardEnvironment();
+        YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
+        loader.load("application-prod", new ClassPathResource("application-prod.yml"))
+                .forEach(propertySource -> environment.getPropertySources().addLast(propertySource));
+
+        ExamSprintReportRuntimeConfiguration.BoundExamSprintReportProperties bound = Binder.get(environment)
+                .bind("ability.exam-sprint.report", ExamSprintReportRuntimeConfiguration.BoundExamSprintReportProperties.class)
+                .orElseThrow(IllegalStateException::new);
+
+        assertThat(bound.getPdf().isPageReuseEnabled()).isTrue();
+        assertThat(bound.getPdf().getPageMaxRenderCount()).isEqualTo(200);
+    }
+
     @Test
     void examSprintReportWarmupRunnerIsRegisteredAndWiredBySpringContext() {
         new ApplicationContextRunner()