Commit 2043b173 by Bogdan Andjelkovic

slanje liste zahteva za odgovarajuci oglas i zakrivanje u zavistnosti prijavljen i vlasnik oglasa

parent 87a78ca1
......@@ -4,10 +4,7 @@ import com.example.SkuciSe.model.korisnik.Korisnik;
import com.example.SkuciSe.model.korisnik.KorisnikDetails;
import com.example.SkuciSe.model.oglas.Oglas;
import com.example.SkuciSe.model.zahtev.Zahtev;
import com.example.SkuciSe.repository.KorisnikRepository;
import com.example.SkuciSe.repository.LokacijaRepository;
import com.example.SkuciSe.repository.OglasRepository;
import com.example.SkuciSe.repository.SlikeRepository;
import com.example.SkuciSe.repository.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
......@@ -34,6 +31,9 @@ public class OglasController
@Autowired
SlikeRepository sRepo;
@Autowired
ZahtevRepository zRepo;
@GetMapping("/novi-oglas")
public String getNoviOglas(Model model, @AuthenticationPrincipal KorisnikDetails loggedUser)
{
......@@ -92,7 +92,8 @@ public class OglasController
model.addAttribute("loggedUser", loggedUser);
model.addAttribute("oglas", oRepo.findById( oglasId));
model.addAttribute("slike", sRepo.findAllById( oglasId));
model.addAttribute("grad",kRepo.findCity(oRepo.findById( oglasId).getLokacijaId()));
model.addAttribute("grad", kRepo.findCity(oRepo.findById( oglasId).getLokacijaId()));
model.addAttribute("zahtevi", zRepo.findAllByOglasId( oglasId));
return("oglas");
}
@GetMapping("/profile/moji-oglasi")
......
......@@ -88,9 +88,11 @@
</ul>
</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">
......
......@@ -170,12 +170,18 @@
</div>
</div>
<form th:if="${loggedUser != null}" th:action="@{/obradi-zahtev/{id}(id=${oglasId})}" method="POST" th:object="${noviZahtev}">
<div th:if="${loggedUser != null}">
<form th:if="${loggedUser.korisnik.korisnikId != oglas.korisnikId}" th:action="@{/obradi-zahtev/{id}(id=${oglasId})}" method="POST" th:object="${noviZahtev}">
<input type="hidden" th:field="${noviZahtev.korisnikId}" th:value="${loggedUser.korisnik.korisnikId}">
<input type="hidden" th:field="${noviZahtev.oglasId}" th:value="${oglas.oglasId}">
<input type="datetime-local" name="datumIVreme">
<button type="submit">POSALJI ZAHTEV</button>
</form>
</form>
<div th:if="${loggedUser.korisnik.korisnikId == oglas.korisnikId}" th:object="${zahtevi}">
<p th:each="zahtev: ${zahtevi}" th:text="${zahtev.toString()}"></p>
</div>
</div>
<div class="container-fluid pb-0 mb-0 justify-content-center text-light ">
<footer>
......
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