Changeset 76712b2 for trip-planner/src/main/java/finki/diplomska
- Timestamp:
- 01/28/22 18:45:54 (3 years ago)
- Branches:
- master
- Children:
- 6fe77af
- Parents:
- b738035
- Location:
- trip-planner/src/main/java/finki/diplomska/tripplanner
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaLocationRepository.java
rb738035 r76712b2 109 109 List<Location> getVillages(); 110 110 111 @Query(value = "SELECT * FROM locations AS l WHERE l.id_city = :cityId", nativeQuery = true) 112 List<Location> getLocationsForCity(@Param("cityId") Long cityId); 111 @Query(value = "SELECT * FROM locations AS l " + 112 "LEFT JOIN cities AS c " + 113 "ON l.id_city = c.id_city " + 114 "LEFT JOIN regions AS r " + 115 "ON l.id_region = r.id_region " + 116 "WHERE c.city_name = :place OR r.region_name = :place", nativeQuery = true) 117 List<Location> getAllLocations(@Param("place") String place); 113 118 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaRegionRepository.java
rb738035 r76712b2 3 3 import finki.diplomska.tripplanner.models.Region; 4 4 import org.springframework.data.jpa.repository.JpaRepository; 5 import org.springframework.data.jpa.repository.Query; 5 6 import org.springframework.stereotype.Repository; 7 8 import java.util.List; 6 9 7 10 @Repository 8 11 public interface JpaRegionRepository extends JpaRepository<Region, Long> { 12 13 @Query(value="SELECT r.region_name " + 14 "FROM regions AS r " + 15 "UNION all " + 16 "SELECT c.city_name FROM cities AS c", nativeQuery = true) 17 List<String> getAllCitiesAndRegions(); 9 18 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConfig.java
rb738035 r76712b2 79 79 .antMatchers("/api/villages").permitAll() 80 80 .antMatchers("/api/cities").permitAll() 81 .antMatchers("/api/all").permitAll() 82 .antMatchers("/api/places").permitAll() 81 83 .anyRequest().authenticated(); 82 84 http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class); -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/LocationService.java
rb738035 r76712b2 25 25 List<Location> getVillages(); 26 26 List<Long> getAllLocationIdsForPlanner(Long plannerId); 27 List<Location> get LocationsForCity(Long cityId);27 List<Location> getAllLocations(String place); 28 28 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/RegionService.java
rb738035 r76712b2 7 7 public interface RegionService { 8 8 List<Region> findAll(); 9 List<String> getAllCitiesAndRegions(); 9 10 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/LocationServiceImpl.java
rb738035 r76712b2 185 185 186 186 @Override 187 public List<Location> get LocationsForCity(Long cityId) {188 return this.locationRepository.get LocationsForCity(cityId);187 public List<Location> getAllLocations(String place) { 188 return this.locationRepository.getAllLocations(place); 189 189 } 190 191 190 192 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/RegionServiceImpl.java
rb738035 r76712b2 21 21 return this.regionRepository.findAll(); 22 22 } 23 24 @Override 25 public List<String> getAllCitiesAndRegions() { 26 return this.regionRepository.getAllCitiesAndRegions(); 27 } 23 28 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/LocationRestController.java
rb738035 r76712b2 77 77 } 78 78 79 @GetMapping(value = "/all") 80 public List<Location> getAllLocations(@RequestParam String place){ 81 return this.locationService.getAllLocations(place); 82 } 83 79 84 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/RegionRestController.java
rb738035 r76712b2 25 25 return this.regionService.findAll(); 26 26 } 27 28 @GetMapping(value = "/places") 29 public List<String> getAllCitiesAndRegions(){ 30 return this.regionService.getAllCitiesAndRegions(); 31 } 27 32 }
Note:
See TracChangeset
for help on using the changeset viewer.