diff --git a/docker-compose.yml b/docker-compose.yml index a9aafa8..64c8fe2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,20 +23,5 @@ services: timeout: 10s retries: 5 - app: - image: 'springbootneo4jshortestpath:latest' - build: - context: . - dockerfile: Dockerfile - container_name: SpringBootNeo4jShortestPath - depends_on: - neo4j-db: - condition: service_healthy # Wait for neo4j to be ready - links: - - neo4j-db - environment: - NEO4J_URI: bolt://neo4j-db:7687 - NEO4J_PASSWORD: 123456 - volumes: app-neo4j-db: \ No newline at end of file diff --git a/src/main/java/com/springshortpath/app/model/City.java b/src/main/java/com/springshortpath/app/model/City.java index 8cdbe78..4bbcf84 100644 --- a/src/main/java/com/springshortpath/app/model/City.java +++ b/src/main/java/com/springshortpath/app/model/City.java @@ -5,6 +5,7 @@ import org.springframework.data.neo4j.core.schema.Node; import org.springframework.data.neo4j.core.schema.Property; import org.springframework.data.neo4j.core.schema.Relationship; +import org.springframework.data.neo4j.core.support.UUIDStringGenerator; import java.util.HashSet; import java.util.Set; @@ -19,6 +20,7 @@ public class City { @Id + @GeneratedValue(GeneratedValue.UUIDGenerator.class) @Property private UUID id; @@ -31,4 +33,14 @@ public class City { public City(String name) { this.name = name; } + + public City withId(UUID id) { + if (this.id.equals(id)) { + return this; + } else { + City newObject = new City(this.name); + newObject.id = id; + return newObject; + } + } } diff --git a/src/main/java/com/springshortpath/app/service/impl/CityServiceImpl.java b/src/main/java/com/springshortpath/app/service/impl/CityServiceImpl.java index fed3810..1d37346 100644 --- a/src/main/java/com/springshortpath/app/service/impl/CityServiceImpl.java +++ b/src/main/java/com/springshortpath/app/service/impl/CityServiceImpl.java @@ -34,7 +34,7 @@ public City getByCityName(String cityName) { @Override public City saveCity(City city) { - return cityRepository.saveCity(city.getName()); + return cityRepository.save(city); } @Override