Skip to content

Commit 7a081f8

Browse files
committed
reafactor(community): 코드 리뷰 사항 반영
- to -> toEntity 변수명 변경 - ResponseDto 스웨거 적용
1 parent 41e2287 commit 7a081f8

File tree

10 files changed

+40
-9
lines changed

10 files changed

+40
-9
lines changed

src/main/java/com/somemore/community/dto/request/CommunityBoardCreateRequestDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public record CommunityBoardCreateRequestDto(
1919
@NotBlank(message = "게시글 내용은 필수 값입니다.")
2020
String content
2121
) {
22-
public CommunityBoard to(UUID writerId, String imgUrl) {
22+
public CommunityBoard toEntity(UUID writerId, String imgUrl) {
2323
return CommunityBoard.builder()
2424
.writerId(writerId)
2525
.title(title)

src/main/java/com/somemore/community/dto/request/CommunityCommentCreateRequestDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public record CommunityCommentCreateRequestDto(
2424
@Nullable
2525
Long parentCommentId
2626
) {
27-
public CommunityComment to(UUID writerId) {
27+
public CommunityComment toEntity(UUID writerId) {
2828
return CommunityComment.builder()
2929
.communityBoardId(communityBoardId)
3030
.writerId(writerId)

src/main/java/com/somemore/community/dto/response/CommunityBoardDetailResponseDto.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@
33
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
44
import com.fasterxml.jackson.databind.annotation.JsonNaming;
55
import com.somemore.community.domain.CommunityBoard;
6+
import io.swagger.v3.oas.annotations.media.Schema;
67

78
import java.time.LocalDateTime;
89
import java.util.UUID;
910

1011
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
12+
@Schema(description = "커뮤니티 게시글 상세 조회 응답 DTO")
1113
public record CommunityBoardDetailResponseDto(
14+
@Schema(description = "커뮤니티 게시글 ID", example = "12")
1215
Long id,
16+
@Schema(description = "작성자(봉사자) ID", example = "123e4567-e89b-12d3-a456-426614174000")
1317
UUID writerId,
18+
@Schema(description = "커뮤니티 게시글 제목", example = "11/29 OO도서관 봉사 같이 갈 사람 모집합니다.")
1419
String title,
20+
@Schema(description = "커뮤니티 게시글 내용", example = "저 포함 5명이 같이 가면 좋을 거 같아요")
1521
String content,
22+
@Schema(description = "이미지 URL", example = "https://image.domain.com/links")
1623
String imageUrl,
24+
@Schema(description = "커뮤니티 게시글 생성 일시", example = "2023-12-02T11:00:00")
1725
LocalDateTime createdAt,
26+
@Schema(description = "커뮤니티 게시글 수정 일시", example = "2023-12-02T11:00:00")
1827
LocalDateTime updatedAt
1928
) {
2029
public static CommunityBoardDetailResponseDto from(CommunityBoard board) {

src/main/java/com/somemore/community/dto/response/CommunityBoardResponseDto.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
44
import com.fasterxml.jackson.databind.annotation.JsonNaming;
55
import com.somemore.community.repository.mapper.CommunityBoardView;
6+
import io.swagger.v3.oas.annotations.media.Schema;
67

78
import java.time.LocalDateTime;
89

910
@JsonNaming(SnakeCaseStrategy.class)
11+
@Schema(description = "커뮤니티 게시글 목록 조회 응답 DTO")
1012
public record CommunityBoardResponseDto(
13+
@Schema(description = "커뮤니티 게시글 ID", example = "12")
1114
Long id,
15+
@Schema(description = "커뮤니티 게시글 ID", example = "12")
1216
String title,
17+
@Schema(description = "작성자(봉사자) ID", example = "123e4567-e89b-12d3-a456-426614174000")
1318
String writerNickname,
19+
@Schema(description = "커뮤니티 게시글 생성 일시", example = "2023-12-02T11:00:00")
1420
LocalDateTime createdAt
1521
) {
1622
public static CommunityBoardResponseDto from(CommunityBoardView board) {

src/main/java/com/somemore/community/dto/response/CommunityCommentResponseDto.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,33 @@
33
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
44
import com.fasterxml.jackson.databind.annotation.JsonNaming;
55
import com.somemore.community.repository.mapper.CommunityCommentView;
6+
import io.swagger.v3.oas.annotations.media.Schema;
67

78
import java.time.LocalDateTime;
89
import java.util.ArrayList;
910
import java.util.List;
1011

1112
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
1213
public record CommunityCommentResponseDto(
14+
@Schema(description = "커뮤니티 댓글 ID", example = "1234")
1315
Long id,
16+
@Schema(description = "작성자(봉사자) 닉네임", example = "dkdudab")
1417
String writerNickname,
18+
@Schema(description = "커뮤니티 댓글 내용", example = "저도 함께 하고 싶습니다.")
1519
String content,
20+
@Schema(description = "커뮤니티 댓글 수정 일시", example = "2023-12-02T11:00:00")
1621
LocalDateTime updatedAt,
22+
@Schema(description = "대댓글 목록", example = """
23+
[
24+
{
25+
"id": 3,
26+
"content": "첫 번째 댓글의 답글입니다.",
27+
"writerNickname": "사용자2",
28+
"createdAt": "2023-12-02T11:00:00",
29+
"replies": []
30+
}
31+
]
32+
""")
1733
List<CommunityCommentResponseDto> replies
1834
) {
1935
public CommunityCommentResponseDto {

src/main/java/com/somemore/community/service/board/CreateCommunityBoardService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class CreateCommunityBoardService implements CreateCommunityBoardUseCase
2020
@Override
2121
public Long createCommunityBoard(CommunityBoardCreateRequestDto requestDto, UUID writerId, String imgUrl) {
2222

23-
CommunityBoard communityBoard = requestDto.to(writerId, imgUrl == null ? "" : imgUrl);
23+
CommunityBoard communityBoard = requestDto.toEntity(writerId, imgUrl == null ? "" : imgUrl);
2424

2525
communityBoardRepository.save(communityBoard);
2626

src/main/java/com/somemore/community/service/comment/CreateCommunityCommentService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class CreateCommunityCommentService implements CreateCommunityCommentUseC
2525

2626
@Override
2727
public Long createCommunityComment(CommunityCommentCreateRequestDto requestDto, UUID writerId) {
28-
CommunityComment communityComment = requestDto.to(writerId);
28+
CommunityComment communityComment = requestDto.toEntity(writerId);
2929

3030
validateCommunityBoardExists(communityComment.getCommunityBoardId());
3131

src/test/java/com/somemore/community/service/comment/CreateCommunityCommentServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void setUp() {
4444

4545
writerId = UUID.randomUUID();
4646

47-
CommunityBoard communityBoard = communityBoardRepository.save(boardDto.to(writerId, "https://test.image/123"));
47+
CommunityBoard communityBoard = communityBoardRepository.save(boardDto.toEntity(writerId, "https://test.image/123"));
4848
boardId = communityBoard.getId();
4949
}
5050

src/test/java/com/somemore/community/service/comment/DeleteCommunityCommentServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ void setUp() {
4343

4444
writerId = UUID.randomUUID();
4545

46-
CommunityBoard communityBoard = communityBoardRepository.save(boardDto.to(writerId, "https://test.image/123"));
46+
CommunityBoard communityBoard = communityBoardRepository.save(boardDto.toEntity(writerId, "https://test.image/123"));
4747

4848
CommunityCommentCreateRequestDto dto = CommunityCommentCreateRequestDto.builder()
4949
.communityBoardId(communityBoard.getId())
5050
.content("커뮤니티 댓글 테스트 내용")
5151
.parentCommentId(null)
5252
.build();
5353

54-
CommunityComment communityComment = communityCommentRepository.save(dto.to(writerId));
54+
CommunityComment communityComment = communityCommentRepository.save(dto.toEntity(writerId));
5555

5656
commentId = communityComment.getId();}
5757

src/test/java/com/somemore/community/service/comment/UpdateCommunityCommentServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ void setUp() {
4646

4747
writerId = UUID.randomUUID();
4848

49-
CommunityBoard communityBoard = communityBoardRepository.save(boardDto.to(writerId, "https://test.image/123"));
49+
CommunityBoard communityBoard = communityBoardRepository.save(boardDto.toEntity(writerId, "https://test.image/123"));
5050

5151
CommunityCommentCreateRequestDto commentDto = CommunityCommentCreateRequestDto.builder()
5252
.communityBoardId(communityBoard.getId())
5353
.content("커뮤니티 댓글 테스트 내용")
5454
.parentCommentId(null)
5555
.build();
5656

57-
CommunityComment communityComment = communityCommentRepository.save(commentDto.to(writerId));
57+
CommunityComment communityComment = communityCommentRepository.save(commentDto.toEntity(writerId));
5858

5959
commentId = communityComment.getId();
6060

0 commit comments

Comments
 (0)