区分临时和本地存储

This commit is contained in:
2025-04-11 16:20:55 +08:00
parent d0d4e37526
commit b5b9064f30
8 changed files with 104 additions and 17 deletions

View File

@@ -38,5 +38,7 @@ public interface ScenicService {
IStorageAdapter getScenicTmpStorageAdapter(Long scenicId);
IStorageAdapter getScenicLocalStorageAdapter(Long scenicId);
IFaceBodyAdapter getScenicFaceBodyAdapter(Long scenicId);
}

View File

@@ -199,6 +199,7 @@ public class ScenicServiceImpl implements ScenicService {
scenicFaceBodyAdapterMap.remove(config.getScenicId());
scenicStorageAdapterMap.remove(config.getScenicId());
scenicTmpStorageAdapterMap.remove(config.getScenicId());
scenicLocalStorageAdapterMap.remove(config.getScenicId());
}
@@ -240,6 +241,26 @@ public class ScenicServiceImpl implements ScenicService {
return adapter;
});
}
private static final Map<Long, IStorageAdapter> scenicLocalStorageAdapterMap = new ConcurrentHashMap<>();
@Override
public IStorageAdapter getScenicLocalStorageAdapter(Long scenicId) {
return scenicLocalStorageAdapterMap.computeIfAbsent(scenicId, (key) -> {
IStorageAdapter adapter;
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenicId);
if (scenicConfig != null && scenicConfig.getLocalStoreType() != null) {
try {
adapter = StorageFactory.get(scenicConfig.getLocalStoreType());
adapter.loadConfig(JSONObject.parseObject(scenicConfig.getLocalStoreConfigJson(), Map.class));
} catch (StorageUnsupportedException ignored) {
return getScenicStorageAdapter(scenicId);
}
} else {
return getScenicStorageAdapter(scenicId);
}
return adapter;
});
}
private static final Map<Long, IFaceBodyAdapter> scenicFaceBodyAdapterMap = new ConcurrentHashMap<>();
@Override
public IFaceBodyAdapter getScenicFaceBodyAdapter(Long scenicId) {