Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…Codiary into feature/#289-alarm
  • Loading branch information
lee-haeseung committed Dec 8, 2024
2 parents 54d4c43 + 6e74fe3 commit 952ee9a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,33 @@ public class MemberController {

@PatchMapping(path = "/profile-image", consumes = "multipart/form-data")
@Operation(summary = "프로필 사진 설정")
public ApiResponse<MemberResponseDTO.MemberImageDTO> updateProfileImage(@ModelAttribute MemberRequestDTO.MemberProfileImageRequestDTO request) {
Member member = memberCommandService.getRequester();

return memberCommandService.updateProfileImage(member, request);
public ApiResponse<MemberResponseDTO.MemberImageDTO> updateProfileImage(@AuthenticationPrincipal CustomMemberDetails memberDetails, @ModelAttribute MemberRequestDTO.MemberProfileImageRequestDTO request) {
return memberCommandService.updateProfileImage(memberDetails.getId(), request);
}

@DeleteMapping("/profile-image")
@Operation(summary = "프로필 사진 삭제")
public ApiResponse<String> deleteProfileImage() {
Member member = memberCommandService.getRequester();
return memberCommandService.deleteProfileImage(member);
public ApiResponse<String> deleteProfileImage(@AuthenticationPrincipal CustomMemberDetails memberDetails) {
return memberCommandService.deleteProfileImage(memberDetails.getId());
}

@GetMapping("/{memberId}/profile-image")
@GetMapping("/{member_id}/profile-image")
@Operation(summary = "사용자 프로필 사진 조회")
public ApiResponse<MemberResponseDTO.MemberImageDTO> getProfileImage(@PathVariable Long memberId) {
public ApiResponse<MemberResponseDTO.MemberImageDTO> getProfileImage(@PathVariable("member_id") Long memberId) {
return memberQueryService.getProfileImage(memberId);
}

@GetMapping("/profile/{member_id}")
@Operation(summary = "사용자 프로필 기본 정보 조회", description = "마이페이지 사용자 정보 조회 기능")
public ApiResponse<MemberResponseDTO.SimpleMemberDTO> getUserProfile(@PathVariable(value = "member_id") Long memberId){
Member member = memberCommandService.getRequester();
Member user = memberQueryService.getUserProfile(memberId);
return ApiResponse.onSuccess(SuccessStatus.MEMBER_OK, MemberConverter.toSimpleMemberResponseDto(member, user));
public ApiResponse<MemberResponseDTO.SimpleMemberDTO> getUserProfile(@AuthenticationPrincipal CustomMemberDetails memberDetails, @PathVariable(value = "member_id") Long memberId){
Member user = memberQueryService.getUserProfile(memberDetails.getId());
return ApiResponse.onSuccess(SuccessStatus.MEMBER_OK, MemberConverter.toSimpleMemberResponseDto(user, user));
}

@PutMapping("/info")
@Operation(summary = "사용자 정보 수정", description = "마이페이지 사용자 정보 수정 기능")
public ApiResponse<MemberResponseDTO.MemberInfoDTO> updateUserInfo(@Valid @RequestBody MemberRequestDTO.MemberInfoDTO request){
Member member = memberCommandService.getRequester();
Member updatedMember = memberCommandService.updateMemberInfo(member, request);
public ApiResponse<MemberResponseDTO.MemberInfoDTO> updateUserInfo(@AuthenticationPrincipal CustomMemberDetails memberDetails, @Valid @RequestBody MemberRequestDTO.MemberInfoDTO request){
Member updatedMember = memberCommandService.updateMemberInfo(memberDetails.getId(), request);
return ApiResponse.onSuccess(SuccessStatus.MEMBER_OK, MemberConverter.toMemberInfoResponseDto(updatedMember));
}

Expand All @@ -80,9 +75,8 @@ public ApiResponse<MemberResponseDTO.MemberInfoDTO> getUserInfo(@AuthenticationP

@PatchMapping("/techstack/{techstack_name}")
@Operation(summary = "사용자 기술스택 추가", description = "마이페이지 사용자 기술스택 추가 기능")
public ApiResponse<MemberResponseDTO.MemberTechStackDTO> addTechStack(@PathVariable(value = "techstack_name") TechStack techStackName){
Member member = memberCommandService.getRequester();
Member updatedMember = memberCommandService.addTechStack(member.getMemberId(),techStackName);
public ApiResponse<MemberResponseDTO.MemberTechStackDTO> addTechStack(@AuthenticationPrincipal CustomMemberDetails memberDetails, @PathVariable(value = "techstack_name") TechStack techStackName){
Member updatedMember = memberCommandService.addTechStack(memberDetails.getId(), techStackName);
return ApiResponse.onSuccess(SuccessStatus.MEMBER_OK, MemberConverter.toMemberTechStackResponseDto(updatedMember));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public Optional<Member> findByIdWithFollowers(Long id) {

private void fetchMemberProjects(Long userId, Member fetchedMember) {
List<Project> projects = queryFactory
.selectFrom(project)
.select(project)
.from(member)
.leftJoin(member.projectList, project)
.where(member.memberId.eq(userId)
.and(project.deletedAt.isNull()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public Member getRequester() {
}

@Transactional
public ApiResponse<MemberResponseDTO.MemberImageDTO> updateProfileImage(Member member, MemberRequestDTO.MemberProfileImageRequestDTO request) {
public ApiResponse<MemberResponseDTO.MemberImageDTO> updateProfileImage(Long memberId, MemberRequestDTO.MemberProfileImageRequestDTO request) {
Member member = memberRepository.findById(memberId).orElseThrow(() -> new GeneralException(ErrorStatus.MEMBER_NOT_FOUND));

if (member.getImage() != null) {
s3Manager.deleteFile(member.getImage().getImageUrl());
memberImageRepository.delete(member.getImage());
Expand All @@ -67,7 +69,8 @@ public ApiResponse<MemberResponseDTO.MemberImageDTO> updateProfileImage(Member m
}

@Transactional
public ApiResponse<String> deleteProfileImage(Member member) {
public ApiResponse<String> deleteProfileImage(Long memberId) {
Member member = memberRepository.findById(memberId).orElseThrow(() -> new GeneralException(ErrorStatus.MEMBER_NOT_FOUND));
if (member.getImage() != null) {
s3Manager.deleteFile(member.getImage().getImageUrl());
memberImageRepository.delete(member.getImage());
Expand All @@ -78,7 +81,8 @@ public ApiResponse<String> deleteProfileImage(Member member) {
}

@Transactional
public Member updateMemberInfo(Member member, MemberRequestDTO.MemberInfoDTO request){
public Member updateMemberInfo(Long memberId, MemberRequestDTO.MemberInfoDTO request){
Member member = memberRepository.findById(memberId).orElseThrow(() -> new GeneralException(ErrorStatus.MEMBER_NOT_FOUND));
member.updateInfo(request);
return memberRepository.save(member);
}
Expand Down

0 comments on commit 952ee9a

Please sign in to comment.