Search in sources :

Example 1 with ThemeRequest

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();
}
Also used : ThemeRequest(br.fatecsp.engsoft.domain.ThemeRequest) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with ThemeRequest

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();
}
Also used : ThemeRequest(br.fatecsp.engsoft.domain.ThemeRequest) IOException(java.io.IOException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

ThemeRequest (br.fatecsp.engsoft.domain.ThemeRequest)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 IOException (java.io.IOException)1