-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the functions to set a user message is read
- Loading branch information
Showing
5 changed files
with
96 additions
and
8 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
8 changes: 8 additions & 0 deletions
8
src/main/java/org/highmed/numportal/domain/repository/MessageRepository.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,12 +1,20 @@ | ||
package org.highmed.numportal.domain.repository; | ||
|
||
import org.highmed.numportal.domain.model.Message; | ||
import org.highmed.numportal.domain.model.admin.UserDetails; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Repository | ||
public interface MessageRepository extends JpaRepository<Message, Long>, PagingAndSortingRepository<Message, Long> { | ||
|
||
@Query("SELECT m FROM Message m WHERE :userDetails NOT MEMBER OF m.readByUsers AND m.startDate <= :now AND m.endDate >= :now") | ||
List<Message> findAllActiveMessagesNotReadByUser(@Param("userDetails") UserDetails userDetails, @Param("now")LocalDateTime now); | ||
} |
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
25 changes: 17 additions & 8 deletions
25
src/main/resources/db/migration/num-portal/V08__user_messages.sql
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,11 +1,20 @@ | ||
DROP TABLE IF EXISTS message; | ||
|
||
CREATE TABLE message( | ||
id BIGSERIAL PRIMARY KEY, | ||
title VARCHAR(255) NOT NULL, | ||
text text, | ||
start_date timestamp NOT NULL, | ||
end_date timestamp NOT NULL, | ||
type varchar(125) NOT NULL , | ||
mark_as_deleted boolean | ||
CREATE TABLE message | ||
( | ||
id serial PRIMARY KEY, | ||
title VARCHAR(255) NOT NULL, | ||
text text, | ||
start_date timestamp NOT NULL, | ||
end_date timestamp NOT NULL, | ||
type varchar(125) NOT NULL, | ||
mark_as_deleted boolean, | ||
sessionBased boolean | ||
); | ||
|
||
CREATE TABLE read_message_by_users | ||
( | ||
message_id int REFERENCES message (id) ON UPDATE CASCADE, | ||
user_details_id varchar(250) REFERENCES user_details (user_id) ON UPDATE CASCADE, | ||
CONSTRAINT message_template_pkey PRIMARY KEY (message_id, user_details_id) | ||
); |