This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/toast-251
- Loading branch information
Showing
68 changed files
with
873 additions
and
307 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
8 changes: 5 additions & 3 deletions
8
backend/src/main/java/org/donggle/backend/application/repository/TokenRepository.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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package org.donggle.backend.application.repository; | ||
|
||
import org.donggle.backend.auth.JwtToken; | ||
import org.donggle.backend.auth.RefreshToken; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface TokenRepository extends JpaRepository<JwtToken, Long> { | ||
Optional<JwtToken> findByMemberId(final Long memberId); | ||
public interface TokenRepository extends JpaRepository<RefreshToken, Long> { | ||
Optional<RefreshToken> findByMemberId(final Long memberId); | ||
|
||
void deleteByMemberId(Long memberId); | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...end/src/main/java/org/donggle/backend/application/service/request/CategoryAddRequest.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package org.donggle.backend.application.service.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record CategoryAddRequest( | ||
@NotNull(message = "์นดํ ๊ณ ๋ฆฌ ์ด๋ฆ์ ์ ๋ ฅํด์ฃผ์ธ์.") | ||
@NotBlank(message = "์นดํ ๊ณ ๋ฆฌ ์ด๋ฆ์ ์ ๋ ฅํด์ฃผ์ธ์.") | ||
String categoryName | ||
) { | ||
} |
4 changes: 3 additions & 1 deletion
4
.../src/main/java/org/donggle/backend/application/service/request/CategoryModifyRequest.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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
package org.donggle.backend.application.service.request; | ||
|
||
public record CategoryModifyRequest(String categoryName, Long nextCategoryId) { | ||
public record CategoryModifyRequest( | ||
String categoryName, | ||
Long nextCategoryId) { | ||
} |
60 changes: 38 additions & 22 deletions
60
...c/main/java/org/donggle/backend/application/service/vendor/tistory/TistoryApiService.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 |
---|---|---|
@@ -1,69 +1,85 @@ | ||
package org.donggle.backend.application.service.vendor.tistory; | ||
|
||
import org.donggle.backend.application.service.vendor.exception.VendorApiInternalServerError; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.TistoryBlogInfoResponseWrapper; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.TistoryBlogResponse; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.request.TistoryPublishPropertyRequest; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.request.TistoryPublishRequest; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.response.TistoryPublishStatusResponse; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.response.TistoryPublishWritingResponse; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.response.TistoryResponse; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.response.TistoryGetWritingResponseWrapper; | ||
import org.donggle.backend.application.service.vendor.tistory.dto.response.TistoryPublishWritingResponseWrapper; | ||
import org.springframework.http.HttpStatusCode; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
|
||
import static org.donggle.backend.application.service.vendor.exception.VendorApiException.handle4xxException; | ||
|
||
public class TistoryApiService { | ||
public static final String PLATFORM_NAME = "Tistory"; | ||
private static final String TISTORY_URL = "https://www.tistory.com/apis"; | ||
private static final int OK = 200; | ||
|
||
private final WebClient webClient; | ||
|
||
public TistoryApiService() { | ||
this.webClient = WebClient.create(TISTORY_URL); | ||
} | ||
|
||
public TistoryPublishWritingResponse publishContent(final TistoryPublishRequest request) { | ||
final TistoryPublishStatusResponse response = webClient.post() | ||
public TistoryGetWritingResponseWrapper publishContent(final TistoryPublishRequest request) { | ||
final TistoryPublishWritingResponseWrapper response = webClient.post() | ||
.uri("/post/write?") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.bodyValue(request) | ||
.retrieve() | ||
.onStatus(HttpStatusCode::is4xxClientError, clientResponse -> handle4xxException(clientResponse.statusCode().value(), PLATFORM_NAME)) | ||
.onStatus(HttpStatusCode::is5xxServerError, clientResponse -> clientResponse.bodyToMono(String.class) | ||
.map(e -> new VendorApiInternalServerError(PLATFORM_NAME))) | ||
.bodyToMono(TistoryPublishStatusResponse.class) | ||
.bodyToMono(TistoryPublishWritingResponseWrapper.class) | ||
.block(); | ||
validateResponse(response); | ||
|
||
return findPublishProperty(makeTistoryPublishPropertyRequest(request, response)); | ||
} | ||
|
||
private TistoryPublishPropertyRequest makeTistoryPublishPropertyRequest(final TistoryPublishRequest request, final TistoryPublishStatusResponse response) { | ||
private TistoryPublishPropertyRequest makeTistoryPublishPropertyRequest(final TistoryPublishRequest request, final TistoryPublishWritingResponseWrapper response) { | ||
return TistoryPublishPropertyRequest.builder() | ||
.access_token(request.access_token()) | ||
.postId(response.tistory().postId()) | ||
.blogName(request.blogName()) | ||
.blogName(getDefaultTistoryBlogName(request.access_token())) | ||
.build(); | ||
} | ||
|
||
private void validateResponse(final TistoryResponse response) { | ||
if (response.getStatus() != OK) { | ||
throw new IllegalArgumentException("๋ธ๋ก๊ทธ๋ก ๋ฐํ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๋์ง ์์์ต๋๋ค."); | ||
} | ||
public String getDefaultTistoryBlogName(final String access_token) { | ||
final String blogInfoUri = UriComponentsBuilder.fromUriString(TISTORY_URL) | ||
.path("/blog/info") | ||
.queryParam("access_token", access_token) | ||
.queryParam("output", "json") | ||
.build() | ||
.toUriString(); | ||
final TistoryBlogInfoResponseWrapper blogInfo = webClient.get() | ||
.uri(blogInfoUri) | ||
.retrieve() | ||
.bodyToMono(TistoryBlogInfoResponseWrapper.class) | ||
.block(); | ||
return blogInfo.tistory().item().blogs().stream() | ||
.filter(blog -> blog.defaultValue().equals("Y")) | ||
.map(TistoryBlogResponse::name) | ||
.findFirst() | ||
.orElseThrow(); | ||
} | ||
|
||
public TistoryPublishWritingResponse findPublishProperty(final TistoryPublishPropertyRequest request) { | ||
public TistoryGetWritingResponseWrapper findPublishProperty(final TistoryPublishPropertyRequest request) { | ||
final String publishPropertyUri = UriComponentsBuilder.fromUriString("/post/read") | ||
.queryParam("access_token", request.access_token()) | ||
.queryParam("blogName", request.blogName()) | ||
.queryParam("postId", request.postId()) | ||
.queryParam("output", "json") | ||
.build() | ||
.toUriString(); | ||
return webClient.get() | ||
.uri("/post/read?" + | ||
"access_token=" + request.access_token() + | ||
"&blogName=" + request.blogName() + | ||
"&postId=" + request.postId() + | ||
"&output=json") | ||
.uri(publishPropertyUri) | ||
.retrieve() | ||
.onStatus(HttpStatusCode::is4xxClientError, clientResponse -> handle4xxException(clientResponse.statusCode().value(), PLATFORM_NAME)) | ||
.onStatus(HttpStatusCode::is5xxServerError, clientResponse -> clientResponse.bodyToMono(String.class) | ||
.map(e -> new VendorApiInternalServerError(PLATFORM_NAME))) | ||
.bodyToMono(TistoryPublishWritingResponse.class) | ||
.bodyToMono(TistoryGetWritingResponseWrapper.class) | ||
.block(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...a/org/donggle/backend/application/service/vendor/tistory/dto/TistoryBlogInfoResponse.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 org.donggle.backend.application.service.vendor.tistory.dto; | ||
|
||
import java.util.List; | ||
|
||
public record TistoryBlogInfoResponse( | ||
String id, | ||
Long userId, | ||
List<TistoryBlogResponse> blogs | ||
) { | ||
} |
8 changes: 8 additions & 0 deletions
8
...onggle/backend/application/service/vendor/tistory/dto/TistoryBlogInfoResponseWrapper.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,8 @@ | ||
package org.donggle.backend.application.service.vendor.tistory.dto; | ||
|
||
import org.donggle.backend.application.service.vendor.tistory.dto.response.TistoryItemResponse; | ||
|
||
public record TistoryBlogInfoResponseWrapper( | ||
TistoryItemResponse<TistoryBlogInfoResponse> tistory | ||
) { | ||
} |
Oops, something went wrong.