-
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 #51 from YAPP-Github/feature/MAFOO-46
[MAFOO-46] feat: 여러 브랜드 추가
- Loading branch information
Showing
6 changed files
with
103 additions
and
0 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
32 changes: 32 additions & 0 deletions
32
photo-service/src/main/java/kr/mafoo/photo/service/vendors/MonoMansionQrVendor.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.photo.service.vendors; | ||
|
||
import kr.mafoo.photo.exception.PhotoQrUrlExpiredException; | ||
import kr.mafoo.photo.util.WebClientUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class MonoMansionQrVendor implements QrVendor { | ||
private final WebClient webClient; | ||
|
||
@Override | ||
public Mono<byte[]> extractImageFromQrUrl(String qrUrl) { | ||
String qrCode = extractQrCodeFromUrl(qrUrl); | ||
String imageUrl = String.format("https://monomansion.net/api/download.php?qrcode=%s&type=P", qrCode); | ||
return WebClientUtil | ||
.getBlob(webClient, imageUrl) | ||
.onErrorMap(e -> new PhotoQrUrlExpiredException()); | ||
} | ||
|
||
private String extractQrCodeFromUrl(String url) { | ||
return UriComponentsBuilder | ||
.fromUriString(url) | ||
.build() | ||
.getQueryParams() | ||
.getFirst("qrcode"); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
photo-service/src/main/java/kr/mafoo/photo/service/vendors/PhotoSignatureQrVendor.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,22 @@ | ||
package kr.mafoo.photo.service.vendors; | ||
|
||
import kr.mafoo.photo.exception.PhotoQrUrlExpiredException; | ||
import kr.mafoo.photo.util.WebClientUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class PhotoSignatureQrVendor implements QrVendor { | ||
private final WebClient webClient; | ||
|
||
@Override | ||
public Mono<byte[]> extractImageFromQrUrl(String qrUrl) { | ||
String imageUrl = qrUrl.replace("index.html", "a.jpg"); | ||
return WebClientUtil | ||
.getBlobByAnyMediaType(webClient, imageUrl) | ||
.onErrorMap(e -> new PhotoQrUrlExpiredException()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
photo-service/src/main/java/kr/mafoo/photo/service/vendors/PicDotQrVendor.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.photo.service.vendors; | ||
|
||
import kr.mafoo.photo.exception.PhotoQrUrlExpiredException; | ||
import kr.mafoo.photo.util.WebClientUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class PicDotQrVendor implements QrVendor { | ||
private final WebClient webClient; | ||
|
||
@Override | ||
public Mono<byte[]> extractImageFromQrUrl(String qrUrl) { | ||
String qrCode = extractQrCodeFromUrl(qrUrl); | ||
String imageUrl = String.format("https://picdot.kr/api/download.php?qrcode=%s&type=P", qrCode); | ||
return WebClientUtil | ||
.getBlob(webClient, imageUrl) | ||
.onErrorMap(e -> new PhotoQrUrlExpiredException()); | ||
} | ||
|
||
private String extractQrCodeFromUrl(String url) { | ||
return UriComponentsBuilder | ||
.fromUriString(url) | ||
.build() | ||
.getQueryParams() | ||
.getFirst("qrcode"); | ||
} | ||
} |
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