From 507d4ebb0425bfee22975c9060625c67b9e6f9d0 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Wed, 23 Nov 2022 14:08:02 +0800 Subject: [PATCH] =?UTF-8?q?license=E3=80=81=E7=AB=AF=E5=8F=A3=E6=98=A0?= =?UTF-8?q?=E5=B0=84=E5=9C=A8=E7=BA=BF=E7=8A=B6=E6=80=81=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../neutrino/proxy/server/dal/LicenseMapper.java | 3 +++ .../proxy/server/dal/PortMappingMapper.java | 3 +++ .../proxy/server/service/LicenseService.java | 13 ++++++++++--- .../proxy/server/service/PortMappingService.java | 13 ++++++++++--- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/LicenseMapper.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/LicenseMapper.java index f24dc5b8..d2547af7 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/LicenseMapper.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/LicenseMapper.java @@ -74,6 +74,9 @@ public interface LicenseMapper extends SqlMapper { @Update("update `license` set is_online = :isOnline, update_time = :updateTime where id = :id") void updateOnlineStatus(@Param("id") Integer id, @Param("isOnline") Integer isOnline, @Param("updateTime") Date updateTime); + @Update("update `license` set is_online = :isOnline, update_time = :updateTime") + void updateOnlineStatus(@Param("isOnline") Integer isOnline, @Param("updateTime") Date updateTime); + @Update("update `license` set key = :key,update_time = :updateTime where id = :id") void reset(@Param("id") Integer id, @Param("key") String key, @Param("updateTime") Date updateTime); diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/PortMappingMapper.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/PortMappingMapper.java index 97245a7d..da2714ad 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/PortMappingMapper.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/PortMappingMapper.java @@ -79,4 +79,7 @@ public interface PortMappingMapper extends SqlMapper { @Update("update `port_mapping` set is_online = :isOnline,update_time = :updateTime where license_id = :licenseId") void updateOnlineStatus(@Param("licenseId") Integer licenseId, @Param("isOnline") Integer isOnline, @Param("updateTime") Date updateTime); + + @Update("update `port_mapping` set is_online = :isOnline,update_time = :updateTime") + void updateOnlineStatus(@Param("isOnline") Integer isOnline, @Param("updateTime") Date updateTime); } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java index 4da7fe49..20eaaee3 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java @@ -22,9 +22,7 @@ package fun.asgc.neutrino.proxy.server.service; import com.google.common.collect.Sets; -import fun.asgc.neutrino.core.annotation.Autowired; -import fun.asgc.neutrino.core.annotation.Component; -import fun.asgc.neutrino.core.annotation.NonIntercept; +import fun.asgc.neutrino.core.annotation.*; import fun.asgc.neutrino.core.db.page.Page; import fun.asgc.neutrino.core.db.page.PageQuery; import fun.asgc.neutrino.core.util.CollectionUtil; @@ -202,4 +200,13 @@ public class LicenseService { } return licenseKey.substring(0, 10) + "****" + licenseKey.substring(licenseKey.length() - 10); } + + /** + * 服务端项目停止、启动时,更新在线状态为离线 + */ + @Init + @Destroy + public void destroy() { + licenseMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date()); + } } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java index fea4edce..15adbeb1 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/PortMappingService.java @@ -22,9 +22,7 @@ package fun.asgc.neutrino.proxy.server.service; import com.google.common.collect.Sets; -import fun.asgc.neutrino.core.annotation.Autowired; -import fun.asgc.neutrino.core.annotation.Component; -import fun.asgc.neutrino.core.annotation.NonIntercept; +import fun.asgc.neutrino.core.annotation.*; import fun.asgc.neutrino.core.db.page.Page; import fun.asgc.neutrino.core.db.page.PageQuery; import fun.asgc.neutrino.core.util.CollectionUtil; @@ -220,4 +218,13 @@ public class PortMappingService { return portMappingMapper.findEnableListByLicenseId(licenseId); } + /** + * 服务端项目停止、启动时,更新在线状态为离线 + */ + @Init + @Destroy + public void destroy() { + portMappingMapper.updateOnlineStatus(OnlineStatusEnum.OFFLINE.getStatus(), new Date()); + } + }