Преглед изворни кода

将 StoreLocalCache 和 StoreChannelService 合并为 StoreLocalService, StoreLocalService 负责 oss-store 的本地化配置

reghao пре 1 година
родитељ
комит
a4f7ef080c

+ 6 - 13
oss-store/src/main/java/cn/reghao/oss/store/config/SpringLifecycle.java

@@ -8,8 +8,7 @@ import cn.reghao.oss.store.api.dto.StoreNodeDto;
 import cn.reghao.oss.store.api.dto.StoreProperties;
 import cn.reghao.oss.store.config.props.SpringProperties;
 import cn.reghao.oss.store.service.FileStoreService;
-import cn.reghao.oss.store.service.StoreChannelService;
-import cn.reghao.oss.store.service.StoreLocalCache;
+import cn.reghao.oss.store.service.StoreLocalService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.boot.ApplicationArguments;
@@ -29,17 +28,14 @@ public class SpringLifecycle implements ApplicationRunner, DisposableBean {
     private final SpringProperties springProperties;
     private final FileStoreService fileStoreService;
     private final OssConsoleClient ossConsoleClient;
-    private final StoreChannelService storeChannelService;
-    private final StoreLocalCache storeLocalCache;
+    private final StoreLocalService storeLocalService;
 
     public SpringLifecycle(SpringProperties springProperties, FileStoreService fileStoreService,
-                           OssConsoleClient ossConsoleClient, StoreChannelService storeChannelService,
-                           StoreLocalCache storeLocalCache) {
+                           OssConsoleClient ossConsoleClient, StoreLocalService storeLocalService) {
         this.springProperties = springProperties;
         this.fileStoreService = fileStoreService;
         this.ossConsoleClient = ossConsoleClient;
-        this.storeChannelService = storeChannelService;
-        this.storeLocalCache = storeLocalCache;
+        this.storeLocalService = storeLocalService;
     }
 
     @Override
@@ -63,13 +59,10 @@ public class SpringLifecycle implements ApplicationRunner, DisposableBean {
         String jsonPayload = JsonConverter.objectToJson(storeNodeDto);
         //ossConsoleClient.registerNode(jsonPayload);
 
-        // 获取 oss-store 配置
+        // 获取 oss-store 配置和默认 channel
         StoreProperties storeProperties = ossConsoleClient.getStoreProperties(nodeAddr);
-        storeLocalCache.initOssStore(storeProperties);
-
-        // 获取 oss-store channel
         List<ObjectChannel> objectChannels = ossConsoleClient.getObjectChannels(nodeAddr);
-        storeChannelService.initChannels(objectChannels);
+        storeLocalService.initChannels(storeProperties, objectChannels);
         log.info("StoreNode 初始化完成...");
     }
 

+ 9 - 13
oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectGetController.java

@@ -6,13 +6,11 @@ import cn.reghao.oss.store.api.dto.ObjectChannel;
 import cn.reghao.oss.store.api.dto.ObjectMeta;
 import cn.reghao.oss.store.db.repository.ObjectRepository;
 import cn.reghao.oss.store.service.GetObjectService;
-import cn.reghao.oss.store.service.StoreChannelService;
-import cn.reghao.oss.store.service.StoreLocalCache;
+import cn.reghao.oss.store.service.StoreLocalService;
 import cn.reghao.oss.store.util.JwtUtil;
 import cn.reghao.oss.store.util.ObjectUtil;
 import cn.reghao.oss.store.util.SignatureUtil;
 import cn.reghao.oss.store.api.dto.OssPayload;
-import com.github.benmanes.caffeine.cache.Cache;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
@@ -25,16 +23,14 @@ import java.io.IOException;
 @RestController
 public class ObjectGetController {
     private final GetObjectService getObjectService;
-    private final StoreLocalCache storeLocalCache;
     private final ObjectRepository objectRepository;
-    private final StoreChannelService storeChannelService;
+    private final StoreLocalService storeLocalService;
 
-    public ObjectGetController(GetObjectService getObjectService, StoreLocalCache storeLocalCache,
-                               ObjectRepository objectRepository, StoreChannelService storeChannelService) {
+    public ObjectGetController(GetObjectService getObjectService, ObjectRepository objectRepository, 
+                               StoreLocalService storeLocalService) {
         this.getObjectService = getObjectService;
-        this.storeLocalCache = storeLocalCache;
         this.objectRepository = objectRepository;
-        this.storeChannelService = storeChannelService;
+        this.storeLocalService = storeLocalService;
     }
 
     @RequestMapping(value = "/**", method = RequestMethod.HEAD)
@@ -67,9 +63,9 @@ public class ObjectGetController {
         }
 
         String queryString = String.format("token=%s&t=%s&nonce=%s", token, timestamp, nonce);
-        String url = String.format("//%s/%s", storeLocalCache.getDomain(), objectName);
+        String url = String.format("//%s/%s", storeLocalService.getDomain(), objectName);
         String requestString = String.format("%s%s?%s", "GET", url, queryString);
-        boolean valid = SignatureUtil.valid(requestString, storeLocalCache.getSecretKey(), sign);
+        boolean valid = SignatureUtil.valid(requestString, storeLocalService.getSecretKey(), sign);
         if (!valid) {
             String payload = "sign invalid";
             getObjectService.writeResponse(HttpServletResponse.SC_FORBIDDEN, payload);
@@ -83,10 +79,10 @@ public class ObjectGetController {
             return;
         }
 
-        OssPayload ossPayload = JwtUtil.getOssPayload(token, storeLocalCache.getSecretKey());
+        OssPayload ossPayload = JwtUtil.getOssPayload(token, storeLocalService.getSecretKey());
         int loginUser = ossPayload.getUserId();
         int channelId = ossPayload.getChannelId();
-        ObjectChannel objectChannel = storeChannelService.getChannelByChannelId(loginUser, channelId);
+        ObjectChannel objectChannel = storeLocalService.getChannelByChannelId(loginUser, channelId);
         if (objectChannel == null) {
             String payload = String.format("channel_id %s not exist", channelId);
             getObjectService.writeResponse(HttpServletResponse.SC_FORBIDDEN, payload);

+ 5 - 7
oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectUploadController.java

@@ -32,18 +32,16 @@ public class ObjectUploadController {
     private final FileStoreService fileStoreService;
     private final ObjectNameService objectNameService;
     private final PutObjectService putObjectService;
-    private final StoreLocalCache storeLocalCache;
-    private final StoreChannelService storeChannelService;
+    private final StoreLocalService storeLocalService;
 
     public ObjectUploadController(ChannelValidateService channelValidateService, FileStoreService fileStoreService,
                                   ObjectNameService objectNameService, PutObjectService putObjectService,
-                                  StoreLocalCache storeLocalCache, StoreChannelService storeChannelService) {
+                                  StoreLocalService storeLocalService) {
         this.channelValidateService = channelValidateService;
         this.fileStoreService = fileStoreService;
         this.objectNameService = objectNameService;
         this.putObjectService = putObjectService;
-        this.storeLocalCache = storeLocalCache;
-        this.storeChannelService = storeChannelService;
+        this.storeLocalService = storeLocalService;
     }
 
     @PutMapping(value = "/**")
@@ -61,7 +59,7 @@ public class ObjectUploadController {
                     .body(WebResult.failWithMsg("no token in request"));
         }
 
-        String secretKey = storeLocalCache.getSecretKey();
+        String secretKey = storeLocalService.getSecretKey();
         OssPayload ossPayload = JwtUtil.getOssPayload(token, secretKey);
         String action = ossPayload.getAction();
         if (!"upload".equals(action)) {
@@ -76,7 +74,7 @@ public class ObjectUploadController {
         }
 
         int loginUser = ossPayload.getUserId();
-        ObjectChannel objectChannel = storeChannelService.getChannelByChannelId(loginUser, channelId);
+        ObjectChannel objectChannel = storeLocalService.getChannelByChannelId(loginUser, channelId);
         if (objectChannel == null) {
             String errMsg = String.format("channel validate failed, channel %s not exist", channelId);
             return ResponseEntity.status(HttpStatus.FORBIDDEN)

+ 5 - 5
oss-store/src/main/java/cn/reghao/oss/store/inerceptor/AccessLogInterceptor.java

@@ -1,7 +1,7 @@
 package cn.reghao.oss.store.inerceptor;
 
 import cn.reghao.jutil.web.ServletUtil;
-import cn.reghao.oss.store.service.StoreLocalCache;
+import cn.reghao.oss.store.service.StoreLocalService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.lang.Nullable;
 import org.springframework.stereotype.Component;
@@ -20,10 +20,10 @@ import javax.servlet.http.HttpServletResponse;
 @Slf4j
 @Component
 public class AccessLogInterceptor implements HandlerInterceptor {
-    private final StoreLocalCache storeLocalCache;
+    private final StoreLocalService storeLocalService;
 
-    public AccessLogInterceptor(StoreLocalCache storeLocalCache) {
-        this.storeLocalCache = storeLocalCache;
+    public AccessLogInterceptor(StoreLocalService storeLocalService) {
+        this.storeLocalService = storeLocalService;
     }
 
     @Override
@@ -42,7 +42,7 @@ public class AccessLogInterceptor implements HandlerInterceptor {
             return true;
         }
 
-        String referFrom = storeLocalCache.getReferer();
+        String referFrom = storeLocalService.getReferer();
         String objectName = uri.replaceFirst("/", "");
         if (objectName.startsWith("img/")) {
             return true;

+ 5 - 5
oss-store/src/main/java/cn/reghao/oss/store/inerceptor/TokenFilter.java

@@ -1,6 +1,6 @@
 package cn.reghao.oss.store.inerceptor;
 
-import cn.reghao.oss.store.service.StoreLocalCache;
+import cn.reghao.oss.store.service.StoreLocalService;
 import cn.reghao.oss.store.util.JwtUtil;
 import cn.reghao.oss.store.util.UserContext;
 import cn.reghao.jutil.web.ServletUtil;
@@ -16,10 +16,10 @@ import java.io.IOException;
  */
 @Component
 public class TokenFilter implements Filter {
-    private final StoreLocalCache storeLocalCache;
+    private final StoreLocalService storeLocalService;
 
-    public TokenFilter(StoreLocalCache storeLocalCache) {
-        this.storeLocalCache = storeLocalCache;
+    public TokenFilter(StoreLocalService storeLocalService) {
+        this.storeLocalService = storeLocalService;
     }
 
     @Override
@@ -32,7 +32,7 @@ public class TokenFilter implements Filter {
         int userId = -1;
         String token = ServletUtil.getBearerToken(request);
         if (token != null) {
-            OssPayload ossPayload = JwtUtil.getOssPayload(token, storeLocalCache.getSecretKey());
+            OssPayload ossPayload = JwtUtil.getOssPayload(token, storeLocalService.getSecretKey());
             userId = ossPayload.getUserId();
         }
 

+ 6 - 17
oss-store/src/main/java/cn/reghao/oss/store/rpc/ObjectServiceImpl.java

@@ -8,7 +8,7 @@ import cn.reghao.oss.store.service.ObjectNameService;
 import cn.reghao.oss.store.api.iface.ObjectService;
 import cn.reghao.oss.store.db.mapper.FileMetaMapper;
 import cn.reghao.oss.store.service.SignService;
-import cn.reghao.oss.store.service.StoreLocalCache;
+import cn.reghao.oss.store.service.StoreLocalService;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.stereotype.Service;
 
@@ -25,15 +25,16 @@ public class ObjectServiceImpl implements ObjectService {
     private final ObjectNameService objectNameService;
     private final ObjectRepository objectRepository;
     private final SignService signService;
-    private final StoreLocalCache storeLocalCache;
+    private final StoreLocalService storeLocalService;
 
     public ObjectServiceImpl(FileMetaMapper fileMetaMapper, ObjectNameService objectNameService,
-                             ObjectRepository objectRepository, SignService signService, StoreLocalCache storeLocalCache) {
+                             ObjectRepository objectRepository, SignService signService,
+                             StoreLocalService storeLocalService) {
         this.fileMetaMapper = fileMetaMapper;
         this.objectNameService = objectNameService;
         this.objectRepository = objectRepository;
         this.signService = signService;
-        this.storeLocalCache = storeLocalCache;
+        this.storeLocalService = storeLocalService;
     }
 
     @Override
@@ -83,7 +84,7 @@ public class ObjectServiceImpl implements ObjectService {
         String filename = fileMeta.getFilename();
         long size = fileMeta.getSize();
         ObjectInfo objectInfo = new ObjectInfo(objectId, objectName, fileType, filename, size);
-        String url = String.format("//%s/%s", storeLocalCache.getDomain(), objectName);
+        String url = String.format("//%s/%s", storeLocalService.getDomain(), objectName);
         int scope = fileMeta.getScope();
         if (scope != ObjectScope.PUBLIC.getCode()) {
             String signedUrl = signService.getSignedUrl(loginUser, url, expireSecond);
@@ -92,18 +93,6 @@ public class ObjectServiceImpl implements ObjectService {
             objectInfo.setUrl(url);
         }
 
-        /*if (fileType == 1001) {
-            ObjectMeta objectMeta = objectRepository.getObjectMetaById(objectId);
-            String absolutePath = objectMeta.getAbsolutePath();
-            try {
-                ImageOps.Size resolution = ImageOps.info(new File(absolutePath));
-                objectInfo.setWidth(resolution.getWidth());
-                objectInfo.setHeight(resolution.getHeight());
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }*/
-
         return objectInfo;
     }
 }

+ 10 - 13
oss-store/src/main/java/cn/reghao/oss/store/rpc/StoreServiceImpl.java

@@ -4,8 +4,7 @@ import cn.reghao.oss.store.api.constant.ObjectScope;
 import cn.reghao.oss.store.api.dto.*;
 import cn.reghao.oss.store.service.FileStoreService;
 import cn.reghao.oss.store.service.ObjectNameService;
-import cn.reghao.oss.store.service.StoreChannelService;
-import cn.reghao.oss.store.service.StoreLocalCache;
+import cn.reghao.oss.store.service.StoreLocalService;
 import cn.reghao.oss.store.util.JwtUtil;
 import cn.reghao.oss.store.api.constant.ChannelAction;
 import cn.reghao.oss.store.api.iface.StoreService;
@@ -22,27 +21,25 @@ import java.util.stream.Collectors;
 @DubboService
 @Service
 public class StoreServiceImpl implements StoreService {
-    private final StoreLocalCache storeLocalCache;
-    private final StoreChannelService storeChannelService;
+    private final StoreLocalService storeLocalService;
     private final ObjectNameService objectNameService;
     private final FileStoreService fileStoreService;
 
-    public StoreServiceImpl(StoreLocalCache storeLocalCache, StoreChannelService storeChannelService,
-                            ObjectNameService objectNameService, FileStoreService fileStoreService) {
-        this.storeLocalCache = storeLocalCache;
-        this.storeChannelService = storeChannelService;
+    public StoreServiceImpl(StoreLocalService storeLocalService, ObjectNameService objectNameService,
+                            FileStoreService fileStoreService) {
+        this.storeLocalService = storeLocalService;
         this.objectNameService = objectNameService;
         this.fileStoreService = fileStoreService;
     }
 
     @Override
     public void updateStoreProperties(StoreProperties storeProperties) {
-        storeLocalCache.updateStoreProperties(storeProperties);
+        storeLocalService.updateStoreProperties(storeProperties);
     }
 
     @Override
     public String getUploadToken(int userId, int channelId) {
-        String secretKey = storeLocalCache.getSecretKey();
+        String secretKey = storeLocalService.getSecretKey();
         String action = ChannelAction.upload.getName();
         long expireAt = System.currentTimeMillis() + 3600*1000;
         OssPayload ossPayload = new OssPayload(action, channelId, userId);
@@ -53,15 +50,15 @@ public class StoreServiceImpl implements StoreService {
     public void createChannel(int userId, ObjectChannel channel) {
         String objectName = channel.getPrefix();
         objectNameService.createParentDirs(objectName, ObjectScope.PUBLIC.getCode());
-        storeChannelService.addObjectChannel(channel);
+        storeLocalService.addObjectChannel(channel);
     }
 
     @Override
     public StoreInfo getStoreInfo() {
-        List<ObjectChannel> objectChannels = storeChannelService.getObjectChannels();
+        List<ObjectChannel> objectChannels = storeLocalService.getObjectChannels();
         List<StoreDiskDto> list = fileStoreService.getStoreDisks().stream()
                 .map(StoreDiskDto::new)
                 .collect(Collectors.toList());
-        return new StoreInfo(storeLocalCache.getStoreProperties(), objectChannels, list);
+        return new StoreInfo(storeLocalService.getStoreProperties(), objectChannels, list);
     }
 }

+ 4 - 4
oss-store/src/main/java/cn/reghao/oss/store/service/GetObjectService.java

@@ -24,11 +24,11 @@ public class GetObjectService {
     private final FileMetaMapper fileMetaMapper;
     // 1MiB
     private final int bufSize = 1024*1024;
-    private final StoreLocalCache storeLocalCache;
+    private final StoreLocalService storeLocalService;
 
-    public GetObjectService(FileMetaMapper fileMetaMapper, StoreLocalCache storeLocalCache) {
+    public GetObjectService(FileMetaMapper fileMetaMapper, StoreLocalService storeLocalService) {
         this.fileMetaMapper = fileMetaMapper;
-        this.storeLocalCache = storeLocalCache;
+        this.storeLocalService = storeLocalService;
     }
     
     public void headObject(String objectName) throws IOException {
@@ -79,7 +79,7 @@ public class GetObjectService {
             ContentRange contentRange = parseContentRange(range, len);
             writeContentRange(objectMeta, contentRange);
         } else {
-            if (host.contains(storeLocalCache.getDomain())) {
+            if (host.contains(storeLocalService.getDomain())) {
                 writeWholeContent(objectMeta);
             } else {
                 writeDownloadContent(objectMeta);

+ 6 - 6
oss-store/src/main/java/cn/reghao/oss/store/service/ObjectMultipartUploadService.java

@@ -33,16 +33,16 @@ public class ObjectMultipartUploadService {
     private final Map<String, PathUrl> pathMap = new HashMap<>();
     private final ObjectNameService objectNameService;
     private final PutObjectService putObjectService;
-    private final StoreLocalCache storeLocalCache;
+    private final StoreLocalService storeLocalService;
 
     public ObjectMultipartUploadService(FileMetaMapper fileMetaMapper, FileStoreService fileStoreService,
                                         ObjectNameService objectNameService, PutObjectService putObjectService,
-                                        StoreLocalCache storeLocalCache) {
+                                        StoreLocalService storeLocalService) {
         this.fileMetaMapper = fileMetaMapper;
         this.fileStoreService = fileStoreService;
         this.objectNameService = objectNameService;
         this.putObjectService = putObjectService;
-        this.storeLocalCache = storeLocalCache;
+        this.storeLocalService = storeLocalService;
     }
 
     public synchronized UploadPrepareRet prepareUpload(UploadPrepare uploadPrepare) {
@@ -52,7 +52,7 @@ public class ObjectMultipartUploadService {
             return new UploadPrepareRet("uploadId", PART_SIZE, false, null);
         } else {
             String objectName = fileMeta.getObjectName();
-            String url = String.format("https://%s/%s", storeLocalCache.getDomain(), objectName);
+            String url = String.format("//%s/%s", storeLocalService.getDomain(), objectName);
             return new UploadPrepareRet("uploadId", PART_SIZE, false, url);
         }
     }
@@ -83,7 +83,7 @@ public class ObjectMultipartUploadService {
             ObjectProp objectProp = objectNameService.getObjectProp(objectChannel, suffix);
             putObjectService.copyObject(objectProp, filename, fileMeta);
 
-            String url = String.format("https://%s/%s", storeLocalCache.getDomain(), objectProp);
+            String url = String.format("//%s/%s", storeLocalService.getDomain(), objectProp);
             return new UploadFileRet(sha256sum, url);
         }
 
@@ -125,7 +125,7 @@ public class ObjectMultipartUploadService {
 
             map.remove(sha256sum);
             pathMap.remove(sha256sum);
-            String url = String.format("https://%s/%s", storeLocalCache.getDomain(), objectProp);
+            String url = String.format("//%s/%s", storeLocalService.getDomain(), objectProp);
             return new UploadFileRet(sha256sum, url);
         }
     }

+ 4 - 4
oss-store/src/main/java/cn/reghao/oss/store/service/ObjectNameService.java

@@ -18,15 +18,15 @@ import java.util.UUID;
 @Service
 public class ObjectNameService {
     private final ObjectRepository objectRepository;
-    private final StoreLocalCache storeLocalCache;
+    private final StoreLocalService storeLocalService;
 
-    public ObjectNameService(ObjectRepository objectRepository, StoreLocalCache storeLocalCache) {
+    public ObjectNameService(ObjectRepository objectRepository, StoreLocalService storeLocalService) {
         this.objectRepository = objectRepository;
-        this.storeLocalCache = storeLocalCache;
+        this.storeLocalService = storeLocalService;
     }
 
     public String getObjectUrl(String objectName) {
-        return String.format("//%s/%s", storeLocalCache.getDomain(), objectName);
+        return String.format("//%s/%s", storeLocalService.getDomain(), objectName);
     }
 
     public ObjectProp getObjectProp(ObjectChannel channel, String filename) throws Exception {

+ 5 - 7
oss-store/src/main/java/cn/reghao/oss/store/service/SignService.java

@@ -16,19 +16,17 @@ import java.util.UUID;
  */
 @Service
 public class SignService {
-    private final StoreLocalCache storeLocalCache;
-    private final StoreChannelService storeChannelService;
+    private final StoreLocalService storeLocalService;
 
-    public SignService(StoreLocalCache storeLocalCache, StoreChannelService storeChannelService) {
-        this.storeLocalCache = storeLocalCache;
-        this.storeChannelService = storeChannelService;
+    public SignService(StoreLocalService storeLocalService) {
+        this.storeLocalService = storeLocalService;
     }
 
     public String getSignedUrl(int loginUser, String url, int expire) {
         long timestamp = System.currentTimeMillis() + expire*1000L;
-        int channelId = storeChannelService.getChannelIdByUrl(loginUser, url);
+        int channelId = storeLocalService.getChannelIdByUrl(loginUser, url);
 
-        String secretKey = storeLocalCache.getSecretKey();
+        String secretKey = storeLocalService.getSecretKey();
         String action1 = ChannelAction.download.getName();
         String action = ChannelAction.access.getName();
         OssPayload ossPayload = new OssPayload(action, channelId, loginUser);

+ 0 - 37
oss-store/src/main/java/cn/reghao/oss/store/service/StoreLocalCache.java

@@ -1,37 +0,0 @@
-package cn.reghao.oss.store.service;
-
-import cn.reghao.oss.store.api.dto.StoreProperties;
-import org.springframework.stereotype.Service;
-
-/**
- * @author reghao
- * @date 2024-03-01 08:53:28
- */
-@Service
-public class StoreLocalCache {
-    private StoreProperties storeProperties;
-
-    public void initOssStore(StoreProperties storeProperties) {
-        this.storeProperties = storeProperties;
-    }
-
-    public void updateStoreProperties(StoreProperties storeProperties) {
-        this.storeProperties = storeProperties;
-    }
-
-    public StoreProperties getStoreProperties() {
-        return storeProperties;
-    }
-
-    public String getDomain() {
-        return storeProperties != null ? storeProperties.getDomain() : null;
-    }
-
-    public String getReferer() {
-        return storeProperties != null ? storeProperties.getReferer() : null;
-    }
-
-    public String getSecretKey() {
-        return storeProperties != null ? storeProperties.getSecretKey() : null;
-    }
-}

+ 26 - 8
oss-store/src/main/java/cn/reghao/oss/store/service/StoreChannelService.java → oss-store/src/main/java/cn/reghao/oss/store/service/StoreLocalService.java

@@ -1,6 +1,7 @@
 package cn.reghao.oss.store.service;
 
 import cn.reghao.oss.store.api.dto.ObjectChannel;
+import cn.reghao.oss.store.api.dto.StoreProperties;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -13,16 +14,13 @@ import java.util.Map;
  * @date 2024-03-08 09:20:27
  */
 @Service
-public class StoreChannelService {
+public class StoreLocalService {
+    private StoreProperties storeProperties;
     private final Map<String, ObjectChannel> prefixMap = new HashMap<>();
     private final Map<String, ObjectChannel> channelIdMap = new HashMap<>();
-    private final StoreLocalCache storeLocalCache;
 
-    public StoreChannelService(StoreLocalCache storeLocalCache) {
-        this.storeLocalCache = storeLocalCache;
-    }
-
-    public void initChannels(List<ObjectChannel> list) {
+    public void initChannels(StoreProperties storeProperties, List<ObjectChannel> list) {
+        this.storeProperties = storeProperties;
         for (ObjectChannel channel : list) {
             int createBy = channel.getCreateBy();
 
@@ -33,6 +31,26 @@ public class StoreChannelService {
         }
     }
 
+    public void updateStoreProperties(StoreProperties storeProperties) {
+        this.storeProperties = storeProperties;
+    }
+
+    public StoreProperties getStoreProperties() {
+        return storeProperties;
+    }
+
+    public String getDomain() {
+        return storeProperties != null ? storeProperties.getDomain() : null;
+    }
+
+    public String getReferer() {
+        return storeProperties != null ? storeProperties.getReferer() : null;
+    }
+
+    public String getSecretKey() {
+        return storeProperties != null ? storeProperties.getSecretKey() : null;
+    }
+
     public void addObjectChannel(ObjectChannel channel) {
         int createBy = channel.getCreateBy();
         String prefix = channel.getPrefix();
@@ -46,7 +64,7 @@ public class StoreChannelService {
     }
 
     public ObjectChannel getChannelByUrl(int loginUser, String url) {
-        String domain = storeLocalCache.getDomain();
+        String domain = storeProperties.getDomain();
         String objectName = url.replace("//" + domain + "/", "");
         for (String key : prefixMap.keySet()) {
             String prefix = key.split("-")[1];