Merge remote-tracking branch 'origin/master'

This commit is contained in:
snoop 2017-08-30 19:50:14 +09:00
commit 001602e0d2
4 changed files with 38 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package com.loafle.overflow.module.noauthprobe.service;
import com.loafle.overflow.commons.utils.StringConvertor;
import com.loafle.overflow.module.domain.model.Domain;
import com.loafle.overflow.module.member.model.Member;
import com.loafle.overflow.module.meta.model.MetaNoAuthProbeStatus;
@ -30,6 +31,9 @@ public class NoAuthProbeService {
public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
noAuthProbe.setTempProbeKey(UUID.randomUUID().toString());
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short)3));
return this.noAuthProbeDAO.save(noAuthProbe);
}
@ -50,21 +54,22 @@ public class NoAuthProbeService {
Probe probe = null;
for (NoAuthProbe noAuth : noAuthProbes) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String key = passwordEncoder.encode(UUID.randomUUID().toString());
String encryptKey = passwordEncoder.encode(UUID.randomUUID().toString());
probe = new Probe();
probe.setEncryptionKey(key);
probe.setEncryptionKey(encryptKey);
probe.setProbeKey(noAuth.getApiKey());
probe.setDomain(new Domain(1));
probe.setAuthorizeMember(new Member(1));
probe.setStatus(new MetaProbeStatus((short)1));
probe.setTargetCount(0);
probe.setSensorCount(0);
probe.setEncryptionKey("111");
probe.setDisplayName(noAuth.getHostName()+"'s probe");
String dispName = noAuth.getHostName().isEmpty() ?
StringConvertor.intToIp(noAuth.getIpAddress()) : noAuth.getHostName();
probe.setDisplayName(dispName);
probes.add(probe);
noAuth.setStatus(new MetaNoAuthProbeStatus((short) 1));
}

View File

@ -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")

View File

@ -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);
}
}

View File

@ -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 (