Changeset 8d391a1 for trip-planner
- Timestamp:
- 11/26/21 20:07:18 (3 years ago)
- Branches:
- master
- Children:
- 1ad8e64
- Parents:
- e29cc2e
- Location:
- trip-planner/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaLocationRepository.java
re29cc2e r8d391a1 84 84 List<Location> getAllLocationsForPlanner(@Param("plannerId") Long plannerId); 85 85 86 87 @Query(value = "SELECT l.id_location " + 88 "FROM locations AS l " + 89 "WHERE l.id_location IN " + 90 "(SELECT pl.id_location FROM planners_contain AS pl WHERE pl.id_planner = :plannerId)", nativeQuery = true) 91 List<Long> getAllLocationIdsForPlanner(@Param("plannerId") Long plannerId); 92 86 93 @Query(value = "SELECT *, if(l.id_city is NOT NULL, c.city_name, l.location_name) as result " + 87 94 "FROM locations AS l " + -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/LocationService.java
re29cc2e r8d391a1 5 5 import finki.diplomska.tripplanner.models.Planner; 6 6 import finki.diplomska.tripplanner.models.dto.PlannerLocationDto; 7 import org.springframework.data.repository.query.Param; 7 8 8 9 import java.util.List; … … 23 24 List<Location> getWeekendGetaways(); 24 25 List<Location> getVillages(); 26 List<Long> getAllLocationIdsForPlanner(Long plannerId); 25 27 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/LocationServiceImpl.java
re29cc2e r8d391a1 179 179 } 180 180 181 @Override 182 public List<Long> getAllLocationIdsForPlanner(Long plannerId) { 183 return this.locationRepository.getAllLocationIdsForPlanner(plannerId); 184 } 185 181 186 182 187 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/LocationRestController.java
re29cc2e r8d391a1 5 5 import finki.diplomska.tripplanner.service.LocationService; 6 6 import finki.diplomska.tripplanner.service.PlannerService; 7 import org.springframework.data.repository.query.Param; 7 8 import org.springframework.http.ResponseEntity; 8 9 import org.springframework.web.bind.annotation.*; … … 71 72 return this.locationService.getVillages(); 72 73 } 74 75 @GetMapping(value = "/planner/locationIds") 76 public List<Long> getAllLocationIdsForPlanner(@RequestParam Long plannerId){ 77 return this.locationService.getAllLocationIdsForPlanner(plannerId); 78 } 73 79 } -
trip-planner/src/test/api.http
re29cc2e r8d391a1 61 61 62 62 ### 63 GET http://localhost:8080/api/planner/locationIds?plannerId=2 64 Content-Type: application/x-www-form-urlencoded 65 66 ### 63 67 GET http://localhost:8080/api/weekend 64 68 Content-Type: application/x-www-form-urlencoded
Note:
See TracChangeset
for help on using the changeset viewer.