null 처리 추가
This commit is contained in:
@@ -7,6 +7,7 @@ import com.eactive.testmaster.server.dto.ServerOptionDTO;
|
||||
import com.eactive.testmaster.server.entity.Server;
|
||||
import com.eactive.testmaster.server.entity.ServerOption;
|
||||
import com.eactive.testmaster.server.repository.ServerRepository;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -76,14 +77,14 @@ public class ServerMapper {
|
||||
}
|
||||
public List<ServerOption> mapOptions(List<ServerOptionDTO> dtos) {
|
||||
if (dtos == null) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return dtos.stream().map(this::map).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<ServerOptionDTO> mapOptionsDTO(List<ServerOption> entities) {
|
||||
if (entities == null) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return entities.stream().map(this::map).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -26,10 +26,12 @@ public class ServerMgmtService {
|
||||
}
|
||||
|
||||
public void create(Server server) {
|
||||
if (server.getServerOptions()!=null){
|
||||
server.getServerOptions().forEach(serverOption -> {
|
||||
serverOption.setEnabled(true);
|
||||
serverOption.setServer(server);
|
||||
});
|
||||
}
|
||||
serverRepository.save(server);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user