-
Notifications
You must be signed in to change notification settings - Fork 0
feat: member update API #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
579767e
[#14] feat: WebConfig 추가
choiseoji 06e99f8
[#14] feat: 테스트라서 members 엔드포인트 일단 허용하도록 시큐리티에 추가
choiseoji 7ed5f9b
[#14] feat: 임시 유저 반환하도록 수정
choiseoji 707a321
[#14] feat: 엔티티에 업데이트 메서드 추가
choiseoji 71f2b0c
[#14] feat: 회원 정보 수정하는 API 추가
choiseoji 41aff23
[#14] feat: 정보 request Dto에 설명 추가
choiseoji e036832
[#14] feat: 인터페이스에 회원 정보 수정 추가
choiseoji 4ab085a
[#14] feat: 멤버 정보 수정 서비스 코드 추가
choiseoji 0713621
Merge branch 'develop' into feat/14-member
choiseoji af799cd
[#14] feat: db update로 수정
choiseoji 9468e48
[#14] feat: 파일 삭제 실패 에러 코드 추가
choiseoji d6f9883
[#14] feat: 파일 삭제 실패 exception 추가
choiseoji 7b40e71
[#14] feat: 파일 삭제 메서드 추가
choiseoji fc2406d
[#14] feat: 멤버 정보 업데이트 중 파일 삭제 관련 추가
choiseoji 9a2fa9f
[#14] test: 멤버 정보 업데이트 테스트 코드 작성
choiseoji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
src/main/java/run/backend/domain/member/dto/request/MemberInfoRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,18 @@ | ||
| package run.backend.domain.member.dto.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import org.springframework.lang.Nullable; | ||
| import run.backend.domain.member.enums.Gender; | ||
|
|
||
| public record MemberInfoRequest( | ||
| @Nullable | ||
| @Schema(description = "성별", example = "FEMALE / MALE", nullable = true) | ||
| Gender gender, | ||
| int age, | ||
| @Nullable | ||
| @Schema(description = "나이", example = "24", nullable = true) | ||
| Integer age, | ||
| @Nullable | ||
| @Schema(description = "닉네임", example = "러너스", nullable = true) | ||
| String nickname | ||
| ) { | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/main/java/run/backend/domain/member/service/MemberService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,11 @@ | |
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
| import org.springframework.web.multipart.MultipartFile; | ||
| import run.backend.domain.crew.entity.Crew; | ||
| import run.backend.domain.crew.enums.JoinStatus; | ||
| import run.backend.domain.file.service.FileService; | ||
| import run.backend.domain.member.dto.request.MemberInfoRequest; | ||
| import run.backend.domain.member.dto.response.MemberInfoResponse; | ||
| import run.backend.domain.member.entity.Member; | ||
| import run.backend.domain.member.repository.MemberRepository; | ||
|
|
@@ -15,14 +18,41 @@ | |
| public class MemberServiceImpl implements MemberService { | ||
|
|
||
| private final MemberRepository memberRepository; | ||
| private final FileService fileService; | ||
|
|
||
| @Override | ||
| public MemberInfoResponse getMemberInfo(Member member) { | ||
|
|
||
| String crewName = memberRepository.findCrewByMemberIdAndStatus(member.getId(), JoinStatus.APPROVED) | ||
| .map(Crew::getName) | ||
| .orElse("N/A"); | ||
|
|
||
| return new MemberInfoResponse(member.getProfileImage(), member.getNickname(), crewName); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public void updateMemberInfo(Member member, String imageStatus, MultipartFile image, MemberInfoRequest data) { | ||
|
|
||
| switch (imageStatus) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 깔꼼하다👍 |
||
|
|
||
| case "updated" : | ||
| fileService.deleteImage(member.getProfileImage()); // 기존 이미지 지우기 | ||
| String newImageName = fileService.saveProfileImage(image); // 새로운 이미지 저장 | ||
| member.updateImage(newImageName); | ||
| break ; | ||
| case "removed" : | ||
| fileService.deleteImage(member.getProfileImage()); | ||
| member.updateImage("default-profile-image.png"); | ||
| break ; | ||
| } | ||
|
|
||
| if (data.gender() != null) | ||
| member.updateGender(data.gender()); | ||
| if (data.age() != null) | ||
| member.updateAge(data.age()); | ||
| if (data.nickname() != null) | ||
| member.updateNickname(data.nickname()); | ||
|
|
||
| memberRepository.save(member); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package run.backend.global.config; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
| import run.backend.global.annotation.member.LoginArgumentResolver; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Configuration | ||
| public class WebConfig implements WebMvcConfigurer { | ||
|
|
||
| private final LoginArgumentResolver loginArgumentResolver; | ||
|
|
||
| @Autowired | ||
| public WebConfig(LoginArgumentResolver loginArgumentResolver) { | ||
| this.loginArgumentResolver = loginArgumentResolver; | ||
| } | ||
|
|
||
| @Override | ||
| public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { | ||
| resolvers.add(loginArgumentResolver); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
성별은 변경 안되는거 어떤가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 피그마보고 한건데 그럼 디자이너 분들께 성별은 빼달라고 말할게요..!