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
a8158d86
Commit
a8158d86
authored
Sep 15, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
premestanje setovanja u repository i provera da li je logovan vlasnik oglasa zbog slanja zahteva
parent
6748fcd6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+5
-3
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
+1
-4
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
+4
-1
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
a8158d86
...
@@ -87,12 +87,14 @@ public class OglasController
...
@@ -87,12 +87,14 @@ public class OglasController
@GetMapping
(
"/lista-oglasa/{oglasId}"
)
@GetMapping
(
"/lista-oglasa/{oglasId}"
)
public
String
getOglas
(
Model
model
,
@PathVariable
(
"oglasId"
)
int
oglasId
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
public
String
getOglas
(
Model
model
,
@PathVariable
(
"oglasId"
)
int
oglasId
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
{
model
.
addAttribute
(
"noviZahtev"
,
new
Zahtev
());
Oglas
oglas
=
oRepo
.
findById
(
oglasId
);
model
.
addAttribute
(
"oglas"
,
oglas
);
model
.
addAttribute
(
"oglasId"
,
oglasId
);
model
.
addAttribute
(
"oglasId"
,
oglasId
);
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"oglas"
,
oRepo
.
findById
(
oglasId
));
model
.
addAttribute
(
"slike"
,
sRepo
.
findAllById
(
oglasId
));
model
.
addAttribute
(
"slike"
,
sRepo
.
findAllById
(
oglasId
));
model
.
addAttribute
(
"grad"
,
kRepo
.
findCity
(
oRepo
.
findById
(
oglasId
).
getLokacijaId
()));
model
.
addAttribute
(
"grad"
,
kRepo
.
findCity
(
oglas
.
getLokacijaId
()));
model
.
addAttribute
(
"noviZahtev"
,
new
Zahtev
());
if
(
loggedUser
!=
null
&&
oglas
.
getKorisnikId
()
==
loggedUser
.
getKorisnik
().
getKorisnikId
())
model
.
addAttribute
(
"zahtevi"
,
zRepo
.
findAllByOglasId
(
oglasId
));
model
.
addAttribute
(
"zahtevi"
,
zRepo
.
findAllByOglasId
(
oglasId
));
return
(
"oglas"
);
return
(
"oglas"
);
}
}
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
View file @
a8158d86
...
@@ -32,10 +32,7 @@ public class ZahtevController {
...
@@ -32,10 +32,7 @@ public class ZahtevController {
@PostMapping
(
"/obradi-zahtev/{id}"
)
@PostMapping
(
"/obradi-zahtev/{id}"
)
public
String
postObradizahtev
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
@ModelAttribute
Zahtev
noviZahtev
,
@ModelAttribute
(
"datumIVreme"
)
String
datumIVreme
,
@PathVariable
(
"id"
)
int
oglasId
)
public
String
postObradizahtev
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
@ModelAttribute
Zahtev
noviZahtev
,
@ModelAttribute
(
"datumIVreme"
)
String
datumIVreme
,
@PathVariable
(
"id"
)
int
oglasId
)
{
{
noviZahtev
.
setKorisnikId
(
loggedUser
.
getKorisnik
().
getKorisnikId
());
zRepo
.
insert
(
loggedUser
.
getKorisnik
().
getKorisnikId
(),
oglasId
,
noviZahtev
,
datumIVreme
);
noviZahtev
.
setOglasId
(
oglasId
);
noviZahtev
.
setStatus
(
StanjeZahteva
.
CEKANJE
);
zRepo
.
insert
(
noviZahtev
,
datumIVreme
);
return
"redirect:/lista-oglasa/"
+
oglasId
;
return
"redirect:/lista-oglasa/"
+
oglasId
;
}
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
View file @
a8158d86
...
@@ -16,7 +16,7 @@ import java.util.*;
...
@@ -16,7 +16,7 @@ import java.util.*;
public
class
ZahtevRepository
{
public
class
ZahtevRepository
{
@Autowired
@Autowired
DataBase
dataBase
;
DataBase
dataBase
;
public
void
insert
(
Zahtev
noviZahtev
,
String
datumIVreme
)
public
void
insert
(
int
korisnikId
,
int
oglasId
,
Zahtev
noviZahtev
,
String
datumIVreme
)
{
{
String
datum
=
datumIVreme
.
split
(
" "
)[
0
];
String
datum
=
datumIVreme
.
split
(
" "
)[
0
];
System
.
out
.
println
(
datum
);
System
.
out
.
println
(
datum
);
...
@@ -24,6 +24,9 @@ public class ZahtevRepository {
...
@@ -24,6 +24,9 @@ public class ZahtevRepository {
String
vreme
=
datumIVreme
.
split
(
" "
)[
1
];
String
vreme
=
datumIVreme
.
split
(
" "
)[
1
];
noviZahtev
.
setDatum
(
datumFormatiran
.
toString
());
noviZahtev
.
setDatum
(
datumFormatiran
.
toString
());
noviZahtev
.
setVreme
(
vreme
);
noviZahtev
.
setVreme
(
vreme
);
noviZahtev
.
setKorisnikId
(
korisnikId
);
noviZahtev
.
setOglasId
(
oglasId
);
noviZahtev
.
setStatus
(
StanjeZahteva
.
CEKANJE
);
String
sql
=
"{call insertZahtev(?,?,?,?,?)}"
;
String
sql
=
"{call insertZahtev(?,?,?,?,?)}"
;
CallableStatement
stmt
=
null
;
CallableStatement
stmt
=
null
;
...
...
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