-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Query/Command Adapter 적용 - Private/Team Exception 추가
- Loading branch information
Showing
26 changed files
with
390 additions
and
200 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
src/main/java/liaison/linkit/profile/business/ProfileMapper.java
This file contains 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,4 @@ | ||
package liaison.linkit.profile.business; | ||
|
||
public class ProfileMapper { | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/liaison/linkit/profile/exception/ProfileErrorCode.java
This file contains 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,33 @@ | ||
package liaison.linkit.profile.exception; | ||
|
||
import static liaison.linkit.common.consts.LinkitStatic.NOT_FOUND; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Objects; | ||
import liaison.linkit.common.annotation.ExplainError; | ||
import liaison.linkit.common.exception.BaseErrorCode; | ||
import liaison.linkit.common.exception.ErrorReason; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ProfileErrorCode implements BaseErrorCode { | ||
PROFILE_NOT_FOUND(NOT_FOUND, "PROFILE_404_1", "프로필을 찾을 수 없습니다."); | ||
|
||
private final Integer status; | ||
private final String code; | ||
private final String reason; | ||
|
||
@Override | ||
public ErrorReason getErrorReason() { | ||
return ErrorReason.builder().reason(reason).code(code).status(status).build(); | ||
} | ||
|
||
@Override | ||
public String getExplainError() throws NoSuchFieldException { | ||
Field field = this.getClass().getField(this.name()); | ||
ExplainError annotation = field.getAnnotation(ExplainError.class); | ||
return Objects.nonNull(annotation) ? annotation.value() : this.getReason(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/liaison/linkit/profile/exception/ProfileNotFoundException.java
This file contains 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,11 @@ | ||
package liaison.linkit.profile.exception; | ||
|
||
import liaison.linkit.common.exception.BaseCodeException; | ||
|
||
public class ProfileNotFoundException extends BaseCodeException { | ||
public static BaseCodeException EXCEPTION = new ProfileNotFoundException(); | ||
|
||
private ProfileNotFoundException() { | ||
super(ProfileErrorCode.PROFILE_NOT_FOUND); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/liaison/linkit/profile/implement/ProfileCommandAdapter.java
This file contains 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,4 @@ | ||
package liaison.linkit.profile.implement; | ||
|
||
public class ProfileCommandAdapter { | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/liaison/linkit/profile/implement/ProfileQueryAdapter.java
This file contains 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,23 @@ | ||
package liaison.linkit.profile.implement; | ||
|
||
import liaison.linkit.common.annotation.Adapter; | ||
import liaison.linkit.profile.domain.Profile; | ||
import liaison.linkit.profile.domain.repository.profile.ProfileRepository; | ||
import liaison.linkit.profile.exception.ProfileNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Adapter | ||
@RequiredArgsConstructor | ||
public class ProfileQueryAdapter { | ||
private final ProfileRepository profileRepository; | ||
|
||
public Profile findById(final Long profileId) { | ||
return profileRepository.findById(profileId) | ||
.orElseThrow(() -> ProfileNotFoundException.EXCEPTION); | ||
} | ||
|
||
public Profile findByMemberId(final Long memberId) { | ||
return profileRepository.findByMemberId(memberId) | ||
.orElseThrow(() -> ProfileNotFoundException.EXCEPTION); | ||
} | ||
} |
This file contains 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 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 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 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.