Skip to content

Commit 85c76e7

Browse files
Juye0nLeeGiHwan2
andauthored
✨ 매칭된 돌봄 초기화 api 개발 (#58) (#59)
* 🐛 신청 목록 반환 시 신청 기본키 반환 (#35) (#36) * 🐛 신청 api 응답으로 applyId 반환 (#39) * 🐛 신청 목록 반환 시 신청 기본키 반환 (#35) * 🐛 신청 api 응답으로 applyId 반환 (#38) * 🐛 신청 목록 반환 시 신청 기본키 반환 (#35) (#36) * ✨ 신청 API applyId 반환 * 🐛 신청 세부 조회 로직 수정 (#42) * 🐛 신청 목록 반환 시 신청 기본키 반환 (#35) * 🐛 신청 api 응답으로 applyId 반환 (#38) * 🐛 신청 목록 반환 시 신청 기본키 반환 (#35) (#36) * ✨ 신청 API applyId 반환 * 🐛 신청 조회 로직 수정 (#41) * 🐛 신청 목록 반환 시 신청 기본키 반환 (#35) (#36) * 🐛 신청 api 응답으로 applyId 반환 (#39) * 🐛 신청 목록 반환 시 신청 기본키 반환 (#35) * 🐛 신청 api 응답으로 applyId 반환 (#38) * 🐛 신청 목록 반환 시 신청 기본키 반환 (#35) (#36) * ✨ 신청 API applyId 반환 * 🐛 신청 세부 조회 오류 수정 * 🚀 Cd 파이프라인 수정 * chore: CD 파이프라인 수정 * 🎨 카카오페이 approval_url 배포 도메인으로 수정 (#44) * 🎨 카카오페이 approval_url 배포 도메인으로 수정 * 🐛 신청 - 서류 연관관계 수정 * ✨ 매칭된 돌봄 초기화 api 구현 --------- Co-authored-by: GiHwan2 <[email protected]>
1 parent 9d4922e commit 85c76e7

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/main/java/com/ivory/ivory/controller/CaregiverController.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,10 @@ public ResponseEntity<?> getMatchedCare() {
4343
return ResponseEntity.ok(response);
4444
}
4545

46-
46+
@PutMapping()
47+
public ResponseEntity<?> init() {
48+
Long currentMemberId = securityUtil.getCurrentMemberId();
49+
CustomApiResponse<?> response = caregiverService.init(currentMemberId);
50+
return ResponseEntity.ok(response);
51+
}
4752
}

src/main/java/com/ivory/ivory/repository/ApplyRepository.java

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ public interface ApplyRepository extends JpaRepository<Apply, Long> {
1414
Optional<Apply> findById (Long applyId);
1515
Apply findFirstByChild_IdOrderByCreateAt(Long childID);
1616
Optional<Apply> findFirstByStatusOrderByCreateAtDesc(Status status);
17+
List<Apply> findAllByStatus(Status status);
1718

1819
}

src/main/java/com/ivory/ivory/service/CaregiverService.java

+17
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,21 @@ public CustomApiResponse<?> getMatchedCare(Long currentMemberId) {
170170
CareDto careDto = CareDto.of(applyId,careDate,careTime,childName,age,image);
171171
return CustomApiResponse.createSuccess(HttpStatus.OK.value(), "매칭된 돌봄 활동이 조회 되었습니다.",careDto);
172172
}
173+
174+
175+
public CustomApiResponse<?> init(Long currentMemberId) {
176+
// Optional<Caregiver> caregiver = caregiverRepository.findById(currentMemberId);
177+
// if (caregiver.isEmpty()) {
178+
// throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"돌보미만 초기화가 가능합니다.");
179+
// }
180+
//Status가 MATCHED인 것들을 모두 YET으로 바꿔주기
181+
List<Apply> applies = applyRepository.findAllByStatus(Status.MATCHED);
182+
applies.forEach((apply) -> {
183+
apply.setStatus(Status.YET); //상태 변경
184+
});
185+
186+
//상태 변경 내용 DB 저장
187+
applyRepository.saveAll(applies);
188+
return CustomApiResponse.createSuccess(HttpStatus.OK.value(),"상태가 초기화 되었습니다",null);
189+
}
173190
}

0 commit comments

Comments
 (0)