Changeset ac19a0c for src/main/java/com
- Timestamp:
- 01/13/24 23:19:50 (10 months ago)
- Branches:
- master
- Children:
- e85a562
- Parents:
- e9b4ba9
- Location:
- src/main/java/com/tourMate
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/tourMate/config/SecurityConfig.java
re9b4ba9 rac19a0c 7 7 import org.springframework.http.HttpHeaders; 8 8 import org.springframework.http.HttpMethod; 9 import org.springframework.http.HttpStatus; 9 10 import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 11 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; … … 14 15 import org.springframework.security.web.SecurityFilterChain; 15 16 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 17 import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; 16 18 import org.springframework.security.web.util.matcher.AntPathRequestMatcher; 17 19 import org.springframework.web.cors.CorsConfiguration; … … 72 74 .anyRequest().authenticated() 73 75 .and() 74 .formLogin() .loginPage("http://localhost:3000/login")76 .formLogin() 75 77 .loginProcessingUrl("/api/login").usernameParameter("username").passwordParameter("password") 76 78 .successHandler((request, response, authentication) -> { 77 79 response.setStatus(HttpServletResponse.SC_OK); 80 response.setCharacterEncoding("UTF-8"); 78 81 response.setContentType("application/json"); 79 82 response.getWriter().print("{\"message\": \"Login successful\","); … … 83 86 .failureHandler((request, response, exception) -> { 84 87 response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); 85 response.getWriter().print("Pukla veza\n" + exception.getMessage()); 88 response.sendRedirect("/login"); 89 response.getWriter().print("Neuspesna najava\n" + exception.getMessage()); 86 90 response.getWriter().flush(); 87 91 }) … … 91 95 .sessionCreationPolicy(SessionCreationPolicy.ALWAYS) 92 96 .and() 93 .logout() 97 .logout().logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))) 94 98 .permitAll(); 95 99 -
src/main/java/com/tourMate/controllers/HotelController.java
re9b4ba9 rac19a0c 2 2 3 3 import com.tourMate.dto.HotelDto; 4 import com.tourMate.dto.HotelReservationDto; 5 import com.tourMate.dto.HotelReservationUserDto; 4 6 import com.tourMate.entities.*; 5 7 import com.tourMate.services.HotelManager; … … 117 119 //HOTEL ROOM CRUD 118 120 @PostMapping(path = "/hotel/rooms/add") 119 public void addRoom(@RequestBody HotelRoom room, @RequestParam(name = "hotelId") long hotelId) { 121 public void addRoom(@RequestBody HotelRoom room, 122 @RequestParam(name = "hotelId") long hotelId) { 120 123 Hotels h = hotelManager.findHotelByID(hotelId); 121 hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice() );124 hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice(), room.getNumOfBeds()); 122 125 } 123 126 … … 162 165 //HOTEL AVAILABILITY CRUD 163 166 @PostMapping(path = "/hotel/rooms/available/{id}/add") 164 public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, @PathVariable long id) 167 public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, 168 @PathVariable long id) 165 169 { 166 170 HotelRoom hotelRoom = hotelManager.findRoomById(id); … … 191 195 public List<HotelRoomAvailable> getRoomAvailability(@PathVariable Long id) 192 196 { 193 return hotelManager.getRoomsAvail ibility();197 return hotelManager.getRoomsAvailableById(id); 194 198 } 195 199 196 200 @GetMapping(path = "/hotel/search") 197 public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, 198 @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, @RequestParam(name = "numBeds") int numBeds) 201 public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, 202 @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, 203 @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, 204 @RequestParam(name = "numBeds") int numBeds) 199 205 { 200 206 System.out.println(hotelLocation); … … 216 222 } 217 223 224 @GetMapping(path = "/hotel/{id}/reservations/active") 225 public List<HotelReservationDto> getActiveReservationsForHotel(@PathVariable Long id) 226 { 227 return hotelManager.findVaidReseravtionsByHotel(id); 228 } 229 230 @GetMapping(path = "/hotel/reservations/user/{id}") 231 public List<HotelReservationUserDto> getActiveReservationsForUser(@PathVariable Long id) 232 { 233 return hotelManager.findValidHotelReservationsByUser(id); 234 } 218 235 } -
src/main/java/com/tourMate/controllers/TransportController.java
re9b4ba9 rac19a0c 23 23 24 24 // TRANSPORT CRUD // 25 @PostMapping(path = "/transport/add") 26 public void add(@RequestBody Transport transport) { 27 transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), new User(), transport.getCarPlate()); 25 @PostMapping(path = "/transport/add/{userId}") 26 public void add(@RequestBody Transport transport, 27 @PathVariable Long userId) { 28 transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), userId, transport.getCarPlate()); 28 29 29 30 } … … 48 49 public TransportDto getTransport(@PathVariable(name = "id") long transportId) 49 50 { 50 System.out.println("TUKA SUUUUUM");51 51 return transportManager.findTransportById(transportId); 52 52 } … … 92 92 @PostMapping(path = "/transport/available/add") 93 93 public void add(@RequestBody TransportAvailible transportAvailable, @RequestParam(name = "transportId") long transportId) { 94 System.out.println("OREEEEEL");95 System.out.println("DVA ORLA");96 94 Transport t = transportManager.getTransportById(transportId); 97 95 List<TransportRoute> routes = transportAvailable.getRoutes().stream().toList(); … … 135 133 136 134 @GetMapping(path = "/transport/search") 137 public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, @RequestParam(name = "to") String to, 138 @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date){ 139 return transportManager.getTransportsAvailableByFilters(from, to, date); 135 public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, 136 @RequestParam(name = "to") String to, 137 @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date, 138 @RequestParam(name = "numPassengers") int numPassengers){ 139 return transportManager.getTransportsAvailableByFilters(from, to, date, numPassengers); 140 140 } 141 141 } -
src/main/java/com/tourMate/controllers/UsersController.java
re9b4ba9 rac19a0c 11 11 import org.springframework.web.bind.annotation.*; 12 12 13 import java.util.ArrayList;14 13 import java.util.List; 15 14 … … 39 38 { 40 39 return businessManager.getUnapprovedBusinessesOfUser(userId); 40 } 41 42 @GetMapping(path = "/business/unapproved") 43 public List<Business> getAllUnapprovedBusinesses() 44 { 45 return businessManager.getUnapprovedBusinesses(); 46 } 47 48 @GetMapping(path = "/users/unapproved") 49 public List<User> getAllUnapprovedUsers() 50 { 51 return usersManager.getUnapprovedUsers(); 52 } 53 54 @GetMapping(path = "/users/approve/{userId}") 55 public ResponseEntity<?> approveUserProfile(@PathVariable Long userId) 56 { 57 usersManager.approveUserProfile(userId); 58 return new ResponseEntity<>(HttpStatus.OK); 59 60 61 } 62 63 @GetMapping(path = "/business/approve/{businessId}") 64 public ResponseEntity<?> approveBusiness(@PathVariable Long businessId) 65 { 66 businessManager.approveBusiness(businessId); 67 return new ResponseEntity<>(HttpStatus.OK); 41 68 } 42 69 -
src/main/java/com/tourMate/dao/BusinessDao.java
re9b4ba9 rac19a0c 11 11 @Transactional 12 12 void createBusiness(Business business, long userId); 13 publicList<Business> getUnapprovedBusinessesOfUser(long userId);14 publicvoid deleteBusiness(long businessId);15 publicList<Business> getCreatedBusinesses();16 publicBusiness findBusinessById (long businessId);13 List<Business> getUnapprovedBusinessesOfUser(long userId); 14 void deleteBusiness(long businessId); 15 List<Business> getCreatedBusinesses(); 16 Business findBusinessById (long businessId); 17 17 18 18 @Transactional 19 19 void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved); 20 publicboolean hasBusiness(long userId);20 boolean hasBusiness(long userId); 21 21 22 List<Business> getUnapprovedBusinesses(); 23 24 void approveBusiness(Business business); 22 25 } -
src/main/java/com/tourMate/dao/HotelDao.java
re9b4ba9 rac19a0c 23 23 public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 24 24 25 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price );25 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds); 26 26 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String HotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 27 27 public void deleteRoom(long hotelRoomId); -
src/main/java/com/tourMate/dao/TransportDao.java
re9b4ba9 rac19a0c 12 12 public interface TransportDao { 13 13 14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate); 15 15 16 16 public void deleteTransport(long transportId); … … 47 47 public List<TransportAvailible> getTransportsAvailable(); 48 48 49 public List<TransportRoute> getTransportsAvailableByFilters (String from, String to,Date date);49 public List<TransportRoute> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers); 50 50 51 51 public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order); -
src/main/java/com/tourMate/dao/UsersDao.java
re9b4ba9 rac19a0c 23 23 24 24 UserDetails findUserByUsername(String username); 25 26 List<User> getUnapprovedUsers(); 27 28 void approveUserProfile(User u); 25 29 } -
src/main/java/com/tourMate/dao/impl/BusinessDaoImpl.java
re9b4ba9 rac19a0c 46 46 } 47 47 48 @Override 49 public List<Business> getUnapprovedBusinesses() { 50 return em.createQuery("select b from Business b where not b.approved").getResultList(); 51 } 52 53 @Override 54 @Transactional 55 public void approveBusiness(Business b) { 56 b.setApproved(true); 57 em.persist(b); 58 } 59 48 60 49 61 @Override -
src/main/java/com/tourMate/dao/impl/HotelDaoImpl.java
re9b4ba9 rac19a0c 28 28 public List<Hotels> getHotels() { 29 29 List<Hotels> hoteli = em.createQuery("select h from Hotels h order by h.hotelId").getResultList(); 30 System.out.println("OREEEEEEL");31 30 return hoteli; 32 31 //return em.createQuery("select h from Hotels h order by h.hotelId").getResultList(); … … 119 118 @Transactional 120 119 @Override 121 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price ) {122 HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price );120 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 121 HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price, numOfBeds); 123 122 em.persist(hotelRoom); 124 123 } … … 188 187 public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds) { 189 188 return em.createQuery("select hr from HotelRoomAvailable hr where hr.dateFrom <= :dateFrom and hr.dateTo >= :dateTo " + 190 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr. numberOfBeds >= :numBeds")189 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr.hotelRoom.numOfBeds >= :numBeds") 191 190 .setParameter("hotelLocation", hotelLocation) 192 191 .setParameter("dateFrom", dateFrom) … … 236 235 public List<HotelRoomReservations> findReservationByHotel(Hotels hotel) { 237 236 List<HotelRoom> hotelRooms = getRoomsOfHotel(hotel.getHotelId()); 238 return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom in :hotelRooms").setParameter("hotelRooms", hotelRooms).getResultList();237 return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom.hotel = :hotel").setParameter("hotel", hotel).getResultList(); 239 238 } 240 239 -
src/main/java/com/tourMate/dao/impl/TransportDaoImpl.java
re9b4ba9 rac19a0c 22 22 @Override 23 23 @Transactional 24 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) {25 User u = em.find(User.class, 1);24 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) { 25 User u = em.find(User.class, userId); 26 26 Transport t=new Transport(transportName,carBrand,carType,carManufacturedYear,noPassengers,noBags,EMBG,u,carPlate); 27 27 em.persist(t); … … 62 62 y.getFreeSpace(), 63 63 y.getTime(), 64 y.getRoutes() 65 )).toList() 64 y.getRoutes(), 65 y.getRoutes().stream() 66 .mapToDouble(TransportRoute::getPrice) 67 .max().orElse(0) 68 )).toList(), 69 x.getAvailableRoutes().stream() 70 .flatMapToDouble(y -> y.getRoutes() 71 .stream() 72 .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0) 66 73 )).toList(); 67 74 } … … 78 85 x.getFreeSpace(), 79 86 x.getTime(), 80 x.getRoutes() 87 x.getRoutes(), 88 x.getRoutes().stream() 89 .mapToDouble(TransportRoute::getPrice) 90 .max().orElse(0) 81 91 )).toList(); 82 92 } … … 103 113 y.getFreeSpace(), 104 114 y.getTime(), 105 y.getRoutes() 106 )).toList()); 115 y.getRoutes(), 116 y.getRoutes().stream() 117 .mapToDouble(TransportRoute::getPrice) 118 .max().orElse(0) 119 )).toList(), 120 x.getAvailableRoutes().stream() 121 .flatMapToDouble(y -> y.getRoutes() 122 .stream() 123 .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0)); 107 124 } 108 125 … … 151 168 152 169 @Override 153 public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date ) {170 public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date, int numPassengers) { 154 171 System.out.println(fromL + " " + toL); 155 return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol").setParameter("froml", fromL). 156 setParameter("tol", toL).getResultList(); 172 return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol and h.freeSpace >= :nump") 173 .setParameter("froml", fromL) 174 .setParameter("tol", toL) 175 .setParameter("nump", numPassengers) 176 .getResultList(); 157 177 } 158 178 -
src/main/java/com/tourMate/dao/impl/UsersDaoImpl.java
re9b4ba9 rac19a0c 74 74 } 75 75 76 @Override 77 public List<User> getUnapprovedUsers() { 78 return em.createQuery("select u from User u where not u.enabled").getResultList(); 79 } 80 81 @Override 82 @Transactional 83 public void approveUserProfile(User u) { 84 u.setEnabled(true); 85 em.persist(u); 86 } 76 87 77 88 -
src/main/java/com/tourMate/dto/RouteListingDto.java
re9b4ba9 rac19a0c 18 18 private Date time; 19 19 private Collection<String> routes; 20 private Double maxPrice; 20 21 21 public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes ) {22 public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes, Double maxPrice) { 22 23 this.transportAvailibleId = transportAvailibleId; 23 24 this.from = from; … … 27 28 this.time = time; 28 29 this.routes = routes.stream().map(x -> x.getFrom()).distinct().skip(1).toList(); 30 this.maxPrice = maxPrice; 29 31 } 30 32 … … 84 86 this.routes = routes; 85 87 } 88 89 public Double getMaxPrice() { 90 return maxPrice; 91 } 86 92 } -
src/main/java/com/tourMate/dto/TransportDto.java
re9b4ba9 rac19a0c 16 16 private User owner; 17 17 private String carPlate; 18 private Double maxPrice; 18 19 private Collection<RouteListingDto> availableRoutes; 19 20 20 public TransportDto(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate, Collection<RouteListingDto> availableRoutes ) {21 public TransportDto(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate, Collection<RouteListingDto> availableRoutes, Double maxPrice) { 21 22 this.transportID = transportID; 22 23 this.transportName = transportName; … … 30 31 this.carPlate = carPlate; 31 32 this.availableRoutes = availableRoutes; 33 this.maxPrice = maxPrice; 32 34 } 33 35 -
src/main/java/com/tourMate/entities/Business.java
re9b4ba9 rac19a0c 88 88 } 89 89 90 @OneToOne(fetch = FetchType. LAZY)90 @OneToOne(fetch = FetchType.EAGER) 91 91 @JoinColumn(name = "owner_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_biznis_kon_korisnik")) 92 92 public User getUser() { … … 107 107 this.approved = approved; 108 108 } 109 109 110 } -
src/main/java/com/tourMate/entities/HotelRoom.java
re9b4ba9 rac19a0c 16 16 private String hotelRoomName; 17 17 private double price; 18 private int numOfBeds; 18 19 private Boolean kitchenAvailable; 19 20 private Boolean airConditioning; 20 21 private Boolean balcony; 21 22 22 public HotelRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, double price, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony ) {23 public HotelRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, double price, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, int numOfBeds) { 23 24 this.hotelRoomId = hotelRoomId; 24 25 this.hotel = hotel; … … 29 30 this.airConditioning = airConditioning; 30 31 this.balcony = balcony; 32 this.numOfBeds = numOfBeds; 31 33 } 32 34 33 35 public HotelRoom(Hotels hotel, String hotelRoomDescription, String type, 34 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price ) {36 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 35 37 this.hotel = hotel; 36 38 this.hotelRoomDescription = hotelRoomDescription; … … 40 42 this.balcony = balcony; 41 43 this.price = price; 44 this.numOfBeds = numOfBeds; 42 45 } 43 46 44 47 public HotelRoom(String hotelRoomDescription, String type, 45 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price ) {48 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 46 49 this.hotel = hotel; 47 50 this.hotelRoomDescription = hotelRoomDescription; … … 51 54 this.balcony = balcony; 52 55 this.price = price; 56 this.numOfBeds = numOfBeds; 53 57 } 54 58 … … 68 72 } 69 73 70 @ManyToOne(fetch = FetchType. LAZY)74 @ManyToOne(fetch = FetchType.EAGER) 71 75 @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_room_kon_hotel")) 72 76 public Hotels getHotel() { … … 134 138 this.balcony = balcony; 135 139 } 140 141 @Column(name = "hotel_room_num_beds", unique = false) 142 public int getNumOfBeds() { 143 return numOfBeds; 144 } 145 146 public void setNumOfBeds(int numOfBeds) { 147 this.numOfBeds = numOfBeds; 148 } 136 149 } -
src/main/java/com/tourMate/entities/HotelRoomReservations.java
re9b4ba9 rac19a0c 41 41 } 42 42 43 @ManyToOne(fetch = FetchType. LAZY)43 @ManyToOne(fetch = FetchType.EAGER) 44 44 @JoinColumn(name = "room_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_room")) 45 45 public HotelRoom getHotelRoom() { … … 57 57 } 58 58 59 @OneToOne(fetch = FetchType. LAZY)59 @OneToOne(fetch = FetchType.EAGER) 60 60 @JoinColumn(name = "user_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_user")) 61 61 public User getUser() { -
src/main/java/com/tourMate/entities/Reviews.java
re9b4ba9 rac19a0c 71 71 72 72 @ManyToOne(fetch = FetchType.LAZY) 73 @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel"))73 @JoinColumn(name = "hotel_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel")) 74 74 public Hotels getHotel () { 75 75 return hotel; … … 81 81 82 82 @ManyToOne(fetch = FetchType.LAZY) 83 @JoinColumn(name = "restaurant_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani"))83 @JoinColumn(name = "restaurant_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani")) 84 84 public Restaurant getRestaurant () { 85 85 return restaurant; … … 91 91 92 92 @ManyToOne(fetch = FetchType.LAZY) 93 @JoinColumn(name = "transport_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport"))93 @JoinColumn(name = "transport_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport")) 94 94 public Transport getTransport () { 95 95 return transport; -
src/main/java/com/tourMate/entities/User.java
re9b4ba9 rac19a0c 52 52 private Role role; 53 53 @Column(name = "locked", unique = false, nullable = false) 54 boolean locked ;54 boolean locked = false; 55 55 56 56 @Column(name = "enabled", unique = false, nullable = false) … … 162 162 @Override 163 163 public boolean isAccountNonLocked() { 164 return true;164 return locked; 165 165 } 166 166 -
src/main/java/com/tourMate/services/BusinessManager.java
re9b4ba9 rac19a0c 9 9 public List<Business> getUnapprovedBusinessesOfUser(long userId); 10 10 public void deleteBusiness(long businessId); 11 public List<Business> getCreatedBusinesses(); 11 public List<Business> getUnapprovedBusinesses(); 12 public void approveBusiness(Long businessId); 12 13 public Business findBusinessById (long businessId); 13 14 public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved); -
src/main/java/com/tourMate/services/HotelManager.java
re9b4ba9 rac19a0c 2 2 3 3 import com.tourMate.dto.HotelDto; 4 import com.tourMate.dto.HotelReservationDto; 5 import com.tourMate.dto.HotelReservationUserDto; 4 6 import com.tourMate.entities.*; 5 7 … … 23 25 public HotelRoom findRoomById (long hotelRoomId); 24 26 public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 25 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price );27 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds); 26 28 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 27 29 public void deleteRoom(long hotelRoomId); 28 public List<HotelRoomAvailable> getRoomsAvailable(Long id);29 30 public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); 30 31 public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); … … 33 34 public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId); 34 35 public List<HotelRoomAvailable> getRoomsAvailibility(); 36 public List<HotelRoomAvailable> getRoomsAvailableById(Long id); 35 37 public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel); 36 38 public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds); … … 38 40 public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds); 39 41 public void deleteReservation(long hotelRoomReservedId); 42 public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId); 43 public List<HotelReservationUserDto> findValidHotelReservationsByUser(Long userId); 40 44 public HotelRoomReservations findReservationById(long hotelRoomReservedId); 41 45 public List<HotelRoomReservations> findReservationByUser(User user); -
src/main/java/com/tourMate/services/TransportManager.java
re9b4ba9 rac19a0c 12 12 public interface TransportManager { 13 13 14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate); 15 15 16 16 public void deleteTransport(long transportId); … … 33 33 public Transport getTransportById(long transportId); 34 34 35 public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date );35 public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers); 36 36 37 37 public List<TransportReservation> getTransportsReservationsByUserID(long userID); -
src/main/java/com/tourMate/services/UsersManager.java
re9b4ba9 rac19a0c 16 16 17 17 public void editUser(long userID, String name, String surname, String email, Date birthDate, String address, String contact); 18 public List<User> getUnapprovedUsers(); 19 public void approveUserProfile(long userId); 18 20 } -
src/main/java/com/tourMate/services/impl/BusinessManagerImpl.java
re9b4ba9 rac19a0c 34 34 35 35 @Override 36 public boolean hasBusiness(long userId){37 return businessDao. hasBusiness(userId);36 public List<Business> getUnapprovedBusinesses() { 37 return businessDao.getUnapprovedBusinesses(); 38 38 } 39 39 40 40 @Override 41 public List<Business> getCreatedBusinesses() { 42 return businessDao.getCreatedBusinesses(); 41 public void approveBusiness(Long businessId) { 42 Business b = findBusinessById(businessId); 43 businessDao.approveBusiness(b); 44 } 45 46 @Override 47 public boolean hasBusiness(long userId){ 48 return businessDao.hasBusiness(userId); 43 49 } 44 50 -
src/main/java/com/tourMate/services/impl/HotelManagerImpl.java
re9b4ba9 rac19a0c 4 4 import com.tourMate.dao.UsersDao; 5 5 import com.tourMate.dto.HotelDto; 6 import com.tourMate.dto.HotelReservationDto; 7 import com.tourMate.dto.HotelReservationUserDto; 6 8 import com.tourMate.entities.*; 7 9 import com.tourMate.services.HotelManager; … … 10 12 11 13 import java.time.Duration; 12 import java.util.Collection;13 14 import java.util.Date; 14 15 import java.util.List; … … 104 105 105 106 @Override 106 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price ) {107 hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price );107 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 108 hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price, numOfBeds); 108 109 } 109 110 … … 118 119 } 119 120 120 @Override 121 public List<HotelRoomAvailable> getRoomsAvailable(Long id) { 121 122 @Override 123 public List<HotelRoomAvailable> getRoomsAvailableById(Long id) { 122 124 return hotelDao.getRoomsAvailable(id); 123 125 } … … 203 205 204 206 @Override 207 public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId) { 208 Hotels hotel = findHotelByID(hotelId); 209 List<HotelRoomReservations> reservations = hotelDao.findReservationByHotel(hotel); 210 return reservations.stream() 211 // .filter(x -> x.getDateFrom().after(new Date())) 212 .map(x -> new HotelReservationDto( 213 x.getUser(), 214 x.getHotelRoom(), 215 x.getDateFrom(), 216 x.getDateTo(), 217 x.getNumberOfBeds() 218 )).toList(); 219 } 220 221 @Override 222 public List<HotelReservationUserDto> findValidHotelReservationsByUser(Long userId) { 223 User u = usersDao.findUserByID(userId); 224 List<HotelRoomReservations> reservations = hotelDao.findReservationByUser(u); 225 return reservations.stream().map(x -> new HotelReservationUserDto( 226 x.getUser(), 227 x.getHotelRoom(), 228 x.getDateFrom(), 229 x.getDateTo(), 230 x.getNumberOfBeds(), 231 x.getHotelRoom().getHotel().getHotelName(), 232 x.getHotelRoom().getHotel().getHotelLocation(), 233 "" 234 )).toList(); 235 } 236 237 @Override 205 238 public HotelRoomReservations findReservationById(long hotelRoomReservedId) { 206 239 return hotelDao.findReservationById(hotelRoomReservedId); -
src/main/java/com/tourMate/services/impl/TransportManagerImpl.java
re9b4ba9 rac19a0c 24 24 25 25 @Override 26 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) {27 transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, owner, carPlate);26 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) { 27 transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, userId, carPlate); 28 28 } 29 29 … … 83 83 84 84 @Override 85 public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date ) {86 List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date );85 public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date, int numPassengers) { 86 List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date, numPassengers); 87 87 Map<TransportAvailible, List<TransportRoute>> transportsByTransporter = transportAvailable.stream().collect(Collectors.groupingBy(x -> x.getParentRoute())); 88 88 List<TransportListingDto> transportList = transportsByTransporter.keySet().stream().toList().stream() -
src/main/java/com/tourMate/services/impl/UsersManagerImpl.java
re9b4ba9 rac19a0c 45 45 46 46 @Override 47 public List<User> getUnapprovedUsers() { 48 return usersDao.getUnapprovedUsers(); 49 } 50 51 @Override 52 public void approveUserProfile(long userId) { 53 User u = findUserByID(userId); 54 usersDao.approveUserProfile(u); 55 } 56 57 @Override 47 58 public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 48 59 return usersDao.findUserByUsername(username);
Note:
See TracChangeset
for help on using the changeset viewer.