Commit 9a5e5b42 by Bogdan Andjelkovic

kreiran oglas vodi na taj oglas

parent 60e95c38
......@@ -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")
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment