Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SkuciSe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tim 2 - 2022
SkuciSe
Commits
6fcfbc14
Commit
6fcfbc14
authored
Sep 16, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
obrisi zahtev - back
parent
440596bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
8 deletions
+24
-8
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
+10
-3
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
+13
-0
SkuciSe/src/main/resources/templates/moji-zahtevi.html
+1
-5
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
View file @
6fcfbc14
...
@@ -31,15 +31,16 @@ public class ZahtevController {
...
@@ -31,15 +31,16 @@ public class ZahtevController {
@GetMapping
(
"/profile/moji-zahtevi"
)
@GetMapping
(
"/profile/moji-zahtevi"
)
public
String
getMojiZahtevi
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
public
String
getMojiZahtevi
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
List
<
Zahtev
>
mojiZahtevi
=
zRepo
.
findAllByKorisnikId
(
loggedUser
.
getKorisnik
().
getKorisnikId
());
List
<
Zahtev
>
mojiZahtevi
=
zRepo
.
findAllByKorisnikId
(
loggedUser
.
getKorisnik
().
getKorisnikId
());
List
<
Oglas
>
mojiOglasi
=
new
ArrayList
<
Oglas
>();
List
<
Oglas
>
mojiOglasi
=
new
ArrayList
<
Oglas
>();
for
(
Zahtev
zahtev:
mojiZahtevi
)
for
(
Zahtev
zahtev:
mojiZahtevi
)
mojiOglasi
.
add
(
oRepo
.
findById
(
zahtev
.
getOglasId
()));
mojiOglasi
.
add
(
oRepo
.
findById
(
zahtev
.
getOglasId
()));
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"zahtevi"
,
mojiZahtevi
);
model
.
addAttribute
(
"zahtevi"
,
mojiZahtevi
);
//model.addAttribute("oglasi", mojiOglasi);
model
.
addAttribute
(
"oglasi"
,
mojiOglasi
);
return
"moji-zahtevi"
;
return
"moji-zahtevi"
;
}
}
...
@@ -74,4 +75,10 @@ public class ZahtevController {
...
@@ -74,4 +75,10 @@ public class ZahtevController {
return
(
"redirect:/lista-oglasa/"
+
oglasId
);
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
);
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
View file @
6fcfbc14
...
@@ -140,4 +140,17 @@ public class ZahtevRepository {
...
@@ -140,4 +140,17 @@ public class ZahtevRepository {
throw
new
RuntimeException
(
e
);
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
);
}
}
}
}
SkuciSe/src/main/resources/templates/moji-zahtevi.html
View file @
6fcfbc14
<!DOCTYPE html>
<!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>
<head>
<meta
charset=
"utf-8"
/>
<meta
charset=
"utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
/>
...
@@ -103,10 +103,6 @@
...
@@ -103,10 +103,6 @@
</div>
</div>
</nav>
</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 "
>
<div
class=
"container-fluid pb-0 mb-0 justify-content-center text-light "
>
<footer>
<footer>
<div
class=
"row my-5 justify-content-center py-5"
>
<div
class=
"row my-5 justify-content-center py-5"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment