diff --git a/src/main/java/com/sitblueprint/admin/controller/blogs/BlogController.java b/src/main/java/com/sitblueprint/admin/controller/blogs/BlogController.java index 3d8e238..9de4ffd 100644 --- a/src/main/java/com/sitblueprint/admin/controller/blogs/BlogController.java +++ b/src/main/java/com/sitblueprint/admin/controller/blogs/BlogController.java @@ -18,4 +18,29 @@ public class BlogController { public List getAllBlogs(){ return blogsService.getAllBlogs(); } + + @GetMapping("/{blogId}") + public ResponseEntity getBlog(@PathVariable("blogId") Long blogId) { + try { + Blog blog = blogsService.getBlogById(blogId); + return ResponseEntity.ok(blog); + } catch (NumberFormatException e) { + return ResponseEntity.badRequest().body("Invalid blog id format"); + } + } + + @PostMapping("/create") + public Blog createBlog(@RequestBody Blog blog) { + return blogsService.createBlog(blog); + } + + @PutMapping("/update") + public Blog updateBlog(@RequestBody Blog blog) { + return blogsService.updateBlog(blog); + } + + @DeleteMapping("/{blogId}") + public void deleteBlog(String blogId) { + blogsService.deleteBlogById(Long.parseLong(blogId)); + } }