Skip to content
Snippets Groups Projects
Commit d2d0609d authored by hugcubi's avatar hugcubi
Browse files

Arregladas las cosas para que conecten bien bookings, hotels y users

parent 9d629449
No related branches found
No related tags found
2 merge requests!36Develop,!31Dev/refactor hotels booking
......@@ -17,7 +17,8 @@ public class ClientApi {
private String CLIENTS_API_URL;
public boolean existsById(int id) {
String url = CLIENTS_API_URL + "/{id}";
String url = CLIENTS_API_URL + "/" + id;
System.out.println(url);
ResponseEntity<Void> response = restTemplate.getForEntity(url, Void.class, id);
return response.getStatusCode() == HttpStatus.OK;
}
......
......@@ -14,5 +14,5 @@ security.jwt.secret-key=MiClaveDeSeguridadMuyLargaParaQueNoFalleSpringBoot
security.jwt.expiration-time=3600000
security.jwt.kid=cYz3kNRLAirxVhHXQ5rh5xKrOwHwZVui
external.services.clients.url=localhost:8201/users/clients
external.services.hotels.url=localhost:8301/hotels
\ No newline at end of file
external.services.clients.url=http://localhost:8201/users/clients
external.services.hotels.url=http://localhost:8301/hotels
\ No newline at end of file
......@@ -21,7 +21,7 @@ public class BookingAPI {
public List<Booking> getAllBookingsByUserId(int id) {
String url = BOOKING_API_URL + "?userId={id}";
System.out.println("\n" + url);
Booking[] bookingsArray = restTemplate
.getForObject(url, Booking[].class, id);
......
package com.uva.api.services;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeanUtils;
......@@ -31,11 +32,18 @@ public class ClientService {
public Client findById(int id) {
Client client = Utils.assertUser(clientRepository.findById(id));
List<Booking> bookings = bookingAPI.getAllBookingsByUserId(client.getId());
List<Booking> bookings;
try {
bookings = bookingAPI.getAllBookingsByUserId(client.getId());
} catch (Exception e) {
bookings = new ArrayList<>();
}
client.setBookings(bookings);
return client;
}
public Client deleteById(int id) {
Client client = Utils.assertUser(clientRepository.findById(id));
clientRepository.delete(client);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment