-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 채널 추천 결과 저장 API 구현 #133
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
Show all changes
5 commits
Select commit
Hold shift + click to select a range
766e59b
fix(security): scope the public recommendations path to GET
1117mg 999cf10
fix(openapi): publish data and error as required on response wrappers
1117mg 2ec534c
feat(recommendation): add channel recommendation save API
1117mg f491365
fix(recommendation): serialize saves per onboarding
1117mg 51bfabb
feat: add flyway migration v16
1117mg 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
48 changes: 48 additions & 0 deletions
48
src/main/java/chaeso/zip/server/common/config/ResponseWrapperSchemaCustomizer.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,48 @@ | ||
| package chaeso.zip.server.common.config; | ||
|
|
||
| import chaeso.zip.server.common.response.ApiResponse; | ||
| import io.swagger.v3.oas.models.media.Schema; | ||
| import java.util.Map; | ||
| import org.springdoc.core.customizers.OpenApiCustomizer; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| @Configuration | ||
| public class ResponseWrapperSchemaCustomizer { | ||
|
|
||
| private static final String WRAPPER = ApiResponse.class.getSimpleName(); | ||
| private static final String VOID_WRAPPER = WRAPPER + "Void"; | ||
| private static final String DATA = "data"; | ||
| private static final String ERROR = "error"; | ||
|
|
||
| @Bean | ||
| public OpenApiCustomizer responseWrapperRequiredFields() { | ||
| return openApi -> { | ||
| Map<String, Schema> schemas = openApi.getComponents().getSchemas(); | ||
| if (schemas == null) { | ||
| return; | ||
| } | ||
| schemas.forEach((name, schema) -> { | ||
| if (carriesPayload(name)) { | ||
| require(schema, DATA); | ||
| } else if (name.equals(WRAPPER)) { | ||
| require(schema, ERROR); | ||
| } | ||
| }); | ||
| }; | ||
| } | ||
|
|
||
| private boolean carriesPayload(String schemaName) { | ||
| return schemaName.startsWith(WRAPPER) | ||
| && !schemaName.equals(WRAPPER) | ||
| && !schemaName.equals(VOID_WRAPPER); | ||
| } | ||
|
|
||
| private void require(Schema<?> schema, String field) { | ||
| boolean present = schema.getProperties() != null && schema.getProperties().containsKey(field); | ||
| boolean alreadyRequired = schema.getRequired() != null && schema.getRequired().contains(field); | ||
| if (present && !alreadyRequired) { | ||
| schema.addRequiredItem(field); | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/chaeso/zip/server/onboarding/domain/repository/OnboardingRepository.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,14 +1,23 @@ | ||
| package chaeso.zip.server.onboarding.domain.repository; | ||
|
|
||
| import chaeso.zip.server.onboarding.domain.entity.Onboarding; | ||
| import jakarta.persistence.LockModeType; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.UUID; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Lock; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| /** | ||
| * 온보딩 응답 리포지토리 인터페이스. | ||
| */ | ||
| public interface OnboardingRepository extends JpaRepository<Onboarding, UUID> { | ||
|
|
||
| List<Onboarding> findByUserIdAndIsActiveTrue(UUID userId); | ||
|
|
||
| @Lock(LockModeType.PESSIMISTIC_WRITE) | ||
| @Query("select o from Onboarding o where o.id = :onboardingId") | ||
| Optional<Onboarding> findByIdForUpdate(@Param("onboardingId") UUID onboardingId); | ||
| } |
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.
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.