Repository navigation
[Feat/#125] 학생회비 납부 관리자 API 개편 #126
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
Open
xeoxxn
wants to merge
5
commits into
feat/#123-fee-app-api-revision
from
feat/#125-fee-admin-api-revision
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f63adc1
feat: 회비 상태 기준 회원 조회와 관리자 처리 규칙 추가
xeoxxn 1347c71
feat: 학생회비 납부 관리자 API 개편
xeoxxn 8dc8f5c
chore: 사용자 PR의 member 되돌림을 반영
xeoxxn e969b8e
refactor: 관리자 목록을 회비 쪽 기준으로 되돌리고 member 변경을 없앤다
xeoxxn d18e49d
refactor: 회비 메서드 이름을 하는 일에 맞춘다
xeoxxn 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
32 changes: 32 additions & 0 deletions
32
api/admin-api/src/main/java/kr/ac/kookmin/stream/api/admin/welfare/fee/FeeAccount.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,32 @@ | ||
| package kr.ac.kookmin.stream.api.admin.welfare.fee; | ||
|
|
||
| import kr.ac.kookmin.stream.welfare.domain.fee.service.FeeAmountCalculator; | ||
| import kr.ac.kookmin.stream.welfare.domain.fee.service.TossTransferLinkGenerator; | ||
|
|
||
| /** | ||
| * 관리자가 설정한 회비 납부 설정. 계좌는 전역 하나이고 학년도별로 나누지 않는다. | ||
| * <p> | ||
| * {@code api:app-api}에도 같은 모양의 record가 있다. 공유하지 않는 이유는 둘을 담을 자리가 없어서다 — | ||
| * {@code api:common-api}는 welfare·internal 모듈을 모르고, 그 의존을 추가하면 "role 무관 공통 인프라"라는 | ||
| * 그 모듈의 역할이 깨진다. 설정 키는 {@code FeeConfigKeys} 하나를 같이 쓰므로 값이 어긋나지는 않는다. | ||
| * | ||
| * @param bank 설정 전이면 null | ||
| * @param accountNo 설정 전이면 null | ||
| * @param amount 학기당 회비. 설정 전이면 기본값 | ||
| */ | ||
| public record FeeAccount(String bank, String accountNo, long amount) { | ||
|
|
||
| public boolean isConfigured() { | ||
| return bank != null && accountNo != null; | ||
| } | ||
|
|
||
| /** 금액이 빠진 송금 기본 링크. 계좌가 설정되기 전이면 null이다. */ | ||
| public String generateTransferLinkUrl() { | ||
| return isConfigured() ? TossTransferLinkGenerator.generate(bank, accountNo, null) : null; | ||
| } | ||
|
|
||
| /** 남은 학기 수를 낸 학생의 납부 금액. 아직 내지 않았으면 null이다. */ | ||
| public Long calculateTransferAmount(Integer remainingSemesters) { | ||
| return remainingSemesters == null ? null : FeeAmountCalculator.calculate(remainingSemesters, amount); | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
...dmin-api/src/main/java/kr/ac/kookmin/stream/api/admin/welfare/fee/FeeAccountProvider.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,41 @@ | ||
| package kr.ac.kookmin.stream.api.admin.welfare.fee; | ||
|
|
||
| import java.util.Map; | ||
| import kr.ac.kookmin.stream.internal.domain.config.service.AdminConfigValueService; | ||
| import kr.ac.kookmin.stream.welfare.WelfareConstants; | ||
| import kr.ac.kookmin.stream.welfare.domain.fee.domain.FeeConfigKeys; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * 회비 납부 설정을 읽고 쓴다. welfare 도메인은 internal 모듈에 의존할 수 없어 이 조합을 api에 둔다. | ||
| * <p> | ||
| * 학생 쪽과 달리 계좌가 없어도 예외를 던지지 않는다 — 관리자 화면은 "아직 설정하지 않음"을 보여주고 | ||
| * 그 자리에서 설정하게 해야 하기 때문이다. | ||
| */ | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class FeeAccountProvider { | ||
|
|
||
| private final AdminConfigValueService adminConfigValueService; | ||
|
|
||
| public FeeAccount getAccount() { | ||
| return new FeeAccount( | ||
| adminConfigValueService.getValue(FeeConfigKeys.TRANSFER_BANK).orElse(null), | ||
| adminConfigValueService.getValue(FeeConfigKeys.TRANSFER_ACCOUNT_NO).orElse(null), | ||
| adminConfigValueService.getValue(FeeConfigKeys.TRANSFER_AMOUNT) | ||
| .map(Long::parseLong) | ||
| .orElse(WelfareConstants.DEFAULT_TRANSFER_AMOUNT) | ||
| ); | ||
| } | ||
|
|
||
| // 계좌와 금액은 한 화면에서 같이 저장하므로 세 키를 한 번에 쓴다 | ||
| public FeeAccount save(String bank, String accountNo, long amount) { | ||
| adminConfigValueService.upsertValues(Map.of( | ||
| FeeConfigKeys.TRANSFER_BANK, bank, | ||
| FeeConfigKeys.TRANSFER_ACCOUNT_NO, accountNo, | ||
| FeeConfigKeys.TRANSFER_AMOUNT, String.valueOf(amount) | ||
| )); | ||
| return new FeeAccount(bank, accountNo, amount); | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
...min-api/src/main/java/kr/ac/kookmin/stream/api/admin/welfare/fee/FeeAccountValidator.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,39 @@ | ||
| package kr.ac.kookmin.stream.api.admin.welfare.fee; | ||
|
|
||
| import kr.ac.kookmin.stream.api.admin.welfare.fee.request.FeeAccountUpdateRequest; | ||
| import kr.ac.kookmin.stream.common.BusinessException; | ||
| import kr.ac.kookmin.stream.welfare.domain.fee.domain.FeeBanks; | ||
| import kr.ac.kookmin.stream.welfare.domain.fee.domain.FeeErrorCode; | ||
|
|
||
| /** | ||
| * 회비 납부 설정 입력 검증. 항목마다 전용 에러 코드를 내려줘야 해서 Bean Validation 대신 직접 본다 | ||
| * (fee-domain-study 08번 문서 — 애노테이션으로는 공통 INVALID_INPUT이 된다). | ||
| */ | ||
| final class FeeAccountValidator { | ||
|
|
||
| private static final int MIN_ACCOUNT_NO_LENGTH = 10; | ||
| private static final int MAX_ACCOUNT_NO_LENGTH = 14; | ||
|
|
||
| private FeeAccountValidator() {} | ||
|
|
||
| static void validate(FeeAccountUpdateRequest request) { | ||
| FeeBanks.validate(request.bank()); | ||
| validateAccountNo(request.accountNo()); | ||
| validateAmount(request.amount()); | ||
| } | ||
|
|
||
| private static void validateAccountNo(String accountNo) { | ||
| if (accountNo == null | ||
| || !accountNo.matches("^[0-9]+$") | ||
| || accountNo.length() < MIN_ACCOUNT_NO_LENGTH | ||
| || accountNo.length() > MAX_ACCOUNT_NO_LENGTH) { | ||
| throw new BusinessException(FeeErrorCode.INVALID_ACCOUNT_NO); | ||
| } | ||
| } | ||
|
|
||
| private static void validateAmount(Integer amount) { | ||
| if (amount == null || amount < 1) { | ||
| throw new BusinessException(FeeErrorCode.INVALID_TRANSFER_AMOUNT); | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
...main/java/kr/ac/kookmin/stream/api/admin/welfare/fee/request/FeeAccountUpdateRequest.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,21 @@ | ||
| package kr.ac.kookmin.stream.api.admin.welfare.fee.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| /** | ||
| * 회비 납부 설정 변경. 계좌와 학기당 회비를 한 화면에서 같이 저장하므로 함께 받는다. | ||
| * <p> | ||
| * 검증에 Bean Validation을 쓰지 않는다 — 항목마다 전용 에러 코드를 내려줘야 하는데 | ||
| * 애노테이션으로는 공통 INVALID_INPUT이 되기 때문이다(fee-domain-study 08번 문서). | ||
| */ | ||
| public record FeeAccountUpdateRequest( | ||
| @Schema(description = "은행명 (허용 목록 중 하나)", example = "카카오뱅크") | ||
| String bank, | ||
|
|
||
| @Schema(description = "계좌번호 (하이픈 제외, 10~14자리)", example = "3333011234567") | ||
| String accountNo, | ||
|
|
||
| @Schema(description = "학기당 학생회비", example = "20000") | ||
| Integer amount | ||
| ) { | ||
| } |
12 changes: 0 additions & 12 deletions
12
.../main/java/kr/ac/kookmin/stream/api/admin/welfare/fee/request/FeeAmountUpdateRequest.java
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
...rc/main/java/kr/ac/kookmin/stream/api/admin/welfare/fee/request/FeeLinkUpdateRequest.java
This file was deleted.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: billilge/stream-server
Length of output: 2684
🏁 Script executed:
Repository: billilge/stream-server
Length of output: 7227
🏁 Script executed:
Repository: billilge/stream-server
Length of output: 9478
status입력 검증을 복원하십시오.status가 없거나null인 요청은TransferStatus.from(null)을 통해null상태로 처리됩니다. 이후reviewed.getStatus().name()에서NullPointerException이 발생하고 500 응답으로 변환됩니다.status에@NotBlank를 추가하고 컨트롤러의@Valid를 복원하십시오.🐛 Suggested fix
🤖 Prompt for AI Agents
Source: Path instructions