Skip to content

Commit

Permalink
refactor: WaterDate -> WaterDetail 네이밍 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
rawfishthelgh committed Jan 2, 2024
1 parent 9512fad commit f5410f0
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 78 deletions.
20 changes: 10 additions & 10 deletions backend/pium/src/main/java/com/official/pium/domain/PetPlant.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.official.pium.domain;

import com.official.pium.domain.vo.PetPlantState;
import com.official.pium.domain.vo.WaterDate;
import com.official.pium.domain.vo.WaterDetail;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -62,7 +62,7 @@ public class PetPlant extends BaseEntity {
private LocalDate birthDate;

@Embedded
private WaterDate waterDate;
private WaterDetail waterDetail;

@Min(MIN_WATER_CYCLE)
@Max(MAX_WATER_CYCLE)
Expand All @@ -78,7 +78,7 @@ private PetPlant(
String imageUrl,
PetPlantState petPlantState,
LocalDate birthDate,
WaterDate waterDate,
WaterDetail waterDetail,
Integer waterCycle
) {
this.dictionaryPlant = dictionaryPlant;
Expand All @@ -87,7 +87,7 @@ private PetPlant(
this.imageUrl = imageUrl;
this.petPlantState = petPlantState;
this.birthDate = birthDate;
this.waterDate = waterDate;
this.waterDetail = waterDetail;
this.waterCycle = waterCycle;
}

Expand All @@ -102,7 +102,7 @@ public Long calculateDaySince(LocalDate currentDate) {
* - 0 : 오늘 할 일 - 음수 : 할 일 - 양수 : 지각
*/
public Long calculateDday(LocalDate currentDate) {
return waterDate.calculateDday(currentDate);
return waterDetail.calculateDday(currentDate);
}

public void updatePetPlant(
Expand All @@ -118,9 +118,9 @@ public void updatePetPlant(
validateLocalDate(birthDate);
validateLocalDate(lastWaterDate);
validateImageUrl(imageUrl);
waterDate.changeLastWaterDate(lastWaterDate);
waterDetail.changeLastWaterDate(lastWaterDate);
if (!Objects.equals(waterCycle, this.waterCycle)) {
waterDate.plusNextWaterDate(waterCycle);
waterDetail.plusNextWaterDate(waterCycle);
}
this.nickname = nickname;
this.petPlantState = petPlantState;
Expand Down Expand Up @@ -154,19 +154,19 @@ private void validateImageUrl(String imageUrl) {
}

public void water(LocalDate newWaterDate) {
waterDate.water(newWaterDate, this.waterCycle);
waterDetail.water(newWaterDate, this.waterCycle);
}

public void changeNextWaterDate(LocalDate newWaterDate) {
waterDate.changeNextWaterDate(newWaterDate);
waterDetail.changeNextWaterDate(newWaterDate);
}

public boolean isNotOwnerOf(Member member) {
return !Objects.equals(this.member, member);
}

public boolean isDifferentLastWaterDate(LocalDate lastWaterDate) {
return waterDate.isDifferentLastWaterDate(lastWaterDate);
return waterDetail.isDifferentLastWaterDate(lastWaterDate);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Getter
@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class WaterDate {
public class WaterDetail {

@NotNull
@Column(name = "next_water_date", nullable = false)
Expand All @@ -24,7 +24,7 @@ public class WaterDate {
private LocalDate lastWaterDate;

@Builder
private WaterDate(LocalDate nextWaterDate, LocalDate lastWaterDate) {
private WaterDetail(LocalDate nextWaterDate, LocalDate lastWaterDate) {
this.nextWaterDate = nextWaterDate;
this.lastWaterDate = lastWaterDate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static PetPlantHistory from(PetPlant petPlant) {
.light(petPlant.getPetPlantState().getLight())
.wind(petPlant.getPetPlantState().getWind())
.waterCycle(petPlant.getWaterCycle().toString())
.lastWaterDate(petPlant.getWaterDate().getLastWaterDate().toString())
.lastWaterDate(petPlant.getWaterDetail().getLastWaterDate().toString())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private void publishPetPlantHistories(PetPlant petPlant, PetPlantHistory previou

previousPetPlantHistory.generateUpdateLastWaterDateHistoryEvent(
petPlant.getId(),
petPlant.getWaterDate().getLastWaterDate()
petPlant.getWaterDetail().getLastWaterDate()
).ifPresent(publisher::publishEvent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public void water(ReminderCreateRequest reminderCreateRequest, Long petPlantId,

checkOwner(petPlant, member);

LocalDate previousWaterDate = petPlant.getWaterDate().getLastWaterDate();
LocalDate previousWaterDate = petPlant.getWaterDetail().getLastWaterDate();
petPlant.water(reminderCreateRequest.getWaterDate());
LocalDate currentWaterDate = petPlant.getWaterDate().getLastWaterDate();
LocalDate currentWaterDate = petPlant.getWaterDetail().getLastWaterDate();

publisher.publishEvent(
HistoryEvent.of(petPlantId, previousWaterDate, currentWaterDate, HistoryType.LAST_WATER_DATE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.official.pium.service.dto;

import com.official.pium.domain.vo.PetPlantState;
import com.official.pium.domain.vo.WaterDate;
import com.official.pium.domain.vo.WaterDetail;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PastOrPresent;
Expand Down Expand Up @@ -59,8 +59,8 @@ public PetPlantState toPetPlantState() {
.build();
}

public WaterDate toWaterDate() {
return WaterDate.builder()
public WaterDetail toWaterDate() {
return WaterDetail.builder()
.lastWaterDate(lastWaterDate)
.nextWaterDate(LocalDate.now().plusDays(waterCycle))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public static PetPlantResponse of(PetPlant petPlant, Long dday, Long daySince) {
.light(petPlant.getPetPlantState().getLight())
.wind(petPlant.getPetPlantState().getWind())
.birthDate(petPlant.getBirthDate())
.lastWaterDate(petPlant.getWaterDate().getLastWaterDate())
.lastWaterDate(petPlant.getWaterDetail().getLastWaterDate())
.waterCycle(petPlant.getWaterCycle())
.dday(dday)
.nextWaterDate(petPlant.getWaterDate().getNextWaterDate())
.nextWaterDate(petPlant.getWaterDetail().getNextWaterDate())
.daySince(daySince)
.dictionaryPlant(PetPlantResponse.DictionaryPlantResponse.builder()
.id(dictionaryPlant.getId())
Expand All @@ -77,10 +77,10 @@ public static PetPlantResponse of(PetPlant petPlant, Long dday, Long daySince,
.light(petPlant.getPetPlantState().getLight())
.wind(petPlant.getPetPlantState().getWind())
.birthDate(petPlant.getBirthDate())
.lastWaterDate(petPlant.getWaterDate().getLastWaterDate())
.lastWaterDate(petPlant.getWaterDetail().getLastWaterDate())
.waterCycle(petPlant.getWaterCycle())
.dday(dday)
.nextWaterDate(petPlant.getWaterDate().getNextWaterDate())
.nextWaterDate(petPlant.getWaterDetail().getNextWaterDate())
.daySince(daySince)
.dictionaryPlant(PetPlantResponse.DictionaryPlantResponse.builder()
.id(dictionaryPlant.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public static ReminderResponse of(PetPlant petPlant, Long dday) {
.nickName(petPlant.getNickname())
.dictionaryPlantName(petPlant.getDictionaryPlant().getClassification().getName())
.dday(dday)
.nextWaterDate(petPlant.getWaterDate().getNextWaterDate())
.lastWaterDate(petPlant.getWaterDate().getLastWaterDate())
.nextWaterDate(petPlant.getWaterDetail().getNextWaterDate())
.lastWaterDate(petPlant.getWaterDetail().getLastWaterDate())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ class 반려_식물_수정_시_ {
.lastWaterDate(LocalDate.of(2022, 4, 1))
.build();

LocalDate firstWaterDate = petPlant.getWaterDate().getLastWaterDate().plusDays(2);
LocalDate firstWaterDate = petPlant.getWaterDetail().getLastWaterDate().plusDays(2);
반려_식물_물주기(petPlant.getId(), firstWaterDate);
LocalDate secondWaterDate = firstWaterDate.plusDays(3);
반려_식물_물주기(petPlant.getId(), secondWaterDate);
Expand Down Expand Up @@ -608,7 +608,7 @@ class 반려_식물_수정_시_ {
.lastWaterDate(LocalDate.of(2022, 4, 1))
.build();

LocalDate firstWaterDate = petPlant.getWaterDate().getLastWaterDate().plusDays(1);
LocalDate firstWaterDate = petPlant.getWaterDetail().getLastWaterDate().plusDays(1);
반려_식물_물주기(petPlant.getId(), firstWaterDate);
LocalDate secondWaterDate = firstWaterDate.plusDays(3);
반려_식물_물주기(petPlant.getId(), secondWaterDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class 물주기_수행_시_ {
String sessionId = 로그인_요청();

PetPlant petPlant = petPlantSupport.builder().build();
ReminderCreateRequest request = 리마인더_물주기_요청(petPlant.getWaterDate().getLastWaterDate().plusDays(1));
ReminderCreateRequest request = 리마인더_물주기_요청(petPlant.getWaterDetail().getLastWaterDate().plusDays(1));

RestAssured
.given()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.official.pium.domain.vo.PetPlantState;
import com.official.pium.domain.vo.WaterDate;
import com.official.pium.domain.vo.WaterDetail;
import java.time.LocalDate;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.DisplayNameGeneration;
Expand Down Expand Up @@ -82,7 +82,7 @@ private History generateHistory(LocalDate lastWaterDate) {
.waterCycle(5)
.birthDate(LocalDate.of(2021, 7, 1))
.waterDate(
WaterDate.builder()
WaterDetail.builder()
.lastWaterDate(lastWaterDate)
.nextWaterDate(lastWaterDate.plusDays(5))
.build()
Expand Down
Loading

0 comments on commit f5410f0

Please sign in to comment.