Skip to content

Commit 99acc52

Browse files
committed
🚚Rename: 게시글 응답 dto 클래스명 수정
1 parent a5cbc01 commit 99acc52

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/main/java/com/be/sportizebe/domain/post/controller/PostController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.be.sportizebe.domain.post.dto.request.CreatePostRequest;
44
import com.be.sportizebe.domain.post.dto.request.UpdatePostRequest;
5-
import com.be.sportizebe.domain.post.dto.response.CreatePostResponse;
5+
import com.be.sportizebe.domain.post.dto.response.PostResponse;
66
import com.be.sportizebe.domain.post.entity.PostProperty;
77
import com.be.sportizebe.domain.post.service.PostService;
88
import com.be.sportizebe.domain.user.entity.User;
@@ -28,23 +28,23 @@ public class PostController {
2828

2929
@PostMapping("/posts/{property}")
3030
@Operation(summary = "게시글 생성", description = "게시판 종류별 게시글 생성")
31-
public ResponseEntity<BaseResponse<CreatePostResponse>> createPost(
31+
public ResponseEntity<BaseResponse<PostResponse>> createPost(
3232
@Parameter(description = "게시판 종류 (SOCCER, BASKETBALL, FREE)") @PathVariable PostProperty property,
3333
@RequestBody @Valid CreatePostRequest request) {
34-
CreatePostResponse response = postService.createPost(property, request);
34+
PostResponse response = postService.createPost(property, request);
3535
return ResponseEntity.status(HttpStatus.CREATED)
3636
.body(BaseResponse.success("게시글 생성 성공", response));
3737
}
3838

3939
@PutMapping("/posts/{postId}")
4040
@Operation(summary = "게시글 수정", description = "게시글 수정 (작성자만 가능)")
41-
public ResponseEntity<BaseResponse<CreatePostResponse>> updatePost(
41+
public ResponseEntity<BaseResponse<PostResponse>> updatePost(
4242
@Parameter(description = "게시글 ID") @PathVariable Long postId,
4343
@RequestBody @Valid UpdatePostRequest request) {
4444
// TODO: 인증 로직 개발 후 @AuthenticationPrincipal User user로 변경
4545
User user = userRepository.findById(1L)
4646
.orElseThrow(() -> new RuntimeException("테스트 유저가 없습니다. users 테이블에 id=1인 유저를 추가해주세요."));
47-
CreatePostResponse response = postService.updatePost(postId, request, user);
47+
PostResponse response = postService.updatePost(postId, request, user);
4848
return ResponseEntity.ok(BaseResponse.success("게시글 수정 성공", response));
4949
}
5050

src/main/java/com/be/sportizebe/domain/post/dto/response/CreatePostResponse.java renamed to src/main/java/com/be/sportizebe/domain/post/dto/response/PostResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
@Builder
88
@Schema(title = "CreatePostResponse DTO", description = "게시글 생성 응답")
9-
public record CreatePostResponse(
9+
public record PostResponse(
1010
@Schema(description = "게시글 고유번호", example = "1") Long postId,
1111
@Schema(description = "게시글 제목", example = "게시글 제목 ...") String title,
1212
@Schema(description = "게시글 내용", example = "게시글 글 내용 ...") String content,
1313
@Schema(description = "게시글 등록자", example = "사용자명") String publisher,
1414
@Schema(description = "게시글 사진 url", example = "s3 url") String imgUrl,
1515
@Schema(description = "익명 여부", example = "true:익명 / false:사용자명") String isAnonymous) {
1616

17-
public static CreatePostResponse from(Post post) { // Post -> Response 변환
18-
return CreatePostResponse.builder()
17+
public static PostResponse from(Post post) { // Post -> Response 변환
18+
return PostResponse.builder()
1919
.postId(post.getId())
2020
.title(post.getTitle())
2121
.content(post.getContent())

src/main/java/com/be/sportizebe/domain/post/service/PostService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import com.be.sportizebe.domain.post.dto.request.CreatePostRequest;
44
import com.be.sportizebe.domain.post.dto.request.UpdatePostRequest;
5-
import com.be.sportizebe.domain.post.dto.response.CreatePostResponse;
5+
import com.be.sportizebe.domain.post.dto.response.PostResponse;
66
import com.be.sportizebe.domain.post.entity.PostProperty;
77
import com.be.sportizebe.domain.user.entity.User;
88

99
public interface PostService {
10-
CreatePostResponse createPost(PostProperty property, CreatePostRequest request); // 게시글 생성
10+
PostResponse createPost(PostProperty property, CreatePostRequest request); // 게시글 생성
1111

12-
CreatePostResponse updatePost(Long postId, UpdatePostRequest request, User user); // 게시글 수정
12+
PostResponse updatePost(Long postId, UpdatePostRequest request, User user); // 게시글 수정
1313

1414
void deletePost(Long postId, User user); // 게시글 삭제
1515
}

src/main/java/com/be/sportizebe/domain/post/service/PostServiceImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.be.sportizebe.domain.post.dto.request.CreatePostRequest;
44
import com.be.sportizebe.domain.post.dto.request.UpdatePostRequest;
5-
import com.be.sportizebe.domain.post.dto.response.CreatePostResponse;
5+
import com.be.sportizebe.domain.post.dto.response.PostResponse;
66
import com.be.sportizebe.domain.post.entity.Post;
77
import com.be.sportizebe.domain.post.entity.PostProperty;
88
import com.be.sportizebe.domain.post.exception.PostErrorCode;
@@ -23,17 +23,17 @@ public class PostServiceImpl implements PostService {
2323

2424
@Override
2525
@Transactional
26-
public CreatePostResponse createPost(PostProperty property, CreatePostRequest request) {
26+
public PostResponse createPost(PostProperty property, CreatePostRequest request) {
2727
Post post = request.toEntity(property); // 요청 dto 데이터를 entity로 변환
2828

2929
Post savedPost = postRepository.save(post); // db에 저장
3030

31-
return CreatePostResponse.from(savedPost); // entity를 dto로 변환하여 응답
31+
return PostResponse.from(savedPost); // entity를 dto로 변환하여 응답
3232
}
3333

3434
@Override
3535
@Transactional
36-
public CreatePostResponse updatePost(Long postId, UpdatePostRequest request, User user) {
36+
public PostResponse updatePost(Long postId, UpdatePostRequest request, User user) {
3737
Post post = postRepository.findById(postId)
3838
.orElseThrow(() -> new CustomException(PostErrorCode.POST_NOT_FOUND));
3939

@@ -44,7 +44,7 @@ public CreatePostResponse updatePost(Long postId, UpdatePostRequest request, Use
4444

4545
post.update(request.title(), request.content(), request.imgUrl());
4646

47-
return CreatePostResponse.from(post);
47+
return PostResponse.from(post);
4848
}
4949

5050
@Override

0 commit comments

Comments
 (0)