Skip to content

Commit

Permalink
add: added field
Browse files Browse the repository at this point in the history
  • Loading branch information
thguss committed Nov 27, 2024
1 parent 7882a00 commit 71242e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ public class Diary {
private Long topicId;
private long memberId;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;

public void validateDiaryOwnership(long memberId) {
if (this.memberId != memberId) {
throw new SmeemException(ExceptionCode.INVALID_MEMBER_AND_DIARY);
}
}

public boolean isUpdated() {
return updatedAt.isAfter(createdAt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public record RetrieveDiaryResponse(
String createdAt,
@Schema(description = "일기 작성자 닉네임")
String username,
@Schema(description = "일기 수정 여부")
boolean isUpdated,
@Schema(description = "코칭 결과 정보")
List<CorrectionResponse> corrections,
@Schema(description = "코칭 횟수")
Expand All @@ -45,6 +47,7 @@ public static RetrieveDiaryResponse of(
.content(diary.getContent())
.createdAt(SmeemConverter.toString(diary.getCreatedAt()))
.username(member.getUsername())
.isUpdated(diary.isUpdated())
.corrections(corrections.stream().map(CorrectionResponse::from).toList())
.correctionCount(correctionCount)
.correctionMaxCount(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public Diary toDomain() {
.topicId(topicId)
.memberId(memberId)
.createdAt(createdAt)
.updatedAt(updatedAt)
.build();
}

Expand Down

0 comments on commit 71242e1

Please sign in to comment.