use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.
the class DeckController method listAll.
@RequestMapping(value = "{id}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView listAll(@PathVariable Long id) {
ModelAndView model = new ModelAndView("deck");
model.addObject("cards", cardService.findAllByTheme(id));
session.setAttribute("theme", id);
return model;
}
use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.
the class ThemeController method register.
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView register(@RequestParam("photo") MultipartFile photoFile, @RequestParam("name") String name, @RequestParam("price") BigDecimal price) {
String boardSrc = photosFile.createFile(photoFile);
ThemeRequest themeDTO = new ThemeRequest(name, price, boardSrc);
themeService.register(themeDTO);
return listAll();
}
use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.
the class ThemeController method listAll.
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView listAll() {
ModelAndView model = new ModelAndView("themes");
List<Theme> themes = themeService.findAll();
model.addObject("themes", themes);
return model;
}
use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.
the class ThemeController method edit.
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView edit(@PathVariable("id") Long id) {
ModelAndView model = new ModelAndView("editTheme");
model.addObject("theme", themeService.find(id));
return model;
}
use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.
the class ThemeController method update.
@PostMapping(value = "/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView update(@PathVariable("id") Long id, @RequestParam("photo") MultipartFile photoFile, @RequestParam("name") String name, @RequestParam("price") BigDecimal price) {
String boardSrc = "";
try {
if (photoFile.getBytes().length != 0) {
boardSrc = photosFile.createFile(photoFile);
} else {
boardSrc = themeService.find(id).getImageSrc();
}
} catch (IOException e) {
e.printStackTrace();
}
ThemeRequest themeDTO = new ThemeRequest(name, price, boardSrc);
themeService.update(id, themeDTO);
return listAll();
}
Aggregations