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
75be4f70
Commit
75be4f70
authored
Sep 10, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dosta toga
parent
75ec918a
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
96 additions
and
21 deletions
+96
-21
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
+4
-0
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+17
-0
SkuciSe/src/main/java/com/example/SkuciSe/controller/ProfileController.java
+6
-6
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+51
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/SlikeRepository.java
+2
-0
SkuciSe/src/main/resources/templates/index.html
+1
-1
SkuciSe/src/main/resources/templates/lista-korisnika.html
+1
-1
SkuciSe/src/main/resources/templates/lista-oglasa.html
+1
-1
SkuciSe/src/main/resources/templates/login.html
+1
-1
SkuciSe/src/main/resources/templates/novi-oglas-form.html
+1
-1
SkuciSe/src/main/resources/templates/oglas.html
+2
-1
SkuciSe/src/main/resources/templates/password-edit.html
+2
-2
SkuciSe/src/main/resources/templates/profile-edit.html
+2
-2
SkuciSe/src/main/resources/templates/profile.html
+4
-4
SkuciSe/src/main/resources/templates/register.html
+1
-1
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
View file @
75be4f70
...
...
@@ -4,6 +4,7 @@ import com.example.SkuciSe.model.korisnik.Korisnik;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
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
;
...
...
@@ -23,6 +24,8 @@ public class AdminController
KorisnikRepository
kRepo
;
@Autowired
LokacijaRepository
lRepo
;
@Autowired
OglasRepository
oRepo
;
@GetMapping
(
"/lista-korisnika"
)
public
String
getListaKorisnika
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
...
...
@@ -43,6 +46,7 @@ public class AdminController
@PostMapping
(
"/delete-user/{id}"
)
public
String
deleteUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
,
RedirectAttributes
redirectAttributes
){
oRepo
.
deleteOglasi
(
id
);
kRepo
.
deleteUser
(
id
);
redirectAttributes
.
addFlashAttribute
(
"deleted"
,
true
);
return
"redirect:/lista-korisnika"
;
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
75be4f70
...
...
@@ -74,4 +74,21 @@ public class OglasController
model
.
addAttribute
(
"slike"
,
sRepo
.
findAllById
(
oglasId
));
return
(
"oglas"
);
}
@GetMapping
(
"/profile/moji-oglasi"
)
public
String
getMojiOglasa
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
List
<
Oglas
>
listaOglasa
=
oRepo
.
findAllByKorisnikId
(
loggedUser
.
getKorisnik
().
getKorisnikId
());
while
(
listaOglasa
.
size
()
%
3
!=
0
){
Oglas
o
=
new
Oglas
();
listaOglasa
.
add
(
o
);
}
model
.
addAttribute
(
"oglasi"
,
listaOglasa
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
for
(
Oglas
o:
listaOglasa
)
{
list
.
add
(
kRepo
.
findCity
(
o
.
getLokacijaId
()));
}
model
.
addAttribute
(
"gradovi"
,
list
);
return
"/lista-oglasa"
;
}
}
SkuciSe/src/main/java/com/example/SkuciSe/controller/ProfileController.java
View file @
75be4f70
...
...
@@ -37,7 +37,7 @@ public class ProfileController
return
(
"profile"
);
}
@GetMapping
(
"/profile
-
edit"
)
@GetMapping
(
"/profile
/
edit"
)
public
String
getProfileEdit
(
Model
model
,
@ModelAttribute
Korisnik
korisnik
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
...
...
@@ -45,7 +45,7 @@ public class ProfileController
model
.
addAttribute
(
"lokacije"
,
lRepo
.
findAll
());
return
"/profile-edit"
;
}
@PostMapping
(
"/profile
-
edit-save"
)
@PostMapping
(
"/profile
/
edit-save"
)
public
String
postProfileEditSave
(
Model
model
,
@ModelAttribute
Korisnik
korisnik
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
kRepo
.
update
(
korisnik
);
...
...
@@ -53,7 +53,7 @@ public class ProfileController
return
"redirect:/profile"
;
}
@PostMapping
(
"/profile
-
picture-update"
)
@PostMapping
(
"/profile
/
picture-update"
)
public
String
izmeniSliku
(
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
@RequestParam
(
"image"
)
MultipartFile
file
)
{
kRepo
.
updateSlika
(
loggedUser
.
getKorisnik
(),
file
);
try
{
...
...
@@ -64,19 +64,19 @@ public class ProfileController
return
"redirect:/profile"
;
}
@GetMapping
(
"/password-edit"
)
@GetMapping
(
"/p
rofile/p
assword-edit"
)
public
String
getProfilePasswordEdit
(
Model
model
,
@ModelAttribute
Korisnik
korisnik
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"editUser"
,
loggedUser
.
getKorisnik
());
return
"/password-edit"
;
}
@PostMapping
(
"/password-edit-save"
)
@PostMapping
(
"/p
rofile/p
assword-edit-save"
)
public
String
postPasswordEditSave
(
Model
model
,
@ModelAttribute
Korisnik
korisnik
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
System
.
out
.
println
(
korisnik
.
toString
());
kRepo
.
updateSifra
(
korisnik
,
loggedUser
.
getKorisnik
().
getKorisnikId
());
loggedUser
.
setKorisnikSifra
(
korisnik
.
getSifra
());
return
"redirect:/
index
"
;
return
"redirect:/
profile
"
;
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
75be4f70
...
...
@@ -93,4 +93,54 @@ public class OglasRepository
}
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
)
{
String
sql
=
"select * from oglas where korisnikid = "
+
id
;
ResultSet
rs
=
null
;
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
int
oglasid
=
rs
.
getInt
(
"oglasid"
);
this
.
deleteSlike
(
oglasid
);
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
sql
=
"delete from oglas where KorisnikId = "
+
id
;
try
{
dataBase
.
statement
.
execute
(
sql
);
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
void
deleteSlike
(
Integer
id
)
{
String
sql
=
"delete from slike where oglasid = "
+
id
;
try
{
dataBase
.
statement
.
execute
(
sql
);
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
\ No newline at end of file
SkuciSe/src/main/java/com/example/SkuciSe/repository/SlikeRepository.java
View file @
75be4f70
...
...
@@ -32,4 +32,6 @@ public class SlikeRepository
return
list
;
}
}
SkuciSe/src/main/resources/templates/index.html
View file @
75be4f70
...
...
@@ -76,7 +76,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
SkuciSe/src/main/resources/templates/lista-korisnika.html
View file @
75be4f70
...
...
@@ -71,7 +71,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
SkuciSe/src/main/resources/templates/lista-oglasa.html
View file @
75be4f70
...
...
@@ -73,7 +73,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
SkuciSe/src/main/resources/templates/login.html
View file @
75be4f70
...
...
@@ -70,7 +70,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
SkuciSe/src/main/resources/templates/novi-oglas-form.html
View file @
75be4f70
...
...
@@ -73,7 +73,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
SkuciSe/src/main/resources/templates/oglas.html
View file @
75be4f70
...
...
@@ -73,7 +73,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
@@ -92,6 +92,7 @@
<h1
th:text=
"${oglas.toString()}"
></h1>
</div>
<div
class=
"container"
th:object=
"${slike}"
>
<h1
th:text=
"${slike.size()}"
></h1>
</div>
<div
class=
"container-fluid pb-0 mb-0 justify-content-center text-light "
>
...
...
SkuciSe/src/main/resources/templates/password-edit.html
View file @
75be4f70
...
...
@@ -70,7 +70,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
@@ -91,7 +91,7 @@
<div
class=
"form-content"
>
<div
class=
"form-items"
>
<form
class=
"requires-validation"
novalidate
th:object=
"${editUser}"
method=
"POST"
th:action=
"@{/password-edit-save}"
enctype=
"multipart/form-data"
th:action=
"@{/p
rofile/p
assword-edit-save}"
enctype=
"multipart/form-data"
onsubmit=
"return validateForm()"
>
<div
class=
"col-md-12"
>
...
...
SkuciSe/src/main/resources/templates/profile-edit.html
View file @
75be4f70
...
...
@@ -72,7 +72,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
@@ -93,7 +93,7 @@
<div
class=
"form-content"
>
<div
class=
"form-items"
>
<form
class=
"requires-validation"
novalidate
th:object=
"${editUser}"
method=
"POST"
th:action=
"@{/profile
-
edit-save}"
enctype=
"multipart/form-data"
>
th:action=
"@{/profile
/
edit-save}"
enctype=
"multipart/form-data"
>
<div
class=
"col-md-12"
>
<input
th:field=
"${editUser.ime}"
class=
"form-control"
type=
"text"
name=
"name"
placeholder=
"Ime"
required
>
...
...
SkuciSe/src/main/resources/templates/profile.html
View file @
75be4f70
...
...
@@ -71,7 +71,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
@@ -107,10 +107,10 @@
<p
class=
"fw-bold h4 mt-3"
><span
th:text=
"${loggedUser.getKorisnik().getIme()}"
></span></p>
<p
class=
"text-muted"
th:object=
"${profileRole}"
th:text=
"${profileRole}"
></p>
<div
class=
"d-flex justify-content-around w-75"
>
<a
th:href=
"@{/profile
-
edit}"
>
<a
th:href=
"@{/profile
/
edit}"
>
<button
type=
"button"
class=
"btn btn-secondary m-10"
id=
"fade"
>
Izmeni podatke
</button>
</a>
<a
th:href=
"@{/password-edit}"
>
<a
th:href=
"@{/p
rofile/p
assword-edit}"
>
<button
type=
"button"
class=
"btn btn-secondary m-10"
>
Promeni sifru
</button>
</a>
</div>
...
...
@@ -118,7 +118,7 @@
</div>
</div>
</div>
<form
id=
"formaSlika"
method=
"POST"
th:object=
"${loggedUser}"
th:action=
"@{/profile
-
picture-update}"
<form
id=
"formaSlika"
method=
"POST"
th:object=
"${loggedUser}"
th:action=
"@{/profile
/
picture-update}"
style=
"display: none"
enctype=
"multipart/form-data"
>
<input
type=
"file"
name=
"image"
accept=
"image/png, image/jpeg"
id=
"inputSlika"
style=
"display: none"
onchange=
"document.getElementById('formaSlika').submit();return false;"
/>
...
...
SkuciSe/src/main/resources/templates/register.html
View file @
75be4f70
...
...
@@ -70,7 +70,7 @@
</button>
<div
class=
"dropdown-menu"
aria-labelledby=
"dropdownMenuButton"
>
<a
class=
"dropdown-item"
th:href=
"@{/profile}"
>
Moj Profil
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
moji
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/
profile/moji-
oglasi}"
>
Moji Oglasi
</a>
<a
class=
"dropdown-item"
th:href=
"@{/mojizahtevi}"
>
Moji Zahtevi
</a>
<a
th:if=
"${loggedUser.getKorisnik().getTipId() == 2}"
class=
"dropdown-item"
th:href=
"@{/lista-korisnika}"
>
Lista Profila
</a>
...
...
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