-
Notifications
You must be signed in to change notification settings - Fork 1
[REFACTOR] 기관 선호 물품 리팩토링 #361
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
984bb1f
refactor(prefer-item): 기관 선호 물품 추가 삭제 리팩토링
leebs0521 f31bdb5
test(prefer-item): 기관 선호 물품 추가 삭제 리팩토링 테스트
leebs0521 222bbd6
test(prefer-item): 기관 선호 물품 추가 삭제 리팩토링 테스트
leebs0521 5ad2f66
refactor(prefer-item): 기관 선호 물품 조회 리팩토링
leebs0521 97b6577
refactor(prefer-item): 기관 선호 물품 조회 리팩토링
leebs0521 e08aba3
test(prefer-item): 기관 선호 물품 조회 리팩토링 테스트
leebs0521 6e325e9
chore(prefer-item): 기관 관련 클래스 패키지 이동에 따른 import 변경
leebs0521 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
5 changes: 2 additions & 3 deletions
5
...ore/domains/center/domain/PreferItem.java → ...om/somemore/center/domain/PreferItem.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
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
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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/somemore/center/dto/response/PreferItemResponseDto.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,28 @@ | ||
| package com.somemore.center.dto.response; | ||
|
|
||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
| import com.somemore.center.domain.PreferItem; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.util.UUID; | ||
| import lombok.Builder; | ||
|
|
||
| @JsonNaming(SnakeCaseStrategy.class) | ||
| @Builder | ||
| public record PreferItemResponseDto( | ||
| @Schema(description = "선호 물품 ID", example = "1") | ||
| Long id, | ||
| @Schema(description = "기관 ID", example = "123e4567-e89b-12d3-a456-426614174000") | ||
| UUID centerId, | ||
| @Schema(description = "선호 물품명", example = "쌀20kg") | ||
| String itemName | ||
| ) { | ||
|
|
||
| public static PreferItemResponseDto from(PreferItem preferItem) { | ||
| return PreferItemResponseDto.builder() | ||
| .id(preferItem.getId()) | ||
| .centerId(preferItem.getCenterId()) | ||
| .itemName(preferItem.getItemName()) | ||
| .build(); | ||
| } | ||
| } |
8 changes: 4 additions & 4 deletions
8
...y/preferitem/PreferItemJpaRepository.java → ...y/preferitem/PreferItemJpaRepository.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 |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| package com.somemore.domains.center.repository.preferitem; | ||
|
|
||
| import com.somemore.domains.center.domain.PreferItem; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| package com.somemore.center.repository.preferitem; | ||
|
|
||
| import com.somemore.center.domain.PreferItem; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface PreferItemJpaRepository extends JpaRepository<PreferItem, Long> { | ||
|
|
||
| List<PreferItem> findByCenterId(UUID centerId); | ||
| } |
8 changes: 4 additions & 4 deletions
8
...tory/preferitem/PreferItemRepository.java → ...tory/preferitem/PreferItemRepository.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
9 changes: 4 additions & 5 deletions
9
.../preferitem/PreferItemRepositoryImpl.java → .../preferitem/PreferItemRepositoryImpl.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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/somemore/center/service/CreatePreferItemService.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,35 @@ | ||
| package com.somemore.center.service; | ||
|
|
||
| import com.somemore.center.domain.PreferItem; | ||
| import com.somemore.center.dto.request.PreferItemCreateRequestDto; | ||
| import com.somemore.center.dto.response.PreferItemCreateResponseDto; | ||
| import com.somemore.center.repository.preferitem.PreferItemRepository; | ||
| import com.somemore.center.usecase.CreatePreferItemUseCase; | ||
| import com.somemore.center.usecase.NEWCenterQueryUseCase; | ||
| import java.util.UUID; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Transactional | ||
| @Service | ||
| public class CreatePreferItemService implements CreatePreferItemUseCase { | ||
|
|
||
| private final NEWCenterQueryUseCase centerQueryUseCase; | ||
| private final PreferItemRepository preferItemRepository; | ||
|
|
||
| @Override | ||
| public PreferItemCreateResponseDto createPreferItem(UUID centerId, | ||
| PreferItemCreateRequestDto requestDto) { | ||
|
|
||
| centerQueryUseCase.validateCenterExists(centerId); | ||
|
|
||
| PreferItem preferItem = requestDto.toEntity(centerId); | ||
|
|
||
| preferItemRepository.save(preferItem); | ||
|
|
||
| return PreferItemCreateResponseDto.from(preferItem); | ||
| } | ||
|
|
||
| } | ||
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/somemore/center/usecase/CreatePreferItemUseCase.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,11 @@ | ||
| package com.somemore.center.usecase; | ||
|
|
||
| import com.somemore.center.dto.request.PreferItemCreateRequestDto; | ||
| import com.somemore.center.dto.response.PreferItemCreateResponseDto; | ||
| import java.util.UUID; | ||
|
|
||
| public interface CreatePreferItemUseCase { | ||
|
|
||
| PreferItemCreateResponseDto createPreferItem(UUID centerId, | ||
| PreferItemCreateRequestDto requestDto); | ||
| } |
3 changes: 2 additions & 1 deletion
3
...case/command/DeletePreferItemUseCase.java → ...nter/usecase/DeletePreferItemUseCase.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 |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| package com.somemore.domains.center.usecase.command; | ||
| package com.somemore.center.usecase; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| public interface DeletePreferItemUseCase { | ||
|
|
||
| void deletePreferItem(UUID centerId, Long preferItemId); | ||
| } |
8 changes: 4 additions & 4 deletions
8
...usecase/query/PreferItemQueryUseCase.java → ...enter/usecase/PreferItemQueryUseCase.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
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.
dto.toEntity와 entity.from, entity.of를 구분하는 기준이 있으신가요?
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.
이거 서진님이 작성하신 코드긴한데
저는
RequestDto->Entity는 무조건Dto.toEntity를 사용하고Entity->ResponseDto는 파라미터 개수에 따라 1개from2개이상of를 사용하는 편이긴합니다.