Skip to content

Commit

Permalink
Merge branch 'feature/blogs' of github.com:stevensblueprint/blueprint…
Browse files Browse the repository at this point in the history
…_admin_backend into feature/blogs
  • Loading branch information
miguel-merlin committed Dec 4, 2024
2 parents ca13461 + 2e6ef08 commit 8e95736
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,29 @@ public class BlogController {
public List<Blog> 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));
}
}

0 comments on commit 8e95736

Please sign in to comment.