-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/smunity/server/domain/question/dto/QuestionReadResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.smunity.server.domain.question.dto; | ||
|
||
import com.smunity.server.domain.question.entity.Question; | ||
import lombok.Builder; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Builder | ||
public record QuestionReadResponseDto( | ||
Long id, | ||
String title, | ||
String content, | ||
String author, | ||
boolean isAuthor, | ||
boolean answered, | ||
LocalDateTime createdAt, | ||
LocalDateTime updatedAt | ||
) { | ||
|
||
public static QuestionReadResponseDto of(Long memberId, Question question) { | ||
return QuestionReadResponseDto.builder() | ||
.id(question.getId()) | ||
.title(question.getTitle()) | ||
.content(question.getContent()) | ||
.author(question.getAuthor()) | ||
.isAuthor(question.getIsAuthor(memberId)) | ||
.answered(question.getAnswered()) | ||
.createdAt(question.getCreatedAt()) | ||
.updatedAt(question.getUpdatedAt()) | ||
.build(); | ||
} | ||
|
||
public static Page<QuestionReadResponseDto> of(Long memberId, Page<Question> questions) { | ||
return questions.map(question -> of(memberId, question)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters