Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ public class CommentController {
private final CommentService commentService;

// 댓글 작성
@PostMapping("/comments/posts/{postId}")
@PostMapping("/comments/post/{postId}")
public ResponseEntity<CommentResponse> createComment(
@PathVariable Long postId,
@AuthenticationPrincipal JwtPayload jwtPayload,
@RequestBody CreateCommentRequest request
@RequestBody @Valid CreateCommentRequest request
) {
Long profileId = jwtPayload.getProfileId();
CommentResponse response = commentService.createComment(postId, profileId, request);
return ResponseEntity.ok(response);
}

// 댓글 전체 조회 (게시글 기준, 정렬/필터 가능)
@GetMapping("/comments/posts/{postId}")
@GetMapping("/comments/post/{postId}")
public ResponseEntity<List<CommentResponse>> getCommentsByPostId(
@PathVariable Long postId,
@RequestParam(defaultValue = "latest") String sort // latest 또는 oldest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.example.feeda.domain.post.dto.PostResponseDto;
import com.example.feeda.domain.post.service.PostService;
import com.example.feeda.security.jwt.JwtPayload;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
Expand Down Expand Up @@ -38,7 +39,7 @@ public class PostController {
private final PostService postService;

@PostMapping
public ResponseEntity<PostResponseDto> createPost(@RequestBody PostRequestDto requestDto,
public ResponseEntity<PostResponseDto> createPost(@RequestBody @Valid PostRequestDto requestDto,
@AuthenticationPrincipal JwtPayload jwtPayload) {

PostResponseDto post = postService.createPost(requestDto, jwtPayload);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.example.feeda.domain.post.dto;

import jakarta.persistence.Column;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
public class PostRequestDto {

@NotNull(message = "제목은 필수 항목입니다.")
private final String title;

@NotNull(message = "내용은 필수 항목입니다.")
private final String content;

@Size(max = 50, message = "카테고리는 50자 이하로 입력하세요.")
private final String category;

public PostRequestDto(String title, String content, String category) {
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/example/feeda/domain/post/entity/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;


Expand All @@ -23,15 +21,12 @@ public class Post extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotNull(message = "제목은 필수 항목입니다.")
@Column(length = 100, nullable = false)
private String title;

@NotNull(message = "내용은 필수 항목입니다.")
@Column(columnDefinition = "longtext", nullable = false)
private String content;

@Size(max = 50, message = "카테고리는 50자 이하로 입력하세요.")
@Column(length = 50)
private String category;

Expand All @@ -47,6 +42,7 @@ public Post(String title, String content, String category, Profile profile) {
}

protected Post() {
super();
}

public void update(String title, String content, String category) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ResponseEntity<GetProfileWithFollowCountResponseDto> getProfile(@PathVari
@GetMapping("/profiles")
public ResponseEntity<ProfileListResponseDto> getProfiles(
@RequestParam(required = false) String keyword,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size) {

ProfileListResponseDto response = profileService.getProfiles(keyword, page, size);
Expand Down