Skip to content

Commit

Permalink
fix: 정적 팩토리 메서드를 생성자로 변경 #450
Browse files Browse the repository at this point in the history
  • Loading branch information
leegwichan committed Jan 3, 2025
1 parent b42e68c commit 0794d0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ public static BalanceContentAdminResponse create(TotalBalanceContent totalConten
return new BalanceContentAdminResponse(
totalContent.getContentId(),
totalContent.getContentName(),
BalanceOptionAdminResponse.existVoteResponse(
totalContent.getFirstOption(), totalVoteCount, firstOptionVoteCount),
BalanceOptionAdminResponse.existVoteResponse(
totalContent.getSecondOption(), totalVoteCount, secondOptionVoteCount)
new BalanceOptionAdminResponse(totalContent.getFirstOption(), totalVoteCount, firstOptionVoteCount),
new BalanceOptionAdminResponse(totalContent.getSecondOption(), totalVoteCount, secondOptionVoteCount)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public BalanceContentCreateResponse(BalanceContent content,
this(content.getId(),
content.getName(),
content.getCategory(),
BalanceOptionAdminResponse.notExistVoteResponse(firstOption),
BalanceOptionAdminResponse.notExistVoteResponse(secondOption));
new BalanceOptionAdminResponse(firstOption),
new BalanceOptionAdminResponse(secondOption));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ public record BalanceOptionAdminResponse(
private static final int NOT_EXIST_VOTE_COUNT = 0;
private static final int NOT_EXIST_VOTE_PERCENTAGE = 0;

public static BalanceOptionAdminResponse notExistVoteResponse(BalanceOption option) {
return new BalanceOptionAdminResponse(
public BalanceOptionAdminResponse(BalanceOption option) {
this(option.getId(), option.getName(), NOT_EXIST_VOTE_COUNT, NOT_EXIST_VOTE_PERCENTAGE);
}

public BalanceOptionAdminResponse(BalanceOption option, int contentVoteCount, int optionVoteCount) {
this(
option.getId(),
option.getName(),
NOT_EXIST_VOTE_COUNT,
NOT_EXIST_VOTE_PERCENTAGE
optionVoteCount,
PercentageCalculator.calculate(optionVoteCount, contentVoteCount)
);
}

Expand Down

0 comments on commit 0794d0f

Please sign in to comment.