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
9a5e5b42
Commit
9a5e5b42
authored
Sep 12, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kreiran oglas vodi na taj oglas
parent
60e95c38
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
+4
-2
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
+3
-3
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/OglasController.java
View file @
9a5e5b42
...
...
@@ -45,8 +45,10 @@ public class OglasController
@PostMapping
(
"/novi-oglas/save"
)
public
String
postSaveNoviOglas
(
@ModelAttribute
(
"newOglas"
)
Oglas
newOglas
,
@RequestParam
(
"images"
)
MultipartFile
[]
files
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
oRepo
.
insert
(
loggedUser
.
getKorisnik
().
getKorisnikId
(),
newOglas
,
files
);
return
(
"redirect:/profile"
);
int
oglasId
=
oRepo
.
insert
(
loggedUser
.
getKorisnik
().
getKorisnikId
(),
newOglas
,
files
);
if
(
oglasId
==
-
1
)
return
(
"redirect:/novi-oglas"
);
return
(
"redirect:/lista-oglasa/"
+
oglasId
);
}
@GetMapping
(
"/lista-oglasa"
)
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/OglasRepository.java
View file @
9a5e5b42
...
...
@@ -17,7 +17,7 @@ public class OglasRepository
@Autowired
DataBase
dataBase
;
public
void
insert
(
int
korisnikId
,
Oglas
newOglas
,
MultipartFile
[]
files
)
public
int
insert
(
int
korisnikId
,
Oglas
newOglas
,
MultipartFile
[]
files
)
{
int
oglasId
;
//String sql = "{ call insertOglas(?,?,?,?,?,?,?,?,?,?,?,?)}";
...
...
@@ -49,14 +49,14 @@ public class OglasRepository
sql
+=
" values ("
+
oglasId
+
",'"
+
filename
+
"')"
;
dataBase
.
statement
.
executeUpdate
(
sql
);
}
return
(
oglasId
);
}
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
(
-
1
);
}
public
Oglas
findById
(
int
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