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
f42b1e89
Commit
f42b1e89
authored
Sep 18, 2022
by
Mihailo Sebek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete komentar by korisnikId i oglasId
parent
5d8aa8df
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
4 deletions
+31
-4
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
+4
-4
SkuciSe/src/main/java/com/example/SkuciSe/repository/KomentarRepository.java
+24
-0
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+3
-0
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/AdminController.java
View file @
f42b1e89
...
...
@@ -2,10 +2,7 @@ package com.example.SkuciSe.controller;
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
com.example.SkuciSe.repository.ZahtevRepository
;
import
com.example.SkuciSe.repository.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -22,6 +19,8 @@ import java.util.List;
public
class
AdminController
{
@Autowired
KomentarRepository
komRepo
;
@Autowired
KorisnikRepository
kRepo
;
@Autowired
LokacijaRepository
lRepo
;
...
...
@@ -50,6 +49,7 @@ public class AdminController
@PostMapping
(
"/delete-user/{id}"
)
public
String
deleteUser
(
@PathVariable
(
"id"
)
Integer
id
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
komRepo
.
deleteKomentariByKorisnikId
(
id
);
zRepo
.
deleteZahteviByKorisnikId
(
id
);
oRepo
.
deleteOglasi
(
id
);
kRepo
.
deleteUser
(
id
);
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/KomentarRepository.java
View file @
f42b1e89
...
...
@@ -57,4 +57,28 @@ public class KomentarRepository {
return
(
komentari
);
}
public
void
deleteKomentariByKorisnikId
(
Integer
id
)
throws
RuntimeException
{
String
sql
=
"{call deleteKomentarByKorisnikId(?)}"
;
CallableStatement
stmt
=
null
;
try
{
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
id
);
stmt
.
execute
();
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
void
deleteKomentariByOglasId
(
Integer
id
)
throws
RuntimeException
{
String
sql
=
"{call deleteKomentarByOglasId(?)}"
;
CallableStatement
stmt
=
null
;
try
{
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
id
);
stmt
.
execute
();
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
f42b1e89
...
...
@@ -15,6 +15,8 @@ import java.util.List;
public
class
OglasRepository
{
@Autowired
KomentarRepository
komRepo
;
@Autowired
DataBase
dataBase
;
public
int
insert
(
int
korisnikId
,
Oglas
newOglas
,
MultipartFile
[]
files
)
...
...
@@ -91,6 +93,7 @@ public class OglasRepository
while
(
rs
.
next
())
{
int
oglasid
=
rs
.
getInt
(
"oglasid"
);
komRepo
.
deleteKomentariByOglasId
(
oglasid
);
this
.
deleteSlike
(
oglasid
);
this
.
deleteZahteviByOglasId
(
oglasid
);
}
...
...
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