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
a55247fc
Commit
a55247fc
authored
Sep 01, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
profile edit 1
parent
c39022db
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
7 deletions
+46
-7
SkuciSe/src/main/java/com/example/SkuciSe/controller/AppController.java
+8
-0
SkuciSe/src/main/java/com/example/SkuciSe/model/korisnik/Korisnik.java
+2
-5
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
+36
-1
SkuciSe/src/main/resources/templates/profile.html
+0
-1
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/AppController.java
View file @
a55247fc
...
...
@@ -58,7 +58,15 @@ public class AppController
public
String
getProfile
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"editUser"
,
loggedUser
);
model
.
addAttribute
(
"profileRole"
,
kRepo
.
findRoleById
(
loggedUser
.
getKorisnik
().
getTipId
()));
return
(
"profile"
);
}
@PostMapping
(
"/profile-edit"
)
public
String
postProfileEdit
(
@ModelAttribute
KorisnikDetails
korisnikDetails
)
{
kRepo
.
update
(
korisnikDetails
.
getKorisnik
());
return
"redirect:/profile"
;
}
}
SkuciSe/src/main/java/com/example/SkuciSe/model/korisnik/Korisnik.java
View file @
a55247fc
...
...
@@ -37,9 +37,5 @@ public class Korisnik {
'}'
;
}
/*public String getEncodedPic(){
String slika=null;
slika= Base64.getEncoder().encodeToString(getSlika());
return slika;
*/
}
\ No newline at end of file
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
View file @
a55247fc
...
...
@@ -28,7 +28,6 @@ public class KorisnikRepository
public
void
insert
(
Korisnik
korisnik
,
MultipartFile
multipartFile
)
throws
IOException
{
String
fileName
=
StringUtils
.
cleanPath
(
multipartFile
.
getOriginalFilename
());
String
slika
=
Base64
.
getEncoder
().
encodeToString
(
multipartFile
.
getBytes
());
System
.
out
.
println
(
slika
);
String
sql
=
"insert into korisnik( ime, prezime, telefon, email, sifra, tipId, slika) values('"
+
korisnik
.
getIme
()+
"','"
+
korisnik
.
getPrezime
()+
"','"
+
korisnik
.
getTelefon
()+
"','"
+
korisnik
.
getEmail
()+
"','"
+
new
BCryptPasswordEncoder
().
encode
(
korisnik
.
getSifra
())+
"',1, '"
+
slika
+
"')"
;
...
...
@@ -40,6 +39,42 @@ public class KorisnikRepository
}
}
public
void
update
(
Korisnik
korisnik
)
{
String
sql
=
" insert into korisnik "
+
" where korisnikid = "
+
korisnik
.
getKorisnikId
()
+
" set ime = "
+
korisnik
.
getIme
()
+
",set prezime = "
+
korisnik
.
getPrezime
()
+
",set email = "
+
korisnik
.
getEmail
()
+
",set sifra = "
+
new
BCryptPasswordEncoder
().
encode
(
korisnik
.
getSifra
())
+
",set telefon = "
+
korisnik
.
getTelefon
();
try
{
System
.
out
.
println
(
sql
);
statement
.
executeUpdate
(
sql
);
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
void
updateSlika
(
Korisnik
korisnik
,
MultipartFile
file
)
{
String
fileName
=
StringUtils
.
cleanPath
(
file
.
getOriginalFilename
());
String
slika
=
null
;
String
sql
=
null
;
try
{
slika
=
Base64
.
getEncoder
().
encodeToString
(
file
.
getBytes
());
sql
=
" insert into korisnik "
+
" where korisnikid = "
+
korisnik
.
getKorisnikId
()
+
" set slika = "
+
slika
;
System
.
out
.
println
(
sql
);
statement
.
executeUpdate
(
sql
);
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
Korisnik
findByEmail
(
String
email
)
{
String
sql
=
"select * from korisnik where email = '"
+
email
+
"'"
;
...
...
SkuciSe/src/main/resources/templates/profile.html
View file @
a55247fc
...
...
@@ -63,7 +63,6 @@
<img
class=
"photo"
th:src=
"@{'data:image/png;charset=utf-8;base64,'+${loggedUser.getKorisnik().getSlika()}}"
alt=
"slika korisnika"
>
<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>
<br>
<div
class=
"d-flex "
>
<div
class=
"btn btn-outline-primary message"
>
Poruka
</div>
</div>
...
...
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