Class PostController

java.lang.Object
com.bytedesk.forum.post.PostController

@RestController @RequestMapping("/api/v1/posts") public class PostController extends Object
  • Field Details

  • Constructor Details

    • PostController

      public PostController()
  • Method Details

    • createPost

      @PostMapping @PreAuthorize("isAuthenticated()") public org.springframework.http.ResponseEntity<PostEntity> createPost(@RequestParam String title, @RequestParam String content, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails, @RequestParam Long categoryId)
    • updatePost

      @PutMapping("/{postId}") @PreAuthorize("isAuthenticated() and @postService.isPostOwner(#postId, authentication.name)") public org.springframework.http.ResponseEntity<PostEntity> updatePost(@PathVariable Long postId, @RequestParam String title, @RequestParam String content)
    • deletePost

      @DeleteMapping("/{postId}") @PreAuthorize("isAuthenticated() and @postService.isPostOwner(#postId, authentication.name)") public org.springframework.http.ResponseEntity<Void> deletePost(@PathVariable Long postId)
    • getPost

      @GetMapping("/{postId}") public org.springframework.http.ResponseEntity<PostEntity> getPost(@PathVariable Long postId)
    • getPosts

      @GetMapping public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<PostEntity>> getPosts(org.springframework.data.domain.Pageable pageable)
    • getPostsByCategory

      @GetMapping("/category/{categoryId}") public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<PostEntity>> getPostsByCategory(@PathVariable Long categoryId, org.springframework.data.domain.Pageable pageable)
    • getPostsByUser

      @GetMapping("/user/{userId}") public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<PostEntity>> getPostsByUser(@PathVariable Long userId, org.springframework.data.domain.Pageable pageable)
    • incrementViewCount

      @PostMapping("/{postId}/view") public org.springframework.http.ResponseEntity<Void> incrementViewCount(@PathVariable Long postId)
    • incrementLikeCount

      @PostMapping("/{postId}/like") public org.springframework.http.ResponseEntity<Void> incrementLikeCount(@PathVariable Long postId)
    • searchPosts

      @PostMapping("/search") public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<PostEntity>> searchPosts(@RequestBody PostSearchCriteria criteria, org.springframework.data.domain.Pageable pageable)
    • fullTextSearch

      @GetMapping("/search/fulltext") public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<PostEntity>> fullTextSearch(@RequestParam String keyword, org.springframework.data.domain.Pageable pageable)
    • fullTextSearchByCategory

      @GetMapping("/search/fulltext/category/{categoryId}") public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<PostEntity>> fullTextSearchByCategory(@RequestParam String keyword, @PathVariable Long categoryId, org.springframework.data.domain.Pageable pageable)