Package org.imageconverter.controller
Class ImageConversionRestController
java.lang.Object
org.imageconverter.controller.ImageConversionRestController
@Loggable
@RestController
@Description("Controller for image converstion API")
@RequestMapping("/rest/images/conversion")
public class ImageConversionRestController
extends Object
Image converter http rest.
- Author:
- Fernando Romulo da Silva
-
Method Summary
Modifier and TypeMethodDescriptionconvert
(org.springframework.web.multipart.MultipartFile[] files, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Convert multiple images file on text.convert
(org.springframework.web.multipart.MultipartFile file, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Convert a image file on text.convertWithArea
(org.springframework.web.multipart.MultipartFile file, Integer xAxis, Integer yAxis, Integer width, Integer height, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Convert a image file with area on text.void
Delete a image conversion.org.springframework.http.ResponseEntity<org.springframework.core.io.InputStreamResource>
downloadImageConversionCsv
(org.springframework.data.jpa.domain.Specification<ImageConversion> filter) Create a CSV file using filter.org.springframework.data.domain.Page<ImageConversionResponse>
getByFilter
(org.springframework.data.jpa.domain.Specification<ImageConversion> filter, org.springframework.data.domain.Pageable page) Get conversions by filter.Get a conversion already done.
-
Method Details
-
getById
@ResponseStatus(OK) @GetMapping(value="/{id:[\\d]*}", produces="application/json") public ImageConversionResponse getById(@PathVariable(name="id",required=true) Long id) Get a conversion already done.- Parameters:
id
- The image conversion's id- Returns:
- A
ImageConversionResponse
object - Throws:
ElementNotFoundException
- if a element with id not found
-
getByFilter
@ResponseStatus(OK) @GetMapping(produces="application/json") public org.springframework.data.domain.Page<ImageConversionResponse> getByFilter(org.springframework.data.jpa.domain.Specification<ImageConversion> filter, @PageableDefault(value=10,page=0) org.springframework.data.domain.Pageable page) Get conversions by filter.- Parameters:
filter
- A objectSpecification
that specific the filter the searchpage
- A objectPageable
that page the result- Returns:
- A
List
or a empty list
-
convert
@ResponseStatus(CREATED) @PostMapping(consumes="multipart/form-data", produces="application/json") public ImageConversionPostResponse convert(@RequestPart(name="file",required=true) org.springframework.web.multipart.MultipartFile file, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Convert a image file on text.- Parameters:
file
- The image to convert- Returns:
- A
ImageConversionResponse
object with response.
-
convertWithArea
@ResponseStatus(CREATED) @PostMapping(value="/area", consumes="multipart/form-data", produces="application/json") public ImageConversionPostResponse convertWithArea(@RequestPart(name="file",required=true) org.springframework.web.multipart.MultipartFile file, @RequestParam(required=true) Integer xAxis, @RequestParam(required=true) Integer yAxis, @RequestParam(required=true) Integer width, @RequestParam(required=true) Integer height, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Convert a image file with area on text.- Parameters:
file
- The image to convertxAxis
- The image's x coordinateyAxis
- The image's y coordinatewidth
- The image's width in pixelsheight
- The image's height in pixels- Returns:
- A
ImageConversionResponse
object with response.
-
convert
@ResponseStatus(CREATED) @PostMapping(value="/multiple", consumes="multipart/form-data", produces="application/json") public List<ImageConversionPostResponse> convert(@RequestPart(name="files",required=true) org.springframework.web.multipart.MultipartFile[] files, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Convert multiple images file on text.- Parameters:
files
- The images' collection to convert- Returns:
- A list of
ImageConversionResponse
with each response.
-
delete
@ResponseStatus(NO_CONTENT) @DeleteMapping("/{id:[\\d]*}") public void delete(@PathVariable(name="id",required=true) Long id) Delete a image conversion.- Parameters:
id
- The conversion id
-
downloadImageConversionCsv
@ResponseStatus(OK) @GetMapping(value="/export", produces="txt/csv") public org.springframework.http.ResponseEntity<org.springframework.core.io.InputStreamResource> downloadImageConversionCsv(org.springframework.data.jpa.domain.Specification<ImageConversion> filter) Create a CSV file using filter.- Parameters:
filter
- A objectSpecification
that specific the filter the search- Returns:
- A Csv file
-