Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
001602e0d2
|
@ -1,5 +1,6 @@
|
||||||
package com.loafle.overflow.module.noauthprobe.service;
|
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.domain.model.Domain;
|
||||||
import com.loafle.overflow.module.member.model.Member;
|
import com.loafle.overflow.module.member.model.Member;
|
||||||
import com.loafle.overflow.module.meta.model.MetaNoAuthProbeStatus;
|
import com.loafle.overflow.module.meta.model.MetaNoAuthProbeStatus;
|
||||||
|
@ -30,6 +31,9 @@ public class NoAuthProbeService {
|
||||||
|
|
||||||
public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
|
public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
|
||||||
|
|
||||||
|
noAuthProbe.setTempProbeKey(UUID.randomUUID().toString());
|
||||||
|
noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short)3));
|
||||||
|
|
||||||
return this.noAuthProbeDAO.save(noAuthProbe);
|
return this.noAuthProbeDAO.save(noAuthProbe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,21 +54,22 @@ public class NoAuthProbeService {
|
||||||
Probe probe = null;
|
Probe probe = null;
|
||||||
for (NoAuthProbe noAuth : noAuthProbes) {
|
for (NoAuthProbe noAuth : noAuthProbes) {
|
||||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
String key = passwordEncoder.encode(UUID.randomUUID().toString());
|
String encryptKey = passwordEncoder.encode(UUID.randomUUID().toString());
|
||||||
|
|
||||||
probe = new Probe();
|
probe = new Probe();
|
||||||
probe.setEncryptionKey(key);
|
probe.setEncryptionKey(encryptKey);
|
||||||
probe.setProbeKey(noAuth.getApiKey());
|
probe.setProbeKey(noAuth.getApiKey());
|
||||||
probe.setDomain(new Domain(1));
|
probe.setDomain(new Domain(1));
|
||||||
probe.setAuthorizeMember(new Member(1));
|
probe.setAuthorizeMember(new Member(1));
|
||||||
probe.setStatus(new MetaProbeStatus((short)1));
|
probe.setStatus(new MetaProbeStatus((short)1));
|
||||||
probe.setTargetCount(0);
|
probe.setTargetCount(0);
|
||||||
probe.setSensorCount(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);
|
probes.add(probe);
|
||||||
|
|
||||||
noAuth.setStatus(new MetaNoAuthProbeStatus((short) 1));
|
noAuth.setStatus(new MetaNoAuthProbeStatus((short) 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,16 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by insanity on 17. 8. 25.
|
* Created by insanity on 17. 8. 25.
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface NotificationDAO extends JpaRepository<Notification, Long> {
|
public interface NotificationDAO extends JpaRepository<Notification, Long> {
|
||||||
|
|
||||||
|
List<Notification> findAllByMember(Member member);
|
||||||
|
|
||||||
Page<Notification> findAllByMember(Member member, Pageable pageRequest);
|
Page<Notification> findAllByMember(Member member, Pageable pageRequest);
|
||||||
|
|
||||||
@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")
|
||||||
|
|
|
@ -9,6 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by insanity on 17. 8. 25.
|
* Created by insanity on 17. 8. 25.
|
||||||
*/
|
*/
|
||||||
|
@ -33,4 +36,22 @@ public class NotificationService {
|
||||||
public int readUnconfirmedCount(Member member) {
|
public int readUnconfirmedCount(Member member) {
|
||||||
return this.notificationDAO.findAllUnconfirmedCountByMember(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 (
|
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);
|
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 (
|
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 (
|
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);
|
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 (
|
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 (
|
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);
|
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 (
|
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 (
|
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);
|
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 (
|
INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id) VALUES (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user