Ignore:
Timestamp:
11/23/21 14:58:44 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
e29cc2e
Parents:
ceaed42
Message:

adding photos

Location:
trip-planner/src/main/java/finki/diplomska/tripplanner
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • trip-planner/src/main/java/finki/diplomska/tripplanner/models/Location.java

    rceaed42 r59329aa  
    22
    33import com.fasterxml.jackson.annotation.JsonBackReference;
     4import com.fasterxml.jackson.annotation.JsonManagedReference;
    45import lombok.AllArgsConstructor;
    56import lombok.Getter;
     
    7273
    7374
     75    @OneToMany(mappedBy = "location", cascade = CascadeType.REMOVE, orphanRemoval = true)
     76    @JsonManagedReference
     77    private List<Images> imagesList;
     78
     79
    7480}
  • trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaLocationRepository.java

    rceaed42 r59329aa  
    8383            "(SELECT pl.id_location FROM planners_contain AS pl WHERE pl.id_planner = :plannerId)", nativeQuery = true)
    8484    List<Location> getAllLocationsForPlanner(@Param("plannerId") Long plannerId);
     85
     86    @Query(value = "SELECT *, if(l.id_city is NOT NULL, c.city_name, l.location_name) as result " +
     87            "FROM locations AS l " +
     88            "LEFT JOIN cities AS c " +
     89            "ON l.id_city = c.id_city " +
     90            "LEFT JOIN locations_belong AS lb " +
     91            "ON l.id_location = lb.id_location " +
     92            "WHERE lb.id_category=20", nativeQuery = true)
     93    List<Location> getWeekendGetaways();
     94
     95    @Query(value = "SELECT *, if(l.id_city is NOT NULL, c.city_name, l.location_name) as result " +
     96            "FROM locations AS l " +
     97            "LEFT JOIN cities AS c " +
     98            "ON l.id_city = c.id_city " +
     99            "LEFT JOIN locations_belong AS lb " +
     100            "ON l.id_location = lb.id_location " +
     101            "WHERE lb.id_category=4", nativeQuery = true)
     102    List<Location> getVillages();
    85103}
  • trip-planner/src/main/java/finki/diplomska/tripplanner/service/LocationService.java

    rceaed42 r59329aa  
    2121    Location addLocationToPlanner(PlannerLocationDto plannerLocationDto);
    2222    List<Location> getAllLocationsForPlanner(Long plannerId);
    23 
     23    List<Location> getWeekendGetaways();
     24    List<Location> getVillages();
    2425}
  • trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/LocationServiceImpl.java

    rceaed42 r59329aa  
    169169    }
    170170
     171    @Override
     172    public List<Location> getWeekendGetaways() {
     173        return this.locationRepository.getWeekendGetaways();
     174    }
     175
     176    @Override
     177    public List<Location> getVillages() {
     178        return this.locationRepository.getVillages();
     179    }
     180
    171181
    172182}
  • trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/LocationRestController.java

    rceaed42 r59329aa  
    6161        return this.locationService.getAllLocationsForPlanner(plannerId);
    6262    }
     63
     64    @GetMapping(value = "weekend")
     65    public List<Location> getWeekendGetaways(){
     66        return this.locationService.getWeekendGetaways();
     67    }
     68
     69    @GetMapping(value = "villages")
     70    public List<Location> getVillages(){
     71        return this.locationService.getVillages();
     72    }
    6373}
Note: See TracChangeset for help on using the changeset viewer.