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
fbc8a1cb
Commit
fbc8a1cb
authored
Sep 15, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
korisnici za zahteve i odbij prihvati zahtev - back
parent
7bf9e5e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+9
-2
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
+13
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
+14
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
fbc8a1cb
...
@@ -94,8 +94,15 @@ public class OglasController
...
@@ -94,8 +94,15 @@ public class OglasController
model
.
addAttribute
(
"slike"
,
sRepo
.
findAllById
(
oglasId
));
model
.
addAttribute
(
"slike"
,
sRepo
.
findAllById
(
oglasId
));
model
.
addAttribute
(
"grad"
,
kRepo
.
findCity
(
oglas
.
getLokacijaId
()));
model
.
addAttribute
(
"grad"
,
kRepo
.
findCity
(
oglas
.
getLokacijaId
()));
model
.
addAttribute
(
"noviZahtev"
,
new
Zahtev
());
model
.
addAttribute
(
"noviZahtev"
,
new
Zahtev
());
if
(
loggedUser
!=
null
&&
oglas
.
getKorisnikId
()
==
loggedUser
.
getKorisnik
().
getKorisnikId
())
if
(
loggedUser
!=
null
&&
oglas
.
getKorisnikId
()
==
loggedUser
.
getKorisnik
().
getKorisnikId
())
{
model
.
addAttribute
(
"zahtevi"
,
zRepo
.
findAllByOglasId
(
oglasId
));
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"
);
return
(
"oglas"
);
}
}
@GetMapping
(
"/profile/moji-oglasi"
)
@GetMapping
(
"/profile/moji-oglasi"
)
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
View file @
fbc8a1cb
...
@@ -44,4 +44,17 @@ public class ZahtevController {
...
@@ -44,4 +44,17 @@ public class ZahtevController {
return
"redirect:/lista-oglasa/"
+
oglasId
;
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
);
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
View file @
fbc8a1cb
...
@@ -96,4 +96,18 @@ public class ZahtevRepository {
...
@@ -96,4 +96,18 @@ public class ZahtevRepository {
throw
new
RuntimeException
(
e
);
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
);
}
}
}
}
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