|
@@ -4,6 +4,10 @@ import cn.tr.module.api.sys.storage.StoragePojo;
|
|
|
import cn.tr.module.api.sys.storage.SysStorageApi;
|
|
import cn.tr.module.api.sys.storage.SysStorageApi;
|
|
|
import cn.tr.module.sys.storage.service.IStorageFileService;
|
|
import cn.tr.module.sys.storage.service.IStorageFileService;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
@@ -17,10 +21,12 @@ import java.util.Map;
|
|
|
* @Date: 2023年05月18日
|
|
* @Date: 2023年05月18日
|
|
|
*/
|
|
*/
|
|
|
@Component
|
|
@Component
|
|
|
-@AllArgsConstructor
|
|
|
|
|
public class SysStorageApiProvider implements SysStorageApi {
|
|
public class SysStorageApiProvider implements SysStorageApi {
|
|
|
- private final IStorageFileService storageFileService;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IStorageFileService storageFileService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ @Lazy
|
|
|
|
|
+ private SysStorageApiProvider sysStorageApiProvider;
|
|
|
@Override
|
|
@Override
|
|
|
public String upload(byte[] content, String filename, Long millis) throws Exception {
|
|
public String upload(byte[] content, String filename, Long millis) throws Exception {
|
|
|
return storageFileService.upload(null,null,filename,content,millis).getId();
|
|
return storageFileService.upload(null,null,filename,content,millis).getId();
|
|
@@ -29,9 +35,11 @@ public class SysStorageApiProvider implements SysStorageApi {
|
|
|
@Override
|
|
@Override
|
|
|
public void removeById(String fileId) {
|
|
public void removeById(String fileId) {
|
|
|
storageFileService.remove(Collections.singleton(fileId));
|
|
storageFileService.remove(Collections.singleton(fileId));
|
|
|
|
|
+ sysStorageApiProvider.delCache(fileId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Cacheable(key = "#recordId",value = "global:storage")
|
|
|
public byte[] obtainContent(String recordId) throws Exception {
|
|
public byte[] obtainContent(String recordId) throws Exception {
|
|
|
return storageFileService.obtainContent(recordId);
|
|
return storageFileService.obtainContent(recordId);
|
|
|
}
|
|
}
|
|
@@ -40,4 +48,9 @@ public class SysStorageApiProvider implements SysStorageApi {
|
|
|
public Map<String, StoragePojo> findStorage(Collection<String> storageIds) {
|
|
public Map<String, StoragePojo> findStorage(Collection<String> storageIds) {
|
|
|
return storageFileService.findStorageByIds(storageIds);
|
|
return storageFileService.findStorageByIds(storageIds);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @CacheEvict(key = "#recordId",value = "global:storage")
|
|
|
|
|
+ public void delCache(String recordId){
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|