[댓글 시스템] - 계층형(대댓글) 구조 및 회원/비회원 하이브리드 작성 로직 구현 - 비회원 댓글용 비밀번호 암호화 저장 (PasswordEncoder 적용) - 관리자용 댓글 강제 삭제 및 전체 댓글 모니터링(Dashboard) API 구현 [태그 & 카테고리] - N:M 태그 시스템(PostTag) 엔티티 설계 및 게시글 작성 시 자동 저장 로직 - 계층형(Tree) 카테고리 구조 구현 및 관리자 생성/삭제 API - QueryDSL 검색 조건에 태그 및 카테고리 필터링 추가 [이미지 업로드] - AWS S3 (MinIO) 연동 및 Bucket 자동 생성/Public 정책 설정 - 마크다운 에디터용 이미지 업로드 API 구현
38 lines
1.5 KiB
Kotlin
38 lines
1.5 KiB
Kotlin
package me.wypark.blogbackend.api.controller
|
|
|
|
import me.wypark.blogbackend.api.common.ApiResponse
|
|
import me.wypark.blogbackend.api.dto.PostResponse
|
|
import me.wypark.blogbackend.api.dto.PostSummaryResponse
|
|
import me.wypark.blogbackend.domain.post.PostService
|
|
import org.springframework.data.domain.Page
|
|
import org.springframework.data.domain.Pageable
|
|
import org.springframework.data.domain.Sort
|
|
import org.springframework.data.web.PageableDefault
|
|
import org.springframework.http.ResponseEntity
|
|
import org.springframework.web.bind.annotation.*
|
|
|
|
@RestController
|
|
@RequestMapping("/api/posts")
|
|
class PostController(
|
|
private val postService: PostService
|
|
) {
|
|
|
|
// 목록 조회 (기본값: 최신순, 10개씩)
|
|
@GetMapping
|
|
fun getPosts(
|
|
@RequestParam(required = false) keyword: String?,
|
|
@RequestParam(required = false) category: String?,
|
|
@RequestParam(required = false) tag: String?, // 👈 파라미터 추가
|
|
@PageableDefault(size = 10, sort = ["id"], direction = Sort.Direction.DESC) pageable: Pageable
|
|
): ResponseEntity<ApiResponse<Page<PostSummaryResponse>>> {
|
|
|
|
val result = postService.searchPosts(keyword, category, tag, pageable)
|
|
return ResponseEntity.ok(ApiResponse.success(result))
|
|
}
|
|
|
|
// 상세 조회 (Slug)
|
|
@GetMapping("/{slug}")
|
|
fun getPost(@PathVariable slug: String): ResponseEntity<ApiResponse<PostResponse>> {
|
|
return ResponseEntity.ok(ApiResponse.success(postService.getPostBySlug(slug)))
|
|
}
|
|
} |