-
Notifications
You must be signed in to change notification settings - Fork 1
[feat] #139 페스티벌 공동 호스트 추가 API 구현 #140
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
6 changes: 6 additions & 0 deletions
6
src/main/java/org/festimate/team/api/admin/dto/AddHostRequest.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,6 @@ | ||
| package org.festimate.team.api.admin.dto; | ||
|
|
||
| public record AddHostRequest( | ||
| long participantId | ||
| ) { | ||
| } |
33 changes: 33 additions & 0 deletions
33
src/main/java/org/festimate/team/api/facade/FestivalHostFacade.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,33 @@ | ||
| package org.festimate.team.api.facade; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.festimate.team.api.admin.dto.AddHostRequest; | ||
| import org.festimate.team.domain.festival.entity.Festival; | ||
| import org.festimate.team.domain.festival.service.FestivalService; | ||
| import org.festimate.team.domain.festivalHost.service.FestivalHostService; | ||
| import org.festimate.team.domain.participant.entity.Participant; | ||
| import org.festimate.team.domain.participant.service.ParticipantService; | ||
| import org.festimate.team.domain.user.entity.User; | ||
| import org.festimate.team.domain.user.service.UserService; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class FestivalHostFacade { | ||
| private final UserService userService; | ||
| private final FestivalService festivalService; | ||
| private final FestivalHostService festivalHostService; | ||
| private final ParticipantService participantService; | ||
|
|
||
| @Transactional | ||
| public void addHost(Long userId, Long festivalId, AddHostRequest request) { | ||
| User host = userService.getUserByIdOrThrow(userId); | ||
| Festival festival = festivalService.getFestivalByIdOrThrow(festivalId); | ||
| festivalService.isHost(host, festival); | ||
|
|
||
| Participant participant = participantService.getParticipantById(request.participantId()); | ||
| User newHost = participant.getUser(); | ||
| festivalHostService.addHost(newHost, festival); | ||
| } | ||
2hyunjinn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
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
3 changes: 2 additions & 1 deletion
3
.../domain/festival/entity/FestivalHost.java → ...ain/festivalHost/entity/FestivalHost.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
8 changes: 8 additions & 0 deletions
8
src/main/java/org/festimate/team/domain/festivalHost/repository/FestivalHostRepository.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,8 @@ | ||
| package org.festimate.team.domain.festivalHost.repository; | ||
|
|
||
| import org.festimate.team.domain.festivalHost.entity.FestivalHost; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface FestivalHostRepository extends JpaRepository<FestivalHost, Long> { | ||
|
|
||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/org/festimate/team/domain/festivalHost/service/FestivalHostService.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,10 @@ | ||
| package org.festimate.team.domain.festivalHost.service; | ||
|
|
||
| import org.festimate.team.domain.festival.entity.Festival; | ||
| import org.festimate.team.domain.user.entity.User; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| public interface FestivalHostService { | ||
| @Transactional | ||
| void addHost(User newHost, Festival festival); | ||
| } |
30 changes: 30 additions & 0 deletions
30
...ain/java/org/festimate/team/domain/festivalHost/service/impl/FestivalHostServiceImpl.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,30 @@ | ||
| package org.festimate.team.domain.festivalHost.service.impl; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.festimate.team.domain.festival.entity.Festival; | ||
| import org.festimate.team.domain.festivalHost.entity.FestivalHost; | ||
| import org.festimate.team.domain.festivalHost.repository.FestivalHostRepository; | ||
| import org.festimate.team.domain.festivalHost.service.FestivalHostService; | ||
| import org.festimate.team.domain.user.entity.User; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class FestivalHostServiceImpl implements FestivalHostService { | ||
|
|
||
| private final FestivalHostRepository festivalHostRepository; | ||
|
|
||
| @Transactional | ||
| @Override | ||
| public void addHost(User newHost, Festival festival) { | ||
| FestivalHost newFestivalHost = FestivalHost.builder() | ||
| .festival(festival) | ||
| .host(newHost) | ||
| .build(); | ||
|
|
||
| festivalHostRepository.save(newFestivalHost); | ||
| } | ||
2hyunjinn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.