[#1]; refact : 4계층 적용#2
Open
Shin-Yun-Cheol wants to merge 5 commits into
Open
Conversation
- application, business, implement, repository로 크게 4계층을 적용
- business 의 service를 굳이 impl과 나누지 않아도 될 것 같아서 다시 변경
- service에서 Repository바로 접근 보다 implement에서 repository를 접근해서 service에서는 흐름을 볼 수 있게 수정
- dto는 controller에서, command와 result는 service에서 사용할 수 있도록 하여 각자 다른 걸 참조할 수 있도록 수정
seulnan
requested changes
Oct 2, 2025
seulnan
left a comment
Collaborator
There was a problem hiding this comment.
고생하셨습니다 아직 4계층에 대한 적용이 조금 서툰모습들이 보이네요 점차 나아질거라 믿습니다 파이팅입니다
| String content | ||
| ) { | ||
| public UpdatePostCommand{ | ||
| if(id==null) throw new IllegalArgumentException("id is null"); |
Collaborator
|
|
||
| Post saved = postWriter.save( | ||
| Post.builder() | ||
| .title(createPostCommand.title()) |
Collaborator
There was a problem hiding this comment.
엥 제가 빌더패턴말고 정적팩토리메소드를 한번 써보라고했었는데.........왜 써야할까요?
|
|
||
| @PostMapping("/signup") | ||
| public SignUpResponse signup(@RequestBody SignUpRequest req) { | ||
| var cmd = new SignUpCommand(req.email(), req.password(), req.username()); |
Collaborator
There was a problem hiding this comment.
command를 controller에서 생성하는게 책임분리면에서 옳을까요? new로 생성하는게 왜 권장되지않을까요? 그럼 new를 사용하지않으면 어떻게 해야할까요??
Comment on lines
+9
to
+12
| if(email==null || email.isBlank()) throw new IllegalArgumentException("email is null or empty"); | ||
| if(password==null || password.isBlank()) throw new IllegalArgumentException("password is null or empty"); | ||
| if(username==null || username.isBlank()) throw new IllegalArgumentException("username is null or empty"); | ||
| } |
Collaborator
There was a problem hiding this comment.
여기도 위에서 얘기한대로 어노테이션으로 충분해요
Comment on lines
25
to
29
| User.builder() | ||
| .email(signUpRequest.email()) | ||
| .email(signUpCommand.email()) | ||
| .passwordHash(hashedPassword) | ||
| .username(signUpRequest.username()) | ||
| .username(signUpCommand.username()) | ||
| .build() |
Collaborator
There was a problem hiding this comment.
이거도 builder말고 정적팩토리메소드를 알아보시면 좋을듯해요
Comment on lines
+19
to
21
| if(userRepository.existsByEmail(signUpCommand.email())){ | ||
| throw new IllegalArgumentException("email already in use"); | ||
| } |
Collaborator
There was a problem hiding this comment.
큰 흐름을 보여주는 business layer에서 예외를 던지는게 맞을까요?? 그리고 이메일중복검증은 어느계층에 두는게 맞을까요?
Comment on lines
+14
to
+15
| return userRepository.findByEmail(email) | ||
| .orElseThrow(()->new IllegalArgumentException("email not found")); |
|
|
||
| @PostMapping | ||
| public PostCreateResponse create(@RequestBody @Valid CreatePostRequest req) { | ||
| var cmd = new CreatePostCommand(req.email(), req.password(), req.title(), req.content()); |
Collaborator
There was a problem hiding this comment.
new로 command를 생성하는 이유가 있을까요?
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Oct 2, 2025
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Oct 2, 2025
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Oct 2, 2025
- business계층에서 builder 패턴을 이용하던걸 정적팩토리 메소드를 이용해서 각 엔티티에서 생성할 수 있도록 수정
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Nov 4, 2025
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Nov 4, 2025
- business계층에서 builder 패턴을 이용하던걸 정적팩토리 메소드를 이용해서 각 엔티티에서 생성할 수 있도록 수정
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Nov 4, 2025
- Controller에서 command생성하던걸 dto에서 command로 변환하고 정적팩토리로 변환해서 service에 이용
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Nov 4, 2025
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Nov 4, 2025
- BusinessException이라는 클래스를 둬서 에러처리할 수 있게 하고 각 도메인별 커스텀 예외를 만듦. ErrorResponse객체와 GlobalExceptionHandler로 예외를 관리
Shin-Yun-Cheol
added a commit
that referenced
this pull request
Nov 4, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[#1]; refact
application, business, implement, repository로 이루어진 4계층 적용.
하고 있는 일
단위 테스트 작성중