From 206922bb73b5ca4dbb1d75803a08b621afb93a62 Mon Sep 17 00:00:00 2001 From: xusd Date: Tue, 30 Jul 2024 10:27:48 +0800 Subject: [PATCH] =?UTF-8?q?LoRa=20Gateway=20MQTT=20Bridge=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GatewayBridgeController.java | 59 +++++++++++++++++++ .../gateway/lora/domain/GatewayBridge.java | 24 ++++++++ .../lora/mapper/GatewayBridgeMapper.java | 27 +++++++++ .../lora/service/IGatewayBridgeService.java | 27 +++++++++ .../impl/GatewayBridgeServiceImpl.java | 42 +++++++++++++ .../lora/bridge/GatewayBridgeMapper.xml | 29 +++++++++ .../templates/lora/bridge/bridge.html | 44 ++++++++++++++ 7 files changed, 252 insertions(+) create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/controller/GatewayBridgeController.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/domain/GatewayBridge.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/mapper/GatewayBridgeMapper.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/service/IGatewayBridgeService.java create mode 100644 ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/service/impl/GatewayBridgeServiceImpl.java create mode 100644 ruoyi-gateway/src/main/resources/mapper/lora/bridge/GatewayBridgeMapper.xml create mode 100644 ruoyi-gateway/src/main/resources/templates/lora/bridge/bridge.html diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/controller/GatewayBridgeController.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/controller/GatewayBridgeController.java new file mode 100644 index 0000000..b324a07 --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/controller/GatewayBridgeController.java @@ -0,0 +1,59 @@ +package com.ruoyi.gateway.lora.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.gateway.lora.domain.GatewayBridge; +import com.ruoyi.gateway.lora.service.IGatewayBridgeService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.Objects; + +/** + * BridgeController + * + * @Author xusd + * @Date 2024/7/30 9:28 + **/ +@Controller +@RequestMapping("/lora/bridge") +public class GatewayBridgeController extends BaseController { + + private String prefix = "lora/bridge"; + + @Autowired + private IGatewayBridgeService gatewayBridgeService; + + @RequiresPermissions("lora:bridge:view") + @GetMapping() + public String bridge(ModelMap mmap) + { + GatewayBridge bridge = gatewayBridgeService.selectGatewayBridge(); + if (Objects.isNull(bridge)){ + bridge = new GatewayBridge(); + } + mmap.put("gatewayBridge", bridge); + return prefix + "/bridge"; + } + + /** + * 修改保存Bridge + */ + @RequiresPermissions("gateway:bridge:edit") + @Log(title = "Bridge", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(GatewayBridge gatewayBridge) + { + return toAjax(gatewayBridgeService.updateGatewayBridge(gatewayBridge)); + } + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/domain/GatewayBridge.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/domain/GatewayBridge.java new file mode 100644 index 0000000..99082fd --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/domain/GatewayBridge.java @@ -0,0 +1,24 @@ +package com.ruoyi.gateway.lora.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; + +/** + * Bridge对象 gateway_bridge + * + * @Author xusd + * @Date 2024/7/30 9:24 + **/ +@Data +public class GatewayBridge extends BaseEntity { + + /** IP地址 */ + @Excel(name = "IP地址") + private String address; + + /** 端口 */ + @Excel(name = "端口") + private String port; + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/mapper/GatewayBridgeMapper.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/mapper/GatewayBridgeMapper.java new file mode 100644 index 0000000..37c50af --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/mapper/GatewayBridgeMapper.java @@ -0,0 +1,27 @@ +package com.ruoyi.gateway.lora.mapper; + +import com.ruoyi.gateway.lora.domain.GatewayBridge; + +/** + * @Author xusd + * @Date 2024/7/30 9:38 + **/ +public interface GatewayBridgeMapper { + + /** + * 查询Bridge + * + * @return Bridge + */ + GatewayBridge selectGatewayBridge(); + + + /** + * 修改Bridge + * + * @param gatewayBridge Bridge + * @return 结果 + */ + int updateGatewayBridge(GatewayBridge gatewayBridge); + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/service/IGatewayBridgeService.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/service/IGatewayBridgeService.java new file mode 100644 index 0000000..a5ec1b6 --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/service/IGatewayBridgeService.java @@ -0,0 +1,27 @@ +package com.ruoyi.gateway.lora.service; + +import com.ruoyi.gateway.lora.domain.GatewayBridge; + +/** + * @Author xusd + * @Date 2024/7/30 9:31 + **/ +public interface IGatewayBridgeService { + + + /** + * 查询Bridge + * + * @return Bridge + */ + GatewayBridge selectGatewayBridge(); + + /** + * 修改Bridge + * + * @param gatewayBridge Bridge + * @return 结果 + */ + int updateGatewayBridge(GatewayBridge gatewayBridge); + +} diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/service/impl/GatewayBridgeServiceImpl.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/service/impl/GatewayBridgeServiceImpl.java new file mode 100644 index 0000000..2cc034e --- /dev/null +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/lora/service/impl/GatewayBridgeServiceImpl.java @@ -0,0 +1,42 @@ +package com.ruoyi.gateway.lora.service.impl; + +import com.ruoyi.gateway.lora.domain.GatewayBridge; +import com.ruoyi.gateway.lora.mapper.GatewayBridgeMapper; +import com.ruoyi.gateway.lora.service.IGatewayBridgeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Author xusd + * @Date 2024/7/30 9:36 + **/ +@Service +public class GatewayBridgeServiceImpl implements IGatewayBridgeService { + + @Autowired + private GatewayBridgeMapper gatewayBridgeMapper; + + /** + * 查询Bridge + * + * @return Bridge + */ + @Override + public GatewayBridge selectGatewayBridge() + { + return gatewayBridgeMapper.selectGatewayBridge(); + } + + /** + * 修改Bridge + * + * @param gatewayBridge Bridge + * @return 结果 + */ + @Override + public int updateGatewayBridge(GatewayBridge gatewayBridge) + { + return gatewayBridgeMapper.updateGatewayBridge(gatewayBridge); + } + +} diff --git a/ruoyi-gateway/src/main/resources/mapper/lora/bridge/GatewayBridgeMapper.xml b/ruoyi-gateway/src/main/resources/mapper/lora/bridge/GatewayBridgeMapper.xml new file mode 100644 index 0000000..30d4504 --- /dev/null +++ b/ruoyi-gateway/src/main/resources/mapper/lora/bridge/GatewayBridgeMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + select address, port from gateway_bridge + + + + + + update gateway_bridge + + address = #{address}, + port = #{port}, + + + + \ No newline at end of file diff --git a/ruoyi-gateway/src/main/resources/templates/lora/bridge/bridge.html b/ruoyi-gateway/src/main/resources/templates/lora/bridge/bridge.html new file mode 100644 index 0000000..1e5f1ec --- /dev/null +++ b/ruoyi-gateway/src/main/resources/templates/lora/bridge/bridge.html @@ -0,0 +1,44 @@ + + + + + + +
+
基本设置
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ 确定 +
+
+
+ + + + \ No newline at end of file