package Ġbr . com . strn . erp . api . controller . ger al Ċ Ċ import Ġbr . com . strn . erp . api . database . entities . ger al . An exo Ċ import Ġbr . com . strn . erp . api . service . ger al . An exo Service Ċ import Ġbr . com . strn . erp . api . util . Constants . Path . Param . HANDLE Ċ import Ġorg . apache . commons . io . IO Utils Ċ import Ġorg . springframework . data . domain . Page Ċ import Ġorg . springframework . data . domain . Page able Ċ import Ġorg . springframework . http . HttpHeaders Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation .* Ċ import Ġorg . springframework . web . multipart . Multipart File Ċ import Ġjava . io . ByteArray InputStream Ċ import Ġjavax . servlet . http . HttpServletResponse Ċ Ċ @ Suppress (" unused ") Ċ @ RestController Ċ @ RequestMapping ( value Ġ= Ġ["/ an exo "], Ġproduces Ġ= Ġ[ MediaType . APPLICATION _ JSON _ VALUE ]) Ċ class ĠAn exo Controller ( ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġservice : ĠAn exo Service , ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġresponse : ĠHttpServletResponse Ċ ) Ġ{ ĊĠĠĠ Ġ@ GetMapping ("/") ĊĠĠĠ Ġfun ĠfindAll ( page able : ĠPage able ): ĠResponseEntity < Page < An exo >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( service . findAll ( page able )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ( HANDLE ) ĊĠĠĠ Ġfun ĠfindBy Handle (@ PathVariable (" handle ") Ġhandle : ĠString ): ĠResponseEntity < An exo > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( service . findBy Handle ( handle )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ PostMapping ("/") ĊĠĠĠ Ġfun Ġadd (@ RequestParam (" file ") Ġfile : ĠMultip art File ): ĠResponseEntity < An exo > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( service . add ( file )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Delete Mapping ( HANDLE ) ĊĠĠĠ Ġfun Ġdelete (@ PathVariable (" handle ") Ġhandle : ĠString ): ĠResponseEntity < An exo > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( service . delete ( handle )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ GetMapping ("$ HANDLE / download ") ĊĠĠĠ Ġ@ ResponseBody ĊĠĠĠ Ġfun Ġdownload (@ PathVariable (" handle ") Ġhandle : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġan exo Ġ= Ġservice . download ( handle ) ĊĠĠĠĠĠĠĠ Ġval Ġist Ġ= ĠByteArrayInputStream ( an exo . cont e udo ) ĊĊĠĠĠĠĠĠĠ Ġresponse . setHeader ( HttpHeaders . CONTENT _ DIS POSITION , Ġ" attachment ; Ġfilename Ġ= Ġ\"" Ġ+ Ġan exo . nome Ar quivo Ġ+ Ġ"\" ") ĊĠĠĠĠĠĠĠ Ġresponse . setHeader ( HttpHeaders . CONTENT _ TYPE , Ġan exo . mime Type ) ĊĠĠĠĠĠĠĠ Ġresponse . setHeader ( HttpHeaders . CONTENT _ ENCODING , Ġ" binary ") ĊĠĠĠĠĠĠĠ ĠIO Utils . copy ( ist , Ġresponse . output Stream ) ĊĠĠĠ Ġ} Ċ }