use of br.fatecsp.engsoft.domain.ThemeRequest 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 br.fatecsp.engsoft.domain.ThemeRequest 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