-
Notifications
You must be signed in to change notification settings - Fork 2
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] facade pattern - Topic #218
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fc6bd7e
facade pattern - topic
kimdozzi 62d1424
refactor: 정적 펙터리 메서드 네이밍 규칙 적용
kimdozzi 0e9e6a5
refactor: else 예약어 제거 및 변수명 수정
kimdozzi ff75d02
feat: topic repository 테스트 코드 리펙토링
kimdozzi a4c47ef
feat: topic service -> facade 테스트 코드 리펙토링
kimdozzi 52c4749
refactor: 코드 리뷰 피드백 반영
kimdozzi 60e7a69
refactor: TopicFacadeTest 리펙토링
kimdozzi 154c72f
refactor: 코드 수정
kimdozzi 9d38cea
refactor: 테스트 코드
kimdozzi 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
13 changes: 0 additions & 13 deletions
13
src/main/java/com/genius/gitget/admin/topic/dto/TopicCreateRequest.java
This file was deleted.
Oops, something went wrong.
87 changes: 0 additions & 87 deletions
87
src/main/java/com/genius/gitget/admin/topic/service/TopicService.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/main/java/com/genius/gitget/challenge/instance/domain/Instance.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
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
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
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
2 changes: 1 addition & 1 deletion
2
.../genius/gitget/admin/signout/Signout.java → ...va/com/genius/gitget/signout/Signout.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
2 changes: 1 addition & 1 deletion
2
...tget/admin/signout/SignoutRepository.java → ...ius/gitget/signout/SignoutRepository.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
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
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
23 changes: 23 additions & 0 deletions
23
src/main/java/com/genius/gitget/topic/dto/TopicCreateRequest.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,23 @@ | ||
package com.genius.gitget.topic.dto; | ||
|
||
import com.genius.gitget.topic.domain.Topic; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record TopicCreateRequest( | ||
String title, | ||
String tags, | ||
String description, | ||
int pointPerPerson, | ||
String notice | ||
) { | ||
public static Topic from(TopicCreateRequest topicCreateRequest) { | ||
return Topic.builder() | ||
.title(topicCreateRequest.title()) | ||
.description(topicCreateRequest.description()) | ||
.tags(topicCreateRequest.tags()) | ||
.pointPerPerson(topicCreateRequest.pointPerPerson()) | ||
.notice(topicCreateRequest.notice()) | ||
.build(); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...t/admin/topic/dto/TopicIndexResponse.java → .../gitget/topic/dto/TopicIndexResponse.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
6 changes: 3 additions & 3 deletions
6
.../admin/topic/dto/TopicPagingResponse.java → ...gitget/topic/dto/TopicPagingResponse.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
2 changes: 1 addition & 1 deletion
2
...t/admin/topic/dto/TopicUpdateRequest.java → .../gitget/topic/dto/TopicUpdateRequest.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.genius.gitget.admin.topic.dto; | ||
package com.genius.gitget.topic.dto; | ||
|
||
import lombok.Builder; | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
...min/topic/repository/TopicRepository.java → ...get/topic/repository/TopicRepository.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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/genius/gitget/topic/service/TopicService.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,42 @@ | ||
package com.genius.gitget.topic.service; | ||
|
||
import com.genius.gitget.global.util.exception.BusinessException; | ||
import com.genius.gitget.global.util.exception.ErrorCode; | ||
import com.genius.gitget.topic.domain.Topic; | ||
import com.genius.gitget.topic.repository.TopicRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@Transactional(readOnly = true) | ||
public class TopicService { | ||
private final TopicRepository topicRepository; | ||
|
||
public Page<Topic> findTopics(Pageable pageable) { | ||
return topicRepository.findAllById(pageable); | ||
} | ||
|
||
public Topic findOne(Long id) { | ||
return topicRepository.findById(id) | ||
.orElseThrow(() -> new BusinessException(ErrorCode.TOPIC_NOT_FOUND)); | ||
} | ||
|
||
@Transactional | ||
public Long create(Topic topic) { | ||
Topic savedTopic = topicRepository.save(topic); | ||
return savedTopic.getId(); | ||
} | ||
|
||
@Transactional | ||
public void delete(Long id) { | ||
Topic topic = topicRepository.findById(id) | ||
.orElseThrow(() -> new BusinessException(ErrorCode.TOPIC_NOT_FOUND)); | ||
topicRepository.delete(topic); | ||
} | ||
} |
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.
오! 정적 팩토리 메서드의 명명법을 따른 네이밍인가보네요! 👍
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.
이펙티브 자바에서 배운 걸 활용해봤습니다 ㅎ