Commit 6fcfbc14 by Bogdan Andjelkovic

obrisi zahtev - back

parent 440596bb
......@@ -31,15 +31,16 @@ public class ZahtevController {
@GetMapping("/profile/moji-zahtevi")
public String getMojiZahtevi(Model model, @AuthenticationPrincipal KorisnikDetails loggedUser)
{
model.addAttribute("loggedUser", loggedUser);
List<Zahtev> mojiZahtevi = zRepo.findAllByKorisnikId( loggedUser.getKorisnik().getKorisnikId());
List<Oglas> mojiOglasi = new ArrayList<Oglas>();
for( Zahtev zahtev: mojiZahtevi)
mojiOglasi.add( oRepo.findById( zahtev.getOglasId()));
model.addAttribute("loggedUser", loggedUser);
model.addAttribute("zahtevi", mojiZahtevi);
//model.addAttribute("oglasi", mojiOglasi);
model.addAttribute("oglasi", mojiOglasi);
return "moji-zahtevi";
}
......@@ -74,4 +75,10 @@ public class ZahtevController {
return ("redirect:/lista-oglasa/" + oglasId);
}
@GetMapping("/oglas-edit/{oglasId}/obrisi-zahtev/{zahtevId}")
public String getObrisiZahtev( Model model, @PathVariable("oglasId") int oglasId, @PathVariable("zahtevId") int zahtevId)
{
zRepo.deleteZahtev( zahtevId);
return ("redirect:/lista-oglasa/" + oglasId);
}
}
......@@ -140,4 +140,17 @@ public class ZahtevRepository {
throw new RuntimeException(e);
}
}
public void deleteZahtev(int zahtevId)
{
String sql = "{ call deleteZahtev(?)}";
CallableStatement cs = null;
try {
cs = dataBase.connection.prepareCall(sql);
cs.setInt( 1, zahtevId);
cs.execute();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns="http://www.w3.org/1999/html" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
......@@ -103,10 +103,6 @@
</div>
</nav>
<div th:object="${zahtevi}">
<p th:each="zahtev: ${zahtevi}" th:text="${zahtev.toString()}"></p>
</div>
<div class="container-fluid pb-0 mb-0 justify-content-center text-light ">
<footer>
<div class="row my-5 justify-content-center py-5">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment