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
8f6bc11a
Commit
8f6bc11a
authored
Sep 02, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dodat AdminController
parent
8bb28e9c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
2 deletions
+50
-2
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
+31
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
+18
-1
SkuciSe/src/main/resources/templates/register.html
+1
-1
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
0 → 100644
View file @
8f6bc11a
package
com
.
example
.
SkuciSe
.
controller
;
import
com.example.SkuciSe.model.korisnik.KorisnikDetails
;
import
com.example.SkuciSe.repository.KorisnikRepository
;
import
com.example.SkuciSe.repository.LokacijaRepository
;
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
;
@Controller
public
class
AdminController
{
@Autowired
KorisnikRepository
kRepo
;
@Autowired
LokacijaRepository
lRepo
;
@GetMapping
(
"/lista-korisnika"
)
public
String
getListaKorisnika
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
if
(
!
kRepo
.
findRoleById
(
loggedUser
.
getKorisnik
().
getTipId
()).
equals
(
"Administrator"
)
)
{
return
"redirect:/index"
;
}
model
.
addAttribute
(
"korisnici"
,
kRepo
.
findAll
());
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
return
"/lista-korisnika"
;
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
View file @
8f6bc11a
...
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
...
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.
Base64
;
import
java.util.
*
;
@Component
@Component
public
class
KorisnikRepository
public
class
KorisnikRepository
...
@@ -110,4 +110,21 @@ public class KorisnikRepository
...
@@ -110,4 +110,21 @@ public class KorisnikRepository
}
}
return
(
null
);
return
(
null
);
}
}
public
List
<
Korisnik
>
findAll
()
{
String
sql
=
"select * from korisnik"
;
List
<
Korisnik
>
list
=
new
ArrayList
<
Korisnik
>();
ResultSet
rs
=
null
;
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
while
(
rs
.
next
())
{
list
.
add
(
new
Korisnik
(
rs
.
getInt
(
"korisnikId"
),
rs
.
getString
(
"ime"
),
rs
.
getString
(
"prezime"
),
rs
.
getString
(
"email"
),
rs
.
getString
(
"sifra"
),
rs
.
getString
(
"telefon"
),
rs
.
getString
(
"slika"
),
rs
.
getInt
(
"tipid"
),
rs
.
getInt
(
"gradid"
)));
}
return
list
;
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
SkuciSe/src/main/resources/templates/register.html
View file @
8f6bc11a
...
@@ -72,7 +72,7 @@
...
@@ -72,7 +72,7 @@
</div>
</div>
div class="col-md-12">
<
div
class=
"col-md-12"
>
<select
th:field=
"${newUser.gradId}"
>
<select
th:field=
"${newUser.gradId}"
>
<option
th:each=
"lokacija: ${lokacije}"
th:value=
"${lokacija.getLokacijaId()}"
th:text=
"${lokacija.getNaziv()}"
>
<option
th:each=
"lokacija: ${lokacije}"
th:value=
"${lokacija.getLokacijaId()}"
th:text=
"${lokacija.getNaziv()}"
>
</option>
</option>
...
...
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