From 20103b6252dbdeeeb54b1428a4d9cc6b0c666452 Mon Sep 17 00:00:00 2001 From: CHAE Date: Fri, 10 Nov 2023 14:09:15 +0900 Subject: [PATCH] =?UTF-8?q?:ambulance:=20Fix:=20=EC=98=A4=EB=8A=98?= =?UTF-8?q?=EC=9D=98=EC=98=81=EC=96=91=20=EC=9D=91=EB=8B=B5=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20LocalDate=20=EC=A3=BC=EC=84=9D=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20(#66)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../diareat/food/dto/ResponseNutritionSumByDateDto.java | 9 ++++++--- .../com/diareat/diareat/food/service/FoodService.java | 2 +- .../diareat/diareat/controller/FoodControllerTest.java | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/diareat/diareat/food/dto/ResponseNutritionSumByDateDto.java b/src/main/java/com/diareat/diareat/food/dto/ResponseNutritionSumByDateDto.java index ea6be33..09a99cd 100644 --- a/src/main/java/com/diareat/diareat/food/dto/ResponseNutritionSumByDateDto.java +++ b/src/main/java/com/diareat/diareat/food/dto/ResponseNutritionSumByDateDto.java @@ -3,15 +3,18 @@ import com.diareat.diareat.user.domain.BaseNutrition; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; +import java.io.Serializable; import java.time.LocalDate; @Getter +@NoArgsConstructor @AllArgsConstructor -public class ResponseNutritionSumByDateDto { +public class ResponseNutritionSumByDateDto implements Serializable { Long userId; - LocalDate checkDate; //조회한 날짜 + // LocalDate checkDate; //조회한 날짜 int nutritionSumType; //조회할 기간을 나타내는 코드. {1: 특정 날짜, 7: 최근 7일간, 30: 최근 한달간} int totalKcal; @@ -30,7 +33,7 @@ public static ResponseNutritionSumByDateDto of (Long userId, LocalDate checkDate int totalCarbohydrate, int totalProtein, int totalFat, double ratioKcal, double ratioCarbohydrate, double ratioProtein, double ratioFat, BaseNutrition baseNutrition){ - return new ResponseNutritionSumByDateDto(userId, checkDate, nutritionSumType, totalKcal, + return new ResponseNutritionSumByDateDto(userId, nutritionSumType, totalKcal, totalCarbohydrate, totalProtein, totalFat, ratioKcal, ratioCarbohydrate, ratioProtein, ratioFat, baseNutrition); } diff --git a/src/main/java/com/diareat/diareat/food/service/FoodService.java b/src/main/java/com/diareat/diareat/food/service/FoodService.java index cd6e080..5b09f16 100644 --- a/src/main/java/com/diareat/diareat/food/service/FoodService.java +++ b/src/main/java/com/diareat/diareat/food/service/FoodService.java @@ -112,7 +112,7 @@ public void deleteFavoriteFood(Long favoriteFoodId, Long userId) { favoriteFoodRepository.deleteById(favoriteFoodId); } - @Cacheable(value = "ResponseNutritionSumByDateDto", key = "#userId+#date.toString()", cacheManager = "diareatCacheManager") + @Cacheable(value = "ResponseNutritionSumByDateDto", key = "#userId + #date.toString()", cacheManager = "diareatCacheManager") @Transactional(readOnly = true) // 유저의 특정 날짜에 먹은 음식들의 영양성분별 총합 조회 (섭취영양소/기준영양소 및 비율까지 계산해서 반환, dto 구체적 협의 필요) public ResponseNutritionSumByDateDto getNutritionSumByDate(Long userId, LocalDate date) { diff --git a/src/test/java/com/diareat/diareat/controller/FoodControllerTest.java b/src/test/java/com/diareat/diareat/controller/FoodControllerTest.java index 57cbba7..4dc0a76 100644 --- a/src/test/java/com/diareat/diareat/controller/FoodControllerTest.java +++ b/src/test/java/com/diareat/diareat/controller/FoodControllerTest.java @@ -273,7 +273,7 @@ void testGetNutritionSumByDate() throws Exception{ .andExpect(MockMvcResultMatchers.jsonPath("$.header.code").value(expectedResponse.getHeader().getCode())) .andExpect(MockMvcResultMatchers.jsonPath("$.header.message").value(expectedResponse.getHeader().getMessage())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.userId").value(expectedResponse.getData().getUserId())) - .andExpect(MockMvcResultMatchers.jsonPath("$.data.checkDate").value(expectedResponse.getData().getCheckDate().toString())) + //.andExpect(MockMvcResultMatchers.jsonPath("$.data.checkDate").value(expectedResponse.getData().getCheckDate().toString())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.nutritionSumType").value(expectedResponse.getData().getNutritionSumType())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.totalKcal").value(expectedResponse.getData().getTotalKcal())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.totalCarbohydrate").value(expectedResponse.getData().getTotalCarbohydrate())) @@ -308,7 +308,7 @@ void testGetNutritionSumByWeek() throws Exception { .andExpect(MockMvcResultMatchers.jsonPath("$.header.code").value(expectedResponse.getHeader().getCode())) .andExpect(MockMvcResultMatchers.jsonPath("$.header.message").value(expectedResponse.getHeader().getMessage())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.userId").value(expectedResponse.getData().getUserId())) - .andExpect(MockMvcResultMatchers.jsonPath("$.data.checkDate").value(expectedResponse.getData().getCheckDate().toString())) + //.andExpect(MockMvcResultMatchers.jsonPath("$.data.checkDate").value(expectedResponse.getData().getCheckDate().toString())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.nutritionSumType").value(expectedResponse.getData().getNutritionSumType())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.totalKcal").value(expectedResponse.getData().getTotalKcal())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.totalCarbohydrate").value(expectedResponse.getData().getTotalCarbohydrate())) @@ -343,7 +343,7 @@ void testGetNutritionSumByMonth() throws Exception { .andExpect(MockMvcResultMatchers.jsonPath("$.header.code").value(expectedResponse.getHeader().getCode())) .andExpect(MockMvcResultMatchers.jsonPath("$.header.message").value(expectedResponse.getHeader().getMessage())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.userId").value(expectedResponse.getData().getUserId())) - .andExpect(MockMvcResultMatchers.jsonPath("$.data.checkDate").value(expectedResponse.getData().getCheckDate().toString())) + //.andExpect(MockMvcResultMatchers.jsonPath("$.data.checkDate").value(expectedResponse.getData().getCheckDate().toString())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.nutritionSumType").value(expectedResponse.getData().getNutritionSumType())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.totalKcal").value(expectedResponse.getData().getTotalKcal())) .andExpect(MockMvcResultMatchers.jsonPath("$.data.totalCarbohydrate").value(expectedResponse.getData().getTotalCarbohydrate()))