|
@@ -2,6 +2,7 @@ package cn.reghao.oss.console.app.service;
|
|
|
|
|
|
|
|
import cn.reghao.jutil.jdk.result.Result;
|
|
import cn.reghao.jutil.jdk.result.Result;
|
|
|
import cn.reghao.oss.console.app.db.repository.StoreNodeRepository;
|
|
import cn.reghao.oss.console.app.db.repository.StoreNodeRepository;
|
|
|
|
|
+import cn.reghao.oss.console.app.db.repository.UserNodeRepository;
|
|
|
import cn.reghao.oss.console.app.model.dto.NodeUpdateDto;
|
|
import cn.reghao.oss.console.app.model.dto.NodeUpdateDto;
|
|
|
import cn.reghao.oss.console.app.model.po.StoreDisk;
|
|
import cn.reghao.oss.console.app.model.po.StoreDisk;
|
|
|
import cn.reghao.oss.console.app.model.po.StoreNode;
|
|
import cn.reghao.oss.console.app.model.po.StoreNode;
|
|
@@ -26,10 +27,13 @@ import java.util.stream.Collectors;
|
|
|
public class StoreNodeService {
|
|
public class StoreNodeService {
|
|
|
private final StoreNodeRepository storeNodeRepository;
|
|
private final StoreNodeRepository storeNodeRepository;
|
|
|
private final RpcService rpcService;
|
|
private final RpcService rpcService;
|
|
|
|
|
+ private final UserNodeRepository userNodeRepository;
|
|
|
|
|
|
|
|
- public StoreNodeService(StoreNodeRepository storeNodeRepository, RpcService rpcService) {
|
|
|
|
|
|
|
+ public StoreNodeService(StoreNodeRepository storeNodeRepository, RpcService rpcService,
|
|
|
|
|
+ UserNodeRepository userNodeRepository) {
|
|
|
this.storeNodeRepository = storeNodeRepository;
|
|
this.storeNodeRepository = storeNodeRepository;
|
|
|
this.rpcService = rpcService;
|
|
this.rpcService = rpcService;
|
|
|
|
|
+ this.userNodeRepository = userNodeRepository;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void add(StoreNodeDto storeNodeDto) {
|
|
public void add(StoreNodeDto storeNodeDto) {
|
|
@@ -65,7 +69,6 @@ public class StoreNodeService {
|
|
|
return Result.success();
|
|
return Result.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String nodeAddr = storeNode.getNodeAddr();
|
|
|
|
|
String secretKey = nodeUpdateDto.getSecretKey();
|
|
String secretKey = nodeUpdateDto.getSecretKey();
|
|
|
String referer = nodeUpdateDto.getReferer();
|
|
String referer = nodeUpdateDto.getReferer();
|
|
|
storeNode.setDomain(domain);
|
|
storeNode.setDomain(domain);
|
|
@@ -86,8 +89,13 @@ public class StoreNodeService {
|
|
|
return Result.fail("node not exist");
|
|
return Result.fail("node not exist");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //storeNodeRepository.delete(storeNode);
|
|
|
|
|
- return Result.success("not implement");
|
|
|
|
|
|
|
+ int total = userNodeRepository.countByNodeId(nodeId);
|
|
|
|
|
+ if (total > 0) {
|
|
|
|
|
+ return Result.fail("someone user the node");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ storeNodeRepository.delete(storeNode);
|
|
|
|
|
+ return Result.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public Page<StoreNode> getByPage(PageRequest pageRequest) {
|
|
public Page<StoreNode> getByPage(PageRequest pageRequest) {
|