-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from CAUSOLDOUTMEN/feature/42-feat-foodservice
�Feat: 유저 주간 랭킹 기능 구현 (#42)
- Loading branch information
Showing
8 changed files
with
225 additions
and
16 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/com/diareat/diareat/food/dto/ResponseAnalysisDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.diareat.diareat.food.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ResponseAnalysisDto { // 그래프 + 점수에 사용되는 DTO | ||
|
||
private double totalScore; | ||
private List<Double> calorieLastSevenDays; // 최근 7일간의 칼로리 (7개 과거부터 나열) | ||
private List<Double> calorieLastFourWeek; // 최근 4주간의 칼로리 (4개 과거부터 나열) | ||
private List<Double> carbohydrateLastSevenDays; // 최근 7일간의 탄수화물 | ||
private List<Double> carbohydrateLastFourWeek; // 최근 4주간의 탄수화물 | ||
private List<Double> proteinLastSevenDays; // 최근 7일간의 단백질 | ||
private List<Double> proteinLastFourWeek; // 최근 4주간의 단백질 | ||
private List<Double> fatLastSevenDays; // 최근 7일간의 지방 | ||
private List<Double> fatLastFourWeek; // 최근 4주간의 지방 | ||
|
||
public static ResponseAnalysisDto of(double totalScore, List<Double> calorieLastSevenDays, List<Double> calorieLastFourWeek, List<Double> carbohydrateLastSevenDays, List<Double> carbohydrateLastFourWeek, List<Double> proteinLastSevenDays, List<Double> proteinLastFourWeek, List<Double> fatLastSevenDays, List<Double> fatLastFourWeek) { | ||
return new ResponseAnalysisDto(totalScore, calorieLastSevenDays, calorieLastFourWeek, carbohydrateLastSevenDays, carbohydrateLastFourWeek, proteinLastSevenDays, proteinLastFourWeek, fatLastSevenDays, fatLastFourWeek); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/diareat/diareat/food/dto/ResponseScoreBestWorstDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.diareat.diareat.food.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ResponseScoreBestWorstDto { // 일기 분석 자세히보기에 사용되는 DTO | ||
|
||
private double calorieScore; | ||
private double carbohydrateScore; | ||
private double proteinScore; | ||
private double fatScore; | ||
private double totalScore; | ||
private List<ResponseSimpleFoodDto> best; | ||
private List<ResponseSimpleFoodDto> worst; | ||
|
||
public static ResponseScoreBestWorstDto of(double calorieScore, double carbohydrateScore, double proteinScore, double fatScore, double totalScore, List<ResponseSimpleFoodDto> best, List<ResponseSimpleFoodDto> worst) { | ||
return new ResponseScoreBestWorstDto(calorieScore, carbohydrateScore, proteinScore, fatScore, totalScore, best, worst); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/diareat/diareat/food/dto/ResponseSimpleFoodDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.diareat.diareat.food.dto; | ||
|
||
import com.diareat.diareat.food.domain.Food; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class ResponseSimpleFoodDto { // Best 3 and Worst 3에 사용될 객체 | ||
|
||
private String name; | ||
private double calorie; | ||
private double carbohydrate; | ||
private double protein; | ||
private double fat; | ||
private LocalDate date; | ||
|
||
public static ResponseSimpleFoodDto of(String name, double calorie, double carbohydrate, double protein, double fat, LocalDate date) { | ||
return new ResponseSimpleFoodDto(name, calorie, carbohydrate, protein, fat, date); | ||
} | ||
|
||
public static ResponseSimpleFoodDto from(Food food) { | ||
return new ResponseSimpleFoodDto(food.getName(), food.getBaseNutrition().getKcal(), food.getBaseNutrition().getCarbohydrate(), | ||
food.getBaseNutrition().getProtein(), food.getBaseNutrition().getFat(), food.getDate()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters