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
bf33d929
Commit
bf33d929
authored
Sep 20, 2022
by
Mihailo Sebek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
countOglas
parent
a7bea246
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+1
-0
SkuciSe/src/main/java/com/example/SkuciSe/controller/ProfileController.java
+1
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+20
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
bf33d929
...
@@ -64,6 +64,7 @@ public class OglasController
...
@@ -64,6 +64,7 @@ public class OglasController
public
String
getOglas
(
Model
model
,
@PathVariable
(
"oglasId"
)
int
oglasId
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
public
String
getOglas
(
Model
model
,
@PathVariable
(
"oglasId"
)
int
oglasId
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
{
Oglas
oglas
=
oRepo
.
findById
(
oglasId
);
Oglas
oglas
=
oRepo
.
findById
(
oglasId
);
model
.
addAttribute
(
"avgOcena"
,
komentarRepository
.
averageOcenaByOglasId
(
oglasId
));
model
.
addAttribute
(
"oglas"
,
oglas
);
model
.
addAttribute
(
"oglas"
,
oglas
);
model
.
addAttribute
(
"oglasId"
,
oglasId
);
model
.
addAttribute
(
"oglasId"
,
oglasId
);
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/ProfileController.java
View file @
bf33d929
...
@@ -94,6 +94,7 @@ public class ProfileController
...
@@ -94,6 +94,7 @@ public class ProfileController
@GetMapping
(
"/korisnik/{korisnikId}"
)
@GetMapping
(
"/korisnik/{korisnikId}"
)
public
String
getKorisnik
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
@PathVariable
(
"korisnikId"
)
int
korisnikId
)
public
String
getKorisnik
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
@PathVariable
(
"korisnikId"
)
int
korisnikId
)
{
{
model
.
addAttribute
(
"countOglas"
,
oRepo
.
countOglasByKorisnikId
(
korisnikId
));
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"korisnik"
,
kRepo
.
findById
(
korisnikId
));
model
.
addAttribute
(
"korisnik"
,
kRepo
.
findById
(
korisnikId
));
List
<
Oglas
>
oglasi
=
oRepo
.
findAllByKorisnikId
(
korisnikId
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
List
<
Oglas
>
oglasi
=
oRepo
.
findAllByKorisnikId
(
korisnikId
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
bf33d929
...
@@ -239,4 +239,23 @@ public class OglasRepository
...
@@ -239,4 +239,23 @@ public class OglasRepository
}
}
return
(
list
);
return
(
list
);
}
}
public
int
countOglasByKorisnikId
(
int
korisnikId
)
{
CallableStatement
stmt
=
null
;
ResultSet
rs
=
null
;
try
{
String
sql
=
"{call countOglasByKorisnikId(?)}"
;
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
korisnikId
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
{
return
(
rs
.
getInt
(
1
));
}
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
return
0
;
}
}
}
\ No newline at end of file
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