Commit fbc8a1cb by Bogdan Andjelkovic

korisnici za zahteve i odbij prihvati zahtev - back

parent 7bf9e5e4
......@@ -94,8 +94,15 @@ public class OglasController
model.addAttribute("slike", sRepo.findAllById( oglasId));
model.addAttribute("grad", kRepo.findCity( oglas.getLokacijaId()));
model.addAttribute("noviZahtev", new Zahtev());
if( loggedUser != null && oglas.getKorisnikId() == loggedUser.getKorisnik().getKorisnikId())
model.addAttribute("zahtevi", zRepo.findAllByOglasId( oglasId));
if( loggedUser != null && oglas.getKorisnikId() == loggedUser.getKorisnik().getKorisnikId()) {
List<Zahtev> zahtevi = zRepo.findAllByOglasId(oglasId);
List<Korisnik> korisnici = new ArrayList<Korisnik>();
for( Zahtev zahtev: zahtevi)
korisnici.add( kRepo.findById( zahtev.getKorisnikId()));
model.addAttribute("zahtevi", zahtevi);
model.addAttribute("korisnici", korisnici);
}
return("oglas");
}
@GetMapping("/profile/moji-oglasi")
......
......@@ -44,4 +44,17 @@ public class ZahtevController {
return "redirect:/lista-oglasa/"+oglasId;
}
@GetMapping("/oglas-edit/{oglasId}/prihvati-zahtev/{zahtevId}")
public String getPrihvatiZahtev( Model model, @PathVariable("oglasId") int oglasId, @PathVariable("zahtevId") int zahtevId)
{
zRepo.updateZahtevStatus( zahtevId, StanjeZahteva.POTVRDJEN);
return ("redirect:/lista-oglasa/" + oglasId);
}
@GetMapping("/oglas-edit/{oglasId}/odbi-zahtev/{zahtevId}")
public String getOdbiZahtev( Model model, @PathVariable("oglasId") int oglasId, @PathVariable("zahtevId") int zahtevId)
{
zRepo.updateZahtevStatus( zahtevId, StanjeZahteva.ODBIJEN);
return ("redirect:/lista-oglasa/" + oglasId);
}
}
......@@ -96,4 +96,18 @@ public class ZahtevRepository {
throw new RuntimeException(e);
}
}
public void updateZahtevStatus(int zahtevId, StanjeZahteva potvrdjen)
{
String sql = "{ call updateZahtevStatus(?,?)}";
CallableStatement cs = null;
try {
cs = dataBase.connection.prepareCall(sql);
cs.setInt(1, zahtevId);
cs.setString(2, potvrdjen.toString());
cs.execute();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
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