-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 스탬프 기능 구현(#23) #29
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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/ject/studytrip/mission/application/dto/MissionInfo.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,24 @@ | ||
| package com.ject.studytrip.mission.application.dto; | ||
|
|
||
| import com.ject.studytrip.global.util.DateUtil; | ||
| import com.ject.studytrip.mission.domain.model.Mission; | ||
|
|
||
| public record MissionInfo( | ||
| Long missionId, | ||
| String missionName, | ||
| int missionOrder, | ||
| boolean completed, | ||
| String createdAt, | ||
| String updatedAt, | ||
| String deletedAt) { | ||
| public static MissionInfo from(Mission mission) { | ||
| return new MissionInfo( | ||
| mission.getId(), | ||
| mission.getName(), | ||
| mission.getMissionOrder(), | ||
| mission.isCompleted(), | ||
| DateUtil.formatDateTime(mission.getCreatedAt()), | ||
| DateUtil.formatDateTime(mission.getUpdatedAt()), | ||
| DateUtil.formatDateTime(mission.getDeletedAt())); | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/ject/studytrip/mission/application/service/MissionService.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,20 @@ | ||
| package com.ject.studytrip.mission.application.service; | ||
|
|
||
| import com.ject.studytrip.mission.application.dto.MissionInfo; | ||
| import com.ject.studytrip.mission.domain.model.Mission; | ||
| import com.ject.studytrip.mission.domain.repository.MissionRepository; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class MissionService { | ||
| private final MissionRepository missionRepository; | ||
|
|
||
| public List<MissionInfo> getMissionsByStamp(Long stampId) { | ||
| List<Mission> missions = missionRepository.findAllByStampIdOrderByMissionOrder(stampId); | ||
|
|
||
| return missions.stream().map(MissionInfo::from).toList(); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/ject/studytrip/mission/domain/repository/MissionRepository.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 com.ject.studytrip.mission.domain.repository; | ||
|
|
||
| import com.ject.studytrip.mission.domain.model.Mission; | ||
| import java.util.List; | ||
|
|
||
| public interface MissionRepository { | ||
| List<Mission> findAllByStampIdOrderByMissionOrder(Long stampId); | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/ject/studytrip/mission/infra/jpa/MissionJpaRepository.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,9 @@ | ||
| package com.ject.studytrip.mission.infra.jpa; | ||
|
|
||
| import com.ject.studytrip.mission.domain.model.Mission; | ||
| import java.util.List; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface MissionJpaRepository extends JpaRepository<Mission, Long> { | ||
| List<Mission> findAllByStampIdOrderByMissionOrder(Long stampId); | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/ject/studytrip/mission/infra/jpa/MissionRepositoryAdapter.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,18 @@ | ||
| package com.ject.studytrip.mission.infra.jpa; | ||
|
|
||
| import com.ject.studytrip.mission.domain.model.Mission; | ||
| import com.ject.studytrip.mission.domain.repository.MissionRepository; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class MissionRepositoryAdapter implements MissionRepository { | ||
| private final MissionJpaRepository missionJpaRepository; | ||
|
|
||
| @Override | ||
| public List<Mission> findAllByStampIdOrderByMissionOrder(Long stampId) { | ||
| return missionJpaRepository.findAllByStampIdOrderByMissionOrder(stampId); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
...in/java/com/ject/studytrip/mission/presentation/dto/response/LoadMissionInfoResponse.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,15 @@ | ||
| package com.ject.studytrip.mission.presentation.dto.response; | ||
|
|
||
| import com.ject.studytrip.mission.application.dto.MissionInfo; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record LoadMissionInfoResponse( | ||
| @Schema(description = "미션 ID") Long missionId, | ||
| @Schema(description = "미션 이름") String missionName, | ||
| @Schema(description = "미션 순서") int missionOrder, | ||
| @Schema(description = "미션 완료여부") boolean completed) { | ||
| public static LoadMissionInfoResponse of(MissionInfo info) { | ||
| return new LoadMissionInfoResponse( | ||
| info.missionId(), info.missionName(), info.missionOrder(), info.completed()); | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/ject/studytrip/stamp/application/dto/StampDetail.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 com.ject.studytrip.stamp.application.dto; | ||
|
|
||
| import com.ject.studytrip.mission.application.dto.MissionInfo; | ||
| import java.util.List; | ||
|
|
||
| public record StampDetail(StampInfo stampInfo, List<MissionInfo> missionInfos) { | ||
| public static StampDetail from(StampInfo stampInfo, List<MissionInfo> missionInfos) { | ||
| return new StampDetail(stampInfo, missionInfos); | ||
| } | ||
| } |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/ject/studytrip/stamp/application/facade/StampFacade.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,77 @@ | ||
| package com.ject.studytrip.stamp.application.facade; | ||
|
|
||
| import com.ject.studytrip.mission.application.dto.MissionInfo; | ||
| import com.ject.studytrip.mission.application.service.MissionService; | ||
| import com.ject.studytrip.stamp.application.dto.StampDetail; | ||
| import com.ject.studytrip.stamp.application.dto.StampInfo; | ||
| import com.ject.studytrip.stamp.application.service.StampService; | ||
| import com.ject.studytrip.stamp.domain.model.Stamp; | ||
| import com.ject.studytrip.stamp.presentation.dto.request.CreateStampRequest; | ||
| import com.ject.studytrip.stamp.presentation.dto.request.UpdateStampNameAndDeadlineRequest; | ||
| import com.ject.studytrip.stamp.presentation.dto.request.UpdateStampOrderRequest; | ||
| import com.ject.studytrip.trip.application.service.TripService; | ||
| import com.ject.studytrip.trip.domain.model.Trip; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class StampFacade { | ||
| private final TripService tripService; | ||
| private final StampService stampService; | ||
| private final MissionService missionService; | ||
|
|
||
| @Transactional | ||
| public StampInfo createStamp(Long memberId, Long tripId, CreateStampRequest request) { | ||
| Trip trip = tripService.getValidTrip(memberId, tripId); | ||
| Stamp stamp = stampService.createStamp(trip, request); | ||
|
|
||
| tripService.increaseTotalStamps(trip); | ||
|
|
||
| return StampInfo.from(stamp); | ||
| } | ||
|
|
||
| @Transactional | ||
| public void updateStampNameAndDeadline( | ||
| Long memberId, Long tripId, Long stampId, UpdateStampNameAndDeadlineRequest request) { | ||
| Trip trip = tripService.getValidTrip(memberId, tripId); | ||
| Stamp stamp = stampService.getValidStamp(trip.getId(), stampId); | ||
|
|
||
| stampService.updateStampNameAndDeadline(trip, stamp, request); | ||
| } | ||
|
|
||
| @Transactional | ||
| public void updateStampOrders(Long memberId, Long tripId, UpdateStampOrderRequest request) { | ||
| Trip trip = tripService.getValidTrip(memberId, tripId); | ||
|
|
||
| stampService.updateStampsOrders(trip, request); | ||
| } | ||
|
|
||
| @Transactional | ||
| public void deleteStamp(Long memberId, Long tripId, Long stampId) { | ||
| Trip trip = tripService.getValidTrip(memberId, tripId); | ||
| Stamp stamp = stampService.getValidStamp(trip.getId(), stampId); | ||
|
|
||
| stampService.deleteStamp(trip.getId(), trip.getCategory(), stamp); | ||
| tripService.decreaseTotalStamps(trip); | ||
|
|
||
| // TODO : 추후 삭제로직 업데이트 (연쇄 삭제 처리) | ||
| } | ||
|
|
||
| public List<StampInfo> getStampsByTrip(Long memberId, Long tripId) { | ||
| Trip trip = tripService.getValidTrip(memberId, tripId); | ||
| List<Stamp> stamps = stampService.getStampsByTripId(trip.getId()); | ||
|
|
||
| return stamps.stream().map(StampInfo::from).toList(); | ||
| } | ||
|
|
||
| public StampDetail getStamp(Long memberId, Long tripId, Long stampId) { | ||
| Trip trip = tripService.getValidTrip(memberId, tripId); | ||
| Stamp stamp = stampService.getValidStamp(trip.getId(), stampId); | ||
| List<MissionInfo> missionInfos = missionService.getMissionsByStamp(stamp.getId()); | ||
|
|
||
| return StampDetail.from(StampInfo.from(stamp), missionInfos); | ||
| } | ||
| } |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/ject/studytrip/stamp/domain/repository/StampQueryRepository.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 com.ject.studytrip.stamp.domain.repository; | ||
|
|
||
| import com.ject.studytrip.stamp.domain.model.Stamp; | ||
| import java.util.List; | ||
|
|
||
| public interface StampQueryRepository { | ||
| List<Stamp> findStampsToShiftAfterOrder(Long tripId, int deletedOrder); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.