Changeset 59329aa for trip-planner


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
Files:
5 added
8 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}
  • trip-planner/src/main/resources/templates/trip-locations-country.html

    rceaed42 r59329aa  
    2727              <span th:text="${loc.getCity().getName()}"/>
    2828            </td>
    29             <!--  <td><img th:src="*{'data:image/jpeg;base64,'+ imgUtil.getImgData(loc.getPhoto())}" alt="" /></td> -->
     29             <td><img th:src="*{'data:image/jpeg;base64,'+ imgUtil.getImgData(loc.getPhoto())}" alt="" /></td>
    3030
    3131            <td>
  • trip-planner/src/main/resources/templates/trip-locations.html

    rceaed42 r59329aa  
    5858            <td th:text="${loc.getName()}" ></td>
    5959            <td th:text="${loc.getId()}"  ></td>
    60         <!--    <td><img th:src="*{'data:image/jpeg;base64,'+ imgUtil.getImgData(loc.getPhoto())}" alt="" /></td> -->
     60        <td><img th:src="*{'data:image/jpeg;base64,'+ imgUtil.getImgData(loc.getPhoto())}" alt="" /></td>
    6161            <td class="selectedLocation">
    6262              <a th:href="@{'/create/trip/locations/{id}' (id=${loc.getId()})}" class="btn btn-primary " >Add to planner</a>
  • trip-planner/src/test/api.http

    rceaed42 r59329aa  
    6060Content-Type: application/x-www-form-urlencoded
    6161
     62###
     63GET http://localhost:8080/api/weekend
     64Content-Type: application/x-www-form-urlencoded
     65
     66###
     67GET http://localhost:8080/api/villages
     68Content-Type: application/x-www-form-urlencoded
     69
     70###
     71GET http://localhost:8080/api/images?locationId=1
     72Content-Type: application/x-www-form-urlencoded
Note: See TracChangeset for help on using the changeset viewer.