-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 멤버 기능 구현(#39) #43
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
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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/ject/studytrip/member/application/dto/CreateMemberCommand.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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.ject.studytrip.member.application.dto; | ||
|
|
||
| public record CreateMemberCommand( | ||
| String socialId, String email, String profileImage, String nickname, String category) { | ||
| public static CreateMemberCommand of( | ||
| String socialId, String email, String profileImage, String nickname, String category) { | ||
| return new CreateMemberCommand(socialId, email, profileImage, nickname, category); | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/ject/studytrip/member/application/dto/MemberDetail.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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.ject.studytrip.member.application.dto; | ||
|
|
||
| import com.ject.studytrip.trip.application.dto.TripCount; | ||
|
|
||
| public record MemberDetail(MemberInfo memberInfo, TripCount tripCount, long studyLogCount) { | ||
| public static MemberDetail from( | ||
| MemberInfo memberInfo, TripCount tripCount, long studyLogCount) { | ||
| return new MemberDetail(memberInfo, tripCount, studyLogCount); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/ject/studytrip/member/application/dto/MemberInfo.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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.ject.studytrip.member.application.dto; | ||
|
|
||
| import com.ject.studytrip.global.util.DateUtil; | ||
| import com.ject.studytrip.member.domain.model.Member; | ||
| import com.ject.studytrip.member.domain.model.MemberCategory; | ||
| import com.ject.studytrip.member.domain.model.MemberRole; | ||
| import com.ject.studytrip.member.domain.model.SocialProvider; | ||
|
|
||
| public record MemberInfo( | ||
| Long memberId, | ||
| SocialProvider socialProvider, | ||
| String socialId, | ||
| String email, | ||
| String nickname, | ||
| String profileImage, | ||
| MemberCategory category, | ||
| MemberRole role, | ||
| String createdAt, | ||
| String updatedAt, | ||
| String deletedAt) { | ||
| public static MemberInfo from(Member member) { | ||
| return new MemberInfo( | ||
| member.getId(), | ||
| member.getSocialProvider(), | ||
| member.getSocialId(), | ||
| member.getEmail(), | ||
| member.getNickname(), | ||
| member.getProfileImage(), | ||
| member.getCategory(), | ||
| member.getRole(), | ||
| DateUtil.formatDateTime(member.getCreatedAt()), | ||
| DateUtil.formatDateTime(member.getUpdatedAt()), | ||
| DateUtil.formatDateTime(member.getDeletedAt())); | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/ject/studytrip/member/application/facade/MemberFacade.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 |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.ject.studytrip.member.application.facade; | ||
|
|
||
| import com.ject.studytrip.member.application.dto.MemberDetail; | ||
| import com.ject.studytrip.member.application.dto.MemberInfo; | ||
| import com.ject.studytrip.member.application.service.MemberService; | ||
| import com.ject.studytrip.member.domain.model.Member; | ||
| import com.ject.studytrip.member.presentation.dto.request.UpdateMemberRequest; | ||
| import com.ject.studytrip.studylog.application.service.StudyLogService; | ||
| import com.ject.studytrip.trip.application.dto.TripCount; | ||
| import com.ject.studytrip.trip.application.service.TripService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class MemberFacade { | ||
| private final MemberService memberService; | ||
| private final TripService tripService; | ||
| private final StudyLogService studyLogService; | ||
|
|
||
| public void updateNicknameAndCategoryIfPresent(Long memberId, UpdateMemberRequest request) { | ||
| Member member = memberService.getActiveMemberById(memberId); | ||
|
|
||
| memberService.updateNicknameAndCategoryIfPresent(member, request); | ||
| } | ||
|
|
||
| public void deleteMember(Long memberId) { | ||
| Member member = memberService.getActiveMemberById(memberId); | ||
|
|
||
| memberService.deleteMember(member); | ||
| } | ||
|
|
||
| public MemberDetail getMemberDetail(Long memberId) { | ||
| Member member = memberService.getActiveMemberById(memberId); | ||
| TripCount tripCount = tripService.getActiveTripCountsByMemberId(memberId); | ||
| long studyLogCount = studyLogService.getActiveStudyLogCountByMemberId(memberId); | ||
|
|
||
| MemberInfo memberInfo = MemberInfo.from(member); | ||
|
|
||
| return MemberDetail.from(memberInfo, tripCount, studyLogCount); | ||
| } | ||
| } |
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
16 changes: 7 additions & 9 deletions
16
src/main/java/com/ject/studytrip/member/domain/policy/MemberPolicy.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,24 +1,22 @@ | ||
| package com.ject.studytrip.member.domain.policy; | ||
|
|
||
| import static io.jsonwebtoken.lang.Strings.hasText; | ||
|
|
||
| import com.ject.studytrip.global.exception.CustomException; | ||
| import com.ject.studytrip.member.domain.error.MemberErrorCode; | ||
| import com.ject.studytrip.member.domain.model.Member; | ||
| import lombok.AccessLevel; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public class MemberPolicy { | ||
|
|
||
| public static void validateNickname(String nickname) { | ||
| if (!hasText(nickname)) { | ||
| throw new CustomException(MemberErrorCode.MEMBER_NICKNAME_REQUIRED); | ||
| public static void validateNotDuplicated(boolean exists) { | ||
| if (exists) { | ||
| throw new CustomException(MemberErrorCode.MEMBER_ALREADY_EXISTS); | ||
| } | ||
| } | ||
|
|
||
| public static void validateNewMember(boolean exists) { | ||
| if (exists) { | ||
| throw new CustomException(MemberErrorCode.MEMBER_ALREADY_EXISTS); | ||
| public static void validateNotDeleted(Member member) { | ||
| if (member.getDeletedAt() != null) { | ||
| throw new CustomException(MemberErrorCode.MEMBER_ALREADY_DELETED); | ||
| } | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.