This commit is contained in:
crusader 2018-05-10 18:04:47 +09:00
parent 009799c079
commit 1267ad22bc
5 changed files with 33 additions and 36 deletions

View File

@ -4,10 +4,12 @@ import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.noauthprobe.NoAuthProbe;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
@ -25,4 +27,8 @@ public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
// List<NoAuthProbeDeprecate> findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent);
// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey")
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
@Modifying(clearAutomatically = true)
@Query("UPDATE NoAuthProbe n set n.connectDate = :connectDate, n.connectAddress = :connectAddress where n.tempProbeKey = :tempProbeKey")
int saveConnect(@Param("tempProbeKey") String tempProbeKey, @Param("connectDate") Date connectDate, @Param("connectAddress") String connectAddress);
}

View File

@ -38,6 +38,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -218,4 +219,13 @@ public class CentralNoAuthProbeService implements NoAuthProbeService {
public NoAuthProbe readByTempProbeKey(String tempKey) throws OverflowException {
return this.noAuthProbeDAO.findByTempProbeKey(tempKey);
}
public void onConnect(String tempKey, String connectAddress) throws OverflowException {
this.noAuthProbeDAO.saveConnect(tempKey, new Date(), connectAddress);
}
public void onDisconnect(String tempKey) throws OverflowException {
this.noAuthProbeDAO.saveConnect(tempKey, null, null);
}
}

View File

@ -4,8 +4,12 @@ import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.probe.Probe;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
@ -17,4 +21,8 @@ public interface ProbeDAO extends JpaRepository<Probe, Long> {
Probe findByProbeKey(String probeKey);
List<Probe> findAllByDomainOrderByIdDesc(Domain domain);
@Modifying(clearAutomatically = true)
@Query("UPDATE Probe p set p.connectDate = :connectDate, p.connectAddress = :connectAddress where p.probeKey = :probeKey")
int saveConnect(@Param("probeKey") String probeKey, @Param("connectDate") Date connectDate, @Param("connectAddress") String connectAddress);
}

View File

@ -1,7 +1,6 @@
package com.loafle.overflow.central.module.probe.service;
import com.loafle.overflow.central.module.probe.dao.ProbeDAO;
import com.loafle.overflow.core.annotation.WebappAPI;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.probe.Probe;
@ -10,6 +9,7 @@ import com.loafle.overflow.service.central.probe.ProbeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
@ -72,4 +72,12 @@ public class CentralProbeService implements ProbeService {
return this.probeDAO.save(probe);
}
public void onConnect(String probeKey, String connectAddress) throws OverflowException {
this.probeDAO.saveConnect(probeKey, new Date(), connectAddress);
}
public void onDisconnect(String probeKey) throws OverflowException {
this.probeDAO.saveConnect(probeKey, null, null);
}
}

View File

@ -1,35 +0,0 @@
package com.loafle.overflow.central.module.websocket;
import javax.persistence.*;
import java.util.Date;
/**
* Created by root on 17. 6. 22.
*/
@Entity
@Table(name = "UI_WEBSOCKET", schema = "public")
public class UiWebsocket {
private long id;
private Date createDate;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Basic
@Column(name = "CREATE_DATE", nullable = true)
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}