|
|
@@ -1,6 +1,7 @@
|
|
|
package cn.reghao.tnb.file.app.rpc;
|
|
|
|
|
|
import cn.reghao.file.api.iface.OssService;
|
|
|
+import cn.reghao.oss.api.iface.ConsoleService;
|
|
|
import cn.reghao.oss.sdk.model.constant.ObjectScope;
|
|
|
import cn.reghao.oss.sdk.model.dto.ObjectInfo;
|
|
|
import cn.reghao.oss.sdk.model.dto.ServerInfo;
|
|
|
@@ -8,9 +9,7 @@ import cn.reghao.oss.sdk.model.dto.media.AudioInfo;
|
|
|
import cn.reghao.oss.sdk.model.dto.media.ConvertedImageInfo;
|
|
|
import cn.reghao.oss.sdk.model.dto.media.ImageInfo;
|
|
|
import cn.reghao.oss.sdk.model.dto.media.VideoInfo;
|
|
|
-import cn.reghao.oss.sdk.OssConsoleClient;
|
|
|
import cn.reghao.tnb.file.app.config.AppProperties;
|
|
|
-import cn.reghao.tnb.file.app.config.OssConsoleClientFactory;
|
|
|
import cn.reghao.tnb.file.app.model.constant.OssType;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -22,25 +21,27 @@ import org.springframework.stereotype.Service;
|
|
|
@DubboService
|
|
|
@Service
|
|
|
public class StoreServiceWrapperRouter implements OssService {
|
|
|
- private final OssConsoleClientFactory ossConsoleClientFactory;
|
|
|
+ private int owner = 10001;
|
|
|
private final int ossType;
|
|
|
+ private final ConsoleService consoleService;
|
|
|
+ private final StoreServiceWrapper storeServiceWrapper;
|
|
|
|
|
|
- public StoreServiceWrapperRouter(OssConsoleClientFactory ossConsoleClientFactory, AppProperties appProperties) {
|
|
|
- this.ossConsoleClientFactory = ossConsoleClientFactory;
|
|
|
+ public StoreServiceWrapperRouter(AppProperties appProperties, ConsoleService consoleService,
|
|
|
+ StoreServiceWrapper storeServiceWrapper) {
|
|
|
this.ossType = appProperties.getOssType();
|
|
|
+ this.consoleService = consoleService;
|
|
|
+ this.storeServiceWrapper = storeServiceWrapper;
|
|
|
}
|
|
|
|
|
|
- public ServerInfo getUploadStore(int channelId) throws Exception {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- ServerInfo serverInfo = ossConsoleClient.getUploadStore(channelId);
|
|
|
- return serverInfo;
|
|
|
+ public ServerInfo getUploadStore(int channelCode) throws Exception {
|
|
|
+ return consoleService.getUploadStore(channelCode);
|
|
|
}
|
|
|
|
|
|
- public Integer getChannelScope(int channelId) {
|
|
|
+ public Integer getChannelScope(int channelCode) {
|
|
|
/*try {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- return ossConsoleClient.getChannelScope(channelId);
|
|
|
+ return ossConsoleClient.getChannelScope(channelCode);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -49,44 +50,39 @@ public class StoreServiceWrapperRouter implements OssService {
|
|
|
return ObjectScope.PRIVATE.getCode();
|
|
|
}
|
|
|
|
|
|
- public void setObjectScope(int channelId, String objectId, int scope) throws Exception {
|
|
|
+ public void setObjectScope(int channelCode, String objectId, int scope) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- ossConsoleClient.setObjectScope(channelId, objectId, scope);
|
|
|
+ storeServiceWrapper.setObjectScope(channelCode, objectId, scope, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void deleteByObjectId(int channelId, String objectId) throws Exception {
|
|
|
+ public void deleteByObjectId(int channelCode, String objectId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- ossConsoleClient.deleteByObjectId(channelId, objectId);
|
|
|
+ storeServiceWrapper.deleteByObjectId(channelCode, objectId, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void deleteByObjectUrl(String objectUrl) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- ossConsoleClient.deleteByObjectUrl(objectUrl);
|
|
|
+ storeServiceWrapper.deleteByObjectUrl(objectUrl, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public ObjectInfo getObjectInfo(int channelId, String objectId) throws Exception {
|
|
|
+ public ObjectInfo getObjectInfo(int channelCode, String objectId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- return ossConsoleClient.getObjectInfo(channelId, objectId);
|
|
|
+ return storeServiceWrapper.getObjectInfo(channelCode, objectId, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|
|
|
throw new Exception("OSSType not found");
|
|
|
}
|
|
|
|
|
|
- public String getSignedUrl(int channelId, String objectId) throws Exception {
|
|
|
+ public String getSignedUrl(int channelCode, String objectId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- return ossConsoleClient.getSignedUrl(channelId, objectId);
|
|
|
+ return storeServiceWrapper.getSignedUrl(channelCode, objectId, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|
|
|
@@ -95,42 +91,37 @@ public class StoreServiceWrapperRouter implements OssService {
|
|
|
|
|
|
public String getSignedUrlByUrl(int channelCode, String objectUrl) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- return ossConsoleClient.getSignedUrlByUrl(channelCode, objectUrl);
|
|
|
+ return storeServiceWrapper.getSignedUrlByUrl(channelCode, objectUrl, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|
|
|
throw new Exception("OSSType not found");
|
|
|
}
|
|
|
|
|
|
- public VideoInfo getVideoInfo(int channelId, String videoFileId) throws Exception {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- return ossConsoleClient.getVideoInfo(channelId, videoFileId);
|
|
|
+ public VideoInfo getVideoInfo(int channelCode, String videoFileId) throws Exception {
|
|
|
+ return storeServiceWrapper.getVideoInfo(channelCode, videoFileId, owner);
|
|
|
}
|
|
|
|
|
|
- public ImageInfo getImageInfo(int channelId, String imageFileId) throws Exception {
|
|
|
+ public ImageInfo getImageInfo(int channelCode, String imageFileId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- return ossConsoleClient.getImageInfo(channelId, imageFileId);
|
|
|
+ return storeServiceWrapper.getImageInfo(channelCode, imageFileId, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|
|
|
throw new Exception("OSSType not found");
|
|
|
}
|
|
|
|
|
|
- public ConvertedImageInfo getWebpInfo(int channelId, String imageFileId) throws Exception {
|
|
|
+ public ConvertedImageInfo getWebpInfo(int channelCode, String imageFileId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- return ossConsoleClient.getWebpInfo(channelId, imageFileId);
|
|
|
+ return storeServiceWrapper.getWebpInfo(channelCode, imageFileId, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
throw new Exception("OSSType not found");
|
|
|
}
|
|
|
|
|
|
- public AudioInfo getAudioInfo(int channelId, String audioFileId) throws Exception {
|
|
|
+ public AudioInfo getAudioInfo(int channelCode, String audioFileId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- OssConsoleClient ossConsoleClient = ossConsoleClientFactory.getOssConsoleClient();
|
|
|
- return ossConsoleClient.getAudioInfo(channelId, audioFileId);
|
|
|
+ return storeServiceWrapper.getAudioInfo(channelCode, audioFileId, owner);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|