|
|
@@ -10,9 +10,10 @@ 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.tnb.file.app.config.AppProperties;
|
|
|
-import cn.reghao.tnb.file.app.db.mapper.StoreConfigMapper;
|
|
|
+import cn.reghao.tnb.file.app.db.repository.StoreRepository;
|
|
|
import cn.reghao.tnb.file.app.model.constant.OssType;
|
|
|
-import cn.reghao.tnb.file.app.model.po.StoreConfig;
|
|
|
+import cn.reghao.tnb.file.app.model.po.UploadChannel;
|
|
|
+import cn.reghao.tnb.file.app.service.StoreConfigService;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -25,27 +26,31 @@ import javax.annotation.PostConstruct;
|
|
|
@DubboService
|
|
|
@Service
|
|
|
public class StoreServiceWrapperRouter implements OssService {
|
|
|
- private int owner = -1;
|
|
|
+ private int ossUser = -1;
|
|
|
private final int ossType;
|
|
|
private final ConsoleService consoleService;
|
|
|
private final StoreServiceWrapper storeServiceWrapper;
|
|
|
- private final StoreConfigMapper storeConfigMapper;
|
|
|
+ private final StoreConfigService storeConfigService;
|
|
|
+ private final StoreRepository storeRepository;
|
|
|
|
|
|
public StoreServiceWrapperRouter(AppProperties appProperties, ConsoleService consoleService,
|
|
|
- StoreServiceWrapper storeServiceWrapper, StoreConfigMapper storeConfigMapper) {
|
|
|
+ StoreServiceWrapper storeServiceWrapper, StoreConfigService storeConfigService,
|
|
|
+ StoreRepository storeRepository) {
|
|
|
this.ossType = appProperties.getOssType();
|
|
|
this.consoleService = consoleService;
|
|
|
this.storeServiceWrapper = storeServiceWrapper;
|
|
|
- this.storeConfigMapper = storeConfigMapper;
|
|
|
+ this.storeConfigService = storeConfigService;
|
|
|
+ this.storeRepository = storeRepository;
|
|
|
}
|
|
|
|
|
|
@PostConstruct
|
|
|
- public void postSetOwner() {
|
|
|
- StoreConfig storeConfig = storeConfigMapper.findByOssType(OssType.localOss.getValue());
|
|
|
- this.owner = Integer.parseInt(storeConfig.getAccessKeyId());
|
|
|
+ public void postSetOssUser() {
|
|
|
+ this.ossUser = storeConfigService.getLocalOssUser(OssType.localOss);
|
|
|
}
|
|
|
|
|
|
- public ServerInfo getUploadStore(int channelCode) throws Exception {
|
|
|
+ public ServerInfo getUploadStore(String channelName) throws Exception {
|
|
|
+ UploadChannel uploadChannel = storeRepository.getUploadChannel(ossUser, channelName);
|
|
|
+ int channelCode = uploadChannel.getChannelCode();
|
|
|
return consoleService.getUploadStore(channelCode);
|
|
|
}
|
|
|
|
|
|
@@ -64,28 +69,28 @@ public class StoreServiceWrapperRouter implements OssService {
|
|
|
|
|
|
public void setObjectScope(int channelCode, String objectId, int scope) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- storeServiceWrapper.setObjectScope(channelCode, objectId, scope, owner);
|
|
|
+ storeServiceWrapper.setObjectScope(channelCode, objectId, scope, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void deleteByObjectId(int channelCode, String objectId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- storeServiceWrapper.deleteByObjectId(channelCode, objectId, owner);
|
|
|
+ storeServiceWrapper.deleteByObjectId(channelCode, objectId, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void deleteByObjectUrl(String objectUrl) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- storeServiceWrapper.deleteByObjectUrl(objectUrl, owner);
|
|
|
+ storeServiceWrapper.deleteByObjectUrl(objectUrl, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public ObjectInfo getObjectInfo(int channelCode, String objectId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- return storeServiceWrapper.getObjectInfo(channelCode, objectId, owner);
|
|
|
+ return storeServiceWrapper.getObjectInfo(channelCode, objectId, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|
|
|
@@ -94,7 +99,7 @@ public class StoreServiceWrapperRouter implements OssService {
|
|
|
|
|
|
public String getSignedUrl(int channelCode, String objectId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- return storeServiceWrapper.getSignedUrl(channelCode, objectId, owner);
|
|
|
+ return storeServiceWrapper.getSignedUrl(channelCode, objectId, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|
|
|
@@ -103,7 +108,7 @@ public class StoreServiceWrapperRouter implements OssService {
|
|
|
|
|
|
public String getSignedUrlByUrl(int channelCode, String objectUrl) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- return storeServiceWrapper.getSignedUrlByUrl(channelCode, objectUrl, owner);
|
|
|
+ return storeServiceWrapper.getSignedUrlByUrl(channelCode, objectUrl, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|
|
|
@@ -111,12 +116,12 @@ public class StoreServiceWrapperRouter implements OssService {
|
|
|
}
|
|
|
|
|
|
public VideoInfo getVideoInfo(int channelCode, String videoFileId) throws Exception {
|
|
|
- return storeServiceWrapper.getVideoInfo(channelCode, videoFileId, owner);
|
|
|
+ return storeServiceWrapper.getVideoInfo(channelCode, videoFileId, ossUser);
|
|
|
}
|
|
|
|
|
|
public ImageInfo getImageInfo(int channelCode, String imageFileId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- return storeServiceWrapper.getImageInfo(channelCode, imageFileId, owner);
|
|
|
+ return storeServiceWrapper.getImageInfo(channelCode, imageFileId, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|
|
|
@@ -125,7 +130,7 @@ public class StoreServiceWrapperRouter implements OssService {
|
|
|
|
|
|
public ConvertedImageInfo getWebpInfo(int channelCode, String imageFileId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- return storeServiceWrapper.getWebpInfo(channelCode, imageFileId, owner);
|
|
|
+ return storeServiceWrapper.getWebpInfo(channelCode, imageFileId, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
throw new Exception("OSSType not found");
|
|
|
@@ -133,7 +138,7 @@ public class StoreServiceWrapperRouter implements OssService {
|
|
|
|
|
|
public AudioInfo getAudioInfo(int channelCode, String audioFileId) throws Exception {
|
|
|
if (ossType == OssType.localOss.getCode()) {
|
|
|
- return storeServiceWrapper.getAudioInfo(channelCode, audioFileId, owner);
|
|
|
+ return storeServiceWrapper.getAudioInfo(channelCode, audioFileId, ossUser);
|
|
|
} else if (ossType == OssType.aliyunOss.getCode()) {
|
|
|
}
|
|
|
|