|
@@ -6,8 +6,8 @@ import cn.reghao.jutil.jdk.result.Result;
|
|
|
import cn.reghao.oss.console.app.model.dto.ChannelProcessDto;
|
|
import cn.reghao.oss.console.app.model.dto.ChannelProcessDto;
|
|
|
import cn.reghao.oss.console.app.rpc.RemoteService;
|
|
import cn.reghao.oss.console.app.rpc.RemoteService;
|
|
|
import cn.reghao.oss.console.util.AuthKeyContext;
|
|
import cn.reghao.oss.console.util.AuthKeyContext;
|
|
|
-import cn.reghao.tnb.file.api.dto.ObjectChannel;
|
|
|
|
|
import cn.reghao.oss.storeapi.iface.StoreService;
|
|
import cn.reghao.oss.storeapi.iface.StoreService;
|
|
|
|
|
+import cn.reghao.tnb.file.api.dto.ObjectChannel;
|
|
|
import cn.reghao.oss.console.account.service.UserContext;
|
|
import cn.reghao.oss.console.account.service.UserContext;
|
|
|
import cn.reghao.oss.console.app.db.repository.UploadChannelRepository;
|
|
import cn.reghao.oss.console.app.db.repository.UploadChannelRepository;
|
|
|
import cn.reghao.oss.console.app.model.dto.ChannelScopeDto;
|
|
import cn.reghao.oss.console.app.model.dto.ChannelScopeDto;
|
|
@@ -47,7 +47,7 @@ public class UploadChannelService {
|
|
|
return Result.fail(String.format("store_node with id %s not exist", nodeId));
|
|
return Result.fail(String.format("store_node with id %s not exist", nodeId));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- long createBy = UserContext.getUser().getId();
|
|
|
|
|
|
|
+ int createBy = UserContext.getUser().getId();
|
|
|
//int createBy = 410;
|
|
//int createBy = 410;
|
|
|
String channelPrefix = uploadChannelDto.getChannelPrefix();
|
|
String channelPrefix = uploadChannelDto.getChannelPrefix();
|
|
|
UploadChannel uploadChannel = uploadChannelRepository.findByPrefixAndCreateByAndNodeId(channelPrefix, createBy, nodeId);
|
|
UploadChannel uploadChannel = uploadChannelRepository.findByPrefixAndCreateByAndNodeId(channelPrefix, createBy, nodeId);
|
|
@@ -80,7 +80,7 @@ public class UploadChannelService {
|
|
|
return Result.success();
|
|
return Result.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private int getNextChannelId(long userId) {
|
|
|
|
|
|
|
+ private int getNextChannelId(int userId) {
|
|
|
int channelId = 101;
|
|
int channelId = 101;
|
|
|
int total = uploadChannelRepository.countByCreateBy(userId);
|
|
int total = uploadChannelRepository.countByCreateBy(userId);
|
|
|
return channelId + total;
|
|
return channelId + total;
|
|
@@ -136,11 +136,11 @@ public class UploadChannelService {
|
|
|
return uploadChannelRepository.findById(id).orElse(null);
|
|
return uploadChannelRepository.findById(id).orElse(null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public UploadChannel getByChannelIdAndCreateBy(int channelId, long createBy) {
|
|
|
|
|
|
|
+ public UploadChannel getByChannelIdAndCreateBy(int channelId, int createBy) {
|
|
|
return uploadChannelRepository.findByChannelIdAndCreateBy(channelId, createBy);
|
|
return uploadChannelRepository.findByChannelIdAndCreateBy(channelId, createBy);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ObjectChannel getObjectChannelByChannelId(int channelId, long createBy) {
|
|
|
|
|
|
|
+ public ObjectChannel getObjectChannelByChannelId(int channelId, int createBy) {
|
|
|
UploadChannel uploadChannel = uploadChannelRepository.findByChannelIdAndCreateBy(channelId, createBy);
|
|
UploadChannel uploadChannel = uploadChannelRepository.findByChannelIdAndCreateBy(channelId, createBy);
|
|
|
return getObjectChannel(uploadChannel);
|
|
return getObjectChannel(uploadChannel);
|
|
|
}
|
|
}
|
|
@@ -154,20 +154,19 @@ public class UploadChannelService {
|
|
|
boolean seturl = uploadChannel.getSeturl();
|
|
boolean seturl = uploadChannel.getSeturl();
|
|
|
int scope = uploadChannel.getScope();
|
|
int scope = uploadChannel.getScope();
|
|
|
String domain = storeNodeService.getById(uploadChannel.getNodeId()).getDomain();
|
|
String domain = storeNodeService.getById(uploadChannel.getNodeId()).getDomain();
|
|
|
- long createBy = uploadChannel.getCreateBy();
|
|
|
|
|
|
|
+ int createBy = uploadChannel.getCreateBy();
|
|
|
return new ObjectChannel(channelId, name, channelPrefix, maxSize, fileType, seturl, scope, domain, createBy);
|
|
return new ObjectChannel(channelId, name, channelPrefix, maxSize, fileType, seturl, scope, domain, createBy);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public StoreNode getStoreNodeByChannelId(int channelId) throws Exception {
|
|
|
|
|
- long userId = AuthKeyContext.getUser();
|
|
|
|
|
- UploadChannel uploadChannel = uploadChannelRepository.findByChannelIdAndCreateBy(channelId, userId);
|
|
|
|
|
|
|
+ public StoreNode getStoreNodeByChannelId(int loginUser, int channelId) throws Exception {
|
|
|
|
|
+ UploadChannel uploadChannel = uploadChannelRepository.findByChannelIdAndCreateBy(channelId, loginUser);
|
|
|
if (uploadChannel == null) {
|
|
if (uploadChannel == null) {
|
|
|
String errMsg = String.format("channel_id %s not exist", channelId);
|
|
String errMsg = String.format("channel_id %s not exist", channelId);
|
|
|
throw new Exception(errMsg);
|
|
throw new Exception(errMsg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String domain = storeNodeService.getById(uploadChannel.getNodeId()).getDomain();
|
|
String domain = storeNodeService.getById(uploadChannel.getNodeId()).getDomain();
|
|
|
- String ossUrl = String.format("https://%s", domain);
|
|
|
|
|
|
|
+ String ossUrl = String.format("//%s", domain);
|
|
|
long maxSize = uploadChannel.getMaxSize();
|
|
long maxSize = uploadChannel.getMaxSize();
|
|
|
|
|
|
|
|
StoreNode storeNode = storeNodeService.getByDomain(domain);
|
|
StoreNode storeNode = storeNodeService.getByDomain(domain);
|
|
@@ -179,11 +178,11 @@ public class UploadChannelService {
|
|
|
return storeNode;
|
|
return storeNode;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<UploadChannel> getByNodeIdAndUserId(int nodeId, long userId) {
|
|
|
|
|
|
|
+ public List<UploadChannel> getByNodeIdAndUserId(int nodeId, int userId) {
|
|
|
return uploadChannelRepository.findByNodeIdAndCreateBy(nodeId, userId);
|
|
return uploadChannelRepository.findByNodeIdAndCreateBy(nodeId, userId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<UploadChannel> getByDomainAndCreateBy(String domain, long createBy) {
|
|
|
|
|
|
|
+ public List<UploadChannel> getByDomainAndCreateBy(String domain, int createBy) {
|
|
|
StoreNode storeNode = storeNodeService.getByDomain(domain);
|
|
StoreNode storeNode = storeNodeService.getByDomain(domain);
|
|
|
int nodeId = storeNode.getId();
|
|
int nodeId = storeNode.getId();
|
|
|
return getByNodeIdAndUserId(nodeId, createBy);
|
|
return getByNodeIdAndUserId(nodeId, createBy);
|