Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/cookbook/repository/NarackiRepository.java
ree27685 ra226bc3 3 3 4 4 import com.example.cookbook.dbConfig.DB; 5 import com.example.cookbook.model.DostavaDTO; 5 6 import com.example.cookbook.model.Naracka; 6 7 import com.example.cookbook.model.Recept; … … 65 66 return stavki; 66 67 } 68 69 public List<DostavaDTO> findDataForDostava(String telefon, LocalDateTime vreme) throws SQLException { 70 Connection connection = DB.getConnection(); 71 String query = "select r.rec_ime, l.adresa, 'Готово' sostojka from so_koi sk\n" + 72 " left join recepti r on\n" + 73 " r.rec_id = sk.rec_id\n" + 74 " left join opsluzuva o on\n" + 75 " o.rec_id = r.rec_id\n" + 76 " left join restorani r2 on\n" + 77 " r2.res_id = o.res_id\n" + 78 " left join se_naogja1 sn on\n" + 79 " sn.res_id = r2.res_id\n" + 80 " left join lokacii l on\n" + 81 " l.l_id = sn.l_id\n" + 82 " where vreme = ? and telefon = ? and sk.nacin = 'Готово'\n" + 83 "union\n" + 84 "select r.rec_ime, l.adresa, s2.s_naziv sostojka from so_koi sk\n" + 85 " left join recepti r on\n" + 86 " r.rec_id = sk.rec_id\n" + 87 " left join sodrzi s on\n" + 88 " r.rec_id = s.rec_id\n" + 89 " left join sostojki s2 on\n" + 90 " s2.s_id = s.s_id\n" + 91 " left join ja_ima ji on\n" + 92 " ji.s_id = s2.s_id\n" + 93 " left join prodavnici p on\n" + 94 " p.pro_id = ji.pro_id\n" + 95 " left join se_naogja2 sn on\n" + 96 " sn.pro_id = p.pro_id\n" + 97 " left join lokacii l on\n" + 98 " l.l_id = sn.l_id\n" + 99 " where vreme = ? and telefon = ? and sk.nacin = 'Состојки'"; 100 PreparedStatement prepStm = connection.prepareStatement(query); 101 102 prepStm.setObject(1, vreme); 103 prepStm.setString(2, telefon); 104 prepStm.setObject(3, vreme); 105 prepStm.setString(4, telefon); 106 107 ResultSet result = prepStm.executeQuery(); 108 109 List<DostavaDTO> dostavaDTOS = new ArrayList<>(); 110 while (result.next()){ 111 DostavaDTO stavka = new DostavaDTO( 112 result.getString("rec_ime"), 113 result.getString("adresa"), 114 result.getString("sostojka") 115 ); 116 117 dostavaDTOS.add(stavka); 118 } 119 DB.closeConnection(); 120 result.close(); 121 prepStm.close(); 122 return dostavaDTOS; 123 } 67 124 }
Note:
See TracChangeset
for help on using the changeset viewer.