Skip to content

Commit

Permalink
[feat] #137 나의 진행도 조회 API 반환값에 goalId 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
chanwoo7 committed Sep 1, 2024
1 parent bcdcc12 commit 5143e8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
@NoArgsConstructor
@AllArgsConstructor
public class MyProgressDto {
private Long goalId;
private Boolean isInProgress;
private Double progressRate;

public static final String description =
"isInProgress : 진행 중 여부 (완료되었거나 목표가 없다면 false) | " +
"goalId: 목표 ID (목표가 없으면 null) | " +
"isInProgress : 진행 중 여부 (완료되었거나 목표가 없으면 false) | " +
"progressRate : 진행도 (완독율)";
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ public MyProgressDto getMyProgress(String isbn) {
Goal goal = goalRepository.findByUserAndIsbn(user, isbn)
.orElse(null);

// 목표가 없으면
if (goal == null) {
return MyProgressDto.builder()
.goalId(null)
.isInProgress(false)
.progressRate(null)
.build();
Expand All @@ -112,13 +114,18 @@ public MyProgressDto getMyProgress(String isbn) {
double progressRate = goalMapper.getFormattedProgressRate((double) goal.getTotalPage(),
(double) goalMapper.getMostRecentPage(recordDtos));

// 완료된 목표이면
if (goal.getIsFinished() == Boolean.TRUE) {
return MyProgressDto.builder()
.goalId(goal.getGoalId())
.isInProgress(false)
.progressRate(progressRate)
.build();
} else {
}
// 진행 중인 목표이면
else {
return MyProgressDto.builder()
.goalId(goal.getGoalId())
.isInProgress(true)
.progressRate(progressRate)
.build();
Expand Down

0 comments on commit 5143e8e

Please sign in to comment.