Skip to content

Commit

Permalink
Merge pull request #22 from GDSC-snowflowerthon/feature/10
Browse files Browse the repository at this point in the history
[Feature] updateSubgoal의 에러메세지 출력 로직 구현
  • Loading branch information
soHyn authored Jan 12, 2024
2 parents 631f05d + 1c8161b commit da576bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tenten.blooming.domain.subgoal.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import tenten.blooming.domain.subgoal.dto.CompletedGoalInfoResponse;
Expand Down Expand Up @@ -33,9 +34,13 @@ public ResponseEntity<ResponseUpdateSubgoal> updateSubgoal(

responseUpdateSubgoal.setSubgoalName(findSubgoal.getSubgoalName());

List<LocalDate> doneDates = subgoalService.updateSubgoal(subgoalId);
responseUpdateSubgoal.setDoneDateList(doneDates);

try {
List<LocalDate> doneDates = subgoalService.updateSubgoal(subgoalId);
responseUpdateSubgoal.setDoneDateList(doneDates);
} catch (IllegalStateException e) {
responseUpdateSubgoal.setErrorMsg(e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(responseUpdateSubgoal);
}
return ResponseEntity.ok(responseUpdateSubgoal);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
public class ResponseUpdateSubgoal {
private List<LocalDate> doneDateList;
private String subgoalName;
private String errorMsg = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public List<LocalDate> addDoneDate(Long subgoalId) {
if(i > 0 && (Objects.equals(doneDates.get(i - 1), today))) {
throw new IllegalStateException("이미 체크된 TASK입니다.");
}
System.out.println(i);
switch (i + 1) {
case 1: {
findSubgoal.setDoneDate1(today);
Expand Down

0 comments on commit da576bf

Please sign in to comment.