-
Notifications
You must be signed in to change notification settings - Fork 1
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 #54 from Project-Catcher/feat-ny-make-schedule-detail
Feat: 추천 템플릿 목록 조회
- Loading branch information
Showing
12 changed files
with
222 additions
and
15 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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/catcher/core/database/TemplateRepository.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,17 @@ | ||
package com.catcher.core.database; | ||
|
||
import com.catcher.core.domain.entity.Template; | ||
import com.catcher.core.domain.entity.enums.RecommendedStatus; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
public interface TemplateRepository { | ||
@Query("SELECT t FROM Template t " + | ||
"JOIN FETCH t.schedule s " + | ||
"WHERE t.recommendedStatus = :status") | ||
List<Template> findByRecommendedStatus(@Param("status") RecommendedStatus recommendedStatus); | ||
|
||
void save(Template template); | ||
} |
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
58 changes: 58 additions & 0 deletions
58
src/main/java/com/catcher/core/dto/response/GetRecommendedTemplateResponse.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,58 @@ | ||
package com.catcher.core.dto.response; | ||
|
||
import com.catcher.core.domain.entity.ScheduleDetail; | ||
import com.catcher.core.domain.entity.Template; | ||
import com.catcher.core.domain.entity.enums.ItemType; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Getter | ||
public class GetRecommendedTemplateResponse { | ||
private final List<TemplateDTO> templates; | ||
|
||
public GetRecommendedTemplateResponse(List<TemplateDTO> templates) { | ||
this.templates = templates; | ||
} | ||
|
||
@Getter | ||
public static class TemplateDTO { | ||
private final Long id; | ||
private final String title; | ||
private final String location; | ||
private final String thumbnailUrl; | ||
private final Long days; | ||
private final List<TemplateScheduleDetailDTO> scheduleDetails; | ||
|
||
public TemplateDTO(Template template, List<TemplateScheduleDetailDTO> scheduleDetails) { | ||
this.id = template.getId(); | ||
this.title = template.getSchedule().getTitle(); | ||
this.location = template.getSchedule().getLocation().getAddress().getDescription(); | ||
this.thumbnailUrl = template.getSchedule().getThumbnailUrl(); | ||
this.days = template.getDays(); | ||
this.scheduleDetails = scheduleDetails; | ||
} | ||
} | ||
|
||
@Getter | ||
public static class TemplateScheduleDetailDTO { | ||
private final Long id; | ||
private final String description; | ||
private final String color; | ||
private final ItemType itemType; | ||
private final Long itemId; | ||
private final LocalDateTime startAt; | ||
private final LocalDateTime endAt; | ||
|
||
public TemplateScheduleDetailDTO(ScheduleDetail scheduleDetail) { | ||
this.id = scheduleDetail.getId(); | ||
this.description = scheduleDetail.getDescription(); | ||
this.color = scheduleDetail.getColor(); | ||
this.itemType = scheduleDetail.getItemType(); | ||
this.itemId = scheduleDetail.getItemId(); | ||
this.startAt = scheduleDetail.getStartAt(); | ||
this.endAt = scheduleDetail.getEndAt(); | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/catcher/datasource/TemplateRepositoryImpl.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,26 @@ | ||
package com.catcher.datasource; | ||
|
||
import com.catcher.core.database.TemplateRepository; | ||
import com.catcher.core.domain.entity.Template; | ||
import com.catcher.core.domain.entity.enums.RecommendedStatus; | ||
import com.catcher.datasource.repository.TemplateJpaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class TemplateRepositoryImpl implements TemplateRepository { | ||
private final TemplateJpaRepository templateJpaRepository; | ||
|
||
@Override | ||
public List<Template> findByRecommendedStatus(RecommendedStatus recommendedStatus) { | ||
return templateJpaRepository.findByRecommendedStatus(recommendedStatus); | ||
} | ||
|
||
@Override | ||
public void save(Template template) { | ||
templateJpaRepository.save(template); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/catcher/datasource/repository/TemplateJpaRepository.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,13 @@ | ||
package com.catcher.datasource.repository; | ||
|
||
import com.catcher.core.domain.entity.Template; | ||
import com.catcher.core.domain.entity.enums.RecommendedStatus; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface TemplateJpaRepository extends JpaRepository<Template, Long> { | ||
|
||
|
||
List<Template> findByRecommendedStatus(RecommendedStatus recommendedStatus); | ||
} |
15 changes: 0 additions & 15 deletions
15
src/main/java/com/catcher/infrastructure/jpa/repository/ScheduleJpaRepository.java
This file was deleted.
Oops, something went wrong.
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