-
Notifications
You must be signed in to change notification settings - Fork 27
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
Feature/nyh365 step3 #31
Open
nyh365
wants to merge
54
commits into
base/nyh365
Choose a base branch
from
feature/nyh365_step3
base: base/nyh365
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,741
−1
Open
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
15352e9
chore: 프로젝트 설정
nyh365 e9a9162
chore: 프로젝트 설정
nyh365 4f37766
feat: baseEntity 추가
nyh365 98b35b0
feat: 예외처리 추가
nyh365 940eaec
feat: user 엔티티 추가
nyh365 31752c4
feat: account 엔티티 추가
nyh365 8b168a8
feat: 회원 등록 기능 추가
nyh365 0bb7b18
feat: 이메일로 회원 조회 기능 추가
nyh365 b39c88e
feat: 메인 계좌 생성 기능 추가
nyh365 ae4b0bf
feat: 적금 계좌 생성 기능 추가
nyh365 d8797fc
feat: 예외처리 추가
nyh365 0478f01
feat: 충전 한도 필드 추가
nyh365 245990d
feat: 이메일 존재 여부 함수 코드 단으로 변경
nyh365 37a4adc
feat: 메인 계좌 필드 추가
nyh365 1a6e47b
feat: 메인 계좌 충전 기능 추가
nyh365 def1910
feat: 인출 요청 및 응답 dto 추가
nyh365 bb9f31c
feat: 메인 계좌에서 적금 계좌로 인출하는 기능 추가
nyh365 49edc05
feat: 충전 한도 타입 수정
nyh365 9029292
feat: 충전 한도 타입 수정
nyh365 a39e1d5
chore: 프로젝트 설정
nyh365 53560c5
feat: 메세지큐 설정 추가
nyh365 cca982f
refactor: 충전 함수로 리팩토링
nyh365 6a14bdc
feat: 메인계좌 존재 여부 확인 기능 추가
nyh365 b0e4b4d
feat: 송금 기능 추가
nyh365 be1fb48
feat: 이벤트 발행 기능 추가
nyh365 a980471
feat: 비동기 실행을 위한 설정 추가
nyh365 4987099
feat: 송금 트랜잭션 엔티티 추가
nyh365 87eb9c6
feat: 송금 기능 추가
nyh365 18de610
feat: 송금 기능 추가
nyh365 0b47496
feat: 누락된 송금 내역 처리를 위한 스케줄러 추가
nyh365 2d85cde
feat: 충전 한도 0시 00분을 기점으로 초기화하는 스케줄러 추가
nyh365 7915c2c
refactor: 미사용 코드 제거
nyh365 aeed0bb
refactor: setter 제거
nyh365 965c0b2
refactor: 유효성 검증 코드 제거
nyh365 7aee74a
style: 주석 추가
nyh365 a0229d2
refactor: 변수명 변경 및 함수화
nyh365 7dcf5b4
refactor: 함수 위치 변경
nyh365 01e9522
refactor: 미사용 코드 제거
nyh365 c704a69
refactor: 미사용 코드 제거
nyh365 8e88df9
feat: 일일 한도 변경 쿼리 변경
nyh365 53eaf2c
chore: 메세지 큐 사용을 위한 설정 추가
nyh365 c4e4638
fix: 적금 계좌 조회 시 락 걸도록 수정
nyh365 0bcf0f1
feat: 대상 유저 수 조회 기능 추가
nyh365 83d0b55
feat: 정산 요청 내역 저장 기능 추가
nyh365 14eb44e
feat: 정산 상세 내역 저장 기능 추가
nyh365 a0ea42f
feat: 정산 엔티티 추가
nyh365 b8eaa19
feat: 정산 상세 내역 엔티티 추가
nyh365 e748dd4
feat: 정산 기능 추가
nyh365 babdff7
fix: 응답 코드 수정
nyh365 2c5b703
fix: 상수 타입 수정
nyh365 a15b04d
feat: 메서드 스코프 수정
nyh365 6c26829
refactor: 변수명 변경
nyh365 9db7511
refactor: 변수명 변경
nyh365 532c732
fix: SecureRandom으로 변경
nyh365 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
feat: 회원 등록 기능 추가
commit 8b168a8e80c824e03b6dd53ffd686bc15206a3c5
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/org/c4marathon/assignment/controller/UserController.java
This file contains 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,25 @@ | ||
package org.c4marathon.assignment.controller; | ||
|
||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.c4marathon.assignment.dto.request.PostUserReq; | ||
import org.c4marathon.assignment.service.UserService; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/v1/users") | ||
@RequiredArgsConstructor | ||
public class UserController { | ||
private final UserService userService; | ||
|
||
@PostMapping() | ||
public ResponseEntity<Void> registerUser(@RequestBody @Valid PostUserReq postUserReq) { | ||
userService.registerUser(postUserReq); | ||
return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/org/c4marathon/assignment/dto/request/PostUserReq.java
This file contains 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,20 @@ | ||
package org.c4marathon.assignment.dto.request; | ||
|
||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record PostUserReq( | ||
@Size(max = 100) | ||
@NotBlank | ||
String username, | ||
|
||
@NotBlank | ||
String email, | ||
|
||
@Size(max = 100) | ||
@NotBlank | ||
String nickname | ||
) { | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/c4marathon/assignment/repository/UserJpaRepository.java
This file contains 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,8 @@ | ||
package org.c4marathon.assignment.repository; | ||
|
||
import org.c4marathon.assignment.entity.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface UserJpaRepository extends JpaRepository<User, Long> { | ||
boolean existsByEmail(String email); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/org/c4marathon/assignment/repository/UserRepository.java
This file contains 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,20 @@ | ||
package org.c4marathon.assignment.repository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import org.c4marathon.assignment.entity.User; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class UserRepository { | ||
private final UserJpaRepository userJpaRepository; | ||
|
||
public boolean isEmailExist(String email) { | ||
return userJpaRepository.existsByEmail(email); | ||
} | ||
|
||
public User save(User user) { | ||
return userJpaRepository.save(user); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/c4marathon/assignment/service/UserService.java
This file contains 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 org.c4marathon.assignment.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.c4marathon.assignment.dto.request.PostUserReq; | ||
import org.c4marathon.assignment.entity.Account; | ||
import org.c4marathon.assignment.entity.User; | ||
import org.c4marathon.assignment.exception.CustomException; | ||
import org.c4marathon.assignment.exception.ErrorCode; | ||
import org.c4marathon.assignment.repository.AccountRepository; | ||
import org.c4marathon.assignment.repository.UserRepository; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UserService { | ||
private final UserRepository userRepository; | ||
private final AccountRepository accountRepository; | ||
|
||
@Transactional | ||
public void registerUser(PostUserReq postUserReq) { | ||
if (isEmailExist(postUserReq.email())) { | ||
throw new CustomException(ErrorCode.DUPLICATED_EMAIL); | ||
} | ||
|
||
User user = userRepository.save(User.builder() | ||
.username(postUserReq.username()) | ||
.email(postUserReq.email()) | ||
.nickname(postUserReq.nickname()) | ||
.build()); | ||
|
||
Account mainAccount = new Account(user.getId()); | ||
accountRepository.save(mainAccount); | ||
} | ||
|
||
public boolean isEmailExist(String email) { | ||
return userRepository.isEmailExist(email); | ||
} | ||
} |
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.
다른 곳에서 이벤트 리스너를 사용하셨으니 이 부분도 이벤트 리스너 사용해서 책임 분리를 하는 것은 어떻게 생각하시나요? 개인적인 의견이 궁금해서 남깁니다
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.
이벤트 리스너 사용 목적에 따라 다르긴한데, 제 생각에는 해당 기능에서 이벤트 리스너를 사용하는 이유가 책임을 분리하기 위한 것이라면 적용해도 괜찮을 것 같아요.