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
0e83d952
Commit
0e83d952
authored
Sep 12, 2022
by
Milovan Samardzic
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
19cf9240
a542740c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
54 deletions
+55
-54
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+4
-2
SkuciSe/src/main/java/com/example/SkuciSe/model/termin/Termin.java
+20
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
+2
-4
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+29
-48
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
0e83d952
...
@@ -71,7 +71,7 @@ public class OglasController
...
@@ -71,7 +71,7 @@ public class OglasController
}
}
model
.
addAttribute
(
"oglasi"
,
listaOglasa
);
model
.
addAttribute
(
"oglasi"
,
listaOglasa
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
List
<
String
>
list
=
new
ArrayList
<
String
>();
for
(
Oglas
o:
oRepo
.
findAll
()
)
{
for
(
Oglas
o:
listaOglasa
)
{
list
.
add
(
kRepo
.
findCity
(
o
.
getLokacijaId
()));
list
.
add
(
kRepo
.
findCity
(
o
.
getLokacijaId
()));
}
}
model
.
addAttribute
(
"gradovi"
,
list
);
model
.
addAttribute
(
"gradovi"
,
list
);
...
@@ -114,6 +114,8 @@ public class OglasController
...
@@ -114,6 +114,8 @@ public class OglasController
list
.
add
(
kRepo
.
findCity
(
o
.
getLokacijaId
()));
list
.
add
(
kRepo
.
findCity
(
o
.
getLokacijaId
()));
}
}
model
.
addAttribute
(
"gradovi"
,
list
);
model
.
addAttribute
(
"gradovi"
,
list
);
return
"/lista-oglasa"
;
model
.
addAttribute
(
"lokacije"
,
lRepo
.
findAll
());
model
.
addAttribute
(
"slikeOglasa"
,
sRepo
.
findAllFirstPics
(
listaOglasa
));
return
"lista-oglasa"
;
}
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/model/termin/Termin.java
0 → 100644
View file @
0e83d952
package
com
.
example
.
SkuciSe
.
model
.
termin
;
import
lombok.*
;
import
java.sql.*
;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public
class
Termin
{
int
terminId
;
int
korisnikId
;
int
oglasId
;
Date
datum
;
Time
vreme
;
String
status
;
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
View file @
0e83d952
...
@@ -36,8 +36,7 @@ public class KorisnikRepository
...
@@ -36,8 +36,7 @@ public class KorisnikRepository
stmt
.
setInt
(
6
,
1
);
stmt
.
setInt
(
6
,
1
);
stmt
.
setString
(
7
,
slika
);
stmt
.
setString
(
7
,
slika
);
stmt
.
setInt
(
8
,
korisnik
.
getGradId
());
stmt
.
setInt
(
8
,
korisnik
.
getGradId
());
stmt
.
addBatch
();
stmt
.
execute
();
stmt
.
executeBatch
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
System
.
out
.
println
(
e
.
getMessage
());
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
...
@@ -62,7 +61,6 @@ public class KorisnikRepository
...
@@ -62,7 +61,6 @@ public class KorisnikRepository
stmt
.
setString
(
4
,
korisnik
.
getTelefon
());
stmt
.
setString
(
4
,
korisnik
.
getTelefon
());
stmt
.
setInt
(
5
,
korisnik
.
getGradId
());
stmt
.
setInt
(
5
,
korisnik
.
getGradId
());
stmt
.
setInt
(
6
,
korisnik
.
getKorisnikId
());
stmt
.
setInt
(
6
,
korisnik
.
getKorisnikId
());
System
.
out
.
println
(
stmt
.
toString
());
stmt
.
execute
();
stmt
.
execute
();
}
}
catch
(
SQLException
e
)
{
catch
(
SQLException
e
)
{
...
@@ -208,7 +206,7 @@ public class KorisnikRepository
...
@@ -208,7 +206,7 @@ public class KorisnikRepository
public
void
enableKorisnik
(
int
korisnikId
)
public
void
enableKorisnik
(
int
korisnikId
)
{
{
String
sql
=
"
call enableKorisnik(?)
"
;
String
sql
=
"
{call enableKorisnik(?)}
"
;
CallableStatement
stmt
=
null
;
CallableStatement
stmt
=
null
;
try
{
try
{
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
0e83d952
...
@@ -59,30 +59,15 @@ public class OglasRepository
...
@@ -59,30 +59,15 @@ 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"
));
list
.
add
(
oglas
);
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
(
list
);
}
public
Oglas
findById
(
int
oglasId
)
public
Oglas
findById
(
int
oglasId
)
{
{
String
sql
=
"select * from oglas where oglasid = "
+
oglasId
;
String
sql
=
"{ call findOglasbyId(?)}"
;
CallableStatement
stmt
=
null
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
try
{
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
oglasId
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
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"
));
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"
));
...
@@ -94,30 +79,15 @@ public class OglasRepository
...
@@ -94,30 +79,15 @@ public class OglasRepository
return
(
null
);
return
(
null
);
}
}
public
List
<
Oglas
>
findAllByKorisnikId
(
int
korisnikId
)
{
List
<
Oglas
>
list
=
new
ArrayList
<
Oglas
>();
String
sql
=
"select * from oglas where korisnikid = "
+
korisnikId
;
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"
));
list
.
add
(
oglas
);
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
(
list
);
}
public
void
deleteOglasi
(
Integer
id
)
public
void
deleteOglasi
(
Integer
id
)
{
{
String
sql
=
"select * from oglas where korisnikid = "
+
id
;
String
sql
=
"{call findAllByKorisnikId(?)}"
;
CallableStatement
stmt
=
null
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
try
{
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
id
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
while
(
rs
.
next
())
{
{
int
oglasid
=
rs
.
getInt
(
"oglasid"
);
int
oglasid
=
rs
.
getInt
(
"oglasid"
);
...
@@ -127,18 +97,24 @@ public class OglasRepository
...
@@ -127,18 +97,24 @@ public class OglasRepository
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
sql
=
"delete from oglas where KorisnikId = "
+
id
;
sql
=
"{call deleteOglasiByKorisnikId(?)}"
;
CallableStatement
stmt1
=
null
;
try
{
try
{
dataBase
.
statement
.
execute
(
sql
);
stmt1
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt1
.
setInt
(
1
,
id
);
stmt1
.
execute
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
}
public
void
deleteSlike
(
Integer
id
)
public
void
deleteSlike
(
Integer
id
)
{
{
String
sql
=
"delete from slike where oglasid = "
+
id
;
String
sql
=
"{call deleteSlike(?)}"
;
CallableStatement
cs
=
null
;
try
{
try
{
dataBase
.
statement
.
execute
(
sql
);
cs
=
dataBase
.
connection
.
prepareCall
(
sql
);
cs
.
setInt
(
1
,
id
);
cs
.
execute
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -147,10 +123,12 @@ public class OglasRepository
...
@@ -147,10 +123,12 @@ public class OglasRepository
public
List
<
Oglas
>
findAll
(
Integer
vrstaOglasaId
,
Integer
lokacijaId
,
Integer
brojSoba
,
Double
cenaMin
,
Double
cenaMax
,
Double
kvadraturaMin
,
Double
kvadraturaMax
,
Boolean
lift
,
Boolean
grejanje
,
Boolean
namesten
)
public
List
<
Oglas
>
findAll
(
Integer
vrstaOglasaId
,
Integer
lokacijaId
,
Integer
brojSoba
,
Double
cenaMin
,
Double
cenaMax
,
Double
kvadraturaMin
,
Double
kvadraturaMax
,
Boolean
lift
,
Boolean
grejanje
,
Boolean
namesten
)
{
{
List
<
Oglas
>
list
=
new
ArrayList
<
Oglas
>();
List
<
Oglas
>
list
=
new
ArrayList
<
Oglas
>();
String
sql
=
"
select * from oglas
"
;
String
sql
=
"
{call findAll()}
"
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
CallableStatement
stmt
=
null
;
try
{
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
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"
));
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"
));
...
@@ -181,10 +159,13 @@ public class OglasRepository
...
@@ -181,10 +159,13 @@ public class OglasRepository
public
List
<
Oglas
>
findAllByKorisnikId
(
int
korisnikId
,
Integer
vrstaOglasaId
,
Integer
lokacijaId
,
Integer
brojSoba
,
Double
cenaMin
,
Double
cenaMax
,
Double
kvadraturaMin
,
Double
kvadraturaMax
,
Boolean
lift
,
Boolean
grejanje
,
Boolean
namesten
)
public
List
<
Oglas
>
findAllByKorisnikId
(
int
korisnikId
,
Integer
vrstaOglasaId
,
Integer
lokacijaId
,
Integer
brojSoba
,
Double
cenaMin
,
Double
cenaMax
,
Double
kvadraturaMin
,
Double
kvadraturaMax
,
Boolean
lift
,
Boolean
grejanje
,
Boolean
namesten
)
{
{
List
<
Oglas
>
list
=
new
ArrayList
<
Oglas
>();
List
<
Oglas
>
list
=
new
ArrayList
<
Oglas
>();
String
sql
=
"
select * from oglas where korisnikid = "
+
korisnikId
;
String
sql
=
"
{call findAllByKorisnikId(?)}"
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
CallableStatement
stmt
=
null
;
try
{
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
korisnikId
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
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"
));
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"
));
...
...
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