-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: 장부 내역 등록 API #19
Conversation
68caa1a
to
1a4b890
Compare
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.
고생 많으셨습니다!!!
if(fundType.equals(FundType.EXPENSE)) return -amount; | ||
return amount; |
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.
dto, service 혹은 이 클래스에서 한 번 정도는 null check를 해주면 좋을 것 같아요.
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.
추후 @Valid
로 유효성 검증 할 예정이예요 null 체크 좋네요!
User user = userService.validateUser(userId); | ||
|
||
// 2. 유저 소속 검증 | ||
AgencyUser agencyUser = agencyService.validateAgencyUser(userId); |
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.
String userToken으로 입력을 받고 요거로 검증할 수 있을까요?? 👍
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.
우선은 userId
로 가져가려고 합니다..! 추후 유저 로직 구현되면 한번 더 고민하도록 하겠습니다.
return ledgerDocuments.stream() | ||
.map(ledgerDocumentRepository::save) | ||
.toList(); |
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.
다른 stream 연산을 사용하지 않으신다면, saveAll()은 어떠신가요?
ref
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.
레퍼런스 읽었습니다. 이 부분 제가 알기로는 save
와 saveAll
의 성능 차이는 없는 것으로 알고있습니다..!
// 4. 유저 권한 검증 | ||
if(!agencyUser.getAgencyUserRole().equals(AgencyUserRole.STAFF)) { | ||
throw new InvalidAccessException(ErrorCode.INVALID_LEDGER_ACCESS); | ||
} |
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.
이 로직을 AgencyUser 엔티티 내부에서 처리하는 것은 어떨까요?
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.
'소속 내 운영진 권한일 경우에 장부 내역을 등록할 수 있다' 라는 비즈니스 로직에 대한 검증이여서 Ledger 내에 있는 것이 맞을 것 같아요.
🤔배경
장부 내역 등록(수동 · 자동) 기능을 개발합니다.
📄 작업 사항
존재하지 않는 회원입니다.
)소속에 가입 후 장부를 사용할 수 있습니다.
)장부가 존재하지 않습니다.
)유효하지 않은 접근입니다.
)0원 ~ 999,999,999원까지 기입 가능합니다.
)💻 테스트 화면
성공 응답 케이스
예외 검증