Skip to content

Commit

Permalink
Feat : #33-Ingredient getter setter 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyobim committed Jan 6, 2023
1 parent 534a00f commit d3d0de0
Showing 1 changed file with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ public RefrigeratorResponse LookUpRefrigerator(String loginId) {

loginUserIngredientList.forEach(ingredient -> {
LocalDate currentTime = LocalDate.now();
Period diff = Period.between(currentTime, ingredient.getIngredientLimit());
Period diff = Period.between(currentTime, ingredient.getIngredientLimitDate());
int diff_time = diff.getYears() * 365 + diff.getMonths() * 30 + diff.getDays();
if (ingredient.getIngredientStatus().equals("freezer")) {
freezer.add(
FoodInfoResponse.builder()
.foodId(ingredient.getIngredientIdx())
.foodName(ingredient.getIngredientName())
.expirationDate(DateInfoResponse.builder()
.year(ingredient.getIngredientLimit().getYear())
.month(ingredient.getIngredientLimit().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientLimit().toString().substring(8)))
.year(ingredient.getIngredientLimitDate().getYear())
.month(ingredient.getIngredientLimitDate().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientLimitDate().toString().substring(8)))
.build())
.purchaseDate(DateInfoResponse.builder()
.year(ingredient.getIngredientBuy().getYear())
.month(ingredient.getIngredientBuy().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientBuy().toString().substring(8)))
.year(ingredient.getIngredientBuyDate().getYear())
.month(ingredient.getIngredientBuyDate().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientBuyDate().toString().substring(8)))
.build())
.amount(ingredient.getIngredientCnt())
.remain(diff_time)
Expand All @@ -79,14 +79,14 @@ public RefrigeratorResponse LookUpRefrigerator(String loginId) {
.foodId(ingredient.getIngredientIdx())
.foodName(ingredient.getIngredientName())
.expirationDate(DateInfoResponse.builder()
.year(ingredient.getIngredientLimit().getYear())
.month(ingredient.getIngredientLimit().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientLimit().toString().substring(8)))
.year(ingredient.getIngredientLimitDate().getYear())
.month(ingredient.getIngredientLimitDate().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientLimitDate().toString().substring(8)))
.build())
.purchaseDate(DateInfoResponse.builder()
.year(ingredient.getIngredientBuy().getYear())
.month(ingredient.getIngredientBuy().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientBuy().toString().substring(8)))
.year(ingredient.getIngredientBuyDate().getYear())
.month(ingredient.getIngredientBuyDate().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientBuyDate().toString().substring(8)))
.build())
.amount(ingredient.getIngredientCnt())
.remain(diff_time)
Expand All @@ -99,14 +99,14 @@ public RefrigeratorResponse LookUpRefrigerator(String loginId) {
.foodId(ingredient.getIngredientIdx())
.foodName(ingredient.getIngredientName())
.expirationDate(DateInfoResponse.builder()
.year(ingredient.getIngredientLimit().getYear())
.month(ingredient.getIngredientLimit().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientLimit().toString().substring(8)))
.year(ingredient.getIngredientLimitDate().getYear())
.month(ingredient.getIngredientLimitDate().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientLimitDate().toString().substring(8)))
.build())
.purchaseDate(DateInfoResponse.builder()
.year(ingredient.getIngredientBuy().getYear())
.month(ingredient.getIngredientBuy().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientBuy().toString().substring(8)))
.year(ingredient.getIngredientBuyDate().getYear())
.month(ingredient.getIngredientBuyDate().getMonthValue())
.day(Integer.parseInt(ingredient.getIngredientBuyDate().toString().substring(8)))
.build())
.amount(ingredient.getIngredientCnt())
.remain(diff_time)
Expand All @@ -131,21 +131,21 @@ public FoodInfoResponse LookUpDetailIngredientInfo(Long foodId) {
}

LocalDate currentTime = LocalDate.now();
Period diff = Period.between(currentTime, selectedIngredient.get().getIngredientLimit());
Period diff = Period.between(currentTime, selectedIngredient.get().getIngredientLimitDate());
int diff_time = diff.getYears() * 365 + diff.getMonths() * 30 + diff.getDays();
log.info("날짜 차이:" + diff.getYears() + diff.getMonths() + diff.getDays());
return FoodInfoResponse.builder()
.foodId(selectedIngredient.get().getIngredientIdx())
.foodName(selectedIngredient.get().getIngredientName())
.expirationDate(DateInfoResponse.builder()
.year(selectedIngredient.get().getIngredientLimit().getYear())
.month(selectedIngredient.get().getIngredientLimit().getMonthValue())
.day(Integer.parseInt(selectedIngredient.get().getIngredientLimit().toString().substring(8)))
.year(selectedIngredient.get().getIngredientLimitDate().getYear())
.month(selectedIngredient.get().getIngredientLimitDate().getMonthValue())
.day(Integer.parseInt(selectedIngredient.get().getIngredientLimitDate().toString().substring(8)))
.build())
.purchaseDate(DateInfoResponse.builder()
.year(selectedIngredient.get().getIngredientBuy().getYear())
.month(selectedIngredient.get().getIngredientBuy().getMonthValue())
.day(Integer.parseInt(selectedIngredient.get().getIngredientBuy().toString().substring(8)))
.year(selectedIngredient.get().getIngredientBuyDate().getYear())
.month(selectedIngredient.get().getIngredientBuyDate().getMonthValue())
.day(Integer.parseInt(selectedIngredient.get().getIngredientBuyDate().toString().substring(8)))
.build())
.amount(selectedIngredient.get().getIngredientCnt())
.remain(diff_time)
Expand All @@ -163,8 +163,8 @@ public AddIngredientResponse addNewIngredient(String loginId, NewIngredientReque

LocalDate limit = LocalDate.of(newIngredientRequest.getExpirationYear(), newIngredientRequest.getExpirationMonth(), newIngredientRequest.getExpirationDay());
LocalDate purchase = LocalDate.of(newIngredientRequest.getPurchaseYear(), newIngredientRequest.getPurchaseMonth(), newIngredientRequest.getPurchaseDay());
newIngredient.setIngredientBuy(purchase);
newIngredient.setIngredientLimit(limit);
newIngredient.setIngredientBuyDate(purchase);
newIngredient.setIngredientLimitDate(limit);
newIngredient.setRefrigerator(loginUserFrige.get());

ingredientRepository.save(newIngredient);
Expand Down Expand Up @@ -211,8 +211,8 @@ public void changeIngredientDetail(NewIngredientRequest changeIngredientRequest,
log.info("바뀐이름" + changeIngredient.getIngredientName());
LocalDate limit = LocalDate.of(changeIngredientRequest.getExpirationYear(), changeIngredientRequest.getExpirationMonth(), changeIngredientRequest.getExpirationDay());
LocalDate purchase = LocalDate.of(changeIngredientRequest.getPurchaseYear(), changeIngredientRequest.getPurchaseMonth(), changeIngredientRequest.getPurchaseDay());
changeIngredient.setIngredientLimit(limit);
changeIngredient.setIngredientBuy(purchase);
changeIngredient.setIngredientLimitDate(limit);
changeIngredient.setIngredientBuyDate(purchase);

changeIngredient.setIngredientStatus(changeIngredientRequest.getStorage());

Expand Down

0 comments on commit d3d0de0

Please sign in to comment.