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
75ec918a
Commit
75ec918a
authored
Sep 10, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dodate klase slika i slikarepository i slanje slika na front za oglas
parent
5babace6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
1 deletions
+57
-1
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+5
-1
SkuciSe/src/main/java/com/example/SkuciSe/model/slika/Slika.java
+15
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/SlikeRepository.java
+35
-0
SkuciSe/src/main/resources/templates/oglas.html
+2
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
75ec918a
...
@@ -6,6 +6,7 @@ import com.example.SkuciSe.model.oglas.Oglas;
...
@@ -6,6 +6,7 @@ import com.example.SkuciSe.model.oglas.Oglas;
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
;
import
com.example.SkuciSe.repository.SlikeRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
;
...
@@ -28,6 +29,9 @@ public class OglasController
...
@@ -28,6 +29,9 @@ public class OglasController
@Autowired
@Autowired
OglasRepository
oRepo
;
OglasRepository
oRepo
;
@Autowired
SlikeRepository
sRepo
;
@GetMapping
(
"/novi-oglas"
)
@GetMapping
(
"/novi-oglas"
)
public
String
getNoviOglas
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
public
String
getNoviOglas
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
{
...
@@ -65,9 +69,9 @@ public class OglasController
...
@@ -65,9 +69,9 @@ 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
)
{
{
System
.
out
.
println
(
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
));
return
(
"oglas"
);
return
(
"oglas"
);
}
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/model/slika/Slika.java
0 → 100644
View file @
75ec918a
package
com
.
example
.
SkuciSe
.
model
.
slika
;
import
lombok.*
;
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public
class
Slika
{
int
slikaId
;
int
oglasId
;
String
slikaCode
;
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/SlikeRepository.java
0 → 100644
View file @
75ec918a
package
com
.
example
.
SkuciSe
.
repository
;
import
com.example.SkuciSe.model.slika.Slika
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.List
;
@Component
public
class
SlikeRepository
{
@Autowired
DataBase
dataBase
;
public
List
<
Slika
>
findAllById
(
int
oglasId
)
{
List
<
Slika
>
list
=
new
ArrayList
<
Slika
>();
String
sql
=
"select * from slike where oglasid = "
+
oglasId
;
ResultSet
rs
=
null
;
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
list
.
add
(
new
Slika
(
rs
.
getInt
(
"slikeId"
),
rs
.
getInt
(
"oglasid"
),
rs
.
getString
(
"slika"
)
));
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
list
;
}
}
SkuciSe/src/main/resources/templates/oglas.html
View file @
75ec918a
...
@@ -91,6 +91,8 @@
...
@@ -91,6 +91,8 @@
<div
class=
"container"
th:object=
"${oglas}"
>
<div
class=
"container"
th:object=
"${oglas}"
>
<h1
th:text=
"${oglas.toString()}"
></h1>
<h1
th:text=
"${oglas.toString()}"
></h1>
</div>
</div>
<div
class=
"container"
th:object=
"${slike}"
>
</div>
<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>
...
...
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