-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from YAPP-Github/feature/MAFOO-181
[MAFOO-181] feat: ๊ณต์ ์จ๋ฒ ๋์ ์ฌ์ฉ์ ๊ฒ์ API๋ฅผ ๊ตฌํํ์ด์
- Loading branch information
Showing
12 changed files
with
182 additions
and
9 deletions.
There are no files selected for viewing
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
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
42 changes: 42 additions & 0 deletions
42
user-service/src/main/java/kr/mafoo/user/controller/dto/response/MemberDetailResponse.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,42 @@ | ||
package kr.mafoo.user.controller.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import kr.mafoo.user.service.dto.MemberDetailDto; | ||
|
||
@Schema(description = "์ฌ์ฉ์์ ์ ๋ณด ์๋ต") | ||
public record MemberDetailResponse( | ||
@Schema(description = "์ฌ์ฉ์ ID", example = "test") | ||
String memberId, | ||
|
||
@Schema(description = "์ฌ์ฉ์ ์ด๋ฆ", example = "์ก์๋ฏผ") | ||
String name, | ||
|
||
@Schema(description = "ํ๋กํ ์ด๋ฏธ์ง URL", example = "https://mafoo.kr/profile.jpg") | ||
String profileImageUrl, | ||
|
||
@Schema(description = "์๋ณ ๋ฒํธ", example = "0000") | ||
String serialNumber, | ||
|
||
@Schema(description = "๊ณต์ ์ฌ์ฉ์ ID", example = "test_shared_member_id") | ||
String sharedMemberId, | ||
|
||
@Schema(description = "๊ณต์ ์ํ", example = "PENDING") | ||
String shareStatus, | ||
|
||
@Schema(description = "๊ถํ ๋จ๊ณ", example = "FULL_ACCESS") | ||
String permissionLevel | ||
) { | ||
public static MemberDetailResponse fromDto( | ||
MemberDetailDto dto | ||
) { | ||
return new MemberDetailResponse( | ||
dto.memberId(), | ||
dto.name(), | ||
dto.profileImageUrl(), | ||
dto.serialNumber(), | ||
dto.sharedMemberId(), | ||
dto.shareStatus(), | ||
dto.permissionLevel() | ||
); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
user-service/src/main/java/kr/mafoo/user/exception/MafooPhotoApiFailedException.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,7 @@ | ||
package kr.mafoo.user.exception; | ||
|
||
public class MafooPhotoApiFailedException extends DomainException { | ||
public MafooPhotoApiFailedException() { | ||
super(ErrorCode.MAFOO_PHOTO_API_FAILED); | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
user-service/src/main/java/kr/mafoo/user/service/SharedMemberService.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,32 @@ | ||
package kr.mafoo.user.service; | ||
import kr.mafoo.user.exception.MafooPhotoApiFailedException; | ||
import kr.mafoo.user.service.dto.SharedMemberDto; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class SharedMemberService { | ||
|
||
@Value("${app.gateway.endpoint}") | ||
private String endpoint; | ||
|
||
private final WebClient client; | ||
|
||
public Mono<SharedMemberDto> getSharedMemberInfoByAlbumId(String albumId, String memberId, String authorizationToken) { | ||
return client | ||
.get() | ||
.uri(endpoint + "/photo/v1/shared-members?albumId=" + albumId + "&memberId=" + memberId) | ||
.header("Authorization", "Bearer " + authorizationToken) | ||
.retrieve() | ||
.onStatus(status -> status.isSameCodeAs(HttpStatus.BAD_REQUEST), (res) -> Mono.empty()) | ||
.onStatus(status -> !status.is2xxSuccessful(), (res) -> Mono.error(new MafooPhotoApiFailedException())) | ||
.bodyToMono(SharedMemberDto.class); | ||
} | ||
|
||
} | ||
|
28 changes: 28 additions & 0 deletions
28
user-service/src/main/java/kr/mafoo/user/service/dto/MemberDetailDto.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,28 @@ | ||
package kr.mafoo.user.service.dto; | ||
|
||
import kr.mafoo.user.domain.MemberEntity; | ||
|
||
public record MemberDetailDto( | ||
String memberId, | ||
String name, | ||
String profileImageUrl, | ||
String serialNumber, | ||
String sharedMemberId, | ||
String shareStatus, | ||
String permissionLevel | ||
) { | ||
public static MemberDetailDto fromSharedMember( | ||
MemberEntity memberEntity, | ||
SharedMemberDto sharedMemberDto | ||
) { | ||
return new MemberDetailDto( | ||
memberEntity.getId(), | ||
memberEntity.getName(), | ||
memberEntity.getProfileImageUrl(), | ||
String.format("%04d", memberEntity.getSerialNumber()), | ||
sharedMemberDto.sharedMemberId(), | ||
sharedMemberDto.shareStatus(), | ||
sharedMemberDto.permissionLevel() | ||
); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
user-service/src/main/java/kr/mafoo/user/service/dto/SharedMemberDto.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,10 @@ | ||
package kr.mafoo.user.service.dto; | ||
|
||
public record SharedMemberDto( | ||
String sharedMemberId, | ||
String shareStatus, | ||
String permissionLevel, | ||
String albumId, | ||
String memberId | ||
) { | ||
} |