-
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.
feat: 유저가 한달 동안 받은 알람을 조회하는 기능 개발 (#185)
* fix: flyway schema에 _이 하나밖에 없는 버그를 수정한다 * feat: 유저가 한달동안 받은 알람을 조회하는 기능을 개발한다 * refactor: AlertRepository의 finalAll 메소드를 findAllByCreatedAt으로 변경한다
- Loading branch information
Showing
6 changed files
with
65 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
package net.teumteum.alert.domain; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface AlertRepository extends JpaRepository<Alert, Long> { | ||
|
||
List<Alert> findAllByUserId(Long userId); | ||
|
||
@Query("select a from alert as a where a.createdAt <= :createdAt") | ||
List<Alert> findAllByCreatedAt(@Param("createdAt") Instant createdAt); | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/net/teumteum/alert/domain/response/AlertsResponse.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,25 @@ | ||
package net.teumteum.alert.domain.response; | ||
|
||
import java.util.List; | ||
import net.teumteum.alert.domain.Alert; | ||
|
||
public record AlertsResponse( | ||
List<AlertResponse> alerts | ||
) { | ||
|
||
public static AlertsResponse of(List<Alert> alerts) { | ||
return new AlertsResponse( | ||
alerts.stream() | ||
.map(alert -> new AlertResponse(alert.getTitle(), alert.getBody(), alert.getType().name())) | ||
.toList() | ||
); | ||
} | ||
|
||
public record AlertResponse( | ||
String title, | ||
String body, | ||
String type | ||
) { | ||
|
||
} | ||
} |
File renamed without changes.
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