Changeset eed0bf8 for trip-planner/src/main
- Timestamp:
- 10/18/21 00:19:16 (3 years ago)
- Branches:
- master
- Children:
- 188ee53
- Parents:
- fa375fe
- Location:
- trip-planner/src/main/java/finki/diplomska/tripplanner
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaLocationRepository.java
rfa375fe reed0bf8 44 44 "GROUP BY l.id_location ORDER BY CASE l.priority WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 END", nativeQuery = true) 45 45 List<Location> findLocationsFromCountry(@Param("locName") String ime, @Param("companion") String companion, @Param("region") String region, @Param("categories") List<String> categories); 46 47 @Query(value = "SELECT * FROM locations AS l " + 48 "LEFT JOIN recommended_companion AS rc ON l.id_location = rc.id_location " + 49 "LEFT JOIN companions AS com ON rc.id_companion = com.id_companion " + 50 "LEFT JOIN locations_belong lb ON l.id_location = lb.id_location " + 51 "LEFT JOIN categories AS cate ON lb.id_category = cate.id_category " + 52 "LEFT JOIN regions AS r" + 53 " ON l.id_region = r.id_region" + 54 " LEFT JOIN cities AS cit" + 55 " ON r.id_region = cit.id_region AND cit.id_city = l.id_city " + 56 "WHERE cit.id_city = :locationId and com.id_companion = :companionId and cate.id_category in (:categories) " + 57 "GROUP BY l.id_location " + 58 "ORDER BY CASE l.priority WHEN 'high' THEN 1 WHEN 'medium' THEN 2 WHEN 'low' THEN 3 END", nativeQuery = true) 59 List<Location> findLocationsFromForm(@Param("locationId") Long locationId, @Param("companionId") Long companionId, @Param("categories") List<Long> categories); 46 60 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/LocationService.java
rfa375fe reed0bf8 15 15 List<Location> scheduleLocations(String locName, String companion,String region, List<String> categories, int numberOfDays); 16 16 Optional<Location> findById(Long id); 17 18 List<Location> findLocations(Long locationId, Long companionId, Long lengthOfStay, String categoryIds); 17 19 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/LocationServiceImpl.java
rfa375fe reed0bf8 8 8 9 9 import java.util.*; 10 import java.util.stream.Collectors; 10 11 11 12 … … 46 47 public Optional<Location> findById(Long id) { 47 48 return this.locationRepository.findById(id); 49 } 50 51 @Override 52 public List<Location> findLocations(Long locationId, Long companionId, Long lengthOfStay, String categoryIds) { 53 List<Long> categories = null; 54 if(categoryIds != null && !categoryIds.isEmpty()){ 55 List<String> ids = Arrays.asList(categoryIds.split(",")); 56 categories = ids.stream().map(Long::valueOf).collect(Collectors.toList()); 57 } 58 List<Location> foundLocations = locationRepository.findLocationsFromForm(locationId, companionId, categories); 59 return foundLocations; 48 60 } 49 61 -
trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/LocationRestController.java
rfa375fe reed0bf8 34 34 } 35 35 36 @ PostMapping(value = "/trip/locations")37 public List<Location> allLocationsAfterSubmittedForm(@RequestParam(required = false) String locName,38 @RequestParam(required = false) String companion,39 @RequestParam(required = false) String region,40 @RequestParam(required = false) List<String> categories,41 @RequestParam(required = false) int numberOfDays) {42 List<Location> generatedLocations = this.locationService.scheduleLocations(locName, companion, region, categories, numberOfDays);36 @GetMapping(value = "/trip/locations") 37 public List<Location> allLocationsAfterSubmittedForm(@RequestParam(required = false) Long locationId, 38 @RequestParam(required = false) Long companionId, 39 @RequestParam(required = false) Long lengthOfStay, 40 @RequestParam(required = false) String categoryIds) { 41 return this.locationService.findLocations(locationId, companionId, lengthOfStay, categoryIds); 42 /* List<Location> generatedLocations = this.locationService.scheduleLocations(locName, companion, region, categories, numberOfDays); 43 43 if(locName.equals("Macedonia")){ 44 44 return generatedLocations; 45 45 }else{ 46 46 return generatedLocations; 47 } 47 }*/ 48 48 } 49 49 }
Note:
See TracChangeset
for help on using the changeset viewer.