From 632e63619565fcdd99dba99f96b519e6208798a6 Mon Sep 17 00:00:00 2001 From: JuyeonLee <104489022+Juye0nLee@users.noreply.github.com> Date: Sat, 7 Dec 2024 00:20:33 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=EB=A7=A4=EC=B9=AD=EB=90=9C=20?= =?UTF-8?q?=EB=8F=8C=EB=B4=84=20=EC=B4=88=EA=B8=B0=ED=99=94=20api=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C=20(#58)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ๐Ÿ› ์‹ ์ฒญ ๋ชฉ๋ก ๋ฐ˜ํ™˜ ์‹œ ์‹ ์ฒญ ๊ธฐ๋ณธํ‚ค ๋ฐ˜ํ™˜ (#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 --- .../ivory/controller/CaregiverController.java | 7 ++++++- .../ivory/ivory/repository/ApplyRepository.java | 1 + .../ivory/ivory/service/CaregiverService.java | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ivory/ivory/controller/CaregiverController.java b/src/main/java/com/ivory/ivory/controller/CaregiverController.java index de7e60d..c887b46 100644 --- a/src/main/java/com/ivory/ivory/controller/CaregiverController.java +++ b/src/main/java/com/ivory/ivory/controller/CaregiverController.java @@ -43,5 +43,10 @@ public ResponseEntity getMatchedCare() { return ResponseEntity.ok(response); } - + @PutMapping() + public ResponseEntity init() { + Long currentMemberId = securityUtil.getCurrentMemberId(); + CustomApiResponse response = caregiverService.init(currentMemberId); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/ivory/ivory/repository/ApplyRepository.java b/src/main/java/com/ivory/ivory/repository/ApplyRepository.java index 54f8338..1958a8d 100644 --- a/src/main/java/com/ivory/ivory/repository/ApplyRepository.java +++ b/src/main/java/com/ivory/ivory/repository/ApplyRepository.java @@ -14,5 +14,6 @@ public interface ApplyRepository extends JpaRepository { Optional findById (Long applyId); Apply findFirstByChild_IdOrderByCreateAt(Long childID); Optional findFirstByStatusOrderByCreateAtDesc(Status status); + List findAllByStatus(Status status); } diff --git a/src/main/java/com/ivory/ivory/service/CaregiverService.java b/src/main/java/com/ivory/ivory/service/CaregiverService.java index 6e715b7..ecc514d 100644 --- a/src/main/java/com/ivory/ivory/service/CaregiverService.java +++ b/src/main/java/com/ivory/ivory/service/CaregiverService.java @@ -170,4 +170,21 @@ public CustomApiResponse getMatchedCare(Long currentMemberId) { CareDto careDto = CareDto.of(applyId,careDate,careTime,childName,age,image); return CustomApiResponse.createSuccess(HttpStatus.OK.value(), "๋งค์นญ๋œ ๋Œ๋ด„ ํ™œ๋™์ด ์กฐํšŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.",careDto); } + + + public CustomApiResponse init(Long currentMemberId) { +// Optional caregiver = caregiverRepository.findById(currentMemberId); +// if (caregiver.isEmpty()) { +// throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"๋Œ๋ณด๋ฏธ๋งŒ ์ดˆ๊ธฐํ™”๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค."); +// } + //Status๊ฐ€ MATCHED์ธ ๊ฒƒ๋“ค์„ ๋ชจ๋‘ YET์œผ๋กœ ๋ฐ”๊ฟ”์ฃผ๊ธฐ + List applies = applyRepository.findAllByStatus(Status.MATCHED); + applies.forEach((apply) -> { + apply.setStatus(Status.YET); //์ƒํƒœ ๋ณ€๊ฒฝ + }); + + //์ƒํƒœ ๋ณ€๊ฒฝ ๋‚ด์šฉ DB ์ €์žฅ + applyRepository.saveAll(applies); + return CustomApiResponse.createSuccess(HttpStatus.OK.value(),"์ƒํƒœ๊ฐ€ ์ดˆ๊ธฐํ™” ๋˜์—ˆ์Šต๋‹ˆ๋‹ค",null); + } }