-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: 일정 수정 API #23
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
Feat: 일정 수정 API #23
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e19b202
[#19] feat: service 인터페이스 제거 & Mapper 적용
west-eastH d050feb
Merge remote-tracking branch 'origin/develop' into feat/19-event
west-eastH 8441418
Merge develop branch
west-eastH 4f95827
[#19] feat: 일정 수정 API
west-eastH 143eab7
[#19] test: 일정 수정 테스트 코드
west-eastH 879d381
[#19] chore: 더미 데이터 생성 스크립트 제거
west-eastH 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
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
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
60 changes: 41 additions & 19 deletions
60
src/main/java/run/backend/domain/event/mapper/EventMapper.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,29 +1,51 @@ | ||
| package run.backend.domain.event.mapper; | ||
|
|
||
| import org.springframework.stereotype.Component; | ||
| import java.util.List; | ||
| import org.mapstruct.Mapper; | ||
| import org.mapstruct.Mapping; | ||
| import org.mapstruct.ReportingPolicy; | ||
| import run.backend.domain.crew.dto.response.EventProfileResponse; | ||
| import run.backend.domain.crew.entity.Crew; | ||
| import run.backend.domain.event.dto.request.EventInfoRequest; | ||
| import run.backend.domain.event.entity.Event; | ||
| import run.backend.domain.event.entity.JoinEvent; | ||
| import run.backend.domain.event.entity.PeriodicEvent; | ||
| import run.backend.domain.member.entity.Member; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| @Mapper( | ||
| componentModel = "spring", | ||
| unmappedTargetPolicy = ReportingPolicy.IGNORE | ||
| ) | ||
| public interface EventMapper { | ||
|
|
||
| @Component | ||
| public class EventMapper { | ||
| @Mapping(target = "date", source = "request.baseDate") | ||
| @Mapping(target = "member", source = "runningCaptain") | ||
| Event toEvent(EventInfoRequest request, Crew crew, Member runningCaptain); | ||
|
|
||
| public List<EventProfileResponse> toEventProfileList(List<Event> events) { | ||
| return events.stream() | ||
| .map(this::toEventProfile) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| @Mapping(target = "member", source = "runningCaptain") | ||
| PeriodicEvent toPeriodicEvent(EventInfoRequest request, Crew crew, Member runningCaptain); | ||
|
|
||
| @Mapping(target = "member", source = "runningCaptain") | ||
| @Mapping(target = "event", source = "event") | ||
| JoinEvent toJoinEvent(Event event, Member runningCaptain); | ||
|
|
||
| @Mapping(target = "eventId", source = "id") | ||
| @Mapping(target = "participants", source = "expectedParticipants") | ||
| EventProfileResponse toEventProfile(Event event); | ||
|
|
||
| List<EventProfileResponse> toEventProfileList(List<Event> events); | ||
|
|
||
| public EventProfileResponse toEventProfile(Event event) { | ||
| return EventProfileResponse.builder() | ||
| .eventId(event.getId()) | ||
| .title(event.getTitle()) | ||
| .date(event.getDate()) | ||
| .startTime(event.getStartTime()) | ||
| .endTime(event.getEndTime()) | ||
| .participants(event.getExpectedParticipants()) | ||
| .build(); | ||
| default EventInfoRequest toEventInfoRequest(EventInfoRequest updateRequest, Event event) { | ||
| return new EventInfoRequest( | ||
| updateRequest.title() != null ? updateRequest.title() : event.getTitle(), | ||
| updateRequest.baseDate() != null ? updateRequest.baseDate() : event.getDate(), | ||
| updateRequest.repeatCycle(), | ||
| updateRequest.repeatDays(), | ||
| updateRequest.startTime() != null ? updateRequest.startTime() : event.getStartTime(), | ||
| updateRequest.endTime() != null ? updateRequest.endTime() : event.getEndTime(), | ||
| updateRequest.place() != null ? updateRequest.place() : event.getPlace(), | ||
| updateRequest.runningCaptainId() != null ? updateRequest.runningCaptainId() | ||
| : event.getMember().getId() | ||
| ); | ||
| } | ||
| } | ||
6 changes: 5 additions & 1 deletion
6
src/main/java/run/backend/domain/event/repository/JoinEventRepository.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,8 +1,12 @@ | ||
| package run.backend.domain.event.repository; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import run.backend.domain.event.entity.Event; | ||
| import run.backend.domain.event.entity.JoinEvent; | ||
| import run.backend.domain.member.entity.Member; | ||
|
|
||
| public interface JoinEventRepository extends JpaRepository<JoinEvent, Long> { | ||
|
|
||
|
|
||
| void deleteByEventAndMember(Event event, Member member); | ||
|
|
||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/run/backend/domain/event/repository/PeriodicEventRepository.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,28 @@ | ||
| package run.backend.domain.event.repository; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
| import run.backend.domain.crew.entity.Crew; | ||
| import run.backend.domain.event.entity.PeriodicEvent; | ||
|
|
||
| import java.time.LocalTime; | ||
| import java.util.Optional; | ||
|
|
||
| public interface PeriodicEventRepository extends JpaRepository<PeriodicEvent, Long> { | ||
|
|
||
| @Query(""" | ||
| SELECT pe | ||
| FROM PeriodicEvent pe | ||
| WHERE pe.crew = :crew | ||
| AND pe.title = :title | ||
| AND pe.startTime = :startTime | ||
| AND pe.endTime = :endTime | ||
| """) | ||
| Optional<PeriodicEvent> findByCrewAndTitleAndTime( | ||
| @Param("crew") Crew crew, | ||
| @Param("title") String title, | ||
| @Param("startTime") LocalTime startTime, | ||
| @Param("endTime") LocalTime endTime | ||
| ); | ||
| } |
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.
우와 이렇게만 하면 자동으로 매칭이 되는거군요..!