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
49c26675
Commit
49c26675
authored
Sep 07, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lista-oglasa - controller i repository
parent
dc175993
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+8
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+23
-1
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
49c26675
...
@@ -42,4 +42,12 @@ public class OglasController
...
@@ -42,4 +42,12 @@ public class OglasController
oRepo
.
insert
(
loggedUser
.
getKorisnik
().
getKorisnikId
(),
newOglas
,
files
);
oRepo
.
insert
(
loggedUser
.
getKorisnik
().
getKorisnikId
(),
newOglas
,
files
);
return
(
"redirect:/profile"
);
return
(
"redirect:/profile"
);
}
}
@GetMapping
(
"/lista-oglasa"
)
public
String
getListaOglasa
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"oglasi"
,
oRepo
.
findAll
());
return
"/lista-oglasa"
;
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
49c26675
...
@@ -7,7 +7,9 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -7,7 +7,9 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.Base64
;
import
java.util.List
;
@Component
@Component
public
class
OglasRepository
public
class
OglasRepository
...
@@ -56,4 +58,23 @@ public class OglasRepository
...
@@ -56,4 +58,23 @@ public class OglasRepository
}
}
}
public
List
<
Oglas
>
findAll
(
)
{
List
<
Oglas
>
list
=
new
ArrayList
<
Oglas
>();
String
sql
=
"select * from oglas"
;
ResultSet
rs
=
null
;
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
Oglas
oglas
=
new
Oglas
(
rs
.
getInt
(
"oglasId"
),
rs
.
getInt
(
"korisnikId"
),
rs
.
getString
(
"naslov"
),
rs
.
getString
(
"opis"
),
rs
.
getInt
(
"lokacijaId"
),
rs
.
getDouble
(
"cena"
),
rs
.
getInt
(
"vrstaOglasaId"
),
rs
.
getDouble
(
"kvadratura"
),
rs
.
getInt
(
"brojSoba"
),
rs
.
getBoolean
(
"namesten"
),
rs
.
getBoolean
(
"grejanje"
),
rs
.
getBoolean
(
"lift"
),
rs
.
getString
(
"lokacija"
));
System
.
out
.
println
(
oglas
.
toString
());
list
.
add
(
oglas
);
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
(
list
);
}
}
\ 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