Changeset 5528b99 for src/main/java/com
- Timestamp:
- 01/16/24 16:34:03 (10 months ago)
- Branches:
- master
- Children:
- 07f4e8b
- Parents:
- e6c2521
- Location:
- src/main/java/com/tourMate
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/tourMate/config/SecurityConfig.java
re6c2521 r5528b99 7 7 import org.springframework.http.HttpHeaders; 8 8 import org.springframework.http.HttpMethod; 9 import org.springframework.http.HttpStatus;10 9 import org.springframework.security.config.annotation.web.builders.HttpSecurity; 11 10 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; … … 15 14 import org.springframework.security.web.SecurityFilterChain; 16 15 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 17 import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;18 16 import org.springframework.security.web.util.matcher.AntPathRequestMatcher; 19 17 import org.springframework.web.cors.CorsConfiguration; … … 76 74 .anyRequest().authenticated() 77 75 .and() 78 .formLogin() 76 .formLogin().loginPage("http://localhost:3000/login") 79 77 .loginProcessingUrl("/api/login").usernameParameter("username").passwordParameter("password") 80 78 .successHandler((request, response, authentication) -> { 81 79 response.setStatus(HttpServletResponse.SC_OK); 82 response.setCharacterEncoding("UTF-8");83 80 response.setContentType("application/json"); 84 81 response.getWriter().print("{\"message\": \"Login successful\","); … … 88 85 .failureHandler((request, response, exception) -> { 89 86 response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); 90 response.sendRedirect("/login"); 91 response.getWriter().print("Neuspesna najava\n" + exception.getMessage()); 87 response.getWriter().print("Pukla veza\n" + exception.getMessage()); 92 88 response.getWriter().flush(); 93 89 }) … … 97 93 .sessionCreationPolicy(SessionCreationPolicy.ALWAYS) 98 94 .and() 99 .logout() .logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK)))95 .logout() 100 96 .permitAll(); 101 97 -
src/main/java/com/tourMate/controllers/HotelController.java
re6c2521 r5528b99 2 2 3 3 import com.tourMate.dto.HotelDto; 4 import com.tourMate.dto.HotelReservationDto;5 import com.tourMate.dto.HotelReservationUserDto;6 4 import com.tourMate.entities.*; 7 5 import com.tourMate.services.HotelManager; … … 106 104 //HOTEL ROOM CRUD 107 105 @PostMapping(path = "/hotel/rooms/add") 108 public void addRoom(@RequestBody HotelRoom room, 109 @RequestParam(name = "hotelId") long hotelId) { 106 public void addRoom(@RequestBody HotelRoom room, @RequestParam(name = "hotelId") long hotelId) { 110 107 Hotels h = hotelManager.findHotelByID(hotelId); 111 hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice() , room.getNumOfBeds());108 hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice()); 112 109 } 113 110 … … 152 149 //HOTEL AVAILABILITY CRUD 153 150 @PostMapping(path = "/hotel/rooms/available/{id}/add") 154 public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, 155 @PathVariable long id) 151 public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, @PathVariable long id) 156 152 { 157 153 HotelRoom hotelRoom = hotelManager.findRoomById(id); … … 182 178 public List<HotelRoomAvailable> getRoomAvailability(@PathVariable Long id) 183 179 { 184 return hotelManager.getRoomsAvail ableById(id);180 return hotelManager.getRoomsAvailibility(); 185 181 } 186 182 187 183 @GetMapping(path = "/hotel/search") 188 public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, 189 @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, 190 @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, 191 @RequestParam(name = "numBeds") int numBeds) 184 public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, 185 @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, @RequestParam(name = "numBeds") int numBeds) 192 186 { 193 187 System.out.println(hotelLocation); … … 209 203 } 210 204 205 <<<<<<< HEAD 211 206 @GetMapping(path = "/hotel/{id}/reservations/active") 212 207 public List<HotelReservationDto> getActiveReservationsForHotel(@PathVariable Long id) … … 238 233 return hotelManager.getRoomImages(id); 239 234 } 235 ======= 236 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) 240 237 } -
src/main/java/com/tourMate/controllers/TransportController.java
re6c2521 r5528b99 20 20 21 21 // TRANSPORT CRUD // 22 @PostMapping(path = "/transport/add/{userId}") 23 public void add(@RequestBody Transport transport, 24 @PathVariable Long userId) { 25 transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), userId, transport.getCarPlate()); 22 @PostMapping(path = "/transport/add") 23 public void add(@RequestBody Transport transport) { 24 transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), new User(), transport.getCarPlate()); 26 25 27 26 } … … 46 45 public TransportDto getTransport(@PathVariable(name = "id") long transportId) 47 46 { 47 System.out.println("TUKA SUUUUUM"); 48 48 return transportManager.findTransportById(transportId); 49 49 } … … 84 84 @PostMapping(path = "/transport/available/add") 85 85 public void add(@RequestBody TransportAvailible transportAvailable, @RequestParam(name = "transportId") long transportId) { 86 System.out.println("OREEEEEL"); 87 System.out.println("DVA ORLA"); 86 88 Transport t = transportManager.getTransportById(transportId); 87 89 List<TransportRoute> routes = transportAvailable.getRoutes().stream().toList(); … … 125 127 126 128 @GetMapping(path = "/transport/search") 127 public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, 128 @RequestParam(name = "to") String to, 129 @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date, 130 @RequestParam(name = "numPassengers") int numPassengers){ 131 return transportManager.getTransportsAvailableByFilters(from, to, date, numPassengers); 129 public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, @RequestParam(name = "to") String to, 130 @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date){ 131 return transportManager.getTransportsAvailableByFilters(from, to, date); 132 132 } 133 133 -
src/main/java/com/tourMate/controllers/UsersController.java
re6c2521 r5528b99 11 11 import org.springframework.web.bind.annotation.*; 12 12 13 import java.util.ArrayList; 13 14 import java.util.List; 14 15 … … 38 39 { 39 40 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);68 41 } 69 42 -
src/main/java/com/tourMate/dao/BusinessDao.java
re6c2521 r5528b99 11 11 @Transactional 12 12 void createBusiness(Business business, long userId); 13 List<Business> getUnapprovedBusinessesOfUser(long userId);14 void deleteBusiness(long businessId);15 List<Business> getCreatedBusinesses();16 Business findBusinessById (long businessId);13 public List<Business> getUnapprovedBusinessesOfUser(long userId); 14 public void deleteBusiness(long businessId); 15 public List<Business> getCreatedBusinesses(); 16 public 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 boolean hasBusiness(long userId);20 public boolean hasBusiness(long userId); 21 21 22 List<Business> getUnapprovedBusinesses();23 24 void approveBusiness(Business business);25 22 } -
src/main/java/com/tourMate/dao/HotelDao.java
re6c2521 r5528b99 22 22 public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 23 23 24 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price , int numOfBeds);24 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 25 25 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String HotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 26 26 public void deleteRoom(long hotelRoomId); -
src/main/java/com/tourMate/dao/TransportDao.java
re6c2521 r5528b99 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, Long userId, String carPlate);14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, 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, int numPassengers);49 public List<TransportRoute> getTransportsAvailableByFilters (String from,String to,Date date); 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
re6c2521 r5528b99 23 23 24 24 UserDetails findUserByUsername(String username); 25 26 List<User> getUnapprovedUsers();27 28 void approveUserProfile(User u);29 25 } -
src/main/java/com/tourMate/dao/impl/BusinessDaoImpl.java
re6c2521 r5528b99 46 46 } 47 47 48 @Override49 public List<Business> getUnapprovedBusinesses() {50 return em.createQuery("select b from Business b where not b.approved").getResultList();51 }52 53 @Override54 @Transactional55 public void approveBusiness(Business b) {56 b.setApproved(true);57 em.persist(b);58 }59 60 48 61 49 @Override -
src/main/java/com/tourMate/dao/impl/HotelDaoImpl.java
re6c2521 r5528b99 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"); 30 31 return hoteli; 31 32 //return em.createQuery("select h from Hotels h order by h.hotelId").getResultList(); … … 122 123 @Transactional 123 124 @Override 124 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price , int numOfBeds) {125 HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price , numOfBeds);125 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) { 126 HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price); 126 127 em.persist(hotelRoom); 127 128 } … … 191 192 public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds) { 192 193 return em.createQuery("select hr from HotelRoomAvailable hr where hr.dateFrom <= :dateFrom and hr.dateTo >= :dateTo " + 194 <<<<<<< HEAD 193 195 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr.hotelRoom.numOfBeds >= :numBeds") 196 ======= 197 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr.numberOfBeds >= :numBeds") 198 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) 194 199 .setParameter("hotelLocation", hotelLocation) 195 200 .setParameter("dateFrom", dateFrom) … … 240 245 public List<HotelRoomReservations> findReservationByHotel(Hotels hotel) { 241 246 List<HotelRoom> hotelRooms = getRoomsOfHotel(hotel.getHotelId()); 242 return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom .hotel = :hotel").setParameter("hotel", hotel).getResultList();247 return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom in :hotelRooms").setParameter("hotelRooms", hotelRooms).getResultList(); 243 248 } 244 249 -
src/main/java/com/tourMate/dao/impl/TransportDaoImpl.java
re6c2521 r5528b99 22 22 @Override 23 23 @Transactional 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);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); 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 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) 64 y.getRoutes() 65 )).toList() 73 66 )).toList(); 74 67 } … … 85 78 x.getFreeSpace(), 86 79 x.getTime(), 87 x.getRoutes(), 88 x.getRoutes().stream() 89 .mapToDouble(TransportRoute::getPrice) 90 .max().orElse(0) 80 x.getRoutes() 91 81 )).toList(); 92 82 } … … 113 103 y.getFreeSpace(), 114 104 y.getTime(), 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)); 105 y.getRoutes() 106 )).toList()); 124 107 } 125 108 … … 167 150 168 151 @Override 169 public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date , int numPassengers) {152 public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date) { 170 153 System.out.println(fromL + " " + toL); 171 return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol and h.freeSpace >= :nump") 172 .setParameter("froml", fromL) 173 .setParameter("tol", toL) 174 .setParameter("nump", numPassengers) 175 .getResultList(); 154 return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol").setParameter("froml", fromL). 155 setParameter("tol", toL).getResultList(); 176 156 } 177 157 -
src/main/java/com/tourMate/dao/impl/UsersDaoImpl.java
re6c2521 r5528b99 74 74 } 75 75 76 @Override77 public List<User> getUnapprovedUsers() {78 return em.createQuery("select u from User u where not u.enabled").getResultList();79 }80 81 @Override82 @Transactional83 public void approveUserProfile(User u) {84 u.setEnabled(true);85 em.persist(u);86 }87 76 88 77 -
src/main/java/com/tourMate/dto/RouteListingDto.java
re6c2521 r5528b99 18 18 private Date time; 19 19 private Collection<String> routes; 20 private Double maxPrice;21 20 22 public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes , Double maxPrice) {21 public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes) { 23 22 this.transportAvailibleId = transportAvailibleId; 24 23 this.from = from; … … 28 27 this.time = time; 29 28 this.routes = routes.stream().map(x -> x.getFrom()).distinct().skip(1).toList(); 30 this.maxPrice = maxPrice;31 29 } 32 30 … … 86 84 this.routes = routes; 87 85 } 88 89 public Double getMaxPrice() {90 return maxPrice;91 }92 86 } -
src/main/java/com/tourMate/dto/TransportDto.java
re6c2521 r5528b99 16 16 private User owner; 17 17 private String carPlate; 18 private Double maxPrice;19 18 private Collection<RouteListingDto> availableRoutes; 20 19 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) {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) { 22 21 this.transportID = transportID; 23 22 this.transportName = transportName; … … 31 30 this.carPlate = carPlate; 32 31 this.availableRoutes = availableRoutes; 33 this.maxPrice = maxPrice;34 32 } 35 33 -
src/main/java/com/tourMate/entities/Business.java
re6c2521 r5528b99 88 88 } 89 89 90 @OneToOne(fetch = FetchType. EAGER)90 @OneToOne(fetch = FetchType.LAZY) 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 110 109 } -
src/main/java/com/tourMate/entities/HotelRoom.java
re6c2521 r5528b99 1 <<<<<<< HEAD 1 2 package com.tourMate.entities; 2 3 … … 159 160 } 160 161 } 162 ======= 163 package com.tourMate.entities; 164 165 import jakarta.persistence.*; 166 import com.fasterxml.jackson.annotation.JsonIgnore; 167 168 import javax.validation.constraints.NotNull; 169 170 @Entity 171 @Table(name="hotel_rooms", schema = "public") 172 public class HotelRoom { 173 private long hotelRoomId; 174 @JsonIgnore 175 private Hotels hotel; 176 private String hotelRoomDescription; 177 @Enumerated(EnumType.STRING) 178 private String hotelRoomName; 179 private double price; 180 private Boolean kitchenAvailable; 181 private Boolean airConditioning; 182 private Boolean balcony; 183 184 public HotelRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, double price, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony) { 185 this.hotelRoomId = hotelRoomId; 186 this.hotel = hotel; 187 this.hotelRoomDescription = hotelRoomDescription; 188 this.hotelRoomName = hotelRoomName; 189 this.price = price; 190 this.kitchenAvailable = kitchenAvailable; 191 this.airConditioning = airConditioning; 192 this.balcony = balcony; 193 } 194 195 public HotelRoom(Hotels hotel, String hotelRoomDescription, String type, 196 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) { 197 this.hotel = hotel; 198 this.hotelRoomDescription = hotelRoomDescription; 199 this.hotelRoomName = type; 200 this.kitchenAvailable = kitchenAvailable; 201 this.airConditioning = airConditioning; 202 this.balcony = balcony; 203 this.price = price; 204 } 205 206 public HotelRoom(String hotelRoomDescription, String type, 207 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) { 208 this.hotel = hotel; 209 this.hotelRoomDescription = hotelRoomDescription; 210 this.hotelRoomName = type; 211 this.kitchenAvailable = kitchenAvailable; 212 this.airConditioning = airConditioning; 213 this.balcony = balcony; 214 this.price = price; 215 } 216 217 public HotelRoom() { 218 219 } 220 221 @Id 222 @GeneratedValue(strategy = GenerationType.IDENTITY) 223 @Column(name = "room_id",unique = true,nullable = false) 224 public long getHotelRoomId() { 225 return hotelRoomId; 226 } 227 228 public void setHotelRoomId(long hotelRoomId) { 229 this.hotelRoomId = hotelRoomId; 230 } 231 232 @ManyToOne(fetch = FetchType.LAZY) 233 @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_room_kon_hotel")) 234 public Hotels getHotel() { 235 return hotel; 236 } 237 238 public void setHotel(Hotels hotelId) { 239 this.hotel = hotelId; 240 } 241 242 @Column(name="hotel_room_description",unique = false,nullable = false) 243 @NotNull 244 public String getHotelRoomDescription() { 245 return hotelRoomDescription; 246 } 247 248 public void setHotelRoomDescription(String hotelRoomDescription) { 249 this.hotelRoomDescription = hotelRoomDescription; 250 } 251 252 @Column(name="hotel_room_price",unique = false,nullable = false) 253 @NotNull 254 public double getPrice() { 255 return price; 256 } 257 258 @Column(name="hotel_room_name",unique = false,nullable = false) 259 @NotNull 260 public String getHotelRoomName() { 261 return hotelRoomName; 262 } 263 264 265 public void setHotelRoomName(String name) { 266 this.hotelRoomName = name; 267 } 268 public void setPrice(double type) { 269 this.price = type; 270 } 271 @Column(name="hotel_room_kitchen",unique = false,nullable = false) 272 @NotNull 273 public Boolean getKitchenAvailable() { 274 return kitchenAvailable; 275 } 276 277 public void setKitchenAvailable(Boolean kitchenAvailable) { 278 this.kitchenAvailable = kitchenAvailable; 279 } 280 @Column(name="hotel_room_ac",unique = false,nullable = false) 281 @NotNull 282 public Boolean getAirConditioning() { 283 return airConditioning; 284 } 285 286 public void setAirConditioning(Boolean airConditioning) { 287 this.airConditioning = airConditioning; 288 } 289 @Column(name="hotel_room_balcony",unique = false,nullable = false) 290 @NotNull 291 public Boolean getBalcony() { 292 return balcony; 293 } 294 295 public void setBalcony(Boolean balcony) { 296 this.balcony = balcony; 297 } 298 } 299 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) -
src/main/java/com/tourMate/entities/HotelRoomReservations.java
re6c2521 r5528b99 43 43 } 44 44 45 @ManyToOne(fetch = FetchType. EAGER)45 @ManyToOne(fetch = FetchType.LAZY) 46 46 @JoinColumn(name = "room_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_room")) 47 47 public HotelRoom getHotelRoom() { … … 59 59 } 60 60 61 @OneToOne(fetch = FetchType. EAGER)61 @OneToOne(fetch = FetchType.LAZY) 62 62 @JoinColumn(name = "user_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_user")) 63 63 public User getUser() { -
src/main/java/com/tourMate/entities/Reviews.java
re6c2521 r5528b99 75 75 76 76 @ManyToOne(fetch = FetchType.LAZY) 77 @JoinColumn(name = "hotel_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel"))77 @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel")) 78 78 public Hotels getHotel () { 79 79 return hotel; … … 85 85 86 86 @ManyToOne(fetch = FetchType.LAZY) 87 @JoinColumn(name = "restaurant_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani"))87 @JoinColumn(name = "restaurant_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani")) 88 88 public Restaurant getRestaurant () { 89 89 return restaurant; … … 95 95 96 96 @ManyToOne(fetch = FetchType.LAZY) 97 @JoinColumn(name = "transport_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport"))97 @JoinColumn(name = "transport_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport")) 98 98 public Transport getTransport () { 99 99 return transport; -
src/main/java/com/tourMate/entities/User.java
re6c2521 r5528b99 52 52 private Role role; 53 53 @Column(name = "locked", unique = false, nullable = false) 54 boolean locked = false;54 boolean locked; 55 55 56 56 @Column(name = "enabled", unique = false, nullable = false) … … 162 162 @Override 163 163 public boolean isAccountNonLocked() { 164 return locked;164 return true; 165 165 } 166 166 -
src/main/java/com/tourMate/services/BusinessManager.java
re6c2521 r5528b99 9 9 public List<Business> getUnapprovedBusinessesOfUser(long userId); 10 10 public void deleteBusiness(long businessId); 11 public List<Business> getUnapprovedBusinesses(); 12 public void approveBusiness(Long businessId); 11 public List<Business> getCreatedBusinesses(); 13 12 public Business findBusinessById (long businessId); 14 13 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
re6c2521 r5528b99 2 2 3 3 import com.tourMate.dto.HotelDto; 4 import com.tourMate.dto.HotelReservationDto;5 import com.tourMate.dto.HotelReservationUserDto;6 4 import com.tourMate.entities.*; 7 5 import org.springframework.web.multipart.MultipartFile; … … 26 24 public List<HotelRoom> getRoomsOfHotel (long hotelId); 27 25 public HotelRoom findRoomById (long hotelRoomId); 26 <<<<<<< HEAD 28 27 public List<HotelRoomImages> getRoomImages(Long hotelRoom); 29 28 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds); 29 ======= 30 public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 31 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 32 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) 30 33 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 31 34 public void deleteRoom(long hotelRoomId); 35 public List<HotelRoomAvailable> getRoomsAvailable(Long id); 32 36 public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); 33 37 public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); … … 36 40 public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId); 37 41 public List<HotelRoomAvailable> getRoomsAvailibility(); 38 public List<HotelRoomAvailable> getRoomsAvailableById(Long id);39 42 public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel); 40 43 public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds); … … 42 45 public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds); 43 46 public void deleteReservation(long hotelRoomReservedId); 44 public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId);45 public List<HotelReservationUserDto> findValidHotelReservationsByUser(Long userId);46 47 public HotelRoomReservations findReservationById(long hotelRoomReservedId); 47 48 public List<HotelRoomReservations> findReservationByUser(User user); -
src/main/java/com/tourMate/services/TransportManager.java
re6c2521 r5528b99 13 13 public interface TransportManager { 14 14 15 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate);15 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate); 16 16 17 17 public void deleteTransport(long transportId); … … 35 35 public Transport getTransportById(long transportId); 36 36 37 <<<<<<< HEAD 37 38 List<Reviews> getReviewsForTransport(long transportId); 38 39 39 40 public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers); 41 ======= 42 public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date); 43 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) 40 44 41 45 public List<TransportReservation> getTransportsReservationsByUserID(long userID); -
src/main/java/com/tourMate/services/UsersManager.java
re6c2521 r5528b99 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);20 18 } -
src/main/java/com/tourMate/services/impl/BusinessManagerImpl.java
re6c2521 r5528b99 34 34 35 35 @Override 36 public List<Business> getUnapprovedBusinesses(){37 return businessDao. getUnapprovedBusinesses();36 public boolean hasBusiness(long userId){ 37 return businessDao.hasBusiness(userId); 38 38 } 39 39 40 40 @Override 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); 41 public List<Business> getCreatedBusinesses() { 42 return businessDao.getCreatedBusinesses(); 49 43 } 50 44 -
src/main/java/com/tourMate/services/impl/HotelManagerImpl.java
re6c2521 r5528b99 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;8 6 import com.tourMate.entities.*; 9 7 import com.tourMate.services.HotelManager; … … 13 11 14 12 import java.time.Duration; 13 import java.util.Collection; 15 14 import java.util.Date; 16 15 import java.util.List; … … 109 108 110 109 @Override 111 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price , int numOfBeds) {112 hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price , numOfBeds);110 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) { 111 hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price); 113 112 } 114 113 … … 123 122 } 124 123 125 126 @Override 127 public List<HotelRoomAvailable> getRoomsAvailableById(Long id) { 124 @Override 125 public List<HotelRoomAvailable> getRoomsAvailable(Long id) { 128 126 return hotelDao.getRoomsAvailable(id); 129 127 } … … 212 210 213 211 @Override 212 <<<<<<< HEAD 214 213 public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId) { 215 214 Hotels hotel = findHotelByID(hotelId); … … 245 244 246 245 @Override 246 ======= 247 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) 247 248 public HotelRoomReservations findReservationById(long hotelRoomReservedId) { 248 249 return hotelDao.findReservationById(hotelRoomReservedId); -
src/main/java/com/tourMate/services/impl/TransportManagerImpl.java
re6c2521 r5528b99 25 25 26 26 @Override 27 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) {28 transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, userId, carPlate);27 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) { 28 transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, owner, carPlate); 29 29 } 30 30 … … 93 93 94 94 @Override 95 <<<<<<< HEAD 95 96 public List<Reviews> getReviewsForTransport(long transportId) { 96 97 Transport transport = getTransportById(transportId); … … 101 102 public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date, int numPassengers) { 102 103 List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date, numPassengers); 104 ======= 105 public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date) { 106 List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date); 107 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) 103 108 Map<TransportAvailible, List<TransportRoute>> transportsByTransporter = transportAvailable.stream().collect(Collectors.groupingBy(x -> x.getParentRoute())); 104 109 List<TransportListingDto> transportList = transportsByTransporter.keySet().stream().toList().stream() -
src/main/java/com/tourMate/services/impl/UsersManagerImpl.java
re6c2521 r5528b99 45 45 46 46 @Override 47 public List<User> getUnapprovedUsers() {48 return usersDao.getUnapprovedUsers();49 }50 51 @Override52 public void approveUserProfile(long userId) {53 User u = findUserByID(userId);54 usersDao.approveUserProfile(u);55 }56 57 @Override58 47 public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 59 48 return usersDao.findUserByUsername(username);
Note:
See TracChangeset
for help on using the changeset viewer.