Skip to content

Instantly share code, notes, and snippets.

@aytekin
Last active December 18, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aytekin/e5d79fe26e75ed8c27f4e217bab6d7fd to your computer and use it in GitHub Desktop.
Save aytekin/e5d79fe26e75ed8c27f4e217bab6d7fd to your computer and use it in GitHub Desktop.
Swagger
@RestController
@RequestMapping("api/product")
@AllArgsConstructor
public class ProductController {
private final ProductService productService;
@GetMapping("findAll")
public List<ProductDto> findAll() {
return productService.getProducts();
}
@GetMapping("get")
public ProductDto get(Long id) throws ClassNotFoundException {
return productService.get(id);
}
@GetMapping("getByTitle")
public ProductDto getByTitle(String title) {
return productService.getByTitle(title);
}
@PostMapping
public Long save(@RequestBody ProductDto product) throws StackOverflowError, IllegalArgumentException {
return productService.save(product);
}
@DeleteMapping
public boolean delete(Long id) {
return productService.delete(id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment