From e640d97ec0634bacf434a4a568984e192824ec98 Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 15:35:45 +0900 Subject: [PATCH 01/12] =?UTF-8?q?pet=EA=B3=BC=20=EB=82=A0=EC=A7=9C?= =?UTF-8?q?=EB=A5=BC=20=ED=86=B5=ED=95=B4=20Remind=EB=A5=BC=20=EC=B0=BE?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reborn_15/_2_remind/repository/RemindRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/reborn/backend/reborn_15/_2_remind/repository/RemindRepository.java b/src/main/java/reborn/backend/reborn_15/_2_remind/repository/RemindRepository.java index eaf5f87..9ee423d 100644 --- a/src/main/java/reborn/backend/reborn_15/_2_remind/repository/RemindRepository.java +++ b/src/main/java/reborn/backend/reborn_15/_2_remind/repository/RemindRepository.java @@ -13,6 +13,8 @@ public interface RemindRepository extends JpaRepository, JpaSpecificationExecutor { Optional findTopByPetOrderByDateDesc(Pet pet); + Optional findByPetAndDate(Pet pet, Integer date); + List findAllByPetAndDateLessThanOrderByDateDesc(Pet pet, Integer date); } \ No newline at end of file From 300e8a896d429034ccc9a3febd5dd1d29f10da9b Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 15:40:37 +0900 Subject: [PATCH 02/12] =?UTF-8?q?pet=EA=B3=BC=20=EB=82=A0=EC=A7=9C?= =?UTF-8?q?=EB=A5=BC=20=ED=86=B5=ED=95=B4=20Reveal=EB=A5=BC=20=EC=B0=BE?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reborn_15/_3_reveal/repository/RevealRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/reborn/backend/reborn_15/_3_reveal/repository/RevealRepository.java b/src/main/java/reborn/backend/reborn_15/_3_reveal/repository/RevealRepository.java index 7706e0c..15c48e0 100644 --- a/src/main/java/reborn/backend/reborn_15/_3_reveal/repository/RevealRepository.java +++ b/src/main/java/reborn/backend/reborn_15/_3_reveal/repository/RevealRepository.java @@ -15,5 +15,7 @@ public interface RevealRepository extends JpaRepository, JpaSpecif List findAllByDate(Integer date); + Optional findByPetAndDate(Pet pet, Integer date); + List findAllByPetAndDateLessThanOrderByDateDesc(Pet pet, Integer date); } From 82277b53c931466ec2056ec27529696c0560c7ca Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 15:41:38 +0900 Subject: [PATCH 03/12] =?UTF-8?q?id=EB=A1=9C=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8D=98=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=EC=9D=84=20pet=EA=B3=BC=20date=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_2_remind/service/RemindService.java | 25 +++++++++-------- .../_3_reveal/service/RevealService.java | 28 +++++++++---------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/main/java/reborn/backend/reborn_15/_2_remind/service/RemindService.java b/src/main/java/reborn/backend/reborn_15/_2_remind/service/RemindService.java index d5b028c..5f66072 100644 --- a/src/main/java/reborn/backend/reborn_15/_2_remind/service/RemindService.java +++ b/src/main/java/reborn/backend/reborn_15/_2_remind/service/RemindService.java @@ -43,16 +43,16 @@ public List findAllByPetAndDateLessThanSortedByDate(Pet pet, Integer dat } @Transactional - public void introRemind(Long id) { - Remind remind = remindRepository.findById(id) + public void introRemind(Integer date, Pet pet) { + Remind remind = remindRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMIND_NOT_FOUND)); remind.getPet().setProgressState("PAT"); } @Transactional - public void patRemind(Long id) { - Remind remind = remindRepository.findById(id) + public void patRemind(Integer date, Pet pet) { + Remind remind = remindRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMIND_NOT_FOUND)); remind.setPat(true); @@ -63,8 +63,8 @@ public void patRemind(Long id) { } @Transactional - public void feedRemind(Long id) { - Remind remind = remindRepository.findById(id) + public void feedRemind(Integer date, Pet pet) { + Remind remind = remindRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMIND_NOT_FOUND)); remind.setFeed(true); @@ -75,8 +75,8 @@ public void feedRemind(Long id) { } @Transactional - public void walkRemind(Long id) { - Remind remind = remindRepository.findById(id) + public void walkRemind(Integer date, Pet pet) { + Remind remind = remindRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMIND_NOT_FOUND)); remind.setWalk(true); @@ -87,8 +87,8 @@ public void walkRemind(Long id) { } @Transactional - public void snackRemind(Long id) { - Remind remind = remindRepository.findById(id) + public void snackRemind(Integer date, Pet pet) { + Remind remind = remindRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMIND_NOT_FOUND)); remind.setSnack(true); @@ -99,14 +99,15 @@ public void snackRemind(Long id) { } @Transactional - public Remind writeRemind(Long id, RemindReqDto remindReqDto) { - Remind remind = remindRepository.findById(id) + public Remind writeRemind(Integer date, RemindReqDto remindReqDto, Pet pet) { + Remind remind = remindRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMIND_NOT_FOUND)); remind.setAnswer(remindReqDto.getAnswer()); remindRepository.save(remind); remind.getPet().setProgressState("FINISH"); + return remind; } diff --git a/src/main/java/reborn/backend/reborn_15/_3_reveal/service/RevealService.java b/src/main/java/reborn/backend/reborn_15/_3_reveal/service/RevealService.java index 23e151e..fe4ed17 100644 --- a/src/main/java/reborn/backend/reborn_15/_3_reveal/service/RevealService.java +++ b/src/main/java/reborn/backend/reborn_15/_3_reveal/service/RevealService.java @@ -46,16 +46,16 @@ public List findAllByPetAndDateLessThanSortedByDate(Pet pet, Integer dat } @Transactional - public void introReveal(Long id) { - Reveal reveal = revealRepository.findById(id) + public void introReveal(Integer date, Pet pet) { + Reveal reveal = revealRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REVEAL_NOT_FOUND)); reveal.getPet().setProgressState("PAT"); } @Transactional - public void patReveal(Long id) { - Reveal reveal = revealRepository.findById(id) + public void patReveal(Integer date, Pet pet) { + Reveal reveal = revealRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REVEAL_NOT_FOUND)); reveal.setPat(true); @@ -66,8 +66,8 @@ public void patReveal(Long id) { } @Transactional - public void feedReveal(Long id) { - Reveal reveal = revealRepository.findById(id) + public void feedReveal(Integer date, Pet pet) { + Reveal reveal = revealRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REVEAL_NOT_FOUND)); reveal.setFeed(true); @@ -78,8 +78,8 @@ public void feedReveal(Long id) { } @Transactional - public void walkReveal(Long id) { - Reveal reveal = revealRepository.findById(id) + public void walkReveal(Integer date, Pet pet) { + Reveal reveal = revealRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REVEAL_NOT_FOUND)); reveal.setWalk(true); @@ -90,8 +90,8 @@ public void walkReveal(Long id) { } @Transactional - public void snackReveal(Long id) { - Reveal reveal = revealRepository.findById(id) + public void snackReveal(Integer date, Pet pet) { + Reveal reveal = revealRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REVEAL_NOT_FOUND)); reveal.setSnack(true); @@ -102,8 +102,8 @@ public void snackReveal(Long id) { } @Transactional - public Reveal writeReveal(Long id, RevealReqDto revealReqDto) { - Reveal reveal = revealRepository.findById(id) + public Reveal writeReveal(Integer date, RevealReqDto revealReqDto, Pet pet) { + Reveal reveal = revealRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REVEAL_NOT_FOUND)); reveal.setDiaryContent(revealReqDto.getDiaryContent()); @@ -124,8 +124,8 @@ public Reveal findById(Long id) { } @Transactional - public Double calculateEmotionPercentage(Long id) { - Reveal reveal = revealRepository.findById(id) + public Double calculateEmotionPercentage(Integer date, Pet pet) { + Reveal reveal = revealRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REVEAL_NOT_FOUND)); List allRevealsByDate = revealRepository.findAllByDate(reveal.getDate()); From 9ae0258fb1386e55289e2678ea28e1a32a2c8aee Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 15:43:16 +0900 Subject: [PATCH 04/12] =?UTF-8?q?=ED=94=84=EB=A1=A0=ED=8A=B8=EC=97=90?= =?UTF-8?q?=EC=84=9C=20id=EB=A5=BC=20=EB=B0=9B=EC=95=84=EC=99=80=20?= =?UTF-8?q?=ED=8C=90=EB=B3=84=ED=95=98=EB=8D=98=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=BD=94=EB=93=9C=EB=A5=BC=20DB=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=9E=90=EC=B2=B4=EC=A0=81=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=ED=8C=90=EB=8B=A8=ED=95=98=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RemindController.java | 48 ++++++++++------- .../controller/RevealController.java | 53 ++++++++++++------- 2 files changed, 63 insertions(+), 38 deletions(-) diff --git a/src/main/java/reborn/backend/reborn_15/_2_remind/controller/RemindController.java b/src/main/java/reborn/backend/reborn_15/_2_remind/controller/RemindController.java index af13737..d0613a8 100644 --- a/src/main/java/reborn/backend/reborn_15/_2_remind/controller/RemindController.java +++ b/src/main/java/reborn/backend/reborn_15/_2_remind/controller/RemindController.java @@ -65,12 +65,14 @@ public ApiResponse getDetailRemind( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMIND_2003", description = "답변 작성이 완료되었습니다.") }) - @PostMapping("/write/{id}") + @PostMapping("/write") public ApiResponse write( - @PathVariable(name = "id") Long id, + @AuthenticationPrincipal CustomUserDetails customUserDetails, @RequestBody RemindReqDto remindReqDto ){ - remindService.writeRemind(id, remindReqDto); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + remindService.writeRemind(pet.getRebornDate(), remindReqDto, pet); return ApiResponse.onSuccess(SuccessCode.REMIND_WRITE_COMPLETED, true); } @@ -79,11 +81,13 @@ public ApiResponse write( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMIND_2004", description = "쓰다듬기가 완료되었습니다.") }) - @PostMapping("/pat/{id}") + @PostMapping("/pat") public ApiResponse pat( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - remindService.patRemind(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + remindService.patRemind(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMIND_PAT_COMPLETED, true); } @@ -92,11 +96,13 @@ public ApiResponse pat( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMIND_2005", description = "밥주기가 완료되었습니다.") }) - @PostMapping("/feed/{id}") + @PostMapping("/feed") public ApiResponse feed( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - remindService.feedRemind(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + remindService.feedRemind(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMIND_FEED_COMPLETED, true); } @@ -105,11 +111,13 @@ public ApiResponse feed( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMIND_2006", description = "산책하기가 완료되었습니다.") }) - @PostMapping("/walk/{id}") + @PostMapping("/walk") public ApiResponse walk( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - remindService.walkRemind(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + remindService.walkRemind(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMIND_WALK_COMPLETED, true); } @@ -118,11 +126,13 @@ public ApiResponse walk( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMIND_2007", description = "간식주기가 완료되었습니다.") }) - @PostMapping("/snack/{id}") + @PostMapping("/snack") public ApiResponse snack( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - remindService.snackRemind(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + remindService.snackRemind(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMIND_SNACK_COMPLETED, true); } @@ -131,11 +141,13 @@ public ApiResponse snack( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMIND_2008", description = "쓰다듬기로 넘어가기가 완료되었습니다.") }) - @PostMapping("/intro/{id}") + @PostMapping("/intro") public ApiResponse intro( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - remindService.introRemind(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + remindService.introRemind(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMIND_INTRO_COMPLETED, true); } diff --git a/src/main/java/reborn/backend/reborn_15/_3_reveal/controller/RevealController.java b/src/main/java/reborn/backend/reborn_15/_3_reveal/controller/RevealController.java index 7b8b0ef..acc1945 100644 --- a/src/main/java/reborn/backend/reborn_15/_3_reveal/controller/RevealController.java +++ b/src/main/java/reborn/backend/reborn_15/_3_reveal/controller/RevealController.java @@ -55,7 +55,8 @@ public ApiResponse create( }) @GetMapping("view/{id}") public ApiResponse getDetailReveal( - @PathVariable(name = "id") Long id + @PathVariable(name = "id") Long id, + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ Reveal reveal = revealService.findById(id); DetailRevealDto detailRevealDto = RevealConverter.toDetailRevealDto(reveal); @@ -67,14 +68,16 @@ public ApiResponse getDetailReveal( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REVEAL_2003", description = "일기 작성이 완료되었습니다.") }) - @PostMapping("/write/{id}") + @PostMapping("/write") public ApiResponse write( - @PathVariable(name = "id") Long id, + @AuthenticationPrincipal CustomUserDetails customUserDetails, @RequestBody RevealReqDto revealReqDto ){ - Reveal reveal = revealService.writeReveal(id, revealReqDto); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + Reveal reveal = revealService.writeReveal(pet.getRebornDate(), revealReqDto, pet); - double emotionPercentage = revealService.calculateEmotionPercentage(reveal.getId()); + double emotionPercentage = revealService.calculateEmotionPercentage(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REVEAL_WRITE_COMPLETED, emotionPercentage); } @@ -83,11 +86,13 @@ public ApiResponse write( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REVEAL_2004", description = "쓰다듬기가 완료되었습니다.") }) - @PostMapping("/pat/{id}") + @PostMapping("/pat") public ApiResponse pat( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - revealService.patReveal(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + revealService.patReveal(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REVEAL_PAT_COMPLETED, true); } @@ -96,11 +101,13 @@ public ApiResponse pat( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REVEAL_2005", description = "밥주기가 완료되었습니다.") }) - @PostMapping("/feed/{id}") + @PostMapping("/feed") public ApiResponse feed( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - revealService.feedReveal(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + revealService.feedReveal(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REVEAL_FEED_COMPLETED, true); } @@ -109,11 +116,13 @@ public ApiResponse feed( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REVEAL_2006", description = "산책하기가 완료되었습니다.") }) - @PostMapping("/walk/{id}") + @PostMapping("/walk") public ApiResponse walk( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - revealService.walkReveal(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + revealService.walkReveal(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REVEAL_WALK_COMPLETED, true); } @@ -122,11 +131,13 @@ public ApiResponse walk( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REVEAL_2007", description = "간식주기가 완료되었습니다.") }) - @PostMapping("/snack/{id}") + @PostMapping("/snack") public ApiResponse snack( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - revealService.snackReveal(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + revealService.snackReveal(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REVEAL_SNACK_COMPLETED, true); } @@ -135,11 +146,13 @@ public ApiResponse snack( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REVEAL_2008", description = "쓰다듬기로 넘어가기가 완료되었습니다.") }) - @PostMapping("/intro/{id}") + @PostMapping("/intro") public ApiResponse intro( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - revealService.introReveal(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + revealService.introReveal(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REVEAL_INTRO_COMPLETED, true); } From 0159b64539e19ade9d663724922da36aa3d27486 Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 16:00:33 +0900 Subject: [PATCH 05/12] =?UTF-8?q?=ED=94=84=EB=A1=A0=ED=8A=B8=EC=97=90?= =?UTF-8?q?=EC=84=9C=20id=EB=A5=BC=20=EB=B0=9B=EC=95=84=EC=99=80=20?= =?UTF-8?q?=ED=8C=90=EB=B3=84=ED=95=98=EB=8D=98=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=BD=94=EB=93=9C=EB=A5=BC=20DB=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=9E=90=EC=B2=B4=EC=A0=81=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=ED=8C=90=EB=8B=A8=ED=95=98=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RememberController.java | 58 ++++++++++++------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/src/main/java/reborn/backend/reborn_15/_4_remember/controller/RememberController.java b/src/main/java/reborn/backend/reborn_15/_4_remember/controller/RememberController.java index b6f3700..897246c 100644 --- a/src/main/java/reborn/backend/reborn_15/_4_remember/controller/RememberController.java +++ b/src/main/java/reborn/backend/reborn_15/_4_remember/controller/RememberController.java @@ -69,14 +69,16 @@ public ApiResponse getDetailRemember( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMEMBER_2003", description = "그림일기 작성이 완료되었습니다.") }) - @PostMapping(value = "/write/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @PostMapping(value = "/write", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ApiResponse write( + @AuthenticationPrincipal CustomUserDetails customUserDetails, @RequestPart(value = "remember") MultipartFile file, - @RequestPart("data") SimpleRememberReqDto simpleRememberReqDto, - @PathVariable(name = "id") Long id + @RequestPart("data") SimpleRememberReqDto simpleRememberReqDto ) throws IOException { + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); String dirName = "remember/"; - rememberService.writeRemember(id, simpleRememberReqDto, dirName, file); + rememberService.writeRemember(pet.getRebornDate(), simpleRememberReqDto, dirName, file, pet); return ApiResponse.onSuccess(SuccessCode.REMEMBER_WRITE_COMPLETED, true); } @@ -85,11 +87,13 @@ public ApiResponse write( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMEMBER_2004", description = "쓰다듬기가 완료되었습니다.") }) - @PostMapping("/pat/{id}") + @PostMapping("/pat") public ApiResponse pat( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rememberService.patRemember(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rememberService.patRemember(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMEMBER_PAT_COMPLETED, true); } @@ -98,11 +102,13 @@ public ApiResponse pat( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMEMBER_2005", description = "밥주기가 완료되었습니다.") }) - @PostMapping("/feed/{id}") + @PostMapping("/feed") public ApiResponse feed( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rememberService.feedRemember(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rememberService.feedRemember(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMEMBER_FEED_COMPLETED, true); } @@ -111,11 +117,13 @@ public ApiResponse feed( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMEMBER_2006", description = "산책하기가 완료되었습니다.") }) - @PostMapping("/walk/{id}") + @PostMapping("/walk") public ApiResponse walk( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rememberService.walkRemember(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rememberService.walkRemember(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMEMBER_WALK_COMPLETED, true); } @@ -124,11 +132,13 @@ public ApiResponse walk( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMEMBER_2007", description = "간식주기가 완료되었습니다.") }) - @PostMapping("/snack/{id}") + @PostMapping("/snack") public ApiResponse snack( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rememberService.snackRemember(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rememberService.snackRemember(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMEMBER_SNACK_COMPLETED, true); } @@ -137,11 +147,13 @@ public ApiResponse snack( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMEMBER_2008", description = "정리1가 완료되었습니다.") }) - @PostMapping("/clean/{id}") + @PostMapping("/clean") public ApiResponse clean( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rememberService.clean_Remember(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rememberService.clean_Remember(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMEMBER_CLEAN_COMPLETED, true); } @@ -150,11 +162,13 @@ public ApiResponse clean( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMEMBER_2009", description = "쓰다듬기로 넘어가기가 완료되었습니다.") }) - @PostMapping("/intro/{id}") + @PostMapping("/intro") public ApiResponse intro( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rememberService.introRemember(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rememberService.introRemember(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REMEMBER_INTRO_COMPLETED, true); } From 9da440e7268f4eb44d41fcbe5cf17eebf60ba6cd Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 16:03:31 +0900 Subject: [PATCH 06/12] =?UTF-8?q?pet=EA=B3=BC=20date=EB=A5=BC=20=ED=86=B5?= =?UTF-8?q?=ED=95=B4=20Remember=EB=A5=BC=20=EA=B2=80=EC=83=89=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reborn_15/_4_remember/repository/RememberRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/reborn/backend/reborn_15/_4_remember/repository/RememberRepository.java b/src/main/java/reborn/backend/reborn_15/_4_remember/repository/RememberRepository.java index 58c5de7..cb3957d 100644 --- a/src/main/java/reborn/backend/reborn_15/_4_remember/repository/RememberRepository.java +++ b/src/main/java/reborn/backend/reborn_15/_4_remember/repository/RememberRepository.java @@ -13,6 +13,8 @@ public interface RememberRepository extends JpaRepository, JpaSpecificationExecutor { Optional findTopByPetOrderByDateDesc(Pet pet); + Optional findByPetAndDate(Pet pet, Integer date); + List findAllByPetAndDateLessThanOrderByDateDesc(Pet pet, Integer date); } From ab4bb69cf520c363e2a4843d9a5b0eb540c7b65b Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 16:04:15 +0900 Subject: [PATCH 07/12] =?UTF-8?q?id=EB=A1=9C=20=EC=88=98=ED=96=89=ED=95=98?= =?UTF-8?q?=EB=8D=98=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=EC=9D=84=20pet=EA=B3=BC=20date=EB=A5=BC=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_4_remember/service/RememberService.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/reborn/backend/reborn_15/_4_remember/service/RememberService.java b/src/main/java/reborn/backend/reborn_15/_4_remember/service/RememberService.java index 33dff03..212f874 100644 --- a/src/main/java/reborn/backend/reborn_15/_4_remember/service/RememberService.java +++ b/src/main/java/reborn/backend/reborn_15/_4_remember/service/RememberService.java @@ -44,8 +44,8 @@ public Remember createRemember(Pet pet) { @Transactional - public void introRemember(Long id) { - Remember remember = rememberRepository.findById(id) + public void introRemember(Integer date, Pet pet) { + Remember remember = rememberRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMEMBER_NOT_FOUND)); remember.getPet().setProgressState("PAT"); @@ -58,8 +58,8 @@ public List findAllByPetAndDateLessThanSortedByDate(Pet pet, Integer d } @Transactional - public void patRemember(Long id) { - Remember remember = rememberRepository.findById(id) + public void patRemember(Integer date, Pet pet) { + Remember remember = rememberRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMEMBER_NOT_FOUND)); remember.setPat(true); @@ -70,8 +70,8 @@ public void patRemember(Long id) { } @Transactional - public void feedRemember(Long id) { - Remember remember = rememberRepository.findById(id) + public void feedRemember(Integer date, Pet pet) { + Remember remember = rememberRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMEMBER_NOT_FOUND)); remember.setFeed(true); @@ -82,8 +82,8 @@ public void feedRemember(Long id) { } @Transactional - public void walkRemember(Long id) { - Remember remember = rememberRepository.findById(id) + public void walkRemember(Integer date, Pet pet) { + Remember remember = rememberRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMEMBER_NOT_FOUND)); remember.setWalk(true); @@ -94,8 +94,8 @@ public void walkRemember(Long id) { } @Transactional - public void snackRemember(Long id) { - Remember remember = rememberRepository.findById(id) + public void snackRemember(Integer date, Pet pet) { + Remember remember = rememberRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMEMBER_NOT_FOUND)); remember.setSnack(true); @@ -106,8 +106,8 @@ public void snackRemember(Long id) { } @Transactional - public void clean_Remember(Long id) { - Remember remember = rememberRepository.findById(id) + public void clean_Remember(Integer date, Pet pet) { + Remember remember = rememberRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMEMBER_NOT_FOUND)); remember.setClean(true); @@ -118,8 +118,8 @@ public void clean_Remember(Long id) { } @Transactional - public void writeRemember(Long id, SimpleRememberReqDto simpleRememberReqDto, String dirName, MultipartFile file) throws IOException { - Remember remember = rememberRepository.findById(id) + public void writeRemember(Integer date, SimpleRememberReqDto simpleRememberReqDto, String dirName, MultipartFile file, Pet pet) throws IOException { + Remember remember = rememberRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMEMBER_NOT_FOUND)); String uploadFileUrl = null; From fff973ff5dd9986192117afdbf9e9f4949e836be Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 18:37:19 +0900 Subject: [PATCH 08/12] =?UTF-8?q?id=EB=A1=9C=20=EC=88=98=ED=96=89=ED=95=98?= =?UTF-8?q?=EB=8D=98=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=EC=9D=84=20pet=EA=B3=BC=20date=EB=A5=BC=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_5_reborn/service/RebornService.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/reborn/backend/reborn_15/_5_reborn/service/RebornService.java b/src/main/java/reborn/backend/reborn_15/_5_reborn/service/RebornService.java index 464ae03..0950e18 100644 --- a/src/main/java/reborn/backend/reborn_15/_5_reborn/service/RebornService.java +++ b/src/main/java/reborn/backend/reborn_15/_5_reborn/service/RebornService.java @@ -40,21 +40,21 @@ public Reborn createReborn(Pet pet) { } @Transactional - public void introReborn(Long id) { - Reborn reborn = rebornRepository.findById(id) - .orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND)); - - reborn.getPet().setProgressState("PAT"); + public List findAllByPetAndDateLessThanSortedByDate(Pet pet, Integer date) { + return rebornRepository.findAllByPetAndDateLessThanOrderByDateDesc(pet, date); } @Transactional - public List findAllByPetAndDateLessThanSortedByDate(Pet pet, Integer date) { - return rebornRepository.findAllByPetAndDateLessThanOrderByDateDesc(pet, date); + public void introReborn(Integer date, Pet pet) { + Reborn reborn = rebornRepository.findByPetAndDate(pet, date) + .orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND)); + + reborn.getPet().setProgressState("PAT"); } @Transactional - public void patReborn(Long id) { - Reborn reborn = rebornRepository.findById(id) + public void patReborn(Integer date, Pet pet) { + Reborn reborn = rebornRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND)); reborn.setPat(true); @@ -65,8 +65,8 @@ public void patReborn(Long id) { } @Transactional - public void feedReborn(Long id) { - Reborn reborn = rebornRepository.findById(id) + public void feedReborn(Integer date, Pet pet) { + Reborn reborn = rebornRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND)); reborn.setFeed(true); @@ -77,8 +77,8 @@ public void feedReborn(Long id) { } @Transactional - public void washReborn(Long id) { - Reborn reborn = rebornRepository.findById(id) + public void washReborn(Integer date, Pet pet) { + Reborn reborn = rebornRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND)); reborn.setWash(true); @@ -89,8 +89,8 @@ public void washReborn(Long id) { } @Transactional - public void clotheReborn(Long id) { - Reborn reborn = rebornRepository.findById(id) + public void clotheReborn(Integer date, Pet pet) { + Reborn reborn = rebornRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND)); reborn.setClothe(true); @@ -101,8 +101,8 @@ public void clotheReborn(Long id) { } @Transactional - public void writeReborn(Long id, ContentRebornReqDto rebornReqDto) { - Reborn reborn = rebornRepository.findById(id) + public void writeReborn(Integer date, ContentRebornReqDto rebornReqDto, Pet pet) { + Reborn reborn = rebornRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND)); reborn.setRebornContent(rebornReqDto.getRebornContent()); @@ -113,8 +113,8 @@ public void writeReborn(Long id, ContentRebornReqDto rebornReqDto) { } @Transactional - public void setReborn(Long id, RebornRebornReqDto rebornReqDto) { - Reborn reborn = rebornRepository.findById(id) + public void setReborn(Integer date, RebornRebornReqDto rebornReqDto, Pet pet) { + Reborn reborn = rebornRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REBORN_NOT_FOUND)); reborn.setRebornType(RebornType.valueOf(rebornReqDto.getRebornType())); From f899d84d4afd6ff837b3fc530af47bf03423f6f6 Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 18:37:41 +0900 Subject: [PATCH 09/12] =?UTF-8?q?pet=EA=B3=BC=20date=EB=A5=BC=20=ED=86=B5?= =?UTF-8?q?=ED=95=B4=20Reborn=EC=9D=84=20=EC=B0=BE=EC=9D=84=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reborn_15/_5_reborn/repository/RebornRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/reborn/backend/reborn_15/_5_reborn/repository/RebornRepository.java b/src/main/java/reborn/backend/reborn_15/_5_reborn/repository/RebornRepository.java index b72441f..1f5a28d 100644 --- a/src/main/java/reborn/backend/reborn_15/_5_reborn/repository/RebornRepository.java +++ b/src/main/java/reborn/backend/reborn_15/_5_reborn/repository/RebornRepository.java @@ -13,5 +13,7 @@ public interface RebornRepository extends JpaRepository, JpaSpecificationExecutor { Optional findTopByPetOrderByDateDesc(Pet pet); + Optional findByPetAndDate(Pet pet, Integer date); + List findAllByPetAndDateLessThanOrderByDateDesc(Pet pet, Integer date); } From 7ff6bbe0ecbe6ab062c56ebd90a243a5eae67808 Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 18:38:32 +0900 Subject: [PATCH 10/12] =?UTF-8?q?id=EB=A5=BC=20=ED=86=B5=ED=95=B4=20?= =?UTF-8?q?=EC=88=98=ED=96=89=ED=95=98=EB=8D=98=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EB=A1=9C=EC=A7=81=20DB=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EC=9E=90=EC=B2=B4=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=ED=95=98=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RebornController.java | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/src/main/java/reborn/backend/reborn_15/_5_reborn/controller/RebornController.java b/src/main/java/reborn/backend/reborn_15/_5_reborn/controller/RebornController.java index 14b915d..864e834 100644 --- a/src/main/java/reborn/backend/reborn_15/_5_reborn/controller/RebornController.java +++ b/src/main/java/reborn/backend/reborn_15/_5_reborn/controller/RebornController.java @@ -66,12 +66,14 @@ public ApiResponse getDetailReBORN( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2003", description = "작별인사 작성이 완료되었습니다.") }) - @PostMapping("/write/{id}") + @PostMapping("/write") public ApiResponse write( - @PathVariable(name = "id") Long id, + @AuthenticationPrincipal CustomUserDetails customUserDetails, @RequestBody ContentRebornReqDto rebornReqDto ){ - rebornService.writeReborn(id, rebornReqDto); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rebornService.writeReborn(pet.getRebornDate(), rebornReqDto, pet); return ApiResponse.onSuccess(SuccessCode.REBORN_WRITE_COMPLETED, true); } @@ -80,12 +82,14 @@ public ApiResponse write( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2009", description = "리본 선택이 완료되었습니다.") }) - @PostMapping("/set/{id}") + @PostMapping("/set") public ApiResponse setReborn( - @PathVariable(name = "id") Long id, + @AuthenticationPrincipal CustomUserDetails customUserDetails, @RequestBody RebornRebornReqDto rebornReqDto ){ - rebornService.setReborn(id, rebornReqDto); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rebornService.setReborn(pet.getRebornDate(), rebornReqDto, pet); return ApiResponse.onSuccess(SuccessCode.REBORN_SET_REBORN_COMPLETED, true); } @@ -94,11 +98,14 @@ public ApiResponse setReborn( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2004", description = "쓰다듬기가 완료되었습니다.") }) - @PostMapping("/pat/{id}") + @PostMapping("/pat") public ApiResponse pat( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rebornService.patReborn(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rebornService.patReborn(pet.getRebornDate(), pet); + return ApiResponse.onSuccess(SuccessCode.REBORN_PAT_COMPLETED, true); } @@ -106,11 +113,13 @@ public ApiResponse pat( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2005", description = "밥주기가 완료되었습니다.") }) - @PostMapping("/feed/{id}") + @PostMapping("/feed") public ApiResponse feed( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rebornService.feedReborn(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rebornService.feedReborn(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REBORN_FEED_COMPLETED, true); } @@ -119,11 +128,14 @@ public ApiResponse feed( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2006", description = "씻겨주기가 완료되었습니다.") }) - @PostMapping("/wash/{id}") + @PostMapping("/wash") public ApiResponse wash( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rebornService.washReborn(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rebornService.washReborn(pet.getRebornDate(), pet); + return ApiResponse.onSuccess(SuccessCode.REBORN_WASH_COMPLETED, true); } @@ -131,11 +143,14 @@ public ApiResponse wash( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2007", description = "옷 입혀주기가 완료되었습니다.") }) - @PostMapping("/clothe/{id}") + @PostMapping("/clothe") public ApiResponse clothe( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rebornService.clotheReborn(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rebornService.clotheReborn(pet.getRebornDate(), pet); + return ApiResponse.onSuccess(SuccessCode.REBORN_CLOTHE_COMPLETED, true); } @@ -143,7 +158,7 @@ public ApiResponse clothe( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2008", description = "15일 콘텐츠가 완료되었습니다.") }) - @PostMapping("finish/{id}") + @PostMapping("finish") public ApiResponse finish( @AuthenticationPrincipal CustomUserDetails customUserDetails ){ @@ -161,11 +176,13 @@ public ApiResponse finish( @ApiResponses(value = { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2010", description = "쓰다듬기로 넘어가기가 완료되었습니다.") }) - @PostMapping("/intro/{id}") + @PostMapping("/intro") public ApiResponse intro( - @PathVariable(name = "id") Long id + @AuthenticationPrincipal CustomUserDetails customUserDetails ){ - rebornService.introReborn(id); + User user = userService.findUserByUserName(customUserDetails.getUsername()); + Pet pet = petService.findById(user.getContentPetId()); + rebornService.introReborn(pet.getRebornDate(), pet); return ApiResponse.onSuccess(SuccessCode.REBORN_INTRO_COMPLETED, true); } From f14b4166046e9819ad1dff38275cac66800f82af Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 18:39:03 +0900 Subject: [PATCH 11/12] =?UTF-8?q?PET=EC=9D=98=20=EC=83=89=EA=B9=94=20YELLO?= =?UTF-8?q?W=20->=20YELLOWDARK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/reborn/backend/global/entity/PetColor.java | 2 +- src/main/java/reborn/backend/pet/dto/PetRequestDto.java | 2 +- src/main/java/reborn/backend/pet/dto/PetResponseDto.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/reborn/backend/global/entity/PetColor.java b/src/main/java/reborn/backend/global/entity/PetColor.java index f497d4f..5803f0e 100644 --- a/src/main/java/reborn/backend/global/entity/PetColor.java +++ b/src/main/java/reborn/backend/global/entity/PetColor.java @@ -3,7 +3,7 @@ public enum PetColor { BLACK, BROWN, - YELLOW, + YELLOWDARK, GRAY, WHITE } diff --git a/src/main/java/reborn/backend/pet/dto/PetRequestDto.java b/src/main/java/reborn/backend/pet/dto/PetRequestDto.java index 8be2d5a..c02df6b 100644 --- a/src/main/java/reborn/backend/pet/dto/PetRequestDto.java +++ b/src/main/java/reborn/backend/pet/dto/PetRequestDto.java @@ -31,7 +31,7 @@ public static class PetReqDto { @Schema(description = "반료동물 종") private String detailPetType; - @Schema(description = "반려동물 색깔(BLACK, BROWN, LIGHTBROWN, GRAY, WHITE") + @Schema(description = "반려동물 색깔(BLACK, BROWN, YELLOWDARK, GRAY, WHITE") private String petColor; } } \ No newline at end of file diff --git a/src/main/java/reborn/backend/pet/dto/PetResponseDto.java b/src/main/java/reborn/backend/pet/dto/PetResponseDto.java index d0ff5d7..709c4d9 100644 --- a/src/main/java/reborn/backend/pet/dto/PetResponseDto.java +++ b/src/main/java/reborn/backend/pet/dto/PetResponseDto.java @@ -56,7 +56,7 @@ public static class DetailPetDto{ @Schema(description = "반료동물 종") private String detailPetType; - @Schema(description = "반려동물 색깔(BLACK, BROWN, YELLOW, GRAY, WHITE") + @Schema(description = "반려동물 색깔(BLACK, BROWN, YELLOWDARK, GRAY, WHITE") private String petColor; } From 61ae9e0d41df1d1943d94640085b047e1e683972 Mon Sep 17 00:00:00 2001 From: KangMinJun Date: Thu, 9 May 2024 20:23:28 +0900 Subject: [PATCH 12/12] =?UTF-8?q?=EC=BB=A8=ED=85=90=EC=B8=A0=EB=A5=BC=20?= =?UTF-8?q?=EC=B2=98=EC=9D=8C=20=EB=A7=8C=EB=93=A4=20=EB=95=8C=20Date?= =?UTF-8?q?=EB=A5=BC=20=EB=84=98=EA=B2=A8=EC=A4=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_2_remind/controller/RemindController.java | 6 +++--- .../reborn_15/_2_remind/service/RemindService.java | 4 +--- .../_3_reveal/controller/RevealController.java | 11 +++++------ .../_4_remember/controller/RememberController.java | 6 +++--- .../_5_reborn/controller/RebornController.java | 6 +++--- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/reborn/backend/reborn_15/_2_remind/controller/RemindController.java b/src/main/java/reborn/backend/reborn_15/_2_remind/controller/RemindController.java index d0613a8..1dcad89 100644 --- a/src/main/java/reborn/backend/reborn_15/_2_remind/controller/RemindController.java +++ b/src/main/java/reborn/backend/reborn_15/_2_remind/controller/RemindController.java @@ -34,17 +34,17 @@ public class RemindController { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMIND_2011", description = "충분한 대화 나누기 생성이 완료되었습니다.") }) @PostMapping("/create") - public ApiResponse create( + public ApiResponse create( @AuthenticationPrincipal CustomUserDetails customUserDetails ){ User user = userService.findUserByUserName(customUserDetails.getUsername()); Pet pet = petService.findById(user.getContentPetId()); - remindService.createRemind(pet); + Remind remind = remindService.createRemind(pet); petService.updateDate(user.getContentPetId()); - return ApiResponse.onSuccess(SuccessCode.REMIND_CREATED, true); + return ApiResponse.onSuccess(SuccessCode.REMIND_CREATED, remind.getDate()); } @Operation(summary = "특정 충분한 대화 나누기 조회 메서드", description = "특정 충분한 대화 나누기를 조회하는 메서드입니다.") diff --git a/src/main/java/reborn/backend/reborn_15/_2_remind/service/RemindService.java b/src/main/java/reborn/backend/reborn_15/_2_remind/service/RemindService.java index 5f66072..3e7bc3e 100644 --- a/src/main/java/reborn/backend/reborn_15/_2_remind/service/RemindService.java +++ b/src/main/java/reborn/backend/reborn_15/_2_remind/service/RemindService.java @@ -99,7 +99,7 @@ public void snackRemind(Integer date, Pet pet) { } @Transactional - public Remind writeRemind(Integer date, RemindReqDto remindReqDto, Pet pet) { + public void writeRemind(Integer date, RemindReqDto remindReqDto, Pet pet) { Remind remind = remindRepository.findByPetAndDate(pet, date) .orElseThrow(() -> GeneralException.of(ErrorCode.REMIND_NOT_FOUND)); remind.setAnswer(remindReqDto.getAnswer()); @@ -107,8 +107,6 @@ public Remind writeRemind(Integer date, RemindReqDto remindReqDto, Pet pet) { remindRepository.save(remind); remind.getPet().setProgressState("FINISH"); - - return remind; } @Transactional diff --git a/src/main/java/reborn/backend/reborn_15/_3_reveal/controller/RevealController.java b/src/main/java/reborn/backend/reborn_15/_3_reveal/controller/RevealController.java index acc1945..4c3f397 100644 --- a/src/main/java/reborn/backend/reborn_15/_3_reveal/controller/RevealController.java +++ b/src/main/java/reborn/backend/reborn_15/_3_reveal/controller/RevealController.java @@ -36,17 +36,17 @@ public class RevealController { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REVEAL_2011", description = "나의 감정 들여다보기 생성이 완료되었습니다.") }) @PostMapping("/create") - public ApiResponse create( + public ApiResponse create( @AuthenticationPrincipal CustomUserDetails customUserDetails ){ User user = userService.findUserByUserName(customUserDetails.getUsername()); Pet pet = petService.findById(user.getContentPetId()); - revealService.createReveal(pet); + Reveal reveal = revealService.createReveal(pet); petService.updateDate(user.getContentPetId()); - return ApiResponse.onSuccess(SuccessCode.REVEAL_CREATED, true); + return ApiResponse.onSuccess(SuccessCode.REVEAL_CREATED, reveal.getDate()); } @Operation(summary = "특정 나의 감정 들여다보기 조회 메서드", description = "특정 나의 감정 들여다보기를 조회하는 메서드입니다.") @@ -55,8 +55,7 @@ public ApiResponse create( }) @GetMapping("view/{id}") public ApiResponse getDetailReveal( - @PathVariable(name = "id") Long id, - @AuthenticationPrincipal CustomUserDetails customUserDetails + @PathVariable(name = "id") Long id ){ Reveal reveal = revealService.findById(id); DetailRevealDto detailRevealDto = RevealConverter.toDetailRevealDto(reveal); @@ -75,7 +74,7 @@ public ApiResponse write( ){ User user = userService.findUserByUserName(customUserDetails.getUsername()); Pet pet = petService.findById(user.getContentPetId()); - Reveal reveal = revealService.writeReveal(pet.getRebornDate(), revealReqDto, pet); + revealService.writeReveal(pet.getRebornDate(), revealReqDto, pet); double emotionPercentage = revealService.calculateEmotionPercentage(pet.getRebornDate(), pet); diff --git a/src/main/java/reborn/backend/reborn_15/_4_remember/controller/RememberController.java b/src/main/java/reborn/backend/reborn_15/_4_remember/controller/RememberController.java index 897246c..d6e38ae 100644 --- a/src/main/java/reborn/backend/reborn_15/_4_remember/controller/RememberController.java +++ b/src/main/java/reborn/backend/reborn_15/_4_remember/controller/RememberController.java @@ -38,17 +38,17 @@ public class RememberController { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REMEMBER_2011", description = "건강한 작별 준비하기 생성이 완료되었습니다.") }) @PostMapping("/create") - public ApiResponse create( + public ApiResponse create( @AuthenticationPrincipal CustomUserDetails customUserDetails ){ User user = userService.findUserByUserName(customUserDetails.getUsername()); Pet pet = petService.findById(user.getContentPetId()); - rememberService.createRemember(pet); + Remember remember = rememberService.createRemember(pet); petService.updateDate(user.getContentPetId()); - return ApiResponse.onSuccess(SuccessCode.REMEMBER_CREATED, true); + return ApiResponse.onSuccess(SuccessCode.REMEMBER_CREATED, remember.getDate()); } @Operation(summary = "특정 건강한 작별 준비하기 조회 메서드", description = "특정 건강한 작별 준비하기를 조회하는 메서드입니다.") diff --git a/src/main/java/reborn/backend/reborn_15/_5_reborn/controller/RebornController.java b/src/main/java/reborn/backend/reborn_15/_5_reborn/controller/RebornController.java index 864e834..09fea4d 100644 --- a/src/main/java/reborn/backend/reborn_15/_5_reborn/controller/RebornController.java +++ b/src/main/java/reborn/backend/reborn_15/_5_reborn/controller/RebornController.java @@ -35,17 +35,17 @@ public class RebornController { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "REBORN_2011", description = "건강한 작별하기 생성이 완료되었습니다.") }) @PostMapping("/create") - public ApiResponse create( + public ApiResponse create( @AuthenticationPrincipal CustomUserDetails customUserDetails ){ User user = userService.findUserByUserName(customUserDetails.getUsername()); Pet pet = petService.findById(user.getContentPetId()); - rebornService.createReborn(pet); + Reborn reborn = rebornService.createReborn(pet); petService.updateDate(user.getContentPetId()); - return ApiResponse.onSuccess(SuccessCode.REBORN_CREATED, true); + return ApiResponse.onSuccess(SuccessCode.REBORN_CREATED, reborn.getDate()); } @Operation(summary = "특정 건강한 작별하기 조회 메서드", description = "특정 건강한 작별하기를 조회하는 메서드입니다.")