Skip to content

Commit

Permalink
refactor: Weight에 memo 필드가 추가된 사항 반영 #8
Browse files Browse the repository at this point in the history
  • Loading branch information
shimbaa committed Sep 13, 2024
1 parent ba62281 commit b8ce3d7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public static WeightResponse toResponse(Weight weight) {
weight.getId(),
weight.getPetId(),
weight.getWeight(),
weight.getRecordedAt());
weight.getRecordedAt(),
weight.getMemo()
);
}

public static List<WeightResponse> toResponseList(List<Weight> weights) {
Expand All @@ -26,6 +28,7 @@ public static Weight toEntity(WeightCreateRequest request) {
.petId(request.petId())
.recordedAt(request.recordedAt())
.weight(request.weight())
.memo(request.memo())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
public record WeightCreateRequest(
Integer petId,
LocalDateTime recordedAt,
Double weight
Double weight,
String memo
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public record WeightResponse(
Long id,
Long petId,
Double weight,
LocalDateTime recordedAt
LocalDateTime recordedAt,
String memo
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

public record WeightUpdateRequest(
LocalDateTime recordedAt,
Double weight
Double weight,
String memo
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public void updateWeightRecord(Long id, WeightUpdateRequest request) {

weight.update( // 변경 포인트를 해당 메서드에 모아서 하나로 통일한다.
request.recordedAt(),
request.weight()
request.weight(),
request.memo()
);
// dirty checking 으로 자동 변경 되고 db에 저장 된다.
}
Expand Down

0 comments on commit b8ce3d7

Please sign in to comment.