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
74dfea5d
Commit
74dfea5d
authored
Sep 15, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
insertovanje zahteva - back uradjen
parent
f1b43020
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
6 deletions
+69
-6
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+3
-0
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
+23
-0
SkuciSe/src/main/java/com/example/SkuciSe/model/zahtev/StanjeZahteva.java
+6
-0
SkuciSe/src/main/java/com/example/SkuciSe/model/zahtev/Zahtev.java
+5
-5
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
+24
-0
SkuciSe/src/main/resources/templates/oglas.html
+8
-1
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
74dfea5d
...
@@ -3,6 +3,7 @@ package com.example.SkuciSe.controller;
...
@@ -3,6 +3,7 @@ package com.example.SkuciSe.controller;
import
com.example.SkuciSe.model.korisnik.Korisnik
;
import
com.example.SkuciSe.model.korisnik.Korisnik
;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
import
com.example.SkuciSe.model.oglas.Oglas
;
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.KorisnikRepository
;
import
com.example.SkuciSe.repository.LokacijaRepository
;
import
com.example.SkuciSe.repository.LokacijaRepository
;
import
com.example.SkuciSe.repository.OglasRepository
;
import
com.example.SkuciSe.repository.OglasRepository
;
...
@@ -86,6 +87,8 @@ public class OglasController
...
@@ -86,6 +87,8 @@ 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
());
model
.
addAttribute
(
"oglasId"
,
oglasId
);
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"oglas"
,
oRepo
.
findById
(
oglasId
));
model
.
addAttribute
(
"oglas"
,
oRepo
.
findById
(
oglasId
));
model
.
addAttribute
(
"slike"
,
sRepo
.
findAllById
(
oglasId
));
model
.
addAttribute
(
"slike"
,
sRepo
.
findAllById
(
oglasId
));
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
View file @
74dfea5d
package
com
.
example
.
SkuciSe
.
controller
;
package
com
.
example
.
SkuciSe
.
controller
;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
import
com.example.SkuciSe.model.zahtev.StanjeZahteva
;
import
com.example.SkuciSe.model.zahtev.Zahtev
;
import
com.example.SkuciSe.repository.ZahtevRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
java.util.Date
;
@Controller
@Controller
public
class
ZahtevController
{
public
class
ZahtevController
{
@Autowired
ZahtevRepository
zRepo
;
@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
);
return
"moji-zahtevi"
;
return
"moji-zahtevi"
;
}
}
@PostMapping
(
"/obradi-zahtev/{id}"
)
public
String
postObradizahtev
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
@ModelAttribute
Zahtev
noviZahtev
,
@ModelAttribute
(
"datumIVreme"
)
String
datumIVreme
,
@PathVariable
(
"id"
)
int
oglasId
)
{
noviZahtev
.
setKorisnikId
(
loggedUser
.
getKorisnik
().
getKorisnikId
());
noviZahtev
.
setOglasId
(
oglasId
);
noviZahtev
.
setStatus
(
StanjeZahteva
.
CEKANJE
);
zRepo
.
insert
(
noviZahtev
,
datumIVreme
);
return
"redirect:/lista-oglasa/"
+
oglasId
;
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/model/zahtev/StanjeZahteva.java
0 → 100644
View file @
74dfea5d
package
com
.
example
.
SkuciSe
.
model
.
zahtev
;
public
enum
StanjeZahteva
{
CEKANJE
,
POTVRDJEN
,
ODBIJEN
,
ZAVRSEN
}
SkuciSe/src/main/java/com/example/SkuciSe/model/
termin/Termin
.java
→
SkuciSe/src/main/java/com/example/SkuciSe/model/
zahtev/Zahtev
.java
View file @
74dfea5d
package
com
.
example
.
SkuciSe
.
model
.
termin
;
package
com
.
example
.
SkuciSe
.
model
.
zahtev
;
import
lombok.*
;
import
lombok.*
;
...
@@ -9,12 +9,12 @@ import java.sql.*;
...
@@ -9,12 +9,12 @@ import java.sql.*;
@NoArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
@AllArgsConstructor
@ToString
@ToString
public
class
Termin
public
class
Zahtev
{
{
int
terminId
;
int
terminId
;
int
korisnikId
;
int
korisnikId
;
int
oglasId
;
int
oglasId
;
Date
datum
;
String
datum
;
Time
vreme
;
String
vreme
;
St
ring
status
;
St
anjeZahteva
status
;
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
View file @
74dfea5d
package
com
.
example
.
SkuciSe
.
repository
;
package
com
.
example
.
SkuciSe
.
repository
;
import
com.example.SkuciSe.model.zahtev.Zahtev
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.sql.SQLException
;
@Component
public
class
ZahtevRepository
{
public
class
ZahtevRepository
{
@Autowired
DataBase
dataBase
;
public
void
insert
(
Zahtev
noviZahtev
,
String
datumIVreme
)
{
String
datum
=
datumIVreme
.
split
(
"T"
)[
0
];
String
vreme
=
datumIVreme
.
split
(
"T"
)[
1
];
noviZahtev
.
setDatum
(
datum
);
noviZahtev
.
setVreme
(
vreme
);
System
.
out
.
println
(
noviZahtev
.
toString
());
String
sql
=
"insert into zahtev( oglasid, korisnikid, datum, vreme, stanje) values ("
+
noviZahtev
.
getOglasId
()+
","
+
noviZahtev
.
getKorisnikId
()+
",'"
+
noviZahtev
.
getDatum
()+
"','"
+
noviZahtev
.
getDatum
()+
"','"
+
noviZahtev
.
getStatus
()+
"')"
;
try
{
dataBase
.
statement
.
executeUpdate
(
sql
);
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
SkuciSe/src/main/resources/templates/oglas.html
View file @
74dfea5d
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
</div>
</div>
</nav>
</nav>
<div
class=
"mt-5 ml-5 mr-0 w-100"
>
<div
class=
"mt-5 ml-5 mr-0 w-100"
th:object=
"${oglasId}"
>
<div
class=
"row mb-5 flex-row"
>
<div
class=
"row mb-5 flex-row"
>
<div
class=
"col-lg-6 col-md-6 col-sm-6"
>
<div
class=
"col-lg-6 col-md-6 col-sm-6"
>
<div
id=
"custCarousel"
class=
"carousel slide"
data-ride=
"carousel"
align=
"center"
>
<div
id=
"custCarousel"
class=
"carousel slide"
data-ride=
"carousel"
align=
"center"
>
...
@@ -170,6 +170,13 @@
...
@@ -170,6 +170,13 @@
</div>
</div>
</div>
</div>
<form
th:if=
"${loggedUser != null}"
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>
<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