Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.example.RealMatch.user.infrastructure.ScrapMockDataProvider;
import com.example.RealMatch.user.presentation.code.UserErrorCode;
import com.example.RealMatch.user.presentation.dto.request.MyEditInfoRequestDto;
import com.example.RealMatch.user.presentation.dto.request.MyProfileCardUpdateRequestDto;
import com.example.RealMatch.user.presentation.dto.response.MyEditInfoResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyLoginResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyPageResponseDto;
Expand Down Expand Up @@ -146,6 +147,30 @@ public MyLoginResponseDto getSocialLoginInfo(Long userId) {
return MyLoginResponseDto.from(linkedProviders);
}

@Transactional
public MyProfileCardResponseDto updateMyProfileImage(
Long userId,
MyProfileCardUpdateRequestDto request
) {
// 유저 조회
User user = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(UserErrorCode.USER_NOT_FOUND));

// 매칭 검사 진행 여부 예외 처리 - 매칭 검사를 안하면 프로필 카드가 없음
UserMatchingDetail detail = userMatchingDetailRepository
.findByUserIdAndIsDeprecatedFalse(userId)
.orElseThrow(() -> new CustomException(UserErrorCode.PROFILE_CARD_NOT_FOUND));

// 이미지 URL만 교체
user.updateProfileImage(request.getProfileImageUrl());

// 변경된 프로필 이미지로 프로필 카드 DTO 재생성
List<UserContentCategory> categories =
userContentCategoryRepository.findByUserId(userId);

return MyProfileCardResponseDto.from(user, detail, categories);
}

@Transactional(readOnly = true)
public boolean isNicknameAvailable(String nickname) {
return nicknameValidator.isAvailable(nickname);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.example.RealMatch.user.application.service.UserService;
import com.example.RealMatch.user.application.service.UserWithdrawService;
import com.example.RealMatch.user.presentation.dto.request.MyEditInfoRequestDto;
import com.example.RealMatch.user.presentation.dto.request.MyProfileCardUpdateRequestDto;
import com.example.RealMatch.user.presentation.dto.response.FavoriteBrandListResponseDto;
import com.example.RealMatch.user.presentation.dto.response.FavoriteCampaignListResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyEditInfoResponseDto;
Expand Down Expand Up @@ -166,4 +167,13 @@ public CustomResponse<FavoriteCampaignListResponseDto> getMyFavoriteCampaigns(
)
);
}
@PatchMapping("/me/profile-image")
public CustomResponse<MyProfileCardResponseDto> updateMyProfileImage(
@AuthenticationPrincipal CustomUserDetails userDetails,
@RequestBody @Valid MyProfileCardUpdateRequestDto request
) {
return CustomResponse.ok(
userService.updateMyProfileImage(userDetails.getUserId(), request)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.RealMatch.user.presentation.dto.request;

import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class MyProfileCardUpdateRequestDto {

@jakarta.validation.constraints.NotBlank
@Size(max = 255)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

프로필 이미지 URL은 비어있지 않은 값이어야 할 것으로 보입니다. profileImageUrl 필드에 @NotBlank 어노테이션을 추가하여 null 이나 공백 문자열이 전달되는 것을 방지하는 것이 좋습니다. 이렇게 하면 API의 유효성 검사가 더 명확해지고, 클라이언트에게 더 빠른 피드백을 줄 수 있습니다.

User.updateProfileImage 메소드에서 null 이나 공백을 처리하고 있지만, DTO 레벨에서 검증하는 것이 더 바람직합니다.

    @jakarta.validation.constraints.NotBlank
    @Size(max = 255)

private String profileImageUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.example.RealMatch.match.domain.entity.enums.CampaignSortType;
import com.example.RealMatch.match.presentation.dto.request.MatchRequestDto;
import com.example.RealMatch.user.presentation.dto.request.MyEditInfoRequestDto;
import com.example.RealMatch.user.presentation.dto.request.MyProfileCardUpdateRequestDto;
import com.example.RealMatch.user.presentation.dto.response.FavoriteBrandListResponseDto;
import com.example.RealMatch.user.presentation.dto.response.FavoriteCampaignListResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyEditInfoResponseDto;
Expand Down Expand Up @@ -148,7 +149,7 @@ CustomResponse<NicknameAvailableResponseDto> checkNicknameAvailable(
@RequestParam String nickname
);

@Operation(summary = "회원 탈퇴", description = "회원 탈퇴(Soft Delete) 처리 후 role을 WITHDRAWN으로 변경합니다.")
@Operation(summary = "회원 탈퇴 API By 고경수 ", description = "회원 탈퇴(Soft Delete) 처리 후 role을 WITHDRAWN으로 변경합니다.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Swagger API 문서의 summary에 개발자 이름을 포함하는 것은 일반적인 관행이 아닙니다. API 문서는 기능 자체에 초점을 맞춰야 하며, 작성자 정보는 Git 커밋 히스토리 등을 통해 추적하는 것이 좋습니다. summary에서 " By 고경수 " 부분을 제거하여 문서를 더 깔끔하고 전문적으로 유지하는 것을 제안합니다.

Suggested change
@Operation(summary = "회원 탈퇴 API By 고경수 ", description = "회원 탈퇴(Soft Delete) 처리 후 role을 WITHDRAWN으로 변경합니다.")
@Operation(summary = "회원 탈퇴 API", description = "회원 탈퇴(Soft Delete) 처리 후 role을 WITHDRAWN으로 변경합니다.")

CustomResponse<Void> withdraw(
@Parameter(hidden = true) @AuthenticationPrincipal CustomUserDetails userDetails
);
Expand Down Expand Up @@ -207,4 +208,11 @@ CustomResponse<FavoriteCampaignListResponseDto> getMyFavoriteCampaigns(
@RequestParam(required = false)
CampaignSortType sort
);

@Operation(summary = "프로필 이미지 수정 API By 고경수",
description = "Attachment API로 업로드된 이미지 URL을 받아 프로필 이미지를 변경합니다")
Comment on lines +212 to +213
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Swagger API 문서의 summary에 개발자 이름을 포함하는 것은 일반적인 관행이 아닙니다. API 문서는 기능 자체에 초점을 맞춰야 하며, 작성자 정보는 Git 커밋 히스토리 등을 통해 추적하는 것이 좋습니다. summary에서 " By 고경수" 부분을 제거하여 문서를 더 깔끔하고 전문적으로 유지하는 것을 제안합니다.

Suggested change
@Operation(summary = "프로필 이미지 수정 API By 고경수",
description = "Attachment API로 업로드된 이미지 URL을 받아 프로필 이미지를 변경합니다")
@Operation(summary = "프로필 이미지 수정 API",
description = "Attachment API로 업로드된 이미지 URL을 받아 프로필 이미지를 변경합니다")

CustomResponse<MyProfileCardResponseDto> updateMyProfileImage(
@Parameter(hidden = true) CustomUserDetails userDetails,
@RequestBody MyProfileCardUpdateRequestDto request
);
}
Loading