-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 저장된 시뮬레이션 목록 및 상세 조회 API 구현 #130
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
7 commits
Select commit
Hold shift + click to select a range
19b2ebd
fix(simulation): mark optional response fields NOT_REQUIRED instead o…
1117mg 90f72ca
feat(simulation): add saved simulation detail API
1117mg c818749
feat(simulation): add paginated my-simulations list API
1117mg 2d78373
chore(simulation): drop unused SimulationNotFoundException import
1117mg acf2383
fix(simulation): omit null fields from simulation item responses
1117mg 08a1160
fix(simulation): count only funded channels in list summaries
1117mg 7058ab0
docs(simulation): add a page/size example to the list API 400 response
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
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
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
68 changes: 68 additions & 0 deletions
68
src/main/java/chaeso/zip/server/simulation/application/dto/SimulationSummaryResponse.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,68 @@ | ||
| package chaeso.zip.server.simulation.application.dto; | ||
|
|
||
| import chaeso.zip.server.onboarding.domain.vo.CampaignPeriod; | ||
| import chaeso.zip.server.simulation.domain.entity.BudgetSimulation; | ||
| import chaeso.zip.server.simulation.domain.entity.BudgetSimulationItem; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.UUID; | ||
|
|
||
| @Schema(description = "저장된 시뮬레이션 목록 요약. 매체별 상세는 상세 조회에서 받는다") | ||
| public record SimulationSummaryResponse( | ||
| @Schema(description = "저장된 시뮬레이션 id", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| UUID simulationId, | ||
| @Schema(description = "저장 시각", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| LocalDateTime createdAt, | ||
| @Schema(description = "총 예산(원)", example = "3000000", | ||
| requiredMode = Schema.RequiredMode.REQUIRED) | ||
| long totalBudgetWon, | ||
| @Schema(description = "집행 기간(온보딩과 같은 구간)", example = "M1", | ||
| requiredMode = Schema.RequiredMode.REQUIRED) | ||
| CampaignPeriod period, | ||
| @Schema(description = "저장 당시 추정 노출 수 합(범위 중앙값 기준)", example = "1150000", | ||
| requiredMode = Schema.RequiredMode.REQUIRED) | ||
| long totalEstImpressions, | ||
| @Schema(description = "저장 당시 추정 클릭 수 합(범위 중앙값 기준)", example = "23000", | ||
| requiredMode = Schema.RequiredMode.REQUIRED) | ||
| long totalEstClicks, | ||
| @Schema(description = "예산을 배분한 매체 개수", example = "3", | ||
| requiredMode = Schema.RequiredMode.REQUIRED) | ||
| int channelCount, | ||
| @Schema(description = "집행 가능한 매체 개수", example = "2", | ||
| requiredMode = Schema.RequiredMode.REQUIRED) | ||
| int executableChannelCount, | ||
| @Schema(description = "어떤 조합이었는지 알아볼 수 있게 예산을 배분한 매체명만 최대 3개 보여 준다. null 이 아닌 배열", | ||
| requiredMode = Schema.RequiredMode.REQUIRED) | ||
| List<String> channelNames) { | ||
|
|
||
| /** 목록에서 조합을 알아볼 정도로만 보여 주는 대표 매체 수 */ | ||
| private static final int PREVIEW_CHANNEL_NAMES = 3; | ||
|
|
||
| /** | ||
| * 스냅샷에는 사용자가 담아만 두고 예산을 주지 않은 매체(배분 0원)도 상세 화면을 그대로 재현하려고 | ||
| * 남아 있다. 목록의 매체 수와 대표 매체명은 실제로 예산을 배분한 매체만 센다. | ||
| */ | ||
| public static SimulationSummaryResponse from(BudgetSimulation simulation, | ||
| List<BudgetSimulationItem> items, Map<UUID, String> channelNames) { | ||
| List<BudgetSimulationItem> allocated = items.stream() | ||
| .filter(item -> item.getAllocatedBudgetWon() > 0) | ||
| .toList(); | ||
| return new SimulationSummaryResponse( | ||
| simulation.getId(), | ||
| simulation.getCreatedAt(), | ||
| simulation.getTotalBudgetWon(), | ||
| simulation.getPeriod(), | ||
| simulation.getTotalEstImpressions(), | ||
| simulation.getTotalEstClicks(), | ||
| allocated.size(), | ||
| (int) allocated.stream().filter(BudgetSimulationItem::isExecutable).count(), | ||
| allocated.stream() | ||
| .map(item -> channelNames.get(item.getChannelId())) | ||
| .filter(Objects::nonNull) | ||
| .limit(PREVIEW_CHANNEL_NAMES) | ||
| .toList()); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/chaeso/zip/server/simulation/domain/SimulationErrorCode.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,17 @@ | ||
| package chaeso.zip.server.simulation.domain; | ||
|
|
||
| import chaeso.zip.server.common.exception.ErrorCode; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum SimulationErrorCode implements ErrorCode { | ||
|
|
||
| SIMULATION_NOT_FOUND(HttpStatus.NOT_FOUND, "SIM-001", "존재하지 않는 시뮬레이션입니다."); | ||
|
|
||
| private final HttpStatus httpStatus; | ||
| private final String code; | ||
| private final String message; | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/chaeso/zip/server/simulation/domain/SimulationNotFoundException.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,12 @@ | ||
| package chaeso.zip.server.simulation.domain; | ||
|
|
||
| import chaeso.zip.server.common.exception.BusinessException; | ||
| import java.util.UUID; | ||
|
|
||
| public class SimulationNotFoundException extends BusinessException { | ||
|
|
||
| public SimulationNotFoundException(UUID simulationId) { | ||
| super(SimulationErrorCode.SIMULATION_NOT_FOUND, | ||
| "존재하지 않는 시뮬레이션입니다. id=" + simulationId); | ||
| } | ||
| } |
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
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.