Procházet zdrojové kódy

调整黑名单路径配置

Eric před 2 roky
rodič
revize
a16d0f7517

+ 11 - 1
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/task/TaskController.java

@@ -4,9 +4,11 @@ import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import org.apache.commons.lang3.StringUtils;
 import org.redisson.api.RBucket;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,6 +39,8 @@ public class TaskController extends BaseController {
     private PlatformCashAccountRecordService platformCashAccountRecordService;
     @Autowired
     private ActivityPlanService activityPlanService;
+    @Value("${app.blacklist:}")
+    private String blackListFilePath;
 
     /***
      * 轮询用户订单
@@ -83,7 +87,13 @@ public class TaskController extends BaseController {
     @PostMapping(value = "/refreshBlackList")
     public HttpResponseResult refreshBlackList() {
         RBucket<Long> bucket = redissonClient.getBucket(SysConfigConstant.BLACK_LIST_UPDATE_TIME);
-        File file = new File(SysConfigConstant.BLACK_LIST_FILE_PATH);
+
+        String filePath = blackListFilePath;
+        if (StringUtils.isEmpty(filePath)) {
+            filePath = SysConfigConstant.BLACK_LIST_FILE_PATH;
+        }
+
+        File file = new File(filePath);
         bucket.set(file.lastModified());
         return HttpResponseResult.succeed();
     }

+ 10 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wordfilter/WordContext.java

@@ -10,6 +10,7 @@ import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 
 import javax.annotation.PostConstruct;
@@ -34,6 +35,8 @@ public class WordContext {
     private SysConfigService sysConfigService;
     @Autowired
     private RedissonClient redissonClient;
+    @Value("${app.blacklist:}")
+    private String blackListFilePath;
 
     /**
      * 敏感词字典
@@ -79,7 +82,13 @@ public class WordContext {
     private void initKeyWord1() {
         try {
             RBucket<Long> bucket = redissonClient.getBucket(SysConfigConstant.BLACK_LIST_UPDATE_TIME);
-            File file = new File(SysConfigConstant.BLACK_LIST_FILE_PATH);
+
+            String filePath = blackListFilePath;
+            if (StringUtils.isEmpty(filePath)) {
+                filePath = SysConfigConstant.BLACK_LIST_FILE_PATH;
+            }
+
+            File file = new File(filePath);
             this.blackList = FileUtils.readFileToString(file, "UTF-8");
             bucket.set(file.lastModified());
             initKeyWord();