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
64bf0e2e
Commit
64bf0e2e
authored
Sep 06, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
model oglas - dodati atributi
OglasController - dodat novi oglas reguest
parent
dd9fb38c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
71 additions
and
57 deletions
+71
-57
SkuciSe/src/main/java/com/example/SkuciSe/configuration/WebSecurityConfig.java
+1
-1
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+45
-0
SkuciSe/src/main/java/com/example/SkuciSe/model/korisnik/Korisnik.java
+2
-20
SkuciSe/src/main/java/com/example/SkuciSe/model/oglas/Oglas.java
+9
-32
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
+4
-4
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+7
-0
SkuciSe/src/main/resources/application.properties
+3
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/configuration/WebSecurityConfig.java
View file @
64bf0e2e
...
@@ -41,7 +41,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter
...
@@ -41,7 +41,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter
@Override
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
http
.
authorizeRequests
()
.
antMatchers
(
"/profile/**"
,
"/moji-oglasi/**"
,
"/moji-zahtevi/**"
,
"/lista-korisnika"
).
authenticated
()
.
antMatchers
(
"/profile/**"
,
"/moji-oglasi/**"
,
"/moji-zahtevi/**"
,
"/lista-korisnika"
,
"/novi-oglas/**"
).
authenticated
()
.
anyRequest
().
permitAll
()
.
anyRequest
().
permitAll
()
.
and
().
formLogin
().
loginPage
(
"/login"
).
permitAll
()
.
and
().
formLogin
().
loginPage
(
"/login"
).
permitAll
()
.
usernameParameter
(
"email"
)
.
usernameParameter
(
"email"
)
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
0 → 100644
View file @
64bf0e2e
package
com
.
example
.
SkuciSe
.
controller
;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
import
com.example.SkuciSe.model.oglas.Oglas
;
import
com.example.SkuciSe.repository.KorisnikRepository
;
import
com.example.SkuciSe.repository.LokacijaRepository
;
import
com.example.SkuciSe.repository.OglasRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.ModelAttribute
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
@Controller
public
class
OglasController
{
@Autowired
LokacijaRepository
lRepo
;
@Autowired
KorisnikRepository
kRepo
;
@Autowired
OglasRepository
oRepo
;
@GetMapping
(
"/novi-oglas"
)
public
String
getNoviOglas
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"newOglas"
,
new
Oglas
());
model
.
addAttribute
(
"lokacije"
,
lRepo
.
findAll
());
return
(
"novi-oglas-form"
);
}
@PostMapping
(
"/novi-oglas/save"
)
public
String
postSaveNoviOglas
(
@ModelAttribute
(
"newOglas"
)
Oglas
newOglas
,
@RequestParam
(
"images"
)
MultipartFile
[]
files
)
{
oRepo
.
insert
(
newOglas
,
files
);
return
(
"redirect:/profile"
);
}
}
SkuciSe/src/main/java/com/example/SkuciSe/model/korisnik/Korisnik.java
View file @
64bf0e2e
package
com
.
example
.
SkuciSe
.
model
.
korisnik
;
package
com
.
example
.
SkuciSe
.
model
.
korisnik
;
import
lombok.AllArgsConstructor
;
import
lombok.*
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Base64
;
import
java.util.Base64
;
...
@@ -12,6 +9,7 @@ import java.util.Base64;
...
@@ -12,6 +9,7 @@ import java.util.Base64;
@Getter
@Getter
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@ToString
public
class
Korisnik
{
public
class
Korisnik
{
int
korisnikId
;
int
korisnikId
;
String
ime
;
String
ime
;
...
@@ -22,20 +20,5 @@ public class Korisnik {
...
@@ -22,20 +20,5 @@ public class Korisnik {
private
String
slika
;
private
String
slika
;
int
tipId
;
int
tipId
;
int
gradId
;
int
gradId
;
boolean
enabled
;
boolean
enabled
;
@Override
public
String
toString
()
{
return
"Korisnik{"
+
"korisnikId="
+
korisnikId
+
", ime='"
+
ime
+
'\''
+
", prezime='"
+
prezime
+
'\''
+
", email='"
+
email
+
'\''
+
", sifra='"
+
sifra
+
'\''
+
", telefon='"
+
telefon
+
'\''
+
", tipId="
+
tipId
+
", gradId="
+
gradId
+
", slika='"
+
slika
+
'\''
+
'}'
;
}
}
}
\ No newline at end of file
SkuciSe/src/main/java/com/example/SkuciSe/model/oglas/Oglas.java
View file @
64bf0e2e
package
com
.
example
.
SkuciSe
.
model
.
oglas
;
package
com
.
example
.
SkuciSe
.
model
.
oglas
;
import
lombok.AllArgsConstructor
;
import
lombok.*
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Getter
@Getter
@Setter
@Setter
@NoArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
@AllArgsConstructor
@ToString
public
class
Oglas
public
class
Oglas
{
{
int
oglasId
;
int
oglasId
;
int
korisnikId
;
int
korisnikId
;
String
naslov
;
String
naslov
;
String
opis
;
String
opis
;
String
lokacija
;
int
lokacijaId
;
int
gradId
;
double
cena
;
double
cena
;
double
kvadratura
;
int
vrstaOglasaId
;
int
vrstaOglasaId
;
double
kvadratura
;
int
brojSoba
;
boolean
namesten
;
boolean
grejanje
;
boolean
lift
;
String
lokacija
;
public
Oglas
(
int
korisnikId
,
String
naslov
,
String
opis
,
String
lokacija
,
int
gradId
,
double
cena
,
double
kvadratura
,
int
vrstaOglasaId
)
{
this
.
korisnikId
=
korisnikId
;
this
.
naslov
=
naslov
;
this
.
opis
=
opis
;
this
.
lokacija
=
lokacija
;
this
.
gradId
=
gradId
;
this
.
cena
=
cena
;
this
.
kvadratura
=
kvadratura
;
this
.
vrstaOglasaId
=
vrstaOglasaId
;
}
@Override
public
String
toString
()
{
return
"Oglas{"
+
"oglasId="
+
oglasId
+
", korisnikId="
+
korisnikId
+
", naslov='"
+
naslov
+
'\''
+
", opis='"
+
opis
+
'\''
+
", lokacija='"
+
lokacija
+
'\''
+
", gradId="
+
gradId
+
", cena="
+
cena
+
", kvadratura="
+
kvadratura
+
", vrstaOglasaId="
+
vrstaOglasaId
+
'}'
;
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
View file @
64bf0e2e
...
@@ -26,10 +26,10 @@ public class KorisnikRepository
...
@@ -26,10 +26,10 @@ public class KorisnikRepository
String
slika
=
Base64
.
getEncoder
().
encodeToString
(
multipartFile
.
getBytes
());
String
slika
=
Base64
.
getEncoder
().
encodeToString
(
multipartFile
.
getBytes
());
String
sql
=
"insert into korisnik( ime, prezime, telefon, email, sifra, tipId, slika, gradid, enabled) values('"
+
korisnik
.
getIme
()+
"','"
+
korisnik
.
getPrezime
()+
"','"
+
korisnik
.
getTelefon
()+
"','"
+
korisnik
.
getEmail
()+
"','"
+
new
BCryptPasswordEncoder
().
encode
(
korisnik
.
getSifra
())+
"',1, '"
+
slika
+
"', "
+
korisnik
.
getGradId
()+
",false)"
;
String
sql
=
"insert into korisnik( ime, prezime, telefon, email, sifra, tipId, slika, gradid, enabled) values('"
+
korisnik
.
getIme
()+
"','"
+
korisnik
.
getPrezime
()+
"','"
+
korisnik
.
getTelefon
()+
"','"
+
korisnik
.
getEmail
()+
"','"
+
new
BCryptPasswordEncoder
().
encode
(
korisnik
.
getSifra
())+
"',1, '"
+
slika
+
"', "
+
korisnik
.
getGradId
()+
",false)"
;
dataBase
.
statement
.
executeUpdate
(
sql
);
dataBase
.
statement
.
executeUpdate
(
sql
);
}
catch
(
SQL
Exception
e
)
{
}
catch
(
IO
Exception
e
)
{
throw
new
RuntimeException
(
e
);
System
.
out
.
println
(
e
.
getMessage
()
);
}
catch
(
IO
Exception
e
)
{
}
catch
(
SQL
Exception
e
)
{
throw
new
RuntimeException
(
e
);
System
.
out
.
println
(
e
.
getMessage
()
);
}
}
}
}
}
}
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
64bf0e2e
package
com
.
example
.
SkuciSe
.
repository
;
package
com
.
example
.
SkuciSe
.
repository
;
import
com.example.SkuciSe.model.oglas.Oglas
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
@Component
@Component
public
class
OglasRepository
public
class
OglasRepository
{
{
@Autowired
@Autowired
DataBase
dataBase
;
DataBase
dataBase
;
public
void
insert
(
Oglas
newOglas
,
MultipartFile
[]
files
)
{
}
}
}
SkuciSe/src/main/resources/application.properties
View file @
64bf0e2e
spring.servlet.multipart.max-file-size
=
16MB
spring.servlet.multipart.max-request-size
=
16MB
\ 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