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
64b58b16
Commit
64b58b16
authored
Sep 18, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lajkovanje uradjeno, brisanje, cuvanje - back ( ostao jos front)
parent
38799f7a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
5 deletions
+16
-5
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
+3
-0
SkuciSe/src/main/java/com/example/SkuciSe/controller/LajkController.java
+2
-2
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+5
-2
SkuciSe/src/main/java/com/example/SkuciSe/model/komentar/Lajk.java
+1
-1
SkuciSe/src/main/java/com/example/SkuciSe/repository/LajkRepository.java
+2
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+3
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
View file @
64b58b16
...
...
@@ -28,6 +28,8 @@ public class AdminController
OglasRepository
oRepo
;
@Autowired
ZahtevRepository
zRepo
;
@Autowired
LajkRepository
lajkRepo
;
@GetMapping
(
"/lista-korisnika"
)
public
String
getListaKorisnika
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
...
...
@@ -51,6 +53,7 @@ public class AdminController
{
komRepo
.
deleteKomentariByKorisnikId
(
id
);
zRepo
.
deleteZahteviByKorisnikId
(
id
);
lajkRepo
.
deleteLajkByKorisnikId
(
id
);
oRepo
.
deleteOglasi
(
id
);
kRepo
.
deleteUser
(
id
);
redirectAttributes
.
addFlashAttribute
(
"deleted"
,
true
);
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/LajkController.java
View file @
64b58b16
...
...
@@ -4,10 +4,10 @@ import com.example.SkuciSe.model.komentar.Lajk;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
import
com.example.SkuciSe.repository.LajkRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.Banner
;
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.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -16,7 +16,7 @@ public class LajkController
{
@Autowired
LajkRepository
lajkRepo
;
@
Pos
tMapping
(
"/lista-oglasa/{oglasId}/lajkuj-oglas"
)
@
Ge
tMapping
(
"/lista-oglasa/{oglasId}/lajkuj-oglas"
)
public
String
postLajkujOglas
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
@PathVariable
(
"oglasId"
)
int
oglasId
)
{
lajkRepo
.
updateLajk
(
new
Lajk
(
oglasId
,
loggedUser
.
getKorisnik
().
getKorisnikId
()));
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
64b58b16
...
...
@@ -119,8 +119,11 @@ public class OglasController
}
model
.
addAttribute
(
"korisniciKomentari"
,
korisniciKomentari
);
model
.
addAttribute
(
"liked"
,
lajkRepo
.
isLiked
(
new
Lajk
(
oglasId
,
loggedUser
.
getKorisnik
().
getKorisnikId
())));
model
.
addAttribute
(
"likesCount"
,
lajkRepo
.
countLajks
(
oglasId
));
if
(
loggedUser
!=
null
)
{
model
.
addAttribute
(
"liked"
,
lajkRepo
.
isLiked
(
new
Lajk
(
oglasId
,
loggedUser
.
getKorisnik
().
getKorisnikId
())));
model
.
addAttribute
(
"likesCount"
,
lajkRepo
.
countLajks
(
oglasId
));
}
return
(
"oglas"
);
}
@GetMapping
(
"/profile/moji-oglasi"
)
...
...
SkuciSe/src/main/java/com/example/SkuciSe/model/komentar/Lajk.java
View file @
64b58b16
...
...
@@ -9,6 +9,6 @@ import lombok.*;
@ToString
public
class
Lajk
{
private
int
korisnikId
;
private
int
oglasId
;
private
int
korisnikId
;
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/LajkRepository.java
View file @
64b58b16
...
...
@@ -25,10 +25,12 @@ public class LajkRepository {
{
if
(
this
.
isLiked
(
lajk
))
{
System
.
out
.
println
(
"delete "
+
lajk
.
toString
());
this
.
deleteLajk
(
lajk
);
}
else
{
System
.
out
.
println
(
"insert "
+
lajk
.
toString
());
this
.
insertLajk
(
lajk
);
}
}
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
64b58b16
...
...
@@ -18,6 +18,8 @@ public class OglasRepository
KomentarRepository
komRepo
;
@Autowired
DataBase
dataBase
;
@Autowired
LajkRepository
lajkRepo
;
public
int
insert
(
int
korisnikId
,
Oglas
newOglas
,
MultipartFile
[]
files
)
{
...
...
@@ -94,6 +96,7 @@ public class OglasRepository
{
int
oglasid
=
rs
.
getInt
(
"oglasid"
);
komRepo
.
deleteKomentariByOglasId
(
oglasid
);
lajkRepo
.
deleteLajkByOglasId
(
oglasid
);
this
.
deleteSlike
(
oglasid
);
this
.
deleteZahteviByOglasId
(
oglasid
);
}
...
...
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