Browse Source

feat: 图片模板缓存

xdd 1 month ago
parent
commit
f83dc5288c

+ 10 - 4
fs-service/src/main/java/com/fs/utils/FileCacheService.java

@@ -1,5 +1,6 @@
 package com.fs.utils;
 
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -17,15 +18,20 @@ public class FileCacheService {
     @Value("${getTuiFont}")
     private String getTuiFont;
 
+    @Value("${tuiImgCache:0}")
+    private String tuiImgCache;
+
     private byte[] templateBytes;
     private byte[] fontBytes;
 
     @PostConstruct
     public void init() throws IOException {
-        // 缓存模板图片文件
-        this.templateBytes = Files.readAllBytes(Paths.get(getTuiImg));
-        // 缓存字体文件
-        this.fontBytes = Files.readAllBytes(Paths.get(getTuiFont));
+        if(StringUtils.equals("1",tuiImgCache)) {
+            // 缓存模板图片文件
+            this.templateBytes = Files.readAllBytes(Paths.get(getTuiImg));
+            // 缓存字体文件
+            this.fontBytes = Files.readAllBytes(Paths.get(getTuiFont));
+        }
     }
 
     /**

+ 0 - 2
fs-service/src/main/resources/application-common.yml

@@ -139,5 +139,3 @@ image:
     local-path: C:\logoFile\logo.jpg
     server-path: C:\logoFile\logo.jpg
 
-getTuiImg: 'C:\Tools\ylrm_his_scrm\images\36f5863ffbbbdfc31620ea177c75284c.jpg'
-getTuiFont: 'C:\Tools\ylrm_his_scrm\images\simsunb.ttf'

+ 4 - 0
fs-service/src/main/resources/application-druid-xzt.yml

@@ -144,3 +144,7 @@ openIM:
     userID: imAdmin
 #是否为新商户,新商户不走mpOpenId
 isNewWxMerchant: true
+#图片模板是否缓存
+tuiImgCache: '1'
+getTuiImg: 'C:\Tools\ylrm_his_scrm\images\36f5863ffbbbdfc31620ea177c75284c.jpg'
+getTuiFont: 'C:\Tools\ylrm_his_scrm\images\simsunb.ttf'