noti mark all as read
This commit is contained in:
parent
cf4f4223f8
commit
285711e3f1
|
@ -9,12 +9,16 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 8. 25.
|
||||
*/
|
||||
@Repository
|
||||
public interface NotificationDAO extends JpaRepository<Notification, Long> {
|
||||
|
||||
List<Notification> findAllByMember(Member member);
|
||||
|
||||
Page<Notification> findAllByMember(Member member, Pageable pageRequest);
|
||||
|
||||
@Query("SELECT n FROM Notification n WHERE n.member.id = :#{#member.id} and n.confirmDate IS NULL")
|
||||
|
|
|
@ -9,6 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 8. 25.
|
||||
*/
|
||||
|
@ -33,4 +36,22 @@ public class NotificationService {
|
|||
public int readUnconfirmedCount(Member member) {
|
||||
return this.notificationDAO.findAllUnconfirmedCountByMember(member);
|
||||
}
|
||||
|
||||
public Page<Notification> markAllAsRead(Member member, PageParams pageParams) {
|
||||
List<Notification> list = this.notificationDAO.findAllByMember(member);
|
||||
for (Notification n : list) {
|
||||
n.setConfirmDate(new Date());
|
||||
}
|
||||
this.notificationDAO.save(list);
|
||||
return this.readAllByMember(member, pageParams);
|
||||
}
|
||||
|
||||
public Page<Notification> markAllAsUnread(Member member, PageParams pageParams) {
|
||||
List<Notification> list = this.notificationDAO.findAllByMember(member);
|
||||
for (Notification n : list) {
|
||||
n.setConfirmDate(null);
|
||||
}
|
||||
this.notificationDAO.save(list);
|
||||
return this.readAllByMember(member, pageParams);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1294,15 +1294,15 @@ INSERT INTO public.notification (id,confirm_date,create_date,message,title,membe
|
|||
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||
23,NULL,'2017-08-29 16:39:18.062','Message22','Title22',1);
|
||||
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||
24,NULL,'2017-08-29 16:39:18.072','Message23','Title23',1);
|
||||
24,'2017-08-29 16:39:16.533','2017-08-29 16:39:18.072','Message23','Title23',1);
|
||||
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||
25,NULL,'2017-08-29 16:39:18.083','Message24','Title24',1);
|
||||
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||
26,NULL,'2017-08-29 16:39:18.096','Message25','Title25',1);
|
||||
26,'2017-08-29 16:39:16.533','2017-08-29 16:39:18.096','Message25','Title25',1);
|
||||
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||
27,NULL,'2017-08-29 16:39:18.108','Message26','Title26',1);
|
||||
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||
28,NULL,'2017-08-29 16:39:18.118','Message27','Title27',1);
|
||||
28,'2017-08-29 16:39:16.533','2017-08-29 16:39:18.118','Message27','Title27',1);
|
||||
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||
29,NULL,'2017-08-29 16:39:18.130','Message28','Title28',1);
|
||||
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||
|
|
Loading…
Reference in New Issue
Block a user