From 2ca01e058215b09d878f3451c360f027653febc8 Mon Sep 17 00:00:00 2001 From: hyeangjun Date: Tue, 16 Jul 2024 12:43:11 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[Fix]=20url=20=EC=88=98=EC=A0=95,=20userUpd?= =?UTF-8?q?ate=20http=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95=20-?= =?UTF-8?q?=20#105?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/controller/ProfileController.java | 20 +++++++++---------- .../controller/ProfilePhotoController.java | 8 ++++---- .../user/controller/UserController.java | 2 +- .../snaptime/user/dto/req/UserUpdateDto.java | 3 --- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/me/snaptime/profile/controller/ProfileController.java b/src/main/java/me/snaptime/profile/controller/ProfileController.java index 60658a22..c76bee50 100644 --- a/src/main/java/me/snaptime/profile/controller/ProfileController.java +++ b/src/main/java/me/snaptime/profile/controller/ProfileController.java @@ -38,10 +38,10 @@ public class ProfileController { @Operation(summary = "유저 앨범, 스냅 조회", description = "유저의 앨범들과, 각 앨범의 스냅들을 조회합니다." + "
자신의 프로필 조회 -> 앨범 당 private, public 관계 없이 최근 snap 2개 리턴" + "
다른 사람의 프로필 조회 -> snap이 전부 private이거나 없는 경우 앨범 리턴 x 그리고 private 인 snap 리턴 x") - @Parameter(name = "login_id", description = "앨범과 사진들을 가져오기 위한 loginId", required = true) - @GetMapping("/album_snap") + @Parameter(name = "loginId", description = "앨범과 사진들을 가져오기 위한 loginId", required = true) + @GetMapping("/album-snap") public ResponseEntity>> getAlbumSnap(@AuthenticationPrincipal UserDetails principal, - @RequestParam("login_id") + @RequestParam("loginId") @NotBlank(message = "로그인 아이디 입력은 필수입니다.") String targetLoginId){ String yourLoginId = principal.getUsername(); List albumSnapResDtoList = profileService.getAlbumSnap(yourLoginId, targetLoginId); @@ -55,9 +55,9 @@ public ResponseEntity>> getAlbumSnap(@Au @Operation(summary = "유저 이름, 프로필 사진 조회", description = "유저의 이름과, 프로필 사진을 조회합니다." + "
유저 번호, 유저 이름, 프로필 사진 url 리턴(토큰 없이 url 접근 가능)" + "
토큰이 없어도 해당 Api 엔드포인트를 요청할 수 있습니다.") - @Parameter(name = "login_id", description = "이름과 프로필 사진을 가져오기 위한 loginId", required = true) + @Parameter(name = "loginId", description = "이름과 프로필 사진을 가져오기 위한 loginId", required = true) @GetMapping("/profile") - public ResponseEntity> getUserProfile(@RequestParam("login_id") + public ResponseEntity> getUserProfile(@RequestParam("loginId") @NotBlank(message = "로그인 아이디 입력은 필수입니다.") String loginId){ UserProfileResDto userProfileResDto = profileService.getUserProfile(loginId); return ResponseEntity.status(HttpStatus.OK).body( @@ -68,9 +68,9 @@ public ResponseEntity> getUserProfile(@Requ } @Operation(summary = "유저의 Snap 수, Follower 수, Following 수 조회", description = "유저의 loginId로 유저의 snap 수, 팔로워 수, 팔로잉 수를 조회합니다.") - @Parameter(name = "login_id", description = "팔로워와 팔로잉 수를 가져오기 위한 loginId", required = true) + @Parameter(name = "loginId", description = "팔로워와 팔로잉 수를 가져오기 위한 loginId", required = true) @GetMapping("/count") - public ResponseEntity> getProfileCnt(@RequestParam("login_id") + public ResponseEntity> getProfileCnt(@RequestParam("loginId") @NotBlank(message = "로그인 아이디 입력은 필수입니다.") String loginId){ ProfileCntResDto profileCntResDto = profileService.getUserProfileCnt(loginId); return ResponseEntity.status(HttpStatus.OK).body( @@ -82,9 +82,9 @@ public ResponseEntity> getProfileCnt(@Reques @Operation(summary = "유저의 태그된 snap 들 조회", description = "유저의 loginId로 유저가 태그된 snap 들을 조회합니다" + "
snap id 기준 내림차순으로 조회합니다.(최근 snap 이 제일 먼저 조회)") - @Parameter(name = "login_id", description = "팔로워와 팔로잉 수를 가져오기 위한 loginId", required = true) - @GetMapping("/tag_snap") - public ResponseEntity>> getTagSnap(@RequestParam("login_id") + @Parameter(name = "loginId", description = "팔로워와 팔로잉 수를 가져오기 위한 loginId", required = true) + @GetMapping("/tag-snap") + public ResponseEntity>> getTagSnap(@RequestParam("loginId") @NotBlank(message = "로그인 아이디 입력은 필수입니다.") String loginId){ List profileTagSnapResDto = profileService.getTagSnap(loginId); diff --git a/src/main/java/me/snaptime/profilePhoto/controller/ProfilePhotoController.java b/src/main/java/me/snaptime/profilePhoto/controller/ProfilePhotoController.java index eaf15ead..238e7846 100644 --- a/src/main/java/me/snaptime/profilePhoto/controller/ProfilePhotoController.java +++ b/src/main/java/me/snaptime/profilePhoto/controller/ProfilePhotoController.java @@ -21,16 +21,16 @@ @Tag(name ="[ProfilePhoto] ProfilePhoto API", description = "프로필 사진 생성, 프로필 사진 조회, 프로필 사진 수정, 프로필 사진 삭제") @Slf4j @RestController -@RequestMapping("/profile_photos") +@RequestMapping("/profile-photos") @RequiredArgsConstructor public class ProfilePhotoController { private final ProfilePhotoService profilePhotoService; @Operation(summary = "프로필 사진 조회",description = "유저의 번호로 유저의 프로필 사진을 조회 합니다.") - @Parameter(name = "profile_photo_id", description = "조회 할 프로필 사진의 id") - @GetMapping("/{profile_photo_id}") - public ResponseEntity downloadProfileToFileSystem(@PathVariable("profile_photo_id") Long profilePhotoId) { + @Parameter(name = "profilePhotoId", description = "조회 할 프로필 사진의 id") + @GetMapping("/{profile-photo-id}") + public ResponseEntity downloadProfileToFileSystem(@PathVariable("profilePhotoId") Long profilePhotoId) { log.info("[downloadProfile] 유저의 프로필 사진을 조회합니다. profilePhotoId : {}",profilePhotoId); byte[] downloadProfile = profilePhotoService.downloadPhotoFromFileSystem(profilePhotoId); diff --git a/src/main/java/me/snaptime/user/controller/UserController.java b/src/main/java/me/snaptime/user/controller/UserController.java index 79ce3fcc..d53abd4f 100644 --- a/src/main/java/me/snaptime/user/controller/UserController.java +++ b/src/main/java/me/snaptime/user/controller/UserController.java @@ -46,7 +46,7 @@ public ResponseEntity> getUser(@AuthenticationPrin @Operation(summary = "유저 정보 수정",description = "해당 유저의 정보를 수정합니다. " + "
유저 loginId 수정 이후에는, Token의 loginId 정보와 현재 유저의 loginId가 다르므로," + "
Token을 버리고 재 login을 유도해야 합니다.") - @PutMapping() + @PatchMapping() public ResponseEntity> changeUser(@AuthenticationPrincipal UserDetails principal, @Valid @RequestBody UserUpdateDto userUpdateDto){ UserResDto userResDto = userService.updateUser(principal.getUsername(), userUpdateDto); diff --git a/src/main/java/me/snaptime/user/dto/req/UserUpdateDto.java b/src/main/java/me/snaptime/user/dto/req/UserUpdateDto.java index 354e8bc5..a69c4ce7 100644 --- a/src/main/java/me/snaptime/user/dto/req/UserUpdateDto.java +++ b/src/main/java/me/snaptime/user/dto/req/UserUpdateDto.java @@ -10,19 +10,16 @@ public record UserUpdateDto( example = "홍길순", description = "유저의 이름을 입력해주세요" ) - @NotBlank(message = "유저 이름 입력은 필수입니다.") String name, @Schema( example = "strong@gmail.com", description = "유저의 이메일을 입력해주세요" ) - @NotBlank(message = "유저 이메일 입력은 필수입니다.") String email, @Schema( example = "1999-10-29", description = "유저의 생년월일을 입력해주세요" ) - @NotBlank(message = "유저 생년월일 입력은 필수입니다.") String birthDay ){} From 6f8ef3abc2cc2108702cab6d1120fdcecb2e71be Mon Sep 17 00:00:00 2001 From: hyeangjun Date: Tue, 16 Jul 2024 12:48:30 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=EB=B9=A0=EC=A7=84=EA=B1=B0=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 --- .../profilePhoto/controller/ProfilePhotoController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/snaptime/profilePhoto/controller/ProfilePhotoController.java b/src/main/java/me/snaptime/profilePhoto/controller/ProfilePhotoController.java index 238e7846..b3097639 100644 --- a/src/main/java/me/snaptime/profilePhoto/controller/ProfilePhotoController.java +++ b/src/main/java/me/snaptime/profilePhoto/controller/ProfilePhotoController.java @@ -29,7 +29,7 @@ public class ProfilePhotoController { @Operation(summary = "프로필 사진 조회",description = "유저의 번호로 유저의 프로필 사진을 조회 합니다.") @Parameter(name = "profilePhotoId", description = "조회 할 프로필 사진의 id") - @GetMapping("/{profile-photo-id}") + @GetMapping("/{profilePhotoId}") public ResponseEntity downloadProfileToFileSystem(@PathVariable("profilePhotoId") Long profilePhotoId) { log.info("[downloadProfile] 유저의 프로필 사진을 조회합니다. profilePhotoId : {}",profilePhotoId); From 783c25a79aa0d60c4801bdc9dfb6ca43e0efd681 Mon Sep 17 00:00:00 2001 From: hyeangjun Date: Tue, 16 Jul 2024 12:53:10 +0900 Subject: [PATCH 3/7] =?UTF-8?q?test=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/snaptime/user/controller/UserControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/me/snaptime/user/controller/UserControllerTest.java b/src/test/java/me/snaptime/user/controller/UserControllerTest.java index dcc76744..52d640fb 100644 --- a/src/test/java/me/snaptime/user/controller/UserControllerTest.java +++ b/src/test/java/me/snaptime/user/controller/UserControllerTest.java @@ -139,7 +139,7 @@ void updateUserTest() throws Exception{ String content = gson.toJson(userUpdateDto); //when - mockMvc.perform(put("/users") + mockMvc.perform(patch("/users") .content(content).contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.msg").exists()) .andExpect(jsonPath("$.result.loginId").exists()) From c074bcae18dec02c056a73b6ef114636223d06d6 Mon Sep 17 00:00:00 2001 From: hyeangjun Date: Wed, 17 Jul 2024 15:52:03 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[Fix]=20url=20=EC=88=98=EC=A0=95,=20userUpd?= =?UTF-8?q?ate=20http=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20-#105?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/controller/ProfileController.java | 5 +++-- .../profile/dto/res/UserProfileResDto.java | 4 +++- .../snaptime/profile/service/ProfileService.java | 4 ++-- .../profile/service/impl/ProfileServiceImpl.java | 15 +++++++++------ .../snaptime/user/controller/UserController.java | 6 +++--- .../{UserUpdateDto.java => UserUpdateReqDto.java} | 3 +-- .../me/snaptime/user/service/UserService.java | 4 ++-- .../user/service/impl/UserServiceImpl.java | 4 ++-- .../user/controller/UserControllerTest.java | 8 ++++---- .../me/snaptime/user/service/UserServiceTest.java | 4 ++-- 10 files changed, 31 insertions(+), 26 deletions(-) rename src/main/java/me/snaptime/user/dto/req/{UserUpdateDto.java => UserUpdateReqDto.java} (88%) diff --git a/src/main/java/me/snaptime/profile/controller/ProfileController.java b/src/main/java/me/snaptime/profile/controller/ProfileController.java index c76bee50..1ce0a8fd 100644 --- a/src/main/java/me/snaptime/profile/controller/ProfileController.java +++ b/src/main/java/me/snaptime/profile/controller/ProfileController.java @@ -57,9 +57,10 @@ public ResponseEntity>> getAlbumSnap(@Au "
토큰이 없어도 해당 Api 엔드포인트를 요청할 수 있습니다.") @Parameter(name = "loginId", description = "이름과 프로필 사진을 가져오기 위한 loginId", required = true) @GetMapping("/profile") - public ResponseEntity> getUserProfile(@RequestParam("loginId") + public ResponseEntity> getUserProfile(@AuthenticationPrincipal UserDetails principal, + @RequestParam("loginId") @NotBlank(message = "로그인 아이디 입력은 필수입니다.") String loginId){ - UserProfileResDto userProfileResDto = profileService.getUserProfile(loginId); + UserProfileResDto userProfileResDto = profileService.getUserProfile(principal.getUsername(),loginId); return ResponseEntity.status(HttpStatus.OK).body( new CommonResponseDto<>( "유저 이름과, 프로필 사진 조회를 성공적으로 완료하였습니다.", diff --git a/src/main/java/me/snaptime/profile/dto/res/UserProfileResDto.java b/src/main/java/me/snaptime/profile/dto/res/UserProfileResDto.java index 2ec76f79..941631de 100644 --- a/src/main/java/me/snaptime/profile/dto/res/UserProfileResDto.java +++ b/src/main/java/me/snaptime/profile/dto/res/UserProfileResDto.java @@ -8,13 +8,15 @@ public record UserProfileResDto( Long userId, String userName, String profileURL +// Boolean isFollow ){ - public static UserProfileResDto toDto(User user, String profileURL) + public static UserProfileResDto toDto(User user, String profileURL /*, boolean isFollow*/) { return UserProfileResDto.builder() .userId(user.getId()) .userName(user.getName()) .profileURL(profileURL) + //.isFollow(isFollow) .build(); } } diff --git a/src/main/java/me/snaptime/profile/service/ProfileService.java b/src/main/java/me/snaptime/profile/service/ProfileService.java index b5fda617..e73bb175 100644 --- a/src/main/java/me/snaptime/profile/service/ProfileService.java +++ b/src/main/java/me/snaptime/profile/service/ProfileService.java @@ -9,9 +9,9 @@ public interface ProfileService { /* 호출자의 loginId, 피호출자의 loginId를 통해 피호출자의 album과 snap을 조회 */ - public List getAlbumSnap(String yourLoginId, String targetLoginId); + public List getAlbumSnap(String ownLoginId, String targetLoginId); /* loginId에 해당하는 User의 profile 사진을 조회 */ - public UserProfileResDto getUserProfile(String loginId); + public UserProfileResDto getUserProfile(String ownLoginId, String targetLoginId); /* loginId에 해당하는 User의 스냅, 팔로우, 팔로워 수 리턴 */ public ProfileCntResDto getUserProfileCnt(String loginId); /* loginId에 해당하는 User가 Tag된 snap들을 조회합니다 */ diff --git a/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java b/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java index fb0e2678..a86f0504 100644 --- a/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java +++ b/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java @@ -32,19 +32,22 @@ public class ProfileServiceImpl implements ProfileService { @Override @Transactional(readOnly = true) - public List getAlbumSnap(String yourLoginId, String targetLoginId) { + public List getAlbumSnap(String ownLoginId, String targetLoginId) { User targetUser = userRepository.findByLoginId(targetLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); - return userRepository.findAlbumSnap(targetUser, yourLoginId.equals(targetLoginId)); + return userRepository.findAlbumSnap(targetUser, ownLoginId.equals(targetLoginId)); } @Override @Transactional(readOnly = true) - public UserProfileResDto getUserProfile(String loginId) { - User reqUser = userRepository.findByLoginId(loginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); - String profileURL = urlComponent.makeProfileURL(reqUser.getProfilePhoto().getId()); + public UserProfileResDto getUserProfile(String ownLoginId, String targetLoginId) { + User targetUser = userRepository.findByLoginId(targetLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); + User ownUser = userRepository.findByLoginId(ownLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); +// boolean isFollow = friendRepository.checkFriend(ownUser,targetUser); + + String profileURL = urlComponent.makeProfileURL(targetUser.getProfilePhoto().getId()); - return UserProfileResDto.toDto(reqUser, profileURL); + return UserProfileResDto.toDto(targetUser, profileURL /*, isFollow*/); } @Override diff --git a/src/main/java/me/snaptime/user/controller/UserController.java b/src/main/java/me/snaptime/user/controller/UserController.java index d53abd4f..54e22db8 100644 --- a/src/main/java/me/snaptime/user/controller/UserController.java +++ b/src/main/java/me/snaptime/user/controller/UserController.java @@ -9,7 +9,7 @@ import me.snaptime.common.CommonResponseDto; import me.snaptime.user.dto.req.SignInReqDto; import me.snaptime.user.dto.req.UserReqDto; -import me.snaptime.user.dto.req.UserUpdateDto; +import me.snaptime.user.dto.req.UserUpdateReqDto; import me.snaptime.user.dto.res.SignInResDto; import me.snaptime.user.dto.res.UserResDto; import me.snaptime.user.service.SignService; @@ -48,7 +48,7 @@ public ResponseEntity> getUser(@AuthenticationPrin "
Token을 버리고 재 login을 유도해야 합니다.") @PatchMapping() public ResponseEntity> changeUser(@AuthenticationPrincipal UserDetails principal, - @Valid @RequestBody UserUpdateDto userUpdateDto){ + @Valid @RequestBody UserUpdateReqDto userUpdateDto){ UserResDto userResDto = userService.updateUser(principal.getUsername(), userUpdateDto); return ResponseEntity.status(HttpStatus.OK).body( new CommonResponseDto<>( @@ -56,7 +56,7 @@ public ResponseEntity> changeUser(@AuthenticationP userResDto)); } @Operation(summary = "유저 비밀번호 수정",description = "해당 유저의 비밀번호를 수정합니다.") - @PutMapping("/password") + @PatchMapping("/password") public ResponseEntity> changeUser(@AuthenticationPrincipal UserDetails principal, @RequestParam("password") @NotBlank(message = "로그인 아이디 입력은 필수입니다.") String password) { diff --git a/src/main/java/me/snaptime/user/dto/req/UserUpdateDto.java b/src/main/java/me/snaptime/user/dto/req/UserUpdateReqDto.java similarity index 88% rename from src/main/java/me/snaptime/user/dto/req/UserUpdateDto.java rename to src/main/java/me/snaptime/user/dto/req/UserUpdateReqDto.java index a69c4ce7..74d302a6 100644 --- a/src/main/java/me/snaptime/user/dto/req/UserUpdateDto.java +++ b/src/main/java/me/snaptime/user/dto/req/UserUpdateReqDto.java @@ -1,11 +1,10 @@ package me.snaptime.user.dto.req; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; import lombok.Builder; @Builder -public record UserUpdateDto( +public record UserUpdateReqDto( @Schema( example = "홍길순", description = "유저의 이름을 입력해주세요" diff --git a/src/main/java/me/snaptime/user/service/UserService.java b/src/main/java/me/snaptime/user/service/UserService.java index b102e034..6dd719e5 100644 --- a/src/main/java/me/snaptime/user/service/UserService.java +++ b/src/main/java/me/snaptime/user/service/UserService.java @@ -1,11 +1,11 @@ package me.snaptime.user.service; -import me.snaptime.user.dto.req.UserUpdateDto; +import me.snaptime.user.dto.req.UserUpdateReqDto; import me.snaptime.user.dto.res.UserResDto; public interface UserService { public UserResDto getUser(String loginId); - public UserResDto updateUser(String loginId, UserUpdateDto userUpdateDto); + public UserResDto updateUser(String loginId, UserUpdateReqDto userUpdateDto); public void deleteUser(String loginId); public void updatePassword(String loginId, String password); } diff --git a/src/main/java/me/snaptime/user/service/impl/UserServiceImpl.java b/src/main/java/me/snaptime/user/service/impl/UserServiceImpl.java index d53bfcbc..3f07689b 100644 --- a/src/main/java/me/snaptime/user/service/impl/UserServiceImpl.java +++ b/src/main/java/me/snaptime/user/service/impl/UserServiceImpl.java @@ -6,7 +6,7 @@ import me.snaptime.exception.CustomException; import me.snaptime.exception.ExceptionCode; import me.snaptime.user.domain.User; -import me.snaptime.user.dto.req.UserUpdateDto; +import me.snaptime.user.dto.req.UserUpdateReqDto; import me.snaptime.user.dto.res.UserResDto; import me.snaptime.user.repository.UserRepository; import me.snaptime.user.service.UserService; @@ -31,7 +31,7 @@ public UserResDto getUser(String loginId) { return UserResDto.toDto(user); } - public UserResDto updateUser(String loginId, UserUpdateDto userUpdateDto) { + public UserResDto updateUser(String loginId, UserUpdateReqDto userUpdateDto) { User user = userRepository.findByLoginId(loginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); diff --git a/src/test/java/me/snaptime/user/controller/UserControllerTest.java b/src/test/java/me/snaptime/user/controller/UserControllerTest.java index 52d640fb..a7ec13e5 100644 --- a/src/test/java/me/snaptime/user/controller/UserControllerTest.java +++ b/src/test/java/me/snaptime/user/controller/UserControllerTest.java @@ -6,7 +6,7 @@ import me.snaptime.jwt.UserDetailsServiceImpl; import me.snaptime.profile.service.impl.ProfileServiceImpl; import me.snaptime.user.dto.req.UserReqDto; -import me.snaptime.user.dto.req.UserUpdateDto; +import me.snaptime.user.dto.req.UserUpdateReqDto; import me.snaptime.user.dto.res.UserResDto; import me.snaptime.user.service.impl.SignServiceImpl; import me.snaptime.user.service.impl.UserServiceImpl; @@ -121,13 +121,13 @@ void signUpTest() throws Exception{ void updateUserTest() throws Exception{ //given - UserUpdateDto userUpdateDto = UserUpdateDto.builder() + UserUpdateReqDto userUpdateDto = UserUpdateReqDto.builder() .name("홍길순") .email("strong@naver.com") .birthDay("1999-10-29") .build(); - given(userService.updateUser(eq("kang4746"),any(UserUpdateDto.class))) + given(userService.updateUser(eq("kang4746"),any(UserUpdateReqDto.class))) .willReturn(UserResDto.builder() .loginId("kang4746") .name("홍길순") @@ -148,7 +148,7 @@ void updateUserTest() throws Exception{ .andDo(print()); //then - verify(userService,times(1)).updateUser(eq("kang4746"),any(UserUpdateDto.class)); + verify(userService,times(1)).updateUser(eq("kang4746"),any(UserUpdateReqDto.class)); } @Test diff --git a/src/test/java/me/snaptime/user/service/UserServiceTest.java b/src/test/java/me/snaptime/user/service/UserServiceTest.java index ed77b9d1..74567bb0 100644 --- a/src/test/java/me/snaptime/user/service/UserServiceTest.java +++ b/src/test/java/me/snaptime/user/service/UserServiceTest.java @@ -6,7 +6,7 @@ import me.snaptime.user.domain.User; import me.snaptime.user.dto.req.SignInReqDto; import me.snaptime.user.dto.req.UserReqDto; -import me.snaptime.user.dto.req.UserUpdateDto; +import me.snaptime.user.dto.req.UserUpdateReqDto; import me.snaptime.user.dto.res.SignInResDto; import me.snaptime.user.dto.res.UserResDto; import me.snaptime.user.repository.UserRepository; @@ -165,7 +165,7 @@ public void deleteUser() { @DisplayName("given_when_then 방식으로 updateUser 서비스 성공 테스트") public void updateUser() { //given - UserUpdateDto userUpdateDto = UserUpdateDto.builder() + UserUpdateReqDto userUpdateDto = UserUpdateReqDto.builder() .name("") .email("strong@naver.com") .birthDay("") From da55f345d5135b4a92aef560eaa40b52150aac0c Mon Sep 17 00:00:00 2001 From: hyeangjun Date: Wed, 17 Jul 2024 16:40:51 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[Feat]=20gerProfile=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=EC=97=90=20=ED=8C=94=EB=A1=9C=EC=9A=B0=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EB=A6=AC=ED=84=B4=20-=20#105?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/dto/res/UserProfileResDto.java | 8 ++++---- .../profile/service/impl/ProfileServiceImpl.java | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/snaptime/profile/dto/res/UserProfileResDto.java b/src/main/java/me/snaptime/profile/dto/res/UserProfileResDto.java index 941631de..07dc35d4 100644 --- a/src/main/java/me/snaptime/profile/dto/res/UserProfileResDto.java +++ b/src/main/java/me/snaptime/profile/dto/res/UserProfileResDto.java @@ -7,16 +7,16 @@ public record UserProfileResDto( Long userId, String userName, - String profileURL -// Boolean isFollow + String profileURL, + Boolean isFollow ){ - public static UserProfileResDto toDto(User user, String profileURL /*, boolean isFollow*/) + public static UserProfileResDto toDto(User user, String profileURL , Boolean isFollow) { return UserProfileResDto.builder() .userId(user.getId()) .userName(user.getName()) .profileURL(profileURL) - //.isFollow(isFollow) + .isFollow(isFollow) .build(); } } diff --git a/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java b/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java index a86f0504..989551aa 100644 --- a/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java +++ b/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java @@ -41,13 +41,22 @@ public List getAlbumSnap(String ownLoginId, String targetLoginI @Override @Transactional(readOnly = true) public UserProfileResDto getUserProfile(String ownLoginId, String targetLoginId) { + + Boolean isFollow = null; User targetUser = userRepository.findByLoginId(targetLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); - User ownUser = userRepository.findByLoginId(ownLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); -// boolean isFollow = friendRepository.checkFriend(ownUser,targetUser); + + if(ownLoginId.equals(targetLoginId)){ + isFollow = null; /* 자기 자신을 조회한 경우 */ + } + else{ + User ownUser = userRepository.findByLoginId(ownLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); + if (friendService.checkIsFollow(ownUser,targetUser)) isFollow = true; /* 팔로우 한 상대를 조회*/ + else isFollow = false; /* 팔로우 하지 않은 상대를 조회 */ + } String profileURL = urlComponent.makeProfileURL(targetUser.getProfilePhoto().getId()); - return UserProfileResDto.toDto(targetUser, profileURL /*, isFollow*/); + return UserProfileResDto.toDto(targetUser, profileURL, isFollow); } @Override From c230762d296194f71a8e0dd34f4f76c2229584ed Mon Sep 17 00:00:00 2001 From: hyeangjun Date: Wed, 17 Jul 2024 16:53:35 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[Fix]=20=EC=88=98=EC=A0=95=ED=95=98?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/snaptime/profile/service/impl/ProfileServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java b/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java index 989551aa..16bf2640 100644 --- a/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java +++ b/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java @@ -46,12 +46,10 @@ public UserProfileResDto getUserProfile(String ownLoginId, String targetLoginId) User targetUser = userRepository.findByLoginId(targetLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); if(ownLoginId.equals(targetLoginId)){ - isFollow = null; /* 자기 자신을 조회한 경우 */ } else{ User ownUser = userRepository.findByLoginId(ownLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); - if (friendService.checkIsFollow(ownUser,targetUser)) isFollow = true; /* 팔로우 한 상대를 조회*/ - else isFollow = false; /* 팔로우 하지 않은 상대를 조회 */ + isFollow = friendService.checkIsFollow(ownUser,targetUser); } String profileURL = urlComponent.makeProfileURL(targetUser.getProfilePhoto().getId()); From f4aa552c73e0b352eafb9ce30523863ebb713a9c Mon Sep 17 00:00:00 2001 From: hyeangjun Date: Wed, 17 Jul 2024 17:07:12 +0900 Subject: [PATCH 7/7] =?UTF-8?q?getUserProfile=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../me/snaptime/profile/service/impl/ProfileServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java b/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java index 16bf2640..db8adfcd 100644 --- a/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java +++ b/src/main/java/me/snaptime/profile/service/impl/ProfileServiceImpl.java @@ -45,9 +45,7 @@ public UserProfileResDto getUserProfile(String ownLoginId, String targetLoginId) Boolean isFollow = null; User targetUser = userRepository.findByLoginId(targetLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); - if(ownLoginId.equals(targetLoginId)){ - } - else{ + if(!ownLoginId.equals(targetLoginId)){ User ownUser = userRepository.findByLoginId(ownLoginId).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST)); isFollow = friendService.checkIsFollow(ownUser,targetUser); }