|
|
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* 接口表;(ip_interface)表服务接口实现类
|
|
|
@@ -33,11 +34,15 @@ public class IpInterfaceServiceImpl implements IpInterfaceService {
|
|
|
* @return 实例对象
|
|
|
*/
|
|
|
public IpInterfaceVO queryById(Long id){
|
|
|
- IpInterfacePO ipInterfacePO = ipInterfaceRepository.queryById(id);
|
|
|
- IpInterfaceVO ipInterfaceVO = new IpInterfaceVO();
|
|
|
- if(ipInterfacePO != null){
|
|
|
- BeanUtils.copyProperties(ipInterfacePO, ipInterfaceVO);
|
|
|
- return ipInterfaceVO;
|
|
|
+// IpInterfacePO ipInterfacePO = ipInterfaceRepository.findById(id).get();
|
|
|
+ Optional<IpInterfacePO> optional = ipInterfaceRepository.findById(id);
|
|
|
+ if(optional.isPresent()) {
|
|
|
+ IpInterfacePO ipInterfacePO=optional.get();
|
|
|
+ IpInterfaceVO ipInterfaceVO = new IpInterfaceVO();
|
|
|
+ if (ipInterfacePO != null) {
|
|
|
+ BeanUtils.copyProperties(ipInterfacePO, ipInterfaceVO);
|
|
|
+ return ipInterfaceVO;
|
|
|
+ }
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
@@ -86,10 +91,12 @@ public class IpInterfaceServiceImpl implements IpInterfaceService {
|
|
|
|
|
|
@Override
|
|
|
public Boolean switchStatus(SwitchStatusParam switchStatusParam) {
|
|
|
- IpInterfacePO ipInterfacePO = ipInterfaceRepository.queryById(switchStatusParam.getId());
|
|
|
- if(ipInterfacePO == null){
|
|
|
+ Optional<IpInterfacePO> optional = ipInterfaceRepository.findById(switchStatusParam.getId());
|
|
|
+ if(!optional.isPresent()){
|
|
|
throw new RuntimeException("接口不存在");
|
|
|
}
|
|
|
+ IpInterfacePO ipInterfacePO = optional.get();
|
|
|
+
|
|
|
ipInterfacePO.setStatus(switchStatusParam.getStatus());
|
|
|
ipInterfaceRepository.save(ipInterfacePO);
|
|
|
return true;
|