Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat - 일별 챌린지 실패 처리 기능 구현 #45

Merged
merged 14 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ public ResponseEntity<ApiResponse<DailyChallengeResponse>> orderDetailDailyChall
return ResponseEntity
.status(DailyChallengeSuccess.GET_DAILY_CHALLENGE_SUCCESS.getHttpStatus())
.body(ApiResponse.success(DailyChallengeSuccess.GET_DAILY_CHALLENGE_SUCCESS,
dailyChallengeService.getDailyChallenge(IdConverter.getUserId(principal), os)));
dailyChallengeService.getDailyChallenge(IdConverter.getUserId(principal))));
}

@PatchMapping("/failure")
public ResponseEntity<ApiResponse<?>> orderChallengeDailyChallenge(
Principal principal,
@RequestHeader("OS") final String os
Principal principal
) {
dailyChallengeService.modifyDailyChallengeStatus(IdConverter.getUserId(principal), os);
dailyChallengeService.modifyDailyChallengeStatus(IdConverter.getUserId(principal));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P5. 파라미터에 os 정보 빼신거 보고 기존과 달리 일별챌린지 조회할 때 사용자가 하루에 두 운영체제로 들어올 가능성은 적겠지만 헤더의 '운영체제에 맞는 앱들'만 반환해주는게 맞는 것 같다고 생각이 들었습니다! 제가 올린 PR 브랜치에서 해당사항 수정하고 푸시하겠습니다! 확인해주세요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하! ide에서 os가 사용되지 않는 변수로 떠서 삭제했던 것 같습니다! 사용하시는 변수라면 수정해주셔서 감사합니다~

return ResponseEntity
.status(DailyChallengeSuccess.MODIFY_DAILY_CHALLENGE_STATUS_SUCCESS.getHttpStatus())
.body(ApiResponse.success(DailyChallengeSuccess.MODIFY_DAILY_CHALLENGE_STATUS_SUCCESS, new EmptyJsonResponse()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public DailyChallenge(Challenge challenge, Long goalTime) {
this.status = Status.NONE;
}

public void modifyDailyChallengeStatusFailure() {
this.status = Status.FAILURE;
public void modifyStatus(Status status) {
this.status = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sopt.org.HMH.domain.challenge.domain.Challenge;
import sopt.org.HMH.domain.challenge.repository.ChallengeRepository;
import sopt.org.HMH.domain.dailychallenge.domain.DailyChallenge;
import sopt.org.HMH.domain.dailychallenge.domain.Status;
import sopt.org.HMH.domain.dailychallenge.dto.response.DailyChallengeResponse;
import sopt.org.HMH.domain.dailychallenge.repository.DailyChallengeRepository;
import sopt.org.HMH.global.util.IdConverter;
Expand All @@ -34,17 +35,17 @@ public Long addDailyChallenge(Challenge challenge, Long goalTime, List<AppGoalTi
return dailyChallenge.getId();
}

public DailyChallengeResponse getDailyChallenge(Long userId, String os) {
public DailyChallengeResponse getDailyChallenge(Long userId) {
DailyChallenge dailyChallenge = IdConverter.getTodayDailyChallenge(challengeRepository,
dailyChallengeRepository, userId);

return DailyChallengeResponse.of(dailyChallenge);
}

@Transactional
public void modifyDailyChallengeStatus(Long userId, String os) {
public void modifyDailyChallengeStatus(Long userId) {
DailyChallenge dailyChallenge = IdConverter.getTodayDailyChallenge(challengeRepository,
dailyChallengeRepository, userId);
dailyChallenge.modifyDailyChallengeStatusFailure();
dailyChallenge.modifyStatus(Status.FAILURE);
}
}