Commit 6e31cddb by Bogdan Andjelkovic

back za obostrane komentar uradjen jos front da se sakrije kad je komentarisano vec

parent 316631a7
package com.example.SkuciSe.controller;
import com.example.SkuciSe.model.zahtev.Zahtev;
import com.example.SkuciSe.repository.KomentarRepository;
import com.example.SkuciSe.repository.KomentarVlasnikRepository;
import com.example.SkuciSe.repository.ZahtevRepository;
......@@ -25,7 +26,10 @@ public class KomentarController {
{
try {
komentarRepo.insert(korisnikId, oglasId, text, ocenaRadio);
zRepo.deleteZahtev(zahtevId);
zRepo.zahtevKorisnikKom( zahtevId);
Zahtev zahtev = zRepo.findZahtevById( zahtevId);
if( zahtev.getKorisnikKom() && zahtev.getVlasnikKom())
zRepo.deleteZahtev( zahtevId);
} catch (Exception e) {
throw new RuntimeException(e);
}
......@@ -35,11 +39,16 @@ public class KomentarController {
@GetMapping("/oceni-korisnika")
public String getOceniKorisnika(@RequestParam("vlasnikId") int vlasnikId,
@RequestParam("korisnikId") int korisnikId,
@RequestParam("zahtevId") int zahtevId,
@RequestParam("ocenaRadio") int ocenaRadio,
@RequestParam("komentar") String text)
{
try {
komentarVlasnikRepo.insert( vlasnikId, korisnikId, ocenaRadio, text);
zRepo.zahtevVlasnikKom( zahtevId);
Zahtev zahtev = zRepo.findZahtevById( zahtevId);
if( zahtev.getKorisnikKom() && zahtev.getVlasnikKom())
zRepo.deleteZahtev( zahtevId);
} catch (Exception e) {
throw new RuntimeException(e);
}
......
......@@ -178,4 +178,24 @@ public class ZahtevRepository {
throw new RuntimeException(e);
}
}
public Zahtev findZahtevById( int zahtevId)
{
this.postaviFinishedZahteve();
String sql = "call findZahtevById(?)";
CallableStatement stmt = null;
ResultSet rs = null;
try {
stmt = dataBase.connection.prepareCall( sql);
stmt.setInt( 1, zahtevId);
rs = stmt.executeQuery();
while( rs.next())
{
return new Zahtev( rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getString(4), rs.getString(5), StanjeZahteva.valueOf(rs.getString(6)),rs.getBoolean(7), rs.getBoolean(8));
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return( null);
}
}
......@@ -316,6 +316,7 @@
<form method="get" th:action="@{/oceni-korisnika}">
<input type="text" th:value="${loggedUser.korisnik.korisnikId}" name="vlasnikId" style="display: none">
<input type="text" th:value="${korisnik.korisnikId}" name="korisnikId" style="display: none">
<input type="text" th:value="${zahtevi[korisnikStat.index].zahtevId}" name="zahtevId" style="display: none">
<input type="number" name="ocenaRadio"><br>
<input type="text" name="komentar"><br>
<button type="submit">Oceni</button>
......
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