Commit 83027bec by Bogdan Andjelkovic

div u footeru, poruka o vec postojecem aktivnom zahtevu, updatovanje zavrsen na zahtevima

parent fcaca62f
package com.example.SkuciSe.configuration;
public class AktivanZahtevPostoji extends Exception
{
}
package com.example.SkuciSe.controller;
import com.example.SkuciSe.configuration.AktivanZahtevPostoji;
import com.example.SkuciSe.model.korisnik.KorisnikDetails;
import com.example.SkuciSe.model.zahtev.StanjeZahteva;
import com.example.SkuciSe.model.zahtev.Zahtev;
......@@ -33,8 +34,12 @@ public class ZahtevController {
@PostMapping("/obradi-zahtev/{id}")
public String postObradizahtev(Model model, @AuthenticationPrincipal KorisnikDetails loggedUser, @ModelAttribute Zahtev noviZahtev, @ModelAttribute("datumIVreme") String datumIVreme, @PathVariable("id") int oglasId, RedirectAttributes redirectAttributes)
{
try {
zRepo.insert( loggedUser.getKorisnik().getKorisnikId(), oglasId, noviZahtev, datumIVreme);
redirectAttributes.addFlashAttribute("zakazan",true);
} catch (AktivanZahtevPostoji e) {
redirectAttributes.addFlashAttribute("aktivanZahtevPostoji",true);
}
return "redirect:/lista-oglasa/"+oglasId;
}
......
package com.example.SkuciSe.repository;
import com.example.SkuciSe.configuration.AktivanZahtevPostoji;
import com.example.SkuciSe.model.zahtev.StanjeZahteva;
import com.example.SkuciSe.model.zahtev.Zahtev;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -16,8 +17,22 @@ import java.util.*;
public class ZahtevRepository {
@Autowired
DataBase dataBase;
public void insert( int korisnikId, int oglasId, Zahtev noviZahtev, String datumIVreme)
public void insert( int korisnikId, int oglasId, Zahtev noviZahtev, String datumIVreme) throws AktivanZahtevPostoji
{
this.postaviFinishedZahteve();
try {
CallableStatement provera = dataBase.connection.prepareCall( "{ call daLiPostojiAktivanZahtev(?,?)}");
provera.setInt( 1, korisnikId);
provera.setInt( 2, oglasId);
ResultSet rs = provera.executeQuery();
while( rs.next()) {
System.out.println(rs.getString("stanje"));
throw new AktivanZahtevPostoji();
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
String datum = datumIVreme.split(" ")[0];
LocalDate datumFormatiran = LocalDate.parse(datum, DateTimeFormatter.ofPattern("MM/dd/yyyy"));
String vreme = datumIVreme.split(" ")[1];
......@@ -44,6 +59,7 @@ public class ZahtevRepository {
public List<Zahtev> findAllByKorisnikId( int korisnikId)
{
this.postaviFinishedZahteve();
List<Zahtev> list = new ArrayList<Zahtev>();
String sql = "call findAllZahtevByKorisnikId(?)";
CallableStatement stmt = null;
......@@ -65,6 +81,7 @@ public class ZahtevRepository {
public List<Zahtev> findAllByOglasId( int oglasId)
{
this.postaviFinishedZahteve();
List<Zahtev> list = new ArrayList<Zahtev>();
String sql = "call findAllZahtevByOglasId(?)";
CallableStatement stmt = null;
......@@ -109,5 +126,18 @@ public class ZahtevRepository {
} catch (SQLException e) {
throw new RuntimeException(e);
}
this.postaviFinishedZahteve();
}
public void postaviFinishedZahteve()
{
String sql = "{ call postaviFinishedZahteve()}";
CallableStatement cs = null;
try {
cs = dataBase.connection.prepareCall(sql);
cs.execute();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
......@@ -203,7 +203,7 @@
class="fa fa-envelope" aria-hidden="true"></i></span><a href="mailto:someone@yoursite.com" style="text-decoration: none;color:#627482;" onmouseover="this.style.color='#989c9e'" onMouseOut="this.style.color='#627482'"> skucise@gmail.com</a> </small></div>
</div>
</div>
</div>
</div></div>
</footer>
</div>
<!-- JavaScript Bundle with Popper -->
......
......@@ -185,6 +185,7 @@
</div>
</div>
</div>
</div>
</footer>
</div>
<!-- JavaScript Bundle with Popper -->
......
......@@ -379,7 +379,7 @@
class="fa fa-envelope" aria-hidden="true"></i></span><a href="mailto:someone@yoursite.com" style="text-decoration: none;color:#627482;" onmouseover="this.style.color='#989c9e'" onMouseOut="this.style.color='#627482'"> skucise@gmail.com</a> </small></div>
</div>
</div>
</div>
</div></div>
</footer>
</div>
......
......@@ -161,7 +161,7 @@
class="fa fa-envelope" aria-hidden="true"></i></span><a href="mailto:someone@yoursite.com" style="text-decoration: none;color:#627482;" onmouseover="this.style.color='#989c9e'" onMouseOut="this.style.color='#627482'"> skucise@gmail.com</a> </small></div>
</div>
</div>
</div>
</div></div>
</footer>
</div>
<!-- JavaScript Bundle with Popper -->
......
......@@ -139,6 +139,7 @@
</div>
</div>
</div>
</div>
</footer>
</div>
......
......@@ -287,7 +287,7 @@
class="fa fa-envelope" aria-hidden="true"></i></span><a href="mailto:someone@yoursite.com" style="text-decoration: none;color:#627482;" onmouseover="this.style.color='#989c9e'" onMouseOut="this.style.color='#627482'"> skucise@gmail.com</a> </small></div>
</div>
</div>
</div>
</div></div>
</footer>
</div>
<!-- JavaScript Bundle with Popper -->
......
......@@ -107,6 +107,11 @@
<div><strong>Uspesno!</strong> Uspesno ste poslali zahtev za obilazak!</div>
<button type="button" class="btn-close" data-dismiss="alert"></button>
</div>
<div class="alert alert-warning d-flex justify-content-between align-items-center" th:object="${aktivanZahtevPostoji}"
th:if="${aktivanZahtevPostoji == true}" style="width: 96%">
<div><strong>Greška!</strong> Vec postoji aktivan zahtev za ovaj oglas!</div>
<button type="button" class="btn-close" data-dismiss="alert"></button>
</div>
<div class="row mb-5 flex-row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div id="custCarousel" class="carousel slide" data-ride="carousel" align="center">
......@@ -316,7 +321,7 @@
class="fa fa-envelope" aria-hidden="true"></i></span><a href="mailto:someone@yoursite.com" style="text-decoration: none;color:#627482;" onmouseover="this.style.color='#989c9e'" onMouseOut="this.style.color='#627482'"> skucise@gmail.com</a> </small></div>
</div>
</div>
</div>
</div></div>
</footer>
</div>
......
......@@ -169,7 +169,7 @@
class="fa fa-envelope" aria-hidden="true"></i></span><a href="mailto:someone@yoursite.com" style="text-decoration: none;color:#627482;" onmouseover="this.style.color='#989c9e'" onMouseOut="this.style.color='#627482'"> skucise@gmail.com</a> </small></div>
</div>
</div>
</div>
</div></div>
</footer>
</div>
<!-- JavaScript Bundle with Popper -->
......
......@@ -192,7 +192,7 @@
class="fa fa-envelope" aria-hidden="true"></i></span><a href="mailto:someone@yoursite.com" style="text-decoration: none;color:#627482;" onmouseover="this.style.color='#989c9e'" onMouseOut="this.style.color='#627482'"> skucise@gmail.com</a> </small></div>
</div>
</div>
</div>
</div></div>
</footer>
</div>
<!-- JavaScript Bundle with Popper -->
......
......@@ -194,7 +194,7 @@
class="fa fa-envelope" aria-hidden="true"></i></span><a href="mailto:someone@yoursite.com" style="text-decoration: none;color:#627482;" onmouseover="this.style.color='#989c9e'" onMouseOut="this.style.color='#627482'"> skucise@gmail.com</a> </small></div>
</div>
</div>
</div>
</div></div>
</footer>
</div>
<!-- JavaScript Bundle with Popper -->
......
......@@ -207,6 +207,7 @@
</div>
</div>
</div>
</div>
</footer>
</div>
<!-- JavaScript Bundle with Popper -->
......
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