notification
This commit is contained in:
parent
73ded46dc8
commit
110743b483
|
@ -19,4 +19,7 @@ public interface NotificationDAO extends JpaRepository<Notification, Long> {
|
||||||
|
|
||||||
@Query("SELECT n FROM Notification n WHERE n.member.id = :#{#member.id} and n.confirmDate IS NULL")
|
@Query("SELECT n FROM Notification n WHERE n.member.id = :#{#member.id} and n.confirmDate IS NULL")
|
||||||
Page<Notification> findAllUnconfirmedByMember(@Param("member") Member member, Pageable pageRequest);
|
Page<Notification> findAllUnconfirmedByMember(@Param("member") Member member, Pageable pageRequest);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(n) FROM Notification n WHERE n.member.id = :#{#member.id} and n.confirmDate IS NULL")
|
||||||
|
int findAllUnconfirmedCountByMember(@Param("member") Member member);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class Notification {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
@Column(name = "CREATE_DATE", nullable = true)
|
@Column(name = "CONFIRM_DATE", nullable = true)
|
||||||
public Date getConfirmDate() {
|
public Date getConfirmDate() {
|
||||||
return confirmDate;
|
return confirmDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package com.loafle.overflow.module.notification.service;
|
package com.loafle.overflow.module.notification.service;
|
||||||
|
|
||||||
|
import com.loafle.overflow.commons.model.PageParams;
|
||||||
|
import com.loafle.overflow.commons.utils.PageUtil;
|
||||||
import com.loafle.overflow.module.member.model.Member;
|
import com.loafle.overflow.module.member.model.Member;
|
||||||
import com.loafle.overflow.module.notification.dao.NotificationDAO;
|
import com.loafle.overflow.module.notification.dao.NotificationDAO;
|
||||||
import com.loafle.overflow.module.notification.model.Notification;
|
import com.loafle.overflow.module.notification.model.Notification;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,15 +22,15 @@ public class NotificationService {
|
||||||
return this.notificationDAO.save(notification);
|
return this.notificationDAO.save(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> readAllByMember(Member member, int pageNo, int countPerPage) {
|
public Page<Notification> readAllByMember(Member member, PageParams pageParams) {
|
||||||
Pageable pageRequest =
|
return this.notificationDAO.findAllByMember(member, PageUtil.getPageRequest(pageParams));
|
||||||
new PageRequest(pageNo, countPerPage, new Sort(Sort.Direction.DESC, "id"));
|
|
||||||
return this.notificationDAO.findAllByMember(member, pageRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Notification> readAllUnconfirmedByMember(Member member, int pageNo, int countPerPage) {
|
public Page<Notification> readAllUnconfirmedByMember(Member member, PageParams pageParams) {
|
||||||
Pageable pageRequest =
|
return this.notificationDAO.findAllUnconfirmedByMember(member, PageUtil.getPageRequest(pageParams));
|
||||||
new PageRequest(pageNo, countPerPage, new Sort(Sort.Direction.DESC, "id"));
|
}
|
||||||
return this.notificationDAO.findAllUnconfirmedByMember(member, pageRequest);
|
|
||||||
|
public int readUnconfirmedCount(Member member) {
|
||||||
|
return this.notificationDAO.findAllUnconfirmedCountByMember(member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1065,66 +1065,67 @@ INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,
|
||||||
INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES (
|
INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES (
|
||||||
100,'2017-08-24 18:33:27.217','Test History 99',1,1,1,3);
|
100,'2017-08-24 18:33:27.217','Test History 99',1,1,1,3);
|
||||||
|
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
|
||||||
1,'2017-08-25 16:58:48.430','Message0','Title0',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
1,'2017-08-29 16:39:16.198','2017-08-29 16:39:17.756','Message0','Title0',1);
|
||||||
2,NULL,'Message1','Title1',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
2,'2017-08-29 16:39:16.285','2017-08-29 16:39:17.789','Message1','Title1',1);
|
||||||
3,'2017-08-25 16:58:48.520','Message2','Title2',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
3,'2017-08-29 16:39:16.306','2017-08-29 16:39:17.807','Message2','Title2',1);
|
||||||
4,NULL,'Message3','Title3',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
4,'2017-08-29 16:39:16.322','2017-08-29 16:39:17.822','Message3','Title3',1);
|
||||||
5,'2017-08-25 16:58:48.540','Message4','Title4',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
5,'2017-08-29 16:39:16.336','2017-08-29 16:39:17.837','Message4','Title4',1);
|
||||||
6,NULL,'Message5','Title5',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
6,'2017-08-29 16:39:16.350','2017-08-29 16:39:17.852','Message5','Title5',1);
|
||||||
7,'2017-08-25 16:58:48.566','Message6','Title6',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
7,'2017-08-29 16:39:16.365','2017-08-29 16:39:17.864','Message6','Title6',1);
|
||||||
8,NULL,'Message7','Title7',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
8,'2017-08-29 16:39:16.377','2017-08-29 16:39:17.877','Message7','Title7',1);
|
||||||
9,'2017-08-25 16:58:48.596','Message8','Title8',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
9,'2017-08-29 16:39:16.391','2017-08-29 16:39:17.890','Message8','Title8',1);
|
||||||
10,NULL,'Message9','Title9',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
10,'2017-08-29 16:39:16.403','2017-08-29 16:39:17.904','Message9','Title9',1);
|
||||||
11,'2017-08-25 16:58:48.628','Message10','Title10',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
11,'2017-08-29 16:39:16.417','2017-08-29 16:39:17.916','Message10','Title10',1);
|
||||||
12,NULL,'Message11','Title11',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
12,'2017-08-29 16:39:16.430','2017-08-29 16:39:17.929','Message11','Title11',1);
|
||||||
13,'2017-08-25 16:58:48.661','Message12','Title12',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
13,'2017-08-29 16:39:16.442','2017-08-29 16:39:17.941','Message12','Title12',1);
|
||||||
14,NULL,'Message13','Title13',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
14,'2017-08-29 16:39:16.454','2017-08-29 16:39:17.953','Message13','Title13',1);
|
||||||
15,'2017-08-25 16:58:48.682','Message14','Title14',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
15,'2017-08-29 16:39:16.467','2017-08-29 16:39:17.966','Message14','Title14',1);
|
||||||
16,NULL,'Message15','Title15',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
16,'2017-08-29 16:39:16.479','2017-08-29 16:39:17.979','Message15','Title15',1);
|
||||||
17,'2017-08-25 16:58:48.710','Message16','Title16',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
17,'2017-08-29 16:39:16.493','2017-08-29 16:39:17.994','Message16','Title16',1);
|
||||||
18,NULL,'Message17','Title17',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
18,'2017-08-29 16:39:16.508','2017-08-29 16:39:18.008','Message17','Title17',1);
|
||||||
19,'2017-08-25 16:58:48.734','Message18','Title18',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
19,'2017-08-29 16:39:16.522','2017-08-29 16:39:18.020','Message18','Title18',1);
|
||||||
20,NULL,'Message19','Title19',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
20,'2017-08-29 16:39:16.533','2017-08-29 16:39:18.031','Message19','Title19',1);
|
||||||
21,'2017-08-25 16:58:48.755','Message20','Title20',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
21,NULL,'2017-08-29 16:39:18.042','Message20','Title20',1);
|
||||||
22,NULL,'Message21','Title21',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
22,NULL,'2017-08-29 16:39:18.051','Message21','Title21',1);
|
||||||
23,'2017-08-25 16:58:48.778','Message22','Title22',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
23,NULL,'2017-08-29 16:39:18.062','Message22','Title22',1);
|
||||||
24,NULL,'Message23','Title23',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
24,NULL,'2017-08-29 16:39:18.072','Message23','Title23',1);
|
||||||
25,'2017-08-25 16:58:48.804','Message24','Title24',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
25,NULL,'2017-08-29 16:39:18.083','Message24','Title24',1);
|
||||||
26,NULL,'Message25','Title25',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
26,NULL,'2017-08-29 16:39:18.096','Message25','Title25',1);
|
||||||
27,'2017-08-25 16:58:48.829','Message26','Title26',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
27,NULL,'2017-08-29 16:39:18.108','Message26','Title26',1);
|
||||||
28,NULL,'Message27','Title27',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
28,NULL,'2017-08-29 16:39:18.118','Message27','Title27',1);
|
||||||
29,'2017-08-25 16:58:48.850','Message28','Title28',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
INSERT INTO public.notification (id,create_date,message,title,member_id) VALUES (
|
29,NULL,'2017-08-29 16:39:18.130','Message28','Title28',1);
|
||||||
30,NULL,'Message29','Title29',1);
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
|
30,NULL,'2017-08-29 16:39:18.143','Message29','Title29',1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,9 @@ package com.loafle.overflow.module.notification.service;
|
||||||
import com.loafle.overflow.module.member.model.Member;
|
import com.loafle.overflow.module.member.model.Member;
|
||||||
import com.loafle.overflow.module.notification.model.Notification;
|
import com.loafle.overflow.module.notification.model.Notification;
|
||||||
import com.loafle.overflow.spring.AppConfigTest;
|
import com.loafle.overflow.spring.AppConfigTest;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
@ -24,33 +21,32 @@ public class NotificationServiceTest {
|
||||||
private NotificationService notificationService;
|
private NotificationService notificationService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void testRegist() {
|
public void testRegist() {
|
||||||
for (int i=0; i<30; i++) {
|
for (int i=0; i<30; i++) {
|
||||||
Notification n = new Notification();
|
Notification n = new Notification();
|
||||||
n.setMember(new Member(1));
|
n.setMember(new Member(1));
|
||||||
n.setTitle("Title"+i);
|
n.setTitle("Title"+i);
|
||||||
n.setMessage("Message"+i);
|
n.setMessage("Message"+i);
|
||||||
if((i%2)==0) {
|
if(i<20) {
|
||||||
n.setConfirmDate(new Date());
|
n.setConfirmDate(new Date());
|
||||||
}
|
}
|
||||||
this.notificationService.regist(n);
|
this.notificationService.regist(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
@Ignore
|
// @Ignore
|
||||||
public void testReadAll() {
|
// public void testReadAll() {
|
||||||
this.testRegist();
|
// this.testRegist();
|
||||||
Page<Notification> notis = this.notificationService.readAllByMember(new Member(1), 0, 10);
|
// Page<Notification> notis = this.notificationService.readAllByMember(new Member(1), 0, 10);
|
||||||
Assert.assertEquals(30, notis.getTotalElements());
|
// Assert.assertEquals(30, notis.getTotalElements());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
@Ignore
|
// @Ignore
|
||||||
public void testReadAllUnread() {
|
// public void testReadAllUnread() {
|
||||||
this.testRegist();
|
// this.testRegist();
|
||||||
Page<Notification> notis = this.notificationService.readAllUnconfirmedByMember(new Member(1), 0, 10);
|
// Page<Notification> notis = this.notificationService.readAllUnconfirmedByMember(new Member(1), 0, 10);
|
||||||
Assert.assertEquals(15, notis.getTotalElements());
|
// Assert.assertEquals(15, notis.getTotalElements());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user