- Timestamp:
- 01/16/24 16:34:03 (10 months ago)
- Branches:
- master
- Children:
- 07f4e8b
- Parents:
- e6c2521
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.