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
12b14a2e
Commit
12b14a2e
authored
Sep 19, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
komentari vlasnika, stranica korisnika sa njegovim oglasima i komentarima
parent
beca7ae7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
167 additions
and
19 deletions
+167
-19
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
+5
-3
SkuciSe/src/main/java/com/example/SkuciSe/controller/KomentarController.java
+19
-2
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+0
-8
SkuciSe/src/main/java/com/example/SkuciSe/controller/ProfileController.java
+37
-6
SkuciSe/src/main/java/com/example/SkuciSe/model/komentar/KomentarVlasnik.java
+19
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/KomentarVlasnikRepository.java
+69
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+9
-0
SkuciSe/src/main/resources/templates/korisnik.html
+0
-0
SkuciSe/src/main/resources/templates/oglas.html
+9
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
View file @
12b14a2e
...
...
@@ -30,7 +30,8 @@ public class AdminController
ZahtevRepository
zRepo
;
@Autowired
LajkRepository
lajkRepo
;
@Autowired
KomentarVlasnikRepository
komentarVlasnikRepo
;
@GetMapping
(
"/lista-korisnika"
)
public
String
getListaKorisnika
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
...
...
@@ -38,12 +39,12 @@ public class AdminController
{
return
"redirect:/index"
;
}
model
.
addAttribute
(
"korisnici"
,
kRepo
.
findAll
());
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
for
(
Korisnik
k:
kRepo
.
findAll
())
{
list
.
add
(
kRepo
.
findCity
(
k
.
getGradId
()));
}
model
.
addAttribute
(
"korisnici"
,
kRepo
.
findAll
());
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"gradovi"
,
list
);
return
"lista-korisnika"
;
}
...
...
@@ -51,6 +52,7 @@ public class AdminController
@PostMapping
(
"/delete-user/{id}"
)
public
String
deleteUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
komentarVlasnikRepo
.
deleteKomentarVlasnikByKorisnikId
(
id
);
komRepo
.
deleteKomentariByKorisnikId
(
id
);
zRepo
.
deleteZahteviByKorisnikId
(
id
);
lajkRepo
.
deleteLajkByKorisnikId
(
id
);
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/KomentarController.java
View file @
12b14a2e
package
com
.
example
.
SkuciSe
.
controller
;
import
com.example.SkuciSe.repository.KomentarRepository
;
import
com.example.SkuciSe.repository.KomentarVlasnikRepository
;
import
com.example.SkuciSe.repository.ZahtevRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -13,13 +14,15 @@ public class KomentarController {
KomentarRepository
komentarRepo
;
@Autowired
ZahtevRepository
zRepo
;
@Autowired
KomentarVlasnikRepository
komentarVlasnikRepo
;
@GetMapping
(
"/profile/moji-zahtevi/sacuvaj-komentar"
)
public
String
postSacuvajKomentar
(
@RequestParam
(
"korisnikId"
)
int
korisnikId
,
@RequestParam
(
"oglasId"
)
int
oglasId
,
@RequestParam
(
"zahtevId"
)
int
zahtevId
,
@RequestParam
(
"ocenaRadio"
)
int
ocenaRadio
,
@RequestParam
(
"komentar"
)
String
text
)
{
@RequestParam
(
"komentar"
)
String
text
)
{
try
{
komentarRepo
.
insert
(
korisnikId
,
oglasId
,
text
,
ocenaRadio
);
zRepo
.
deleteZahtev
(
zahtevId
);
...
...
@@ -28,4 +31,18 @@ public class KomentarController {
}
return
(
"redirect:/profile/moji-zahtevi"
);
}
@GetMapping
(
"/oceni-korisnika"
)
public
String
getOceniKorisnika
(
@RequestParam
(
"vlasnikId"
)
int
vlasnikId
,
@RequestParam
(
"korisnikId"
)
int
korisnikId
,
@RequestParam
(
"ocenaRadio"
)
int
ocenaRadio
,
@RequestParam
(
"komentar"
)
String
text
)
{
try
{
komentarVlasnikRepo
.
insert
(
vlasnikId
,
korisnikId
,
ocenaRadio
,
text
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
return
(
"redirect:/profile/moji-zahtevi"
);
}
}
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
12b14a2e
...
...
@@ -112,10 +112,6 @@ public class OglasController
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
List
<
Oglas
>
listaOglasa
=
oRepo
.
findAll
(
vrstaOglasaId
,
lokacijaId
,
brojSoba
,
cenaMin
,
cenaMax
,
kvadraturaMin
,
kvadraturaMax
,
lift
,
grejanje
,
namesten
,
pretraga
);
while
(
listaOglasa
.
size
()
%
3
!=
0
){
Oglas
o
=
new
Oglas
();
listaOglasa
.
add
(
o
);
}
model
.
addAttribute
(
"oglasi"
,
listaOglasa
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
for
(
Oglas
o:
listaOglasa
)
{
...
...
@@ -144,10 +140,6 @@ public class OglasController
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
List
<
Oglas
>
listaOglasa
=
oRepo
.
findAllByKorisnikId
(
loggedUser
.
getKorisnik
().
getKorisnikId
(),
vrstaOglasaId
,
lokacijaId
,
brojSoba
,
cenaMin
,
cenaMax
,
kvadraturaMin
,
kvadraturaMax
,
lift
,
grejanje
,
namesten
,
pretraga
);
while
(
listaOglasa
.
size
()
%
3
!=
0
){
Oglas
o
=
new
Oglas
();
listaOglasa
.
add
(
o
);
}
model
.
addAttribute
(
"oglasi"
,
listaOglasa
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
for
(
Oglas
o:
listaOglasa
)
{
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/ProfileController.java
View file @
12b14a2e
package
com
.
example
.
SkuciSe
.
controller
;
import
com.example.SkuciSe.model.komentar.Komentar
;
import
com.example.SkuciSe.model.komentar.KomentarVlasnik
;
import
com.example.SkuciSe.model.korisnik.Korisnik
;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
import
com.example.SkuciSe.
repository.KorisnikRepository
;
import
com.example.SkuciSe.repository.
LokacijaRepository
;
import
com.example.SkuciSe.
model.oglas.Oglas
;
import
com.example.SkuciSe.repository.
*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.List
;
@Controller
public
class
ProfileController
...
...
@@ -26,6 +27,16 @@ public class ProfileController
@Autowired
LokacijaRepository
lRepo
;
@Autowired
OglasRepository
oRepo
;
@Autowired
SlikeRepository
sRepo
;
@Autowired
KomentarRepository
komRepo
;
@Autowired
KomentarVlasnikRepository
komentarVlasnikRepo
;
@GetMapping
(
"/profile"
)
public
String
getProfile
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
...
...
@@ -79,4 +90,24 @@ public class ProfileController
loggedUser
.
setKorisnikSifra
(
korisnik
.
getSifra
());
return
"redirect:/profile"
;
}
@GetMapping
(
"/korisnik/{korisnikId}"
)
public
String
getKorisnik
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
@PathVariable
(
"korisnikId"
)
int
korisnikId
)
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"korisnik"
,
kRepo
.
findById
(
korisnikId
));
List
<
Oglas
>
oglasi
=
oRepo
.
findAllByKorisnikId
(
korisnikId
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
model
.
addAttribute
(
"oglasi"
,
oglasi
);
model
.
addAttribute
(
"slikeOglasa"
,
sRepo
.
findAllFirstPics
(
oglasi
));
model
.
addAttribute
(
"korisniciKomentari"
,
komentarVlasnikRepo
.
findAllKomentarVlasnikByKorisnikID
(
korisnikId
));
List
<
KomentarVlasnik
>
komentari
=
komentarVlasnikRepo
.
findAllKomentarVlasnikByKorisnikID
(
korisnikId
);
List
<
Korisnik
>
korisniciKomentari
=
new
ArrayList
<
Korisnik
>();
for
(
KomentarVlasnik
komentar:
komentari
)
{
korisniciKomentari
.
add
(
kRepo
.
findById
(
komentar
.
getVlasnikId
()));
}
model
.
addAttribute
(
"komentari"
,
komentari
);
model
.
addAttribute
(
"korisniciKomentari"
,
korisniciKomentari
);
return
"korisnik"
;
}
}
SkuciSe/src/main/java/com/example/SkuciSe/model/komentar/KomentarVlasnik.java
0 → 100644
View file @
12b14a2e
package
com
.
example
.
SkuciSe
.
model
.
komentar
;
import
lombok.*
;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public
class
KomentarVlasnik
{
private
int
komentarVlasnikId
;
private
int
vlasnikId
;
private
int
korisnikId
;
private
int
ocena
;
private
String
komentar
;
private
String
datum
;
private
String
vreme
;
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/KomentarVlasnikRepository.java
0 → 100644
View file @
12b14a2e
package
com
.
example
.
SkuciSe
.
repository
;
import
com.example.SkuciSe.model.komentar.Komentar
;
import
com.example.SkuciSe.model.komentar.KomentarVlasnik
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.sql.CallableStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.List
;
@Component
public
class
KomentarVlasnikRepository
{
@Autowired
DataBase
dataBase
;
public
void
insert
(
int
vlasnikId
,
int
korisnikId
,
int
ocenaRadio
,
String
text
)
{
CallableStatement
stmt
=
null
;
ResultSet
rs
=
null
;
try
{
String
sql
=
"{call insertKomentarVlasnik(?,?,?,?)}"
;
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
vlasnikId
);
stmt
.
setInt
(
2
,
korisnikId
);
stmt
.
setInt
(
3
,
ocenaRadio
);
stmt
.
setString
(
4
,
text
);
stmt
.
execute
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
}
public
List
<
KomentarVlasnik
>
findAllKomentarVlasnikByKorisnikID
(
int
korisnikId
)
{
List
<
KomentarVlasnik
>
komentari
=
new
ArrayList
<
KomentarVlasnik
>();
CallableStatement
cs
=
null
;
String
sql
=
"{ call findAllKomentarVlasnikByKorisnikID(?)}"
;
ResultSet
rs
=
null
;
try
{
cs
=
dataBase
.
connection
.
prepareCall
(
sql
);
cs
.
setInt
(
1
,
korisnikId
);
rs
=
cs
.
executeQuery
();
while
(
rs
.
next
())
{
komentari
.
add
(
new
KomentarVlasnik
(
rs
.
getInt
(
1
),
rs
.
getInt
(
2
),
rs
.
getInt
(
3
),
rs
.
getInt
(
4
),
rs
.
getString
(
5
),
rs
.
getString
(
6
),
rs
.
getString
(
7
)));
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
(
komentari
);
}
public
void
deleteKomentarVlasnikByKorisnikId
(
Integer
id
)
throws
RuntimeException
{
String
sql
=
"{call deleteKomentarVlasnikByKorisnikId(?)}"
;
CallableStatement
stmt
=
null
;
try
{
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
id
);
stmt
.
execute
();
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
12b14a2e
...
...
@@ -188,6 +188,10 @@ public class OglasRepository
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
while
(
list
.
size
()
%
3
!=
0
){
Oglas
o
=
new
Oglas
();
list
.
add
(
o
);
}
return
(
list
);
}
...
...
@@ -229,6 +233,10 @@ public class OglasRepository
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
while
(
list
.
size
()
%
3
!=
0
){
Oglas
o
=
new
Oglas
();
list
.
add
(
o
);
}
return
(
list
);
}
}
\ No newline at end of file
SkuciSe/src/main/resources/templates/korisnik.html
0 → 100644
View file @
12b14a2e
This diff is collapsed.
Click to expand it.
SkuciSe/src/main/resources/templates/oglas.html
View file @
12b14a2e
...
...
@@ -299,6 +299,15 @@
</p>
</div>
</div>
<div
class=
"col-md-3 d-flex flex-column justify-content-around align-items-center"
>
<form
method=
"get"
th:action=
"@{/oceni-korisnika}"
>
<input
type=
"text"
th:value=
"${loggedUser.korisnik.korisnikId}"
name=
"vlasnikId"
style=
"display: none"
>
<input
type=
"text"
th:value=
"${korisnik.korisnikId}"
name=
"korisnikId"
style=
"display: none"
>
<input
type=
"number"
name=
"ocenaRadio"
><br>
<input
type=
"text"
name=
"komentar"
><br>
<button
type=
"submit"
>
Oceni
</button>
</form>
</div>
<div
class=
"col-md-2 d-flex flex-column justify-content-around align-items-center"
th:if=
"${zahtevi[korisnikStat.count - 1].status.toString() == 'CEKANJE'}"
>
<form
method=
"GET"
...
...
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