From 5eb2f945ec61f0e99d0f76ee3e114766c1e27640 Mon Sep 17 00:00:00 2001 From: Juser0 Date: Wed, 22 Nov 2023 22:42:31 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[Fix]=20ResponseStatus=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=82=AD=EC=A0=9C=20-=20#67?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../anniversary/AnniversaryController.java | 6 ------ .../favor/favor/friend/FriendController.java | 8 -------- .../com/favor/favor/gift/GiftController.java | 7 ------- .../favor/favor/photo/PhotoController.java | 2 -- .../favor/reminder/ReminderController.java | 11 ----------- .../com/favor/favor/user/UserController.java | 19 ------------------- .../favor/favor/user/UserPhotoController.java | 6 ------ 7 files changed, 59 deletions(-) diff --git a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryController.java b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryController.java index 78a0151..d3c94c4 100644 --- a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryController.java +++ b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryController.java @@ -37,7 +37,6 @@ public class AnniversaryController { @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping public ResponseEntity> createAnniversary( @RequestBody AnniversaryRequestDto anniversaryRequestDto, @@ -66,7 +65,6 @@ public ResponseEntity> createAnniversary( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/{anniversaryNo}") public ResponseEntity> readAnniversary( @PathVariable Long anniversaryNo){ @@ -91,7 +89,6 @@ public ResponseEntity> readAnniversary( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping("/{anniversaryNo}") public ResponseEntity> updateAnniversary( @RequestBody AnniversaryUpdateRequestDto anniversaryUpdateRequestDto, @@ -119,7 +116,6 @@ public ResponseEntity> updateAnniversary( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping("/pin/{anniversaryNo}") public ResponseEntity> updateIsPinned( @PathVariable Long anniversaryNo){ @@ -146,7 +142,6 @@ public ResponseEntity> updateIsPinned( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @DeleteMapping("/{anniversaryNo}") public ResponseEntity> deleteAnniversary( @PathVariable Long anniversaryNo){ @@ -171,7 +166,6 @@ public ResponseEntity> deleteAnniversary( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/admin") public ResponseEntity> readAll(){ diff --git a/favor/src/main/java/com/favor/favor/friend/FriendController.java b/favor/src/main/java/com/favor/favor/friend/FriendController.java index 13f2279..6023721 100644 --- a/favor/src/main/java/com/favor/favor/friend/FriendController.java +++ b/favor/src/main/java/com/favor/favor/friend/FriendController.java @@ -40,7 +40,6 @@ public class FriendController { @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping public ResponseEntity> addFriend( @RequestBody FriendRequestDto friendRequestDto, @@ -70,7 +69,6 @@ public ResponseEntity> addFriend( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/{friendNo}") public ResponseEntity> readFriend( @PathVariable Long friendNo){ @@ -96,7 +94,6 @@ public ResponseEntity> readFriend( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping("/{friendNo}") public ResponseEntity> updateFriend( @PathVariable Long friendNo, @@ -126,7 +123,6 @@ public ResponseEntity> updateFriend( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @DeleteMapping("/{friendNo}") public ResponseEntity> deleteFriend( @PathVariable Long friendNo){ @@ -151,7 +147,6 @@ public ResponseEntity> deleteFriend( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/admin") public ResponseEntity> readAll(){ @@ -171,7 +166,6 @@ public ResponseEntity> readAll(){ @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/total-gifts/{friendNo}") public ResponseEntity> readTotalGiftList( @PathVariable Long friendNo){ @@ -192,7 +186,6 @@ public ResponseEntity> readTotalGiftList( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/given-gifts/{friendNo}") public ResponseEntity> readGivenGiftList( @PathVariable Long friendNo){ // 유저 입장에서 받은 선물이므로 관련 친구가 준 선물임 @@ -213,7 +206,6 @@ public ResponseEntity> readGivenGiftList( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/received-gifts/{friendNo}") public ResponseEntity> readReceivedGiftList( @PathVariable Long friendNo){// 유저 입장에서 준 선물이므로 관련 친구가 받은 선물임 diff --git a/favor/src/main/java/com/favor/favor/gift/GiftController.java b/favor/src/main/java/com/favor/favor/gift/GiftController.java index be1afed..c232256 100644 --- a/favor/src/main/java/com/favor/favor/gift/GiftController.java +++ b/favor/src/main/java/com/favor/favor/gift/GiftController.java @@ -38,7 +38,6 @@ public class GiftController { @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping public ResponseEntity> createGift( @RequestBody GiftRequestDto giftRequestDto, @@ -70,7 +69,6 @@ public ResponseEntity> createGift( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/{giftNo}") public ResponseEntity> readGift( @PathVariable Long giftNo){ @@ -97,7 +95,6 @@ public ResponseEntity> readGift( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping("/{giftNo}") public ResponseEntity> updateGift( @RequestBody GiftUpdateRequestDto giftUpdateRequestDto, @@ -126,7 +123,6 @@ public ResponseEntity> updateGift( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping("/temp-friend-list/{giftNo}") public ResponseEntity> updateTempFriendListGift( @PathVariable Long giftNo, @@ -156,7 +152,6 @@ public ResponseEntity> updateTempFriendListGift( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping("/pin/{giftNo}") public ResponseEntity> updateIsPinned( @PathVariable Long giftNo){ @@ -184,7 +179,6 @@ public ResponseEntity> updateIsPinned( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @DeleteMapping("/{giftNo}") public ResponseEntity> deleteGift( @PathVariable Long giftNo){ @@ -216,7 +210,6 @@ public ResponseEntity> deleteGift( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/admin") public ResponseEntity> readAll(){ diff --git a/favor/src/main/java/com/favor/favor/photo/PhotoController.java b/favor/src/main/java/com/favor/favor/photo/PhotoController.java index 03bab9c..883bdc3 100644 --- a/favor/src/main/java/com/favor/favor/photo/PhotoController.java +++ b/favor/src/main/java/com/favor/favor/photo/PhotoController.java @@ -31,7 +31,6 @@ public class PhotoController { @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PostMapping public ResponseEntity> savePhoto( @ModelAttribute MultipartFile photo){ @@ -58,7 +57,6 @@ public ResponseEntity> savePhoto( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @DeleteMapping public ResponseEntity> deletePhoto( String filename){ diff --git a/favor/src/main/java/com/favor/favor/reminder/ReminderController.java b/favor/src/main/java/com/favor/favor/reminder/ReminderController.java index 78ceb05..bb5ba56 100644 --- a/favor/src/main/java/com/favor/favor/reminder/ReminderController.java +++ b/favor/src/main/java/com/favor/favor/reminder/ReminderController.java @@ -39,7 +39,6 @@ public class ReminderController { @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping("/new") public ResponseEntity> createReminder( @RequestBody ReminderRequestDto reminderRequestDto, @@ -75,7 +74,6 @@ public ResponseEntity> createReminder( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping("/{anniversaryNo}") public ResponseEntity> addReminder( @AuthenticationPrincipal User loginUser, @@ -105,7 +103,6 @@ public ResponseEntity> addReminder( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/{reminderNo}") public ResponseEntity> readReminder( @PathVariable Long reminderNo){ @@ -116,11 +113,6 @@ public ResponseEntity> readReminder( return ResponseEntity.status(200) .body(resWithData("REMINDER_FOUND", "리마인더 조회 완료", dto)); -// .body(DefaultResponseDto.builder() -// .responseCode("REMINDER_FOUND") -// .responseMessage("리마인더 조회 완료") -// .data(dto) -// .build()); } @ApiOperation("리마인더 수정") @@ -135,7 +127,6 @@ public ResponseEntity> readReminder( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping("/{reminderNo}") public ResponseEntity> updateReminder( @RequestBody ReminderUpdateRequestDto reminderUpdateRequestDto, @@ -163,7 +154,6 @@ public ResponseEntity> updateReminder( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @DeleteMapping("/{reminderNo}") public ResponseEntity> deleteReminder( @PathVariable Long reminderNo){ @@ -189,7 +179,6 @@ public ResponseEntity> deleteReminder( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/admin") public ResponseEntity> readAll(){ diff --git a/favor/src/main/java/com/favor/favor/user/UserController.java b/favor/src/main/java/com/favor/favor/user/UserController.java index c8f5103..fb71cc9 100644 --- a/favor/src/main/java/com/favor/favor/user/UserController.java +++ b/favor/src/main/java/com/favor/favor/user/UserController.java @@ -45,7 +45,6 @@ public class UserController { @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping("/sign-up") public ResponseEntity> signUp( @RequestBody @Valid SignDto signDto @@ -75,7 +74,6 @@ public ResponseEntity> signUp( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PatchMapping("/profile") public ResponseEntity> createProfile( @RequestBody @Valid ProfileDto profileDto, @@ -107,7 +105,6 @@ public ResponseEntity> createProfile( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping("/sign-in") public ResponseEntity> signIn( @RequestBody @Valid SignDto signDto @@ -132,7 +129,6 @@ public ResponseEntity> signIn( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping public ResponseEntity> readUser( @AuthenticationPrincipal User loginUser @@ -160,7 +156,6 @@ public ResponseEntity> readUser( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping public ResponseEntity> updateUser( @AuthenticationPrincipal User loginUser, @@ -188,7 +183,6 @@ public ResponseEntity> updateUser( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @DeleteMapping public ResponseEntity> deleteUser( @AuthenticationPrincipal User loginUser){ @@ -218,7 +212,6 @@ public ResponseEntity> deleteUser( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @PatchMapping("/password") public ResponseEntity> updatePassword( @RequestBody @Valid UserUpdatePasswordRequestDto passwordDto){ @@ -244,7 +237,6 @@ public ResponseEntity> updatePassword( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/reminders") public ResponseEntity> readReminderList( @AuthenticationPrincipal User loginUser){ @@ -270,7 +262,6 @@ public ResponseEntity> readReminderList( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/reminders/{year}/{month}") public ResponseEntity> readReminderListByFMonthAndYear( @AuthenticationPrincipal User loginUser, @@ -299,7 +290,6 @@ public ResponseEntity> readReminderListByFMonthAndYea @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/gifts") public ResponseEntity> readGiftList( @AuthenticationPrincipal User loginUser){ @@ -326,7 +316,6 @@ public ResponseEntity> readGiftList( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/friends") public ResponseEntity> readFriendList( @AuthenticationPrincipal User loginUser){ @@ -353,7 +342,6 @@ public ResponseEntity> readFriendList( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/anniversaries") public ResponseEntity> readAnniversaryList( @AuthenticationPrincipal User loginUser){ @@ -379,7 +367,6 @@ public ResponseEntity> readAnniversaryList( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/admin") public ResponseEntity> readAll(){ @@ -402,7 +389,6 @@ public ResponseEntity> readAll(){ @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/gifts-by-name/{giftName}") public ResponseEntity> readGiftListByName ( @AuthenticationPrincipal User loginUser, @@ -430,7 +416,6 @@ public ResponseEntity> readGiftListByName ( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/gifts-by-category/{category}") public ResponseEntity> readGiftListByCategory( @AuthenticationPrincipal User loginUser, @@ -457,7 +442,6 @@ public ResponseEntity> readGiftListByCategory( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/gifts-by-emotion/{emotion}") public ResponseEntity> readGiftListByEmotion( @AuthenticationPrincipal User loginUser, @@ -484,7 +468,6 @@ public ResponseEntity> readGiftListByEmotion( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/{userId}") public ResponseEntity> readUserByUserId( @PathVariable("userId") String userId){ @@ -506,7 +489,6 @@ public ResponseEntity> readUserByUserId( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/gifts-given") public ResponseEntity> readGivenGiftList( @AuthenticationPrincipal User loginUser){ @@ -529,7 +511,6 @@ public ResponseEntity> readGivenGiftList( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/gifts-received") public ResponseEntity> readReceivedGiftList( @AuthenticationPrincipal User loginUser){ diff --git a/favor/src/main/java/com/favor/favor/user/UserPhotoController.java b/favor/src/main/java/com/favor/favor/user/UserPhotoController.java index c298e57..ea3e768 100644 --- a/favor/src/main/java/com/favor/favor/user/UserPhotoController.java +++ b/favor/src/main/java/com/favor/favor/user/UserPhotoController.java @@ -37,7 +37,6 @@ public class UserPhotoController { @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping("/profile") public ResponseEntity> updateUserProfilePhoto( @ModelAttribute MultipartFile file, @@ -65,7 +64,6 @@ public ResponseEntity> updateUserProfilePhoto( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/profile") public ResponseEntity> getUserProfilePhoto( @AuthenticationPrincipal User loginUser @@ -88,7 +86,6 @@ public ResponseEntity> getUserProfilePhoto( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @DeleteMapping("/profile") public ResponseEntity> deleteUserProfilePhoto(@AuthenticationPrincipal User loginUser) { @@ -115,7 +112,6 @@ public ResponseEntity> deleteUserProfilePhoto(@Authen @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.CREATED) @PostMapping("/background") public ResponseEntity> updateUserBackgroundPhoto( @ModelAttribute MultipartFile file, @@ -143,7 +139,6 @@ public ResponseEntity> updateUserBackgroundPhoto( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @GetMapping("/background") public ResponseEntity> getUserBackgroundPhoto( @AuthenticationPrincipal User loginUser @@ -166,7 +161,6 @@ public ResponseEntity> getUserBackgroundPhoto( @ApiResponse(code = 500, message = "SERVER_ERROR") }) - @ResponseStatus(HttpStatus.OK) @DeleteMapping("/background") public ResponseEntity> deleteUserBackgroundPhoto( @AuthenticationPrincipal User loginUser From 968d79eea735df31b1c403e55da880ae7af8511d Mon Sep 17 00:00:00 2001 From: Juser0 Date: Fri, 24 Nov 2023 15:17:54 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Refactor]=20Anniversary=20Entity=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=84=B0=EB=A7=81=20-=20#67?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../favor/favor/anniversary/Anniversary.java | 16 ++-- .../anniversary/AnniversaryController.java | 47 +++------ .../anniversary/AnniversaryRequestDto.java | 1 - .../anniversary/AnniversaryResponseDto.java | 33 ++++--- .../favor/anniversary/AnniversaryService.java | 96 ++++++++++++------- .../AnniversaryUpdateRequestDto.java | 1 - .../favor/common/DefaultResponseDto.java | 4 +- .../favor/favor/friend/FriendController.java | 21 ++-- .../com/favor/favor/friend/FriendService.java | 2 +- .../com/favor/favor/gift/GiftController.java | 19 ++-- .../favor/favor/gift/GiftPhotoController.java | 11 +-- .../favor/reminder/ReminderController.java | 18 ++-- .../com/favor/favor/user/UserController.java | 43 ++++----- .../favor/favor/user/UserPhotoController.java | 13 ++- 14 files changed, 166 insertions(+), 159 deletions(-) diff --git a/favor/src/main/java/com/favor/favor/anniversary/Anniversary.java b/favor/src/main/java/com/favor/favor/anniversary/Anniversary.java index 5a77673..a1964eb 100644 --- a/favor/src/main/java/com/favor/favor/anniversary/Anniversary.java +++ b/favor/src/main/java/com/favor/favor/anniversary/Anniversary.java @@ -19,23 +19,27 @@ public class Anniversary extends TimeStamped { private Long anniversaryNo; private String anniversaryTitle; - public void setAnniversaryTitle(String anniversaryTitle){ this.anniversaryTitle = anniversaryTitle; } private LocalDate anniversaryDate; - public void setAnniversaryDate(LocalDate anniversaryDate){ this.anniversaryDate = anniversaryDate; } private Integer category; - public void setCategory(AnniversaryCategory anniversaryCategory){ - this.category = anniversaryCategory.getType(); - } private Boolean isPinned; - public void setIsPinned(Boolean isPinned){ this.isPinned = isPinned; } @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER) @JoinColumn(name = "user_user_no") private User user; + public void updateAnniversaryTitle(String anniversaryTitle){ this.anniversaryTitle = anniversaryTitle; } + + public void updateAnniversaryDate(LocalDate anniversaryDate){ this.anniversaryDate = anniversaryDate; } + + public void updateCategory(AnniversaryCategory anniversaryCategory){ + this.category = anniversaryCategory.getType(); + } + + public void updateIsPinned(Boolean isPinned){ this.isPinned = isPinned; } + @Builder public Anniversary(String anniversaryTitle, LocalDate anniversaryDate, Integer category, Boolean isPinned, User user) { this.anniversaryTitle = anniversaryTitle; diff --git a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryController.java b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryController.java index d3c94c4..c260ab3 100644 --- a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryController.java +++ b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryController.java @@ -14,9 +14,6 @@ import java.util.List; -import static com.favor.favor.common.DefaultResponseDto.resWithData; -import static com.favor.favor.common.DefaultResponseDto.resWithoutData; - @Api(tags = "Anniversary") @RestController @RequestMapping("/anniversaries") @@ -44,13 +41,10 @@ public ResponseEntity> createAnniversary( Long userNo = loginUser.getUserNo(); - anniversaryService.isExistingUserNo(userNo); - - Anniversary anniversary = anniversaryService.createAnniversary(anniversaryRequestDto, userNo); - AnniversaryResponseDto dto = anniversaryService.returnDto(anniversary); + AnniversaryResponseDto anniversaryResponseDto = anniversaryService.createAnniversary(userNo, anniversaryRequestDto); - return ResponseEntity.status(201) - .body(resWithData("ANIVERSARY_CREATED", "기념일 생성 완료", dto)); + return ResponseEntity.status(HttpStatus.CREATED) + .body(DefaultResponseDto.from("ANNIVERSARY_CREATED", "기념일 생성 완료", anniversaryResponseDto)); } @ApiOperation("기념일 조회") @@ -69,12 +63,9 @@ public ResponseEntity> createAnniversary( public ResponseEntity> readAnniversary( @PathVariable Long anniversaryNo){ - anniversaryService.isExistingAnniversaryNo(anniversaryNo); - Anniversary anniversary = anniversaryService.findAnniversaryByAnniversaryNo(anniversaryNo); - AnniversaryResponseDto dto = anniversaryService.returnDto(anniversary); + AnniversaryResponseDto anniversaryResponseDto = anniversaryService.readAnniversary(anniversaryNo); - return ResponseEntity.status(200) - .body(resWithData("ANNIVERSARY_FOUND", "기념일 조회 완료", dto)); + return ResponseEntity.ok(DefaultResponseDto.from("ANNIVERSARY_FOUND", "기념일 조회 완료", anniversaryResponseDto)); } @ApiOperation("기념일 수정") @@ -94,14 +85,9 @@ public ResponseEntity> updateAnniversary( @RequestBody AnniversaryUpdateRequestDto anniversaryUpdateRequestDto, @PathVariable Long anniversaryNo){ - anniversaryService.isExistingAnniversaryNo(anniversaryNo); - - Anniversary anniversary = anniversaryService.findAnniversaryByAnniversaryNo(anniversaryNo); - anniversaryService.updateAnniversary(anniversaryUpdateRequestDto, anniversary); - AnniversaryResponseDto dto = anniversaryService.returnDto(anniversary); + AnniversaryResponseDto anniversaryResponseDto = anniversaryService.updateAnniversary(anniversaryNo, anniversaryUpdateRequestDto); - return ResponseEntity.status(200) - .body(resWithData("ANNIVERSARY_UPDATED", "기념일 수정 완료", dto)); + return ResponseEntity.ok(DefaultResponseDto.from("ANNIVERSARY_UPDATED", "기념일 수정 완료", anniversaryResponseDto)); } @ApiOperation("기념일 핀 여부 수정") @@ -120,14 +106,9 @@ public ResponseEntity> updateAnniversary( public ResponseEntity> updateIsPinned( @PathVariable Long anniversaryNo){ - anniversaryService.isExistingAnniversaryNo(anniversaryNo); + AnniversaryResponseDto anniversaryResponseDto = anniversaryService.updateIsPinned(anniversaryNo); - Anniversary anniversary = anniversaryService.findAnniversaryByAnniversaryNo(anniversaryNo); - anniversaryService.updateIsPinned(anniversary); - AnniversaryResponseDto dto = anniversaryService.returnDto(anniversary); - - return ResponseEntity.status(200) - .body(resWithData("ANNIVERSARY_PIN_UPDATED", "기념일 핀 수정 완료", dto)); + return ResponseEntity.ok(DefaultResponseDto.from("ANNIVERSARY_PIN_UPDATED", "기념일 핀 수정 완료", anniversaryResponseDto)); } @ApiOperation("기념일 삭제") @@ -146,14 +127,9 @@ public ResponseEntity> updateIsPinned( public ResponseEntity> deleteAnniversary( @PathVariable Long anniversaryNo){ - anniversaryService.isExistingAnniversaryNo(anniversaryNo); - - Anniversary anniversary = anniversaryService.findAnniversaryByAnniversaryNo(anniversaryNo); - anniversaryService.deleteAnniversary(anniversaryNo); - return ResponseEntity.status(200) - .body(resWithoutData("ANNIVERSARY_DELETED", "기념일_삭제_완료")); + return ResponseEntity.ok(DefaultResponseDto.from("ANNIVERSARY_DELETED", "기념일_삭제_완료")); } @ApiOperation("전체 기념일 조회") @@ -171,7 +147,6 @@ public ResponseEntity> readAll(){ List dto = anniversaryService.readAll(); - return ResponseEntity.status(200) - .body(resWithData("ANIVERSARIES_FOUND", "전체 기념일 조회 완료", dto)); + return ResponseEntity.ok(DefaultResponseDto.from("ANNIVERSARIES_FOUND", "전체 기념일 조회 완료", dto)); } } diff --git a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryRequestDto.java b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryRequestDto.java index 2cb5e9d..295bad8 100644 --- a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryRequestDto.java +++ b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryRequestDto.java @@ -12,7 +12,6 @@ @Getter @NoArgsConstructor -@AllArgsConstructor public class AnniversaryRequestDto { @ApiModelProperty(position = 1, required = true, value = "제목", example = "제목") private String anniversaryTitle; diff --git a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryResponseDto.java b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryResponseDto.java index 55ca4aa..5467e58 100644 --- a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryResponseDto.java +++ b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryResponseDto.java @@ -1,7 +1,6 @@ package com.favor.favor.anniversary; import com.favor.favor.common.enums.AnniversaryCategory; -import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -9,7 +8,6 @@ import java.time.LocalDateTime; @Getter -@AllArgsConstructor public class AnniversaryResponseDto { private Long anniversaryNo; private String anniversaryTitle; @@ -21,14 +19,27 @@ public class AnniversaryResponseDto { private AnniversaryCategory anniversaryCategory; @Builder - public AnniversaryResponseDto(Anniversary anniversary){ - this.anniversaryNo = anniversary.getAnniversaryNo(); - this.anniversaryTitle = anniversary.getAnniversaryTitle(); - this.anniversaryDate = anniversary.getAnniversaryDate(); - this.isPinned = anniversary.getIsPinned(); - this.userNo = anniversary.getUser().getUserNo(); - this.createdAt = anniversary.getCreatedAt(); - this.modifiedAt = anniversary.getModifiedAt(); - this.anniversaryCategory = AnniversaryCategory.valueOf(anniversary.getCategory()); + private AnniversaryResponseDto(Long anniversaryNo, String anniversaryTitle, LocalDate anniversaryDate, Boolean isPinned, Long userNo, LocalDateTime createdAt, LocalDateTime modifiedAt, AnniversaryCategory anniversaryCategory) { + this.anniversaryNo = anniversaryNo; + this.anniversaryTitle = anniversaryTitle; + this.anniversaryDate = anniversaryDate; + this.isPinned = isPinned; + this.userNo = userNo; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + this.anniversaryCategory = anniversaryCategory; + } + + public static AnniversaryResponseDto from(Anniversary anniversary) { + return AnniversaryResponseDto.builder() + .anniversaryNo(anniversary.getAnniversaryNo()) + .anniversaryTitle(anniversary.getAnniversaryTitle()) + .anniversaryDate(anniversary.getAnniversaryDate()) + .isPinned(anniversary.getIsPinned()) + .userNo(anniversary.getUser().getUserNo()) + .createdAt(anniversary.getCreatedAt()) + .modifiedAt(anniversary.getModifiedAt()) + .anniversaryCategory(AnniversaryCategory.valueOf(anniversary.getCategory())) + .build(); } } diff --git a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryService.java b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryService.java index 0771768..1366399 100644 --- a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryService.java +++ b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryService.java @@ -12,6 +12,7 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import static com.favor.favor.exception.ExceptionCode.*; @@ -25,52 +26,80 @@ public class AnniversaryService { private final FriendRepository friendRepository; @Transactional - public Anniversary createAnniversary(AnniversaryRequestDto anniversaryRequestDto, Long userNo){ + public AnniversaryResponseDto createAnniversary(Long userNo, AnniversaryRequestDto anniversaryRequestDto){ + isExistingUserNo(userNo); User user = findUserByUserNo(userNo); - Anniversary anniversary = anniversaryRepository.save(anniversaryRequestDto.toEntity(anniversaryRequestDto.getAnniversaryTitle(), user)); - return anniversaryRepository.save(anniversary); + + Anniversary anniversary = anniversaryRequestDto.toEntity(anniversaryRequestDto.getAnniversaryTitle(), user); + anniversaryRepository.save(anniversary); + + return AnniversaryResponseDto.from(anniversary); + } + + public AnniversaryResponseDto readAnniversary(Long anniversaryNo) { + isExistingAnniversaryNo(anniversaryNo); + Anniversary anniversary = findAnniversaryByAnniversaryNo(anniversaryNo); + + return AnniversaryResponseDto.from(anniversary); } @Transactional - public void updateAnniversary(AnniversaryUpdateRequestDto dto, Anniversary anniversary){ - anniversary.setAnniversaryTitle(dto.getAnniversaryTitle()); - anniversary.setAnniversaryDate(LocalDate.parse(dto.getAnniversaryDate())); - anniversary.setCategory(dto.getAnniversaryCategory()); + public AnniversaryResponseDto updateAnniversary(Long anniversaryNo, AnniversaryUpdateRequestDto anniversaryUpdateRequestDto){ + isExistingAnniversaryNo(anniversaryNo); + Anniversary anniversary = findAnniversaryByAnniversaryNo(anniversaryNo); + + anniversary.updateAnniversaryTitle(anniversaryUpdateRequestDto.getAnniversaryTitle()); + anniversary.updateAnniversaryDate(LocalDate.parse(anniversaryUpdateRequestDto.getAnniversaryDate())); + anniversary.updateCategory(anniversaryUpdateRequestDto.getAnniversaryCategory()); anniversaryRepository.save(anniversary); + + return AnniversaryResponseDto.from(anniversary); } @Transactional - public void updateIsPinned(Anniversary anniversary){ - anniversary.setIsPinned(anniversary.getIsPinned() == true ? false : true); + public AnniversaryResponseDto updateIsPinned(Long anniversaryNo){ + isExistingAnniversaryNo(anniversaryNo); + Anniversary anniversary = findAnniversaryByAnniversaryNo(anniversaryNo); + + anniversary.updateIsPinned(anniversary.getIsPinned() == true ? false : true); anniversaryRepository.save(anniversary); + + return AnniversaryResponseDto.from(anniversary); } +// @Transactional +// public void deleteAnniversary(Long anniversaryNo){ +// List friendList = findAnniversaryByAnniversaryNo(anniversaryNo).getUser().getFriendList(); +// for(Friend friend : friendList){ +// if(friend.getAnniversaryNoList().contains(anniversaryNo)){ +// friend.getAnniversaryNoList().remove(anniversaryNo); +// friendRepository.save(friend); +// } +// } +// +// anniversaryRepository.deleteByAnniversaryNo(anniversaryNo); +// } + @Transactional public void deleteAnniversary(Long anniversaryNo){ - List friendList = findAnniversaryByAnniversaryNo(anniversaryNo).getUser().getFriendList(); - for(Friend friend : friendList){ - if(friend.getAnniversaryNoList().contains(anniversaryNo)){ - friend.getAnniversaryNoList().remove(anniversaryNo); - friendRepository.save(friend); - } - } + List updateRequiredFriends = findAnniversaryByAnniversaryNo(anniversaryNo).getUser().getFriendList().stream() + .filter(friend -> friend.getAnniversaryNoList().contains(anniversaryNo)) + .peek(friend -> friend.getAnniversaryNoList().remove(anniversaryNo)) + .collect(Collectors.toList()); + friendRepository.saveAll(updateRequiredFriends); anniversaryRepository.deleteByAnniversaryNo(anniversaryNo); } public List readAll(){ - List a_List = new ArrayList<>(); - for(Anniversary a : anniversaryRepository.findAll()){ - AnniversaryResponseDto dto = new AnniversaryResponseDto(a); - a_List.add(dto); - } - return a_List; + return anniversaryRepository.findAll().stream() + .map(AnniversaryResponseDto::from) + .collect(Collectors.toList()); } - - public User findUserByUserNo(Long userNo){ - User user = null; + private User findUserByUserNo(Long userNo){ + User user; try{ user = userRepository.findByUserNo(userNo).orElseThrow( () -> new RuntimeException() @@ -80,8 +109,9 @@ public User findUserByUserNo(Long userNo){ } return user; } - public Anniversary findAnniversaryByAnniversaryNo(Long anniversaryNo){ - Anniversary anniversary = null; + + private Anniversary findAnniversaryByAnniversaryNo(Long anniversaryNo){ + Anniversary anniversary; try{ anniversary = anniversaryRepository.findAnniversaryByAnniversaryNo(anniversaryNo).orElseThrow( () -> new RuntimeException() @@ -93,12 +123,8 @@ public Anniversary findAnniversaryByAnniversaryNo(Long anniversaryNo){ } - public AnniversaryResponseDto returnDto(Anniversary anniversary){ - return new AnniversaryResponseDto(anniversary); - } - - public void isExistingAnniversaryNo(Long anniversaryNo){ - Boolean isExistingNo = null; + private void isExistingAnniversaryNo(Long anniversaryNo){ + Boolean isExistingNo; try{ isExistingNo = anniversaryRepository.existsByAnniversaryNo(anniversaryNo); }catch(RuntimeException e){ @@ -109,8 +135,8 @@ public void isExistingAnniversaryNo(Long anniversaryNo){ } } - public void isExistingUserNo (Long userNo){ - Boolean isExistingNo = null; + private void isExistingUserNo (Long userNo){ + Boolean isExistingNo; try{ isExistingNo = userRepository.existsByUserNo(userNo); } catch(RuntimeException e){ diff --git a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryUpdateRequestDto.java b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryUpdateRequestDto.java index 66eb64f..09bd568 100644 --- a/favor/src/main/java/com/favor/favor/anniversary/AnniversaryUpdateRequestDto.java +++ b/favor/src/main/java/com/favor/favor/anniversary/AnniversaryUpdateRequestDto.java @@ -9,7 +9,6 @@ @Getter @NoArgsConstructor -@AllArgsConstructor public class AnniversaryUpdateRequestDto { @ApiModelProperty(position = 1, required = true, value = "제목", example = "제목") diff --git a/favor/src/main/java/com/favor/favor/common/DefaultResponseDto.java b/favor/src/main/java/com/favor/favor/common/DefaultResponseDto.java index c61d0ee..781a7f5 100644 --- a/favor/src/main/java/com/favor/favor/common/DefaultResponseDto.java +++ b/favor/src/main/java/com/favor/favor/common/DefaultResponseDto.java @@ -23,14 +23,14 @@ private DefaultResponseDto(String responseCode, String responseMessage, T data){ this.data = data; } - public static DefaultResponseDto resWithoutData(final String responseCode, final String responseMessage){ + public static DefaultResponseDto from(String responseCode, String responseMessage){ return DefaultResponseDto.builder() .responseCode(responseCode) .responseMessage(responseMessage) .build(); } - public static DefaultResponseDto resWithData(final String responseCode, final String responseMessage, final T data){ + public static DefaultResponseDto from(String responseCode, String responseMessage, T data){ return DefaultResponseDto.builder() .responseCode(responseCode) .responseMessage(responseMessage) diff --git a/favor/src/main/java/com/favor/favor/friend/FriendController.java b/favor/src/main/java/com/favor/favor/friend/FriendController.java index 6023721..5cd335d 100644 --- a/favor/src/main/java/com/favor/favor/friend/FriendController.java +++ b/favor/src/main/java/com/favor/favor/friend/FriendController.java @@ -10,15 +10,14 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; import java.util.List; -import static com.favor.favor.common.DefaultResponseDto.resWithData; -import static com.favor.favor.common.DefaultResponseDto.resWithoutData; +import static com.favor.favor.common.DefaultResponseDto.from; +import static com.favor.favor.common.DefaultResponseDto.from; @Api(tags = "Friend") @@ -54,7 +53,7 @@ public ResponseEntity> addFriend( FriendResponseDto dto = friendService.returnDto(friend); return ResponseEntity.status(201) - .body(resWithData("FRIEND_ADDED", "친구 추가 완료", dto)); + .body(DefaultResponseDto.from("FRIEND_ADDED", "친구 추가 완료", dto)); } @ApiOperation("친구 조회") @@ -79,7 +78,7 @@ public ResponseEntity> readFriend( FriendResponseDto dto = friendService.returnDto(friend); return ResponseEntity.status(200) - .body(resWithData("FRIEND_FOUND", "친구 조회 완료", dto)); + .body(DefaultResponseDto.from("FRIEND_FOUND", "친구 조회 완료", dto)); } @ApiOperation("친구 메모 수정") @@ -108,7 +107,7 @@ public ResponseEntity> updateFriend( FriendResponseDto dto = friendService.returnDto(friend); return ResponseEntity.status(200) - .body(resWithData("FRIEND_MEMO_UPDATED", "친구 메모 수정 완료", dto)); + .body(DefaultResponseDto.from("FRIEND_MEMO_UPDATED", "친구 메모 수정 완료", dto)); } @ApiOperation("친구 삭제") @@ -134,7 +133,7 @@ public ResponseEntity> deleteFriend( friendService.deleteFriend(friendNo); return ResponseEntity.status(200) - .body(resWithoutData("FRIEND_DELETED", "친구 삭제 완료")); + .body(from("FRIEND_DELETED", "친구 삭제 완료")); } @ApiOperation("전체 친구 조회") @@ -153,7 +152,7 @@ public ResponseEntity> readAll(){ List dto = friendService.readAll(); return ResponseEntity.status(200) - .body(resWithData("FRIENDS_FOUND", "전체 친구 조회 완료", dto)); + .body(DefaultResponseDto.from("FRIENDS_FOUND", "전체 친구 조회 완료", dto)); } @ApiOperation("친구의 선물 전체 조회") @@ -173,7 +172,7 @@ public ResponseEntity> readTotalGiftList( List dto = friendService.findGiftListByFriendNo(friendNo); return ResponseEntity.status(200) - .body(resWithData("GIFTS_FOUND", "친구의 선물 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFTS_FOUND", "친구의 선물 전체 조회 완료", dto)); } @ApiOperation("친구가 준 선물 전체 조회") @@ -193,7 +192,7 @@ public ResponseEntity> readGivenGiftList( List dto = friendService.findReceivedGiftList(friendNo); return ResponseEntity.status(200) - .body(resWithData("GIFTS_FOUND", "친구가 준 선물 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFTS_FOUND", "친구가 준 선물 전체 조회 완료", dto)); } @ApiOperation("친구가 받은 선물 전체 조회") @@ -213,6 +212,6 @@ public ResponseEntity> readReceivedGiftList( List dto = friendService.findGivenGiftList(friendNo); return ResponseEntity.status(200) - .body(resWithData("GIFTS_FOUND", "친구가 받은 선물 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFTS_FOUND", "친구가 받은 선물 전체 조회 완료", dto)); } } diff --git a/favor/src/main/java/com/favor/favor/friend/FriendService.java b/favor/src/main/java/com/favor/favor/friend/FriendService.java index 29190d0..d1f67c3 100644 --- a/favor/src/main/java/com/favor/favor/friend/FriendService.java +++ b/favor/src/main/java/com/favor/favor/friend/FriendService.java @@ -186,7 +186,7 @@ public FriendResponseDto returnDto(Friend friend){ } List anniversaryList = new ArrayList<>(); for(Anniversary a : friendUser.getAnniversaryList()){ - anniversaryList.add(new AnniversaryResponseDto(a)); + anniversaryList.add(AnniversaryResponseDto.from(a)); } HashMap giftInfo = returnGiftInfo(friend.getFriendNo()); diff --git a/favor/src/main/java/com/favor/favor/gift/GiftController.java b/favor/src/main/java/com/favor/favor/gift/GiftController.java index c232256..766fac2 100644 --- a/favor/src/main/java/com/favor/favor/gift/GiftController.java +++ b/favor/src/main/java/com/favor/favor/gift/GiftController.java @@ -8,15 +8,14 @@ import io.swagger.annotations.ApiResponses; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; import java.util.List; -import static com.favor.favor.common.DefaultResponseDto.resWithData; -import static com.favor.favor.common.DefaultResponseDto.resWithoutData; +import static com.favor.favor.common.DefaultResponseDto.from; +import static com.favor.favor.common.DefaultResponseDto.from; @Api(tags = "Gift") @RestController @@ -54,7 +53,7 @@ public ResponseEntity> createGift( GiftResponseDto dto = giftService.returnDto(gift); return ResponseEntity.status(201) - .body(resWithData("GIFT_CREATED", "선물 생성 완료", dto)); + .body(DefaultResponseDto.from("GIFT_CREATED", "선물 생성 완료", dto)); } @ApiOperation("선물 조회") @@ -80,7 +79,7 @@ public ResponseEntity> readGift( log.info("[Controller] [readGift] DTO 반환"); return ResponseEntity.status(200) - .body(resWithData("GIFT_FOUND", "선물 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFT_FOUND", "선물 조회 완료", dto)); } @ApiOperation("선물 수정") @@ -108,7 +107,7 @@ public ResponseEntity> updateGift( GiftResponseDto dto = giftService.returnDto(gift); return ResponseEntity.status(200) - .body(resWithData("GIFT_UPDATED", "선물 수정 완료", dto)); + .body(DefaultResponseDto.from("GIFT_UPDATED", "선물 수정 완료", dto)); } @ApiOperation("선물 임시친구목록 수정") @@ -137,7 +136,7 @@ public ResponseEntity> updateTempFriendListGift( GiftResponseDto dto = giftService.returnDto(gift); return ResponseEntity.status(200) - .body(resWithData("GIFT_TEMP_FRIEND_LIST_UPDATED", "선물 임시친구목록 수정 완료", dto)); + .body(DefaultResponseDto.from("GIFT_TEMP_FRIEND_LIST_UPDATED", "선물 임시친구목록 수정 완료", dto)); } @ApiOperation("선물 핀 여부 수정") @@ -164,7 +163,7 @@ public ResponseEntity> updateIsPinned( GiftResponseDto dto = giftService.returnDto(gift); return ResponseEntity.status(200) - .body(resWithData("GIFT_PIN_UPDATED", "선물 핀 여부 수정 완료", dto)); + .body(DefaultResponseDto.from("GIFT_PIN_UPDATED", "선물 핀 여부 수정 완료", dto)); } @ApiOperation("선물 삭제") @@ -197,7 +196,7 @@ public ResponseEntity> deleteGift( log.info("[SYSTEM] giftService.deleteGift(giftNo) 완료"); return ResponseEntity.status(200) - .body(resWithoutData("GIFT_DELETED", "선물 삭제 완료")); + .body(from("GIFT_DELETED", "선물 삭제 완료")); } @ApiOperation("전체 선물 조회") @@ -216,7 +215,7 @@ public ResponseEntity> readAll(){ List dto = giftService.readAll(); return ResponseEntity.status(200) - .body(resWithData("GIFTS_FOUND", "전체 선물 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFTS_FOUND", "전체 선물 조회 완료", dto)); } } diff --git a/favor/src/main/java/com/favor/favor/gift/GiftPhotoController.java b/favor/src/main/java/com/favor/favor/gift/GiftPhotoController.java index 2f483ec..ca733cd 100644 --- a/favor/src/main/java/com/favor/favor/gift/GiftPhotoController.java +++ b/favor/src/main/java/com/favor/favor/gift/GiftPhotoController.java @@ -13,11 +13,10 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import javax.transaction.Transactional; import java.util.List; -import static com.favor.favor.common.DefaultResponseDto.resWithData; -import static com.favor.favor.common.DefaultResponseDto.resWithoutData; +import static com.favor.favor.common.DefaultResponseDto.from; +import static com.favor.favor.common.DefaultResponseDto.from; @Api(tags = "Gift-Photo") @RestController @@ -54,7 +53,7 @@ public ResponseEntity> addGiftPhotoList( List dto = giftPhotoService.getGiftPhotoList(giftNo); return ResponseEntity.status(201) - .body(resWithData("GIFT_PHOTO_LIST_ADDED", "선물 사진 추가", dto)); + .body(DefaultResponseDto.from("GIFT_PHOTO_LIST_ADDED", "선물 사진 추가", dto)); } @ApiOperation("선물 사진 목록 조회") @@ -77,7 +76,7 @@ public ResponseEntity> getUserProfilePhoto(Long giftN List dto = giftPhotoService.getGiftPhotoList(giftNo); return ResponseEntity.status(200) - .body(resWithData("GIFT_PHOTO_LIST_FOUND", "선물 사진 목록 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFT_PHOTO_LIST_FOUND", "선물 사진 목록 조회 완료", dto)); } @ApiOperation("선물 사진 삭제") @@ -100,6 +99,6 @@ public ResponseEntity> deleteUserProfilePhoto( giftPhotoService.deleteGiftPhoto(giftNo, fileUrl); return ResponseEntity.status(200) - .body(resWithoutData("GIFT_PHOTO_DELETED", "선물 사진 삭제 완료")); + .body(from("GIFT_PHOTO_DELETED", "선물 사진 삭제 완료")); } } diff --git a/favor/src/main/java/com/favor/favor/reminder/ReminderController.java b/favor/src/main/java/com/favor/favor/reminder/ReminderController.java index bb5ba56..12c1aff 100644 --- a/favor/src/main/java/com/favor/favor/reminder/ReminderController.java +++ b/favor/src/main/java/com/favor/favor/reminder/ReminderController.java @@ -8,16 +8,14 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import lombok.RequiredArgsConstructor; -import lombok.extern.log4j.Log4j2; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; import java.util.List; -import static com.favor.favor.common.DefaultResponseDto.resWithData; -import static com.favor.favor.common.DefaultResponseDto.resWithoutData; +import static com.favor.favor.common.DefaultResponseDto.from; +import static com.favor.favor.common.DefaultResponseDto.from; @Api(tags = "Reminder") @RestController @@ -59,7 +57,7 @@ public ResponseEntity> createReminder( ReminderResponseDto dto = reminderService.returnDto(reminder); return ResponseEntity.status(201) - .body(resWithData("REMINDER_CREATED", "리마인더 생성 완료", dto)); + .body(DefaultResponseDto.from("REMINDER_CREATED", "리마인더 생성 완료", dto)); } @ApiOperation("친구의 기념일을 리마인더로 추가") @@ -88,7 +86,7 @@ public ResponseEntity> addReminder( ReminderResponseDto dto = reminderService.returnDto(reminder); return ResponseEntity.status(201) - .body(resWithData("REMINDER_ADDED", "리마인더 추가 완료", dto)); + .body(DefaultResponseDto.from("REMINDER_ADDED", "리마인더 추가 완료", dto)); } @ApiOperation("리마인더 조회") @@ -112,7 +110,7 @@ public ResponseEntity> readReminder( ReminderResponseDto dto = reminderService.returnDto(reminder); return ResponseEntity.status(200) - .body(resWithData("REMINDER_FOUND", "리마인더 조회 완료", dto)); + .body(DefaultResponseDto.from("REMINDER_FOUND", "리마인더 조회 완료", dto)); } @ApiOperation("리마인더 수정") @@ -139,7 +137,7 @@ public ResponseEntity> updateReminder( ReminderResponseDto dto = reminderService.returnDto(reminder); return ResponseEntity.status(200) - .body(resWithData("REMINDER_UPDATED", "리마인더 수정 완료", dto)); + .body(DefaultResponseDto.from("REMINDER_UPDATED", "리마인더 수정 완료", dto)); } @ApiOperation("리마인더 삭제") @@ -166,7 +164,7 @@ public ResponseEntity> deleteReminder( reminderService.deleteReminder(reminderNo); return ResponseEntity.status(200) - .body(resWithoutData("REMINDER_DELETED", "리마인더 삭제 완료")); + .body(from("REMINDER_DELETED", "리마인더 삭제 완료")); } @ApiOperation("전체 리마인더 조회") @@ -185,7 +183,7 @@ public ResponseEntity> readAll(){ List dto = reminderService.readAll(); return ResponseEntity.status(200) - .body(resWithData("REMINDERS_FOUND", "전체 리마인더 조회 완료", dto)); + .body(DefaultResponseDto.from("REMINDERS_FOUND", "전체 리마인더 조회 완료", dto)); } diff --git a/favor/src/main/java/com/favor/favor/user/UserController.java b/favor/src/main/java/com/favor/favor/user/UserController.java index fb71cc9..a680046 100644 --- a/favor/src/main/java/com/favor/favor/user/UserController.java +++ b/favor/src/main/java/com/favor/favor/user/UserController.java @@ -10,7 +10,6 @@ import com.favor.favor.reminder.ReminderSimpleDto; import io.swagger.annotations.*; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @@ -18,8 +17,8 @@ import javax.validation.Valid; import java.util.List; -import static com.favor.favor.common.DefaultResponseDto.resWithData; -import static com.favor.favor.common.DefaultResponseDto.resWithoutData; +import static com.favor.favor.common.DefaultResponseDto.from; +import static com.favor.favor.common.DefaultResponseDto.from; @Api(tags = "User") @RestController @@ -55,7 +54,7 @@ public ResponseEntity> signUp( UserResponseDto dto = userService.signUp(signDto); return ResponseEntity.status(201) - .body(resWithData("USER_REGISTERED", "회원가입 완료", dto)); + .body(DefaultResponseDto.from("USER_REGISTERED", "회원가입 완료", dto)); } @ApiOperation("프로필 생성") @@ -86,7 +85,7 @@ public ResponseEntity> createProfile( UserResponseDto dto = userService.createProfile(profileDto, userNo); return ResponseEntity.status(200) - .body(resWithData("PROFILE_UPDATED", "프로필 생성 완료", dto)); + .body(DefaultResponseDto.from("PROFILE_UPDATED", "프로필 생성 완료", dto)); } @ApiOperation(value = "로그인") @@ -113,7 +112,7 @@ public ResponseEntity> signIn( SignInResponseDto dto = userService.signIn(signDto); return ResponseEntity.status(201) - .body(resWithData("LOG_IN_SUCCESS", "로그인 완료", dto)); + .body(DefaultResponseDto.from("LOG_IN_SUCCESS", "로그인 완료", dto)); } @@ -141,7 +140,7 @@ public ResponseEntity> readUser( UserResponseDto dto = userService.readUserInfo(userNo); return ResponseEntity.status(200) - .body(resWithData("USER_FOUND", "회원 조회 완료", dto)); + .body(DefaultResponseDto.from("USER_FOUND", "회원 조회 완료", dto)); } @ApiOperation("회원 수정") @@ -167,7 +166,7 @@ public ResponseEntity> updateUser( UserResponseDto dto = userService.updateUser(userNo, userUpdateRequestDto); return ResponseEntity.status(200) - .body(resWithData("USER_UPDATED", "회원 수정 완료", dto)); + .body(DefaultResponseDto.from("USER_UPDATED", "회원 수정 완료", dto)); } @@ -197,7 +196,7 @@ public ResponseEntity> deleteUser( userService.deleteUser(userNo); return ResponseEntity.status(200) - .body(resWithoutData("USER_DELETED", "회원 탈퇴 완료")); + .body(from("USER_DELETED", "회원 탈퇴 완료")); } @ApiOperation("비밀번호 변경") @@ -221,7 +220,7 @@ public ResponseEntity> updatePassword( UserResponseDto dto = userService.updatePassword(passwordDto.getEmail(), passwordDto.getPassword()); return ResponseEntity.status(200) - .body(resWithData("PASSWORD_UPDATED", "비밀번호 변경 완료", dto)); + .body(DefaultResponseDto.from("PASSWORD_UPDATED", "비밀번호 변경 완료", dto)); } @@ -248,7 +247,7 @@ public ResponseEntity> readReminderList( List dto = userService.readReminderList(userNo); return ResponseEntity.status(200) - .body(resWithData("REMINDERS_FOUND", "회원의 리마인더 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("REMINDERS_FOUND", "회원의 리마인더 전체 조회 완료", dto)); } @ApiOperation("회원의 리마인더 필터 조회") @ApiResponses(value={ @@ -275,7 +274,7 @@ public ResponseEntity> readReminderListByFMonthAndYea List dto = userService.readReminderListByFMonthAndYear(userNo, year, month); return ResponseEntity.status(200) - .body(resWithData("REMINDER_FOUND_BY_FILTER", "회원가입 완료", dto)); + .body(DefaultResponseDto.from("REMINDER_FOUND_BY_FILTER", "회원가입 완료", dto)); } @ApiOperation("회원의 선물 전체 조회") @@ -301,7 +300,7 @@ public ResponseEntity> readGiftList( List dto = userService.readGiftList(userNo); return ResponseEntity.status(200) - .body(resWithData("GIFTS_FOUND", "회원의 선물 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFTS_FOUND", "회원의 선물 전체 조회 완료", dto)); } @ApiOperation("회원의 친구 전체 조회") @@ -327,7 +326,7 @@ public ResponseEntity> readFriendList( List dto = userService.readFriendList(userNo); return ResponseEntity.status(200) - .body(resWithData("FRIENDS_FOUND", "회원의 친구 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("FRIENDS_FOUND", "회원의 친구 전체 조회 완료", dto)); } @ApiOperation("회원의 기념일 전체 조회") @@ -353,7 +352,7 @@ public ResponseEntity> readAnniversaryList( List dto = userService.readAnniversaryList(userNo); return ResponseEntity.status(200) - .body(resWithData("ANNIVERSARY_FOUND", "회원의 기념일 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("ANNIVERSARY_FOUND", "회원의 기념일 전체 조회 완료", dto)); } @@ -373,7 +372,7 @@ public ResponseEntity> readAll(){ List dto = userService.readAll(); return ResponseEntity.status(200) - .body(resWithData("USERS_FOUND", "전체 회원 조회 완료", dto)); + .body(DefaultResponseDto.from("USERS_FOUND", "전체 회원 조회 완료", dto)); } @@ -401,7 +400,7 @@ public ResponseEntity> readGiftListByName ( List dto = userService.readGiftListByName(userNo, giftName); return ResponseEntity.status(200) - .body(resWithData("GIFTS_BY_NAME_FOUND", "이름으로 회원 선물 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFTS_BY_NAME_FOUND", "이름으로 회원 선물 조회 완료", dto)); } @ApiOperation("카테고리로 회원 선물 조회") @@ -427,7 +426,7 @@ public ResponseEntity> readGiftListByCategory( List dto = userService.readGiftListByCategory(userNo, giftCategory); return ResponseEntity.status(200) - .body(resWithData("GIFTS_BY_CATEGORY_FOUND", "카테고리로 회원 선물 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFTS_BY_CATEGORY_FOUND", "카테고리로 회원 선물 조회 완료", dto)); } @ApiOperation("감정으로 회원 선물 조회") @@ -453,7 +452,7 @@ public ResponseEntity> readGiftListByEmotion( List dto = userService.readGiftListByEmotion(userNo, emotion); return ResponseEntity.status(200) - .body(resWithData("GIFTS_BY_CATEGORY_FOUND", "감정으로 회원 선물 조회 완료", dto)); + .body(DefaultResponseDto.from("GIFTS_BY_CATEGORY_FOUND", "감정으로 회원 선물 조회 완료", dto)); } @ApiOperation("아이디로 회원 조회") @@ -476,7 +475,7 @@ public ResponseEntity> readUserByUserId( UserResponseDto dto = userService.readUserInfo(user.getUserNo()); return ResponseEntity.status(200) - .body(resWithData("USER_BY_ID_FOUND", "아이디로 회원 조회 완료", dto)); + .body(DefaultResponseDto.from("USER_BY_ID_FOUND", "아이디로 회원 조회 완료", dto)); } @ApiOperation("유저가 준 선물 전체 조회") @@ -498,7 +497,7 @@ public ResponseEntity> readGivenGiftList( List dto = userService.readGivenGiftList(userNo); return ResponseEntity.status(200) - .body(resWithData("GIVEN_GIFTS_FOUND", "유저가 준 선물 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("GIVEN_GIFTS_FOUND", "유저가 준 선물 전체 조회 완료", dto)); } @ApiOperation("유저가 받은 선물 전체 조회") @@ -520,7 +519,7 @@ public ResponseEntity> readReceivedGiftList( List dto = userService.readReceivedGiftList(userNo); return ResponseEntity.status(200) - .body(resWithData("RECEIVED_GIFTS_FOUND", "유저가 받은 선물 전체 조회 완료", dto)); + .body(DefaultResponseDto.from("RECEIVED_GIFTS_FOUND", "유저가 받은 선물 전체 조회 완료", dto)); } } diff --git a/favor/src/main/java/com/favor/favor/user/UserPhotoController.java b/favor/src/main/java/com/favor/favor/user/UserPhotoController.java index ea3e768..6852378 100644 --- a/favor/src/main/java/com/favor/favor/user/UserPhotoController.java +++ b/favor/src/main/java/com/favor/favor/user/UserPhotoController.java @@ -7,7 +7,6 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @@ -49,7 +48,7 @@ public ResponseEntity> updateUserProfilePhoto( UserPhoto dto = user.getUserProfilePhoto(); return ResponseEntity.status(201) - .body(resWithData("USER_PROFILE_PHOTO_UPDATED", "회원 사진 수정 완료", dto)); + .body(DefaultResponseDto.from("USER_PROFILE_PHOTO_UPDATED", "회원 사진 수정 완료", dto)); } @ApiOperation("회원 프로필 사진 조회") @@ -71,7 +70,7 @@ public ResponseEntity> getUserProfilePhoto( UserPhoto dto = userPhotoService.getUserProfilePhoto(loginUser.getUserNo()); return ResponseEntity.status(200) - .body(resWithData("USER_PROFILE_PHOTO_FOUND", "회원 사진 조회 완료", dto)); + .body(DefaultResponseDto.from("USER_PROFILE_PHOTO_FOUND", "회원 사진 조회 완료", dto)); } @ApiOperation("회원 프로필 사진 삭제") @@ -94,7 +93,7 @@ public ResponseEntity> deleteUserProfilePhoto(@Authen userPhotoService.deleteUserProfilePhoto(userNo); return ResponseEntity.status(200) - .body(resWithoutData("USER_PROFILE_PHOTO_DELETED", "회원 사진 삭제 완료")); + .body(from("USER_PROFILE_PHOTO_DELETED", "회원 사진 삭제 완료")); } @@ -124,7 +123,7 @@ public ResponseEntity> updateUserBackgroundPhoto( UserPhoto dto = user.getUserBackgroundPhoto(); return ResponseEntity.status(201) - .body(resWithData("USER_BACKGROUND_PHOTO_UPDATED", "회원 배경 사진 수정 완료", dto)); + .body(DefaultResponseDto.from("USER_BACKGROUND_PHOTO_UPDATED", "회원 배경 사진 수정 완료", dto)); } @ApiOperation("회원 배경 사진 조회") @@ -146,7 +145,7 @@ public ResponseEntity> getUserBackgroundPhoto( UserPhoto dto = userPhotoService.getUserBackgroundPhoto(loginUser.getUserNo()); return ResponseEntity.status(200) - .body(resWithData("USER_BACKGROUND_PHOTO_FOUND", "회원 배경 사진 조회 완료", dto)); + .body(DefaultResponseDto.from("USER_BACKGROUND_PHOTO_FOUND", "회원 배경 사진 조회 완료", dto)); } @ApiOperation("회원 배경 사진 삭제") @@ -170,6 +169,6 @@ public ResponseEntity> deleteUserBackgroundPhoto( userPhotoService.deleteUserBackgroundPhoto(userNo); return ResponseEntity.status(200) - .body(resWithoutData("USER_BACKGROUND_PHOTO_DELETED", "회원 배경 사진 수정 완료")); + .body(from("USER_BACKGROUND_PHOTO_DELETED", "회원 배경 사진 수정 완료")); } } \ No newline at end of file From dec6a787ff0486c166712c6dc2da43203811a2fe Mon Sep 17 00:00:00 2001 From: Juser0 Date: Fri, 24 Nov 2023 15:25:44 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Fix]=20stream=20=EB=82=B4=EB=B6=80=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=9E=90=20->=20=EC=A0=95=EC=A0=81=20?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=86=8C=EB=93=9C?= =?UTF-8?q?=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 --- favor/src/main/java/com/favor/favor/user/UserService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/favor/src/main/java/com/favor/favor/user/UserService.java b/favor/src/main/java/com/favor/favor/user/UserService.java index cd68d5c..016ec68 100644 --- a/favor/src/main/java/com/favor/favor/user/UserService.java +++ b/favor/src/main/java/com/favor/favor/user/UserService.java @@ -301,7 +301,7 @@ public List readFriendList(Long userNo) { public List readAnniversaryList(Long userNo) { User user = findUserByUserNo(userNo); return user.getAnniversaryList().stream() - .map(AnniversaryResponseDto::new).collect(Collectors.toList()); + .map(AnniversaryResponseDto::from).collect(Collectors.toList()); } public List readFavorList(Long userNo) {