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
d23f1a44
Commit
d23f1a44
authored
Sep 15, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
brisanje korisnika brise zahteve
parent
a8158d86
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
6 deletions
+42
-6
SkuciSe/src/main/java/com/example/SkuciSe/configuration/WebSecurityConfig.java
+1
-1
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
+6
-1
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
+7
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+14
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
+13
-3
SkuciSe/src/main/resources/templates/oglas.html
+1
-1
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/configuration/WebSecurityConfig.java
View file @
d23f1a44
...
@@ -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/**"
,
"/
profile/moji-zahtevi
/**"
,
"/lista-korisnika"
,
"/novi-oglas/**"
).
authenticated
()
.
antMatchers
(
"/profile/**"
,
"/moji-oglasi/**"
,
"/
login-zahtev
/**"
,
"/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/AdminController.java
View file @
d23f1a44
...
@@ -5,6 +5,7 @@ import com.example.SkuciSe.model.korisnik.KorisnikDetails;
...
@@ -5,6 +5,7 @@ import com.example.SkuciSe.model.korisnik.KorisnikDetails;
import
com.example.SkuciSe.repository.KorisnikRepository
;
import
com.example.SkuciSe.repository.KorisnikRepository
;
import
com.example.SkuciSe.repository.LokacijaRepository
;
import
com.example.SkuciSe.repository.LokacijaRepository
;
import
com.example.SkuciSe.repository.OglasRepository
;
import
com.example.SkuciSe.repository.OglasRepository
;
import
com.example.SkuciSe.repository.ZahtevRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
...
@@ -26,6 +27,8 @@ public class AdminController
...
@@ -26,6 +27,8 @@ public class AdminController
LokacijaRepository
lRepo
;
LokacijaRepository
lRepo
;
@Autowired
@Autowired
OglasRepository
oRepo
;
OglasRepository
oRepo
;
@Autowired
ZahtevRepository
zRepo
;
@GetMapping
(
"/lista-korisnika"
)
@GetMapping
(
"/lista-korisnika"
)
public
String
getListaKorisnika
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
public
String
getListaKorisnika
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
...
@@ -45,7 +48,9 @@ public class AdminController
...
@@ -45,7 +48,9 @@ public class AdminController
}
}
@PostMapping
(
"/delete-user/{id}"
)
@PostMapping
(
"/delete-user/{id}"
)
public
String
deleteUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
,
RedirectAttributes
redirectAttributes
){
public
String
deleteUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
zRepo
.
deleteZahteviByKorisnikId
(
id
);
oRepo
.
deleteOglasi
(
id
);
oRepo
.
deleteOglasi
(
id
);
kRepo
.
deleteUser
(
id
);
kRepo
.
deleteUser
(
id
);
redirectAttributes
.
addFlashAttribute
(
"deleted"
,
true
);
redirectAttributes
.
addFlashAttribute
(
"deleted"
,
true
);
...
...
SkuciSe/src/main/java/com/example/SkuciSe/controller/ZahtevController.java
View file @
d23f1a44
...
@@ -35,4 +35,11 @@ public class ZahtevController {
...
@@ -35,4 +35,11 @@ public class ZahtevController {
zRepo
.
insert
(
loggedUser
.
getKorisnik
().
getKorisnikId
(),
oglasId
,
noviZahtev
,
datumIVreme
);
zRepo
.
insert
(
loggedUser
.
getKorisnik
().
getKorisnikId
(),
oglasId
,
noviZahtev
,
datumIVreme
);
return
"redirect:/lista-oglasa/"
+
oglasId
;
return
"redirect:/lista-oglasa/"
+
oglasId
;
}
}
@GetMapping
(
"/login-zahtev/{oglasId}"
)
public
String
getLoginZahtev
(
@PathVariable
(
"oglasId"
)
int
oglasId
)
{
return
"redirect:/lista-oglasa/"
+
oglasId
;
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
d23f1a44
...
@@ -92,6 +92,7 @@ public class OglasRepository
...
@@ -92,6 +92,7 @@ public class OglasRepository
{
{
int
oglasid
=
rs
.
getInt
(
"oglasid"
);
int
oglasid
=
rs
.
getInt
(
"oglasid"
);
this
.
deleteSlike
(
oglasid
);
this
.
deleteSlike
(
oglasid
);
this
.
deleteZahteviByOglasId
(
oglasid
);
}
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
...
@@ -120,6 +121,19 @@ public class OglasRepository
...
@@ -120,6 +121,19 @@ public class OglasRepository
}
}
}
}
public
void
deleteZahteviByOglasId
(
Integer
id
)
{
String
sql
=
"{call deleteZahteviByOglasId(?)}"
;
CallableStatement
cs
=
null
;
try
{
cs
=
dataBase
.
connection
.
prepareCall
(
sql
);
cs
.
setInt
(
1
,
id
);
cs
.
execute
();
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
List
<
Oglas
>
findAll
(
Integer
vrstaOglasaId
,
Integer
lokacijaId
,
Integer
brojSoba
,
Double
cenaMin
,
Double
cenaMax
,
Double
kvadraturaMin
,
Double
kvadraturaMax
,
Boolean
lift
,
Boolean
grejanje
,
Boolean
namesten
,
String
pretraga
)
public
List
<
Oglas
>
findAll
(
Integer
vrstaOglasaId
,
Integer
lokacijaId
,
Integer
brojSoba
,
Double
cenaMin
,
Double
cenaMax
,
Double
kvadraturaMin
,
Double
kvadraturaMax
,
Boolean
lift
,
Boolean
grejanje
,
Boolean
namesten
,
String
pretraga
)
{
{
List
<
Oglas
>
list
=
new
ArrayList
<
Oglas
>();
List
<
Oglas
>
list
=
new
ArrayList
<
Oglas
>();
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/ZahtevRepository.java
View file @
d23f1a44
...
@@ -19,7 +19,6 @@ public class ZahtevRepository {
...
@@ -19,7 +19,6 @@ public class ZahtevRepository {
public
void
insert
(
int
korisnikId
,
int
oglasId
,
Zahtev
noviZahtev
,
String
datumIVreme
)
public
void
insert
(
int
korisnikId
,
int
oglasId
,
Zahtev
noviZahtev
,
String
datumIVreme
)
{
{
String
datum
=
datumIVreme
.
split
(
" "
)[
0
];
String
datum
=
datumIVreme
.
split
(
" "
)[
0
];
System
.
out
.
println
(
datum
);
LocalDate
datumFormatiran
=
LocalDate
.
parse
(
datum
,
DateTimeFormatter
.
ofPattern
(
"MM/dd/yyyy"
));
LocalDate
datumFormatiran
=
LocalDate
.
parse
(
datum
,
DateTimeFormatter
.
ofPattern
(
"MM/dd/yyyy"
));
String
vreme
=
datumIVreme
.
split
(
" "
)[
1
];
String
vreme
=
datumIVreme
.
split
(
" "
)[
1
];
noviZahtev
.
setDatum
(
datumFormatiran
.
toString
());
noviZahtev
.
setDatum
(
datumFormatiran
.
toString
());
...
@@ -56,7 +55,6 @@ public class ZahtevRepository {
...
@@ -56,7 +55,6 @@ public class ZahtevRepository {
while
(
rs
.
next
())
while
(
rs
.
next
())
{
{
Zahtev
zahtev
=
new
Zahtev
(
rs
.
getInt
(
1
),
rs
.
getInt
(
2
),
rs
.
getInt
(
3
),
rs
.
getString
(
4
),
rs
.
getString
(
5
),
StanjeZahteva
.
valueOf
(
rs
.
getString
(
6
)));
Zahtev
zahtev
=
new
Zahtev
(
rs
.
getInt
(
1
),
rs
.
getInt
(
2
),
rs
.
getInt
(
3
),
rs
.
getString
(
4
),
rs
.
getString
(
5
),
StanjeZahteva
.
valueOf
(
rs
.
getString
(
6
)));
System
.
out
.
println
(
zahtev
.
toString
());
list
.
add
(
zahtev
);
list
.
add
(
zahtev
);
}
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
...
@@ -78,7 +76,6 @@ public class ZahtevRepository {
...
@@ -78,7 +76,6 @@ public class ZahtevRepository {
while
(
rs
.
next
())
while
(
rs
.
next
())
{
{
Zahtev
zahtev
=
new
Zahtev
(
rs
.
getInt
(
1
),
rs
.
getInt
(
2
),
rs
.
getInt
(
3
),
rs
.
getString
(
4
),
rs
.
getString
(
5
),
StanjeZahteva
.
valueOf
(
rs
.
getString
(
6
)));
Zahtev
zahtev
=
new
Zahtev
(
rs
.
getInt
(
1
),
rs
.
getInt
(
2
),
rs
.
getInt
(
3
),
rs
.
getString
(
4
),
rs
.
getString
(
5
),
StanjeZahteva
.
valueOf
(
rs
.
getString
(
6
)));
System
.
out
.
println
(
zahtev
.
toString
());
list
.
add
(
zahtev
);
list
.
add
(
zahtev
);
}
}
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
...
@@ -86,4 +83,17 @@ public class ZahtevRepository {
...
@@ -86,4 +83,17 @@ public class ZahtevRepository {
}
}
return
(
list
);
return
(
list
);
}
}
public
void
deleteZahteviByKorisnikId
(
Integer
id
)
{
String
sql
=
"{call deleteZahteviByKorisnikId(?)}"
;
CallableStatement
cs
=
null
;
try
{
cs
=
dataBase
.
connection
.
prepareCall
(
sql
);
cs
.
setInt
(
1
,
id
);
cs
.
execute
();
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
SkuciSe/src/main/resources/templates/oglas.html
View file @
d23f1a44
...
@@ -186,7 +186,7 @@
...
@@ -186,7 +186,7 @@
</div>
</div>
<button
type=
"submit"
class=
"btn btn-primary w-25"
>
POSALJI ZAHTEV
</button>
<button
type=
"submit"
class=
"btn btn-primary w-25"
>
POSALJI ZAHTEV
</button>
</form>
</form>
<h3
th:if=
"${loggedUser == null}"
class=
"text-center"
><a
th:href=
"@{/login}"
style=
"text-decoration: none;color:#495056;"
>
Prijavite se
</a></h3>
<h3
th:if=
"${loggedUser == null}"
class=
"text-center"
><a
th:href=
"@{/login
-zahtev/{oglasId}(oglasId=${oglasId})
}"
style=
"text-decoration: none;color:#495056;"
>
Prijavite se
</a></h3>
</div>
</div>
</div>
</div>
</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