Search in sources :

Example 1 with CardRequest

use of br.fatecsp.engsoft.domain.CardRequest in project Projeto_Detetive_ES3 by VitorAndrioli.

the class DeckController method update.

@PostMapping(value = "/card/{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("type") String type) {
    String cardSrc = "";
    try {
        if (photoFile.getBytes().length != 0) {
            cardSrc = photosFile.createFile(photoFile);
        } else {
            cardSrc = cardService.getById(id).getCardSrc();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    CardRequest cardRequest = new CardRequest(name, type, cardSrc);
    Long themeId = (Long) session.getAttribute("theme");
    cardService.update(id, cardRequest);
    return listAll(themeId);
}
Also used : CardRequest(br.fatecsp.engsoft.domain.CardRequest) IOException(java.io.IOException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 2 with CardRequest

use of br.fatecsp.engsoft.domain.CardRequest in project Projeto_Detetive_ES3 by VitorAndrioli.

the class DeckController method register.

@PostMapping(value = "/card", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView register(@RequestParam("photo") MultipartFile photoFile, @RequestParam("name") String name, @RequestParam("type") String type) {
    String cardSrc = photosFile.createFile(photoFile);
    CardRequest cardRequest = new CardRequest(name, type, cardSrc);
    Long themeId = (Long) session.getAttribute("theme");
    cardService.register(themeId, cardRequest);
    return listAll(themeId);
}
Also used : CardRequest(br.fatecsp.engsoft.domain.CardRequest) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

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