Skip to content

Commit e28f14c

Browse files
committed
feat(community): communityBoard 조회 responseDto 생성
1 parent 946085f commit e28f14c

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.somemore.community.dto.response;
2+
3+
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
4+
import com.fasterxml.jackson.databind.annotation.JsonNaming;
5+
import com.somemore.community.domain.CommunityBoard;
6+
7+
import java.time.LocalDateTime;
8+
9+
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
10+
public record CommunityBoardGetDetailResponseDto(
11+
Long id,
12+
String title,
13+
String content,
14+
String imageUrl,
15+
LocalDateTime createdAt,
16+
LocalDateTime updatedAt,
17+
WriterDetailDto writerDetailDto
18+
) {
19+
public static CommunityBoardGetDetailResponseDto fromEntity(CommunityBoard board, WriterDetailDto writer) {
20+
return new CommunityBoardGetDetailResponseDto(
21+
board.getId(),
22+
board.getTitle(),
23+
board.getContent(),
24+
board.getImgUrl(),
25+
board.getCreatedAt(),
26+
board.getUpdatedAt(),
27+
writer
28+
);
29+
}
30+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.somemore.community.dto.response;
2+
3+
import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
4+
import com.fasterxml.jackson.databind.annotation.JsonNaming;
5+
import com.somemore.community.domain.CommunityBoard;
6+
7+
import java.time.LocalDateTime;
8+
9+
@JsonNaming(SnakeCaseStrategy.class)
10+
public record CommunityBoardGetResponseDto(
11+
Long id,
12+
String title,
13+
String writerNickname,
14+
LocalDateTime createdAt
15+
) {
16+
public static CommunityBoardGetResponseDto fromEntity(CommunityBoard board, String writerNickname) {
17+
return new CommunityBoardGetResponseDto(
18+
board.getId(),
19+
board.getTitle(),
20+
writerNickname,
21+
board.getCreatedAt()
22+
);
23+
}
24+
}
25+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.somemore.community.dto.response;
2+
3+
import com.somemore.volunteer.domain.Tier;
4+
5+
import java.util.UUID;
6+
7+
public interface WriterDetailDto {
8+
UUID id();
9+
String name();
10+
String imgUrl();
11+
Tier tier();
12+
}

0 commit comments

Comments
 (0)