-
Notifications
You must be signed in to change notification settings - Fork 0
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
[BSVR-44] 영속성 계층 (JPA) 모듈 추가 #6
Changes from 3 commits
41a10d4
e3b288e
85dce71
82f8d7b
481905f
2bf0af9
62d7982
ca69e78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package org.depromeet.spot.application.config; | ||
|
||
import org.depromeet.spot.jpa.config.JpaConfig; | ||
import org.depromeet.spot.usecase.config.UsecaseConfig; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
|
||
@ComponentScan(basePackages = {"org.depromeet.spot.application"}) | ||
@Configuration | ||
@Import({JpaConfig.class}) | ||
@Import(value = {UsecaseConfig.class, JpaConfig.class}) | ||
public class SpotApplicationConfig {} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.depromeet.spot.application.member.dto.request; | ||
|
||
public record MemberRequest(String name) {} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ include("application") | |
include("infrastructure") | ||
include("infrastructure:jpa") | ||
findProject(":infrastructure:jpa")?.name = "jpa" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jpa로 이름 재정의하는거구나. 간결하게 파악하려고 하는 거 외에 다른 이유가 있어? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요거는 IntelliJ에서 모듈 생성하면 자동으로 작성되는 코드더라고! |
||
include("usecase") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기에서 논의 결과에 따라 usecase 모듈 추가 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
dependencies { | ||
implementation(project(":domain")) | ||
|
||
// spring | ||
implementation("org.springframework.boot:spring-boot-starter") | ||
implementation("org.springframework.boot:spring-boot-starter-web") | ||
} | ||
|
||
tasks.bootJar { enabled = false } | ||
tasks.jar { enabled = true } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.depromeet.spot.usecase.config; | ||
|
||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ComponentScan( | ||
basePackages = { | ||
"org.depromeet.spot.usecase.port", | ||
"org.depromeet.spot.usecase.service", | ||
}) | ||
public class UsecaseConfig {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.depromeet.spot.usecase.port.in; | ||
|
||
import org.depromeet.spot.domain.member.Member; | ||
|
||
public interface MemberUsecase { | ||
|
||
Member create(String name); | ||
} |
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.
UseCase에서도 Dto를 만들어서 한 번 더 검증을 수행하지 않은 건 우리 코드 복잡성이 아직 크지 않아서인거 맞아?
컨트롤러에서 MemberRequest로 HTTP요청에 대한 유효성을 검사하잖아(필수 필드가 왔는지, 유효한 형식인지) 등등, 그러면 Service로 넘길 때 UseCase에 대한 MemberDto를 사용하면 비지니스 로직에 대한 유효성을 검사할 수 있을 것 같아.
분리했을 때의 장점은 만약 우리가 API request에 대한 형식을 바꾸거나 확장하면서 업데이트 할 일이 생긴다면 비지니스 로직에 대한 데이터 검증은 UseCase에 역할을 덜어놨으니 MemberRequest dto에서만 수정을 하면 되고!
그래서 만약 UseCase Dto를 만든다면 수정방향은
Application 내의 controller
UseCase내의 MemberService.java
그리고 UseCase내에 MemberDto 추가..
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.
궁금한 점이 있어! usecase로 넘어갈 때 Dto를 한 번 더 사용하는 것의 이점이 뭘까?
라고 해줬는데, 어차피 로직에 참여하는 주체는 도메인이니까, 유효성 검사는 도메인에서 처리해야 하지 않을까?
DTO는 말 그대로 계층간 이동을 위해 존재하는 객체라서(data transfer), 여기에서 비즈니스 로직을 작성하는건 성격에 맞지 않는 것 같아.
이건 requestDto를 바로 도메인으로 바꾸는 지금과 동일한 것 같고.
DTO는 계층 이동에 사용되는 객체이고, usecase와 domain은 같은 계층이라는 생각이 들었어.
infrastructure는 영속성, application은 http로, 이후 충분히 변동 가능성이 있는 계층이지만, usecase와 domain은 모두 외부에 의존하는 값이 아니라 순수 Java로 동작할 계층이니까!
(ex. rdb는 nosql로, http 어플리케이션은 grpc로 바뀔 수 있지만, usecase와 domain은 항상 자바 로직일 것)
결과적으로 usecase dto는 도메인과 request/response의 맵퍼 정도의 역할만 수행해주는 것 같아. 혹시 내가 의도를 잘못 이해했다면 알려주어~
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.
I agree!! LGTM~