-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from Team-Going/feature/34
[feat] 여행 TODO 전체 조회 API 구현
- Loading branch information
Showing
8 changed files
with
182 additions
and
14 deletions.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
doorip-api/src/main/java/org/doorip/trip/dto/response/TodoAllocatorResponse.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,24 @@ | ||
package org.doorip.trip.dto.response; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import org.doorip.trip.domain.Allocator; | ||
import org.doorip.trip.domain.Participant; | ||
import org.doorip.user.domain.User; | ||
|
||
import java.util.Objects; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record TodoAllocatorResponse( | ||
String name, | ||
boolean isOwner | ||
) { | ||
public static TodoAllocatorResponse of(Long userId, Allocator allocator) { | ||
Participant participant = allocator.getParticipant(); | ||
User user = participant.getUser(); | ||
return TodoAllocatorResponse.builder() | ||
.name(user.getName()) | ||
.isOwner(Objects.equals(user.getId(), userId)) | ||
.build(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
doorip-api/src/main/java/org/doorip/trip/dto/response/TodoGetResponse.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,30 @@ | ||
package org.doorip.trip.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import org.doorip.trip.domain.Secret; | ||
import org.doorip.trip.domain.Todo; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record TodoGetResponse( | ||
Long todoId, | ||
String title, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
LocalDate endDate, | ||
List<TodoAllocatorResponse> allocators, | ||
boolean secret | ||
) { | ||
public static TodoGetResponse of(Todo todo, List<TodoAllocatorResponse> allocators) { | ||
return TodoGetResponse.builder() | ||
.todoId(todo.getId()) | ||
.title(todo.getTitle()) | ||
.endDate(todo.getEndDate()) | ||
.allocators(allocators) | ||
.secret(Secret.of(todo.getSecret())) | ||
.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
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
32 changes: 32 additions & 0 deletions
32
doorip-domain/src/main/java/org/doorip/trip/repository/TodoRepository.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,7 +1,39 @@ | ||
package org.doorip.trip.repository; | ||
|
||
|
||
import org.doorip.trip.domain.Progress; | ||
import org.doorip.trip.domain.Secret; | ||
import org.doorip.trip.domain.Todo; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
public interface TodoRepository extends JpaRepository<Todo, Long> { | ||
@Query("select d " + | ||
"from Todo d " + | ||
"join Trip i " + | ||
"on d.trip = i " + | ||
"where i.id = :tripId " + | ||
"and d.progress = :progress " + | ||
"and d.secret = :secret " + | ||
"order by d.endDate") | ||
List<Todo> findOurTodoByTripId(@Param("tripId") Long tripId, @Param("secret") Secret secret, @Param("progress") Progress progress); | ||
|
||
@Query("select d " + | ||
"from Todo d " + | ||
"join Trip i " + | ||
"on d.trip = i " + | ||
"join Allocator a " + | ||
"on a.todo = d " + | ||
"join Participant p " + | ||
"on a.participant = p " + | ||
"join User u " + | ||
"on p.user = u " + | ||
"where i.id = :tripId " + | ||
"and u.id = :userId " + | ||
"and d.progress = :progress " + | ||
"order by d.endDate") | ||
List<Todo> findMyTodoByTripId(@Param("tripId") Long tripId, @Param("userId") Long userId, @Param("progress") Progress progress); | ||
} |