Commit 698cec92bdf4f5c416874fd89fb6cbc50b8d9c14
1 parent
916024b8
【功能完善】IoT: 重命名插件模块,重构插件管理逻辑,优化代码结构,更新配置文件以支持新插件架构。
Showing
26 changed files
with
183 additions
and
153 deletions
yudao-module-iot/pom.xml
| @@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
| 10 | <modules> | 10 | <modules> |
| 11 | <module>yudao-module-iot-api</module> | 11 | <module>yudao-module-iot-api</module> |
| 12 | <module>yudao-module-iot-biz</module> | 12 | <module>yudao-module-iot-biz</module> |
| 13 | - <module>yudao-module-iot-plugin</module> | 13 | + <module>yudao-module-iot-plugins</module> |
| 14 | </modules> | 14 | </modules> |
| 15 | <modelVersion>4.0.0</modelVersion> | 15 | <modelVersion>4.0.0</modelVersion> |
| 16 | 16 |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/dependency-reduced-pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| 3 | - <parent> | ||
| 4 | - <artifactId>yudao-module-iot-plugin</artifactId> | ||
| 5 | - <groupId>cn.iocoder.boot</groupId> | ||
| 6 | - <version>2.2.0-snapshot</version> | ||
| 7 | - </parent> | ||
| 8 | - <modelVersion>4.0.0</modelVersion> | ||
| 9 | - <artifactId>yudao-module-iot-plugin-http</artifactId> | ||
| 10 | - <name>${project.artifactId}</name> | ||
| 11 | - <version>1.0.0</version> | ||
| 12 | - <description>物联网 插件模块 - http 插件</description> | ||
| 13 | - <build> | ||
| 14 | - <plugins> | ||
| 15 | - <plugin> | ||
| 16 | - <artifactId>maven-shade-plugin</artifactId> | ||
| 17 | - <version>3.2.4</version> | ||
| 18 | - <executions> | ||
| 19 | - <execution> | ||
| 20 | - <phase>package</phase> | ||
| 21 | - <goals> | ||
| 22 | - <goal>shade</goal> | ||
| 23 | - </goals> | ||
| 24 | - <configuration> | ||
| 25 | - <transformers> | ||
| 26 | - <transformer> | ||
| 27 | - <mainClass>com.example.HttpPluginSpringbootApplication</mainClass> | ||
| 28 | - </transformer> | ||
| 29 | - </transformers> | ||
| 30 | - </configuration> | ||
| 31 | - </execution> | ||
| 32 | - </executions> | ||
| 33 | - </plugin> | ||
| 34 | - </plugins> | ||
| 35 | - </build> | ||
| 36 | - <properties> | ||
| 37 | - <plugin.id>${project.artifactId}</plugin.id> | ||
| 38 | - <plugin.description>${project.artifactId}-${project.version}</plugin.description> | ||
| 39 | - <plugin.class>cn.iocoder.yudao.module.iot.config.HttpVertxPlugin</plugin.class> | ||
| 40 | - <plugin.version>${project.version}</plugin.version> | ||
| 41 | - <plugin.provider>yudao</plugin.provider> | ||
| 42 | - </properties> | ||
| 43 | -</project> |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/config/TestConfiguration.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.config; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; | ||
| 5 | -import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceEventReportReqDTO; | ||
| 6 | -import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO; | ||
| 7 | -import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceStatusUpdateReqDTO; | ||
| 8 | -import org.pf4j.DefaultPluginManager; | ||
| 9 | -import org.pf4j.PluginWrapper; | ||
| 10 | -import org.springframework.boot.web.client.RestTemplateBuilder; | ||
| 11 | -import org.springframework.context.annotation.Bean; | ||
| 12 | -import org.springframework.context.annotation.Configuration; | ||
| 13 | -import org.springframework.web.client.RestTemplate; | ||
| 14 | - | ||
| 15 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 16 | - | ||
| 17 | -// TODO 芋艿:临时实现; | ||
| 18 | -@Configuration | ||
| 19 | -public class TestConfiguration { | ||
| 20 | - | ||
| 21 | -// @Resource | ||
| 22 | -// private RestTemplate restTemplate; | ||
| 23 | - | ||
| 24 | - // TODO 芋艿:这里,后续看看怎么创建好点 | ||
| 25 | - @Bean | ||
| 26 | - public RestTemplate restTemplate() { | ||
| 27 | - return new RestTemplateBuilder().build(); | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - @Bean | ||
| 31 | - public DeviceDataApi deviceDataApi(RestTemplate restTemplate) { | ||
| 32 | - return new DeviceDataApi() { | ||
| 33 | - | ||
| 34 | - @Override | ||
| 35 | - public CommonResult<Boolean> updateDeviceStatus(IotDeviceStatusUpdateReqDTO updateReqDTO) { | ||
| 36 | - // TODO haohao:待实现 | ||
| 37 | - return null; | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - @Override | ||
| 41 | - public CommonResult<Boolean> reportDeviceEventData(IotDeviceEventReportReqDTO reportReqDTO) { | ||
| 42 | - // TODO haohao:待实现 | ||
| 43 | - return null; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - @Override | ||
| 47 | - public CommonResult<Boolean> reportDevicePropertyData(IotDevicePropertyReportReqDTO reportReqDTO) { | ||
| 48 | - // TODO haohao:待完整实现 | ||
| 49 | - String url = "http://127.0.0.1:48080/rpc-api/iot/device-data/report-property"; | ||
| 50 | - try { | ||
| 51 | - restTemplate.postForObject(url, reportReqDTO, CommonResult.class); | ||
| 52 | - return success(true); | ||
| 53 | - } catch (Exception e) { | ||
| 54 | - e.printStackTrace(); | ||
| 55 | - return CommonResult.error(400, "error"); | ||
| 56 | - } | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - }; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - // TODO @haohao:可能要看下,有没更好的方式 | ||
| 63 | - @Bean(initMethod = "start") | ||
| 64 | - public HttpVertxPlugin HttpVertxPlugin() { | ||
| 65 | - PluginWrapper pluginWrapper = new PluginWrapper(new DefaultPluginManager(), null, null, null); | ||
| 66 | - return new HttpVertxPlugin(pluginWrapper); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | -} |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/resources/application.yml deleted
yudao-module-iot/yudao-module-iot-plugin/pom.xml renamed to yudao-module-iot/yudao-module-iot-plugins/pom.xml
| @@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
| 8 | <version>${revision}</version> | 8 | <version>${revision}</version> |
| 9 | </parent> | 9 | </parent> |
| 10 | <modules> | 10 | <modules> |
| 11 | + <module>yudao-module-iot-plugin-common</module> | ||
| 11 | <module>yudao-module-iot-plugin-http</module> | 12 | <module>yudao-module-iot-plugin-http</module> |
| 12 | <module>yudao-module-iot-plugin-mqtt</module> | 13 | <module>yudao-module-iot-plugin-mqtt</module> |
| 13 | <module>yudao-module-iot-plugin-emqx</module> | 14 | <module>yudao-module-iot-plugin-emqx</module> |
| @@ -15,7 +16,7 @@ | @@ -15,7 +16,7 @@ | ||
| 15 | 16 | ||
| 16 | <modelVersion>4.0.0</modelVersion> | 17 | <modelVersion>4.0.0</modelVersion> |
| 17 | 18 | ||
| 18 | - <artifactId>yudao-module-iot-plugin</artifactId> | 19 | + <artifactId>yudao-module-iot-plugins</artifactId> |
| 19 | <packaging>pom</packaging> | 20 | <packaging>pom</packaging> |
| 20 | 21 | ||
| 21 | <name>${project.artifactId}</name> | 22 | <name>${project.artifactId}</name> |
yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-common/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 5 | + <parent> | ||
| 6 | + <artifactId>yudao-module-iot-plugins</artifactId> | ||
| 7 | + <groupId>cn.iocoder.boot</groupId> | ||
| 8 | + <version>${revision}</version> | ||
| 9 | + </parent> | ||
| 10 | + <modelVersion>4.0.0</modelVersion> | ||
| 11 | + <artifactId>yudao-module-iot-plugin-common</artifactId> | ||
| 12 | + <packaging>jar</packaging> | ||
| 13 | + | ||
| 14 | + <name>${project.artifactId}</name> | ||
| 15 | + <description> | ||
| 16 | + 物联网 插件 模块 - 通用功能 | ||
| 17 | + </description> | ||
| 18 | + | ||
| 19 | + <dependencies> | ||
| 20 | + <dependency> | ||
| 21 | + <groupId>cn.iocoder.boot</groupId> | ||
| 22 | + <artifactId>yudao-common</artifactId> | ||
| 23 | + </dependency> | ||
| 24 | + <!-- 项目依赖 --> | ||
| 25 | + <dependency> | ||
| 26 | + <groupId>cn.iocoder.boot</groupId> | ||
| 27 | + <artifactId>yudao-module-iot-api</artifactId> | ||
| 28 | + <version>${revision}</version> | ||
| 29 | + </dependency> | ||
| 30 | + | ||
| 31 | + <!-- 其他依赖项 --> | ||
| 32 | + <dependency> | ||
| 33 | + <groupId>org.springframework.boot</groupId> | ||
| 34 | + <artifactId>spring-boot-starter-web</artifactId> | ||
| 35 | + </dependency> | ||
| 36 | + | ||
| 37 | + <!-- PF4J --> | ||
| 38 | + <dependency> | ||
| 39 | + <groupId>org.pf4j</groupId> | ||
| 40 | + <artifactId>pf4j-spring</artifactId> | ||
| 41 | + <exclusions> | ||
| 42 | + <exclusion> | ||
| 43 | + <groupId>org.slf4j</groupId> | ||
| 44 | + <artifactId>slf4j-log4j12</artifactId> | ||
| 45 | + </exclusion> | ||
| 46 | + </exclusions> | ||
| 47 | + </dependency> | ||
| 48 | + | ||
| 49 | + <dependency> | ||
| 50 | + <groupId>org.projectlombok</groupId> | ||
| 51 | + <artifactId>lombok</artifactId> | ||
| 52 | + </dependency> | ||
| 53 | + </dependencies> | ||
| 54 | + | ||
| 55 | +</project> |
yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-common/src/main/java/cn/iocoder/yudao/module/iot/plugin/common/api/DeviceDataApiClient.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.plugin.common.api; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; | ||
| 5 | +import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceEventReportReqDTO; | ||
| 6 | +import cn.iocoder.yudao.module.iot.api.device.dto.IotDevicePropertyReportReqDTO; | ||
| 7 | +import cn.iocoder.yudao.module.iot.api.device.dto.IotDeviceStatusUpdateReqDTO; | ||
| 8 | +import lombok.extern.slf4j.Slf4j; | ||
| 9 | +import org.springframework.web.client.RestTemplate; | ||
| 10 | + | ||
| 11 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 12 | + | ||
| 13 | +@Slf4j | ||
| 14 | +public class DeviceDataApiClient implements DeviceDataApi { | ||
| 15 | + | ||
| 16 | + private final RestTemplate restTemplate; | ||
| 17 | + private final String deviceDataUrl; | ||
| 18 | + | ||
| 19 | + // 可以通过构造器把 RestTemplate 和 baseUrl 注入进来 | ||
| 20 | + public DeviceDataApiClient(RestTemplate restTemplate, String deviceDataUrl) { | ||
| 21 | + this.restTemplate = restTemplate; | ||
| 22 | + this.deviceDataUrl = deviceDataUrl; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public CommonResult<Boolean> updateDeviceStatus(IotDeviceStatusUpdateReqDTO updateReqDTO) { | ||
| 27 | + // 示例:如果对应的远程地址是 /rpc-api/iot/device-data/update-status | ||
| 28 | + String url = deviceDataUrl + "/rpc-api/iot/device-data/update-status"; | ||
| 29 | + return doPost(url, updateReqDTO, "updateDeviceStatus"); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public CommonResult<Boolean> reportDeviceEventData(IotDeviceEventReportReqDTO reportReqDTO) { | ||
| 34 | + // 示例:如果对应的远程地址是 /rpc-api/iot/device-data/report-event | ||
| 35 | + String url = deviceDataUrl + "/rpc-api/iot/device-data/report-event"; | ||
| 36 | + return doPost(url, reportReqDTO, "reportDeviceEventData"); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public CommonResult<Boolean> reportDevicePropertyData(IotDevicePropertyReportReqDTO reportReqDTO) { | ||
| 41 | + // 示例:如果对应的远程地址是 /rpc-api/iot/device-data/report-property | ||
| 42 | + String url = deviceDataUrl + "/rpc-api/iot/device-data/report-property"; | ||
| 43 | + return doPost(url, reportReqDTO, "reportDevicePropertyData"); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 将与远程服务交互的通用逻辑抽取成一个私有方法 | ||
| 48 | + */ | ||
| 49 | + private <T> CommonResult<Boolean> doPost(String url, T requestBody, String actionName) { | ||
| 50 | + log.info("[{}] Sending request to URL: {}", actionName, url); | ||
| 51 | + try { | ||
| 52 | + // 这里指定返回类型为 CommonResult<?>,根据后台服务返回的实际结构做调整 | ||
| 53 | + restTemplate.postForObject(url, requestBody, CommonResult.class); | ||
| 54 | + return success(true); | ||
| 55 | + } catch (Exception e) { | ||
| 56 | + log.error("[{}] Error sending request to URL: {}", actionName, url, e); | ||
| 57 | + return CommonResult.error(400, "Request error: " + e.getMessage()); | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | +} |
yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-common/src/main/java/cn/iocoder/yudao/module/iot/plugin/common/config/DeviceDataApiInitializer.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.plugin.common.config; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; | ||
| 4 | +import cn.iocoder.yudao.module.iot.plugin.common.api.DeviceDataApiClient; | ||
| 5 | +import org.springframework.beans.factory.annotation.Value; | ||
| 6 | +import org.springframework.boot.web.client.RestTemplateBuilder; | ||
| 7 | +import org.springframework.context.annotation.Bean; | ||
| 8 | +import org.springframework.context.annotation.Configuration; | ||
| 9 | +import org.springframework.web.client.RestTemplate; | ||
| 10 | + | ||
| 11 | +@Configuration | ||
| 12 | +public class DeviceDataApiInitializer { | ||
| 13 | + | ||
| 14 | + @Value("${iot.device-data.url}") | ||
| 15 | + private String deviceDataUrl; | ||
| 16 | + | ||
| 17 | + @Bean | ||
| 18 | + public RestTemplate restTemplate() { | ||
| 19 | + // 如果你有更多的自定义需求,比如连接池、超时时间等,可以在这里设置 | ||
| 20 | + return new RestTemplateBuilder().build(); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + @Bean | ||
| 24 | + public DeviceDataApi deviceDataApi(RestTemplate restTemplate) { | ||
| 25 | + // 返回我们自定义的 Client 实例 | ||
| 26 | + return new DeviceDataApiClient(restTemplate, deviceDataUrl); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | +} |
yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-common/src/main/java/cn/iocoder/yudao/module/iot/plugin/common/package-info.java
0 → 100644
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-emqx/plugin.properties renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-emqx/plugin.properties
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-emqx/pom.xml renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-emqx/pom.xml
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | http://maven.apache.org/POM/4.0.0 | 4 | http://maven.apache.org/POM/4.0.0 |
| 5 | http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 5 | http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 6 | <parent> | 6 | <parent> |
| 7 | - <artifactId>yudao-module-iot-plugin</artifactId> | 7 | + <artifactId>yudao-module-iot-plugins</artifactId> |
| 8 | <groupId>cn.iocoder.boot</groupId> | 8 | <groupId>cn.iocoder.boot</groupId> |
| 9 | <version>${revision}</version> | 9 | <version>${revision}</version> |
| 10 | </parent> | 10 | </parent> |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-emqx/src/main/assembly/assembly.xml renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-emqx/src/main/assembly/assembly.xml
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-emqx/src/main/java/cn/iocoder/yudao/module/iot/plugin/EmqxPlugin.java renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-emqx/src/main/java/cn/iocoder/yudao/module/iot/plugin/EmqxPlugin.java
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/plugin.properties renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-http/plugin.properties
| 1 | plugin.id=yudao-module-iot-plugin-http | 1 | plugin.id=yudao-module-iot-plugin-http |
| 2 | -plugin.class=cn.iocoder.yudao.module.iot.config.HttpVertxPlugin | 2 | +plugin.class=cn.iocoder.yudao.module.iot.plugin.http.config.HttpVertxPlugin |
| 3 | plugin.version=1.0.0 | 3 | plugin.version=1.0.0 |
| 4 | plugin.provider=yudao | 4 | plugin.provider=yudao |
| 5 | plugin.dependencies= | 5 | plugin.dependencies= |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/pom.xml renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-http/pom.xml
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | http://maven.apache.org/POM/4.0.0 | 4 | http://maven.apache.org/POM/4.0.0 |
| 5 | http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 5 | http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 6 | <parent> | 6 | <parent> |
| 7 | - <artifactId>yudao-module-iot-plugin</artifactId> | 7 | + <artifactId>yudao-module-iot-plugins</artifactId> |
| 8 | <groupId>cn.iocoder.boot</groupId> | 8 | <groupId>cn.iocoder.boot</groupId> |
| 9 | <version>${revision}</version> | 9 | <version>${revision}</version> |
| 10 | </parent> | 10 | </parent> |
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | <properties> | 22 | <properties> |
| 23 | <!-- 插件相关 --> | 23 | <!-- 插件相关 --> |
| 24 | <plugin.id>${project.artifactId}</plugin.id> | 24 | <plugin.id>${project.artifactId}</plugin.id> |
| 25 | - <plugin.class>cn.iocoder.yudao.module.iot.config.HttpVertxPlugin</plugin.class> | 25 | + <plugin.class>cn.iocoder.yudao.module.iot.plugin.http.config.HttpVertxPlugin</plugin.class> |
| 26 | <plugin.version>${project.version}</plugin.version> | 26 | <plugin.version>${project.version}</plugin.version> |
| 27 | <plugin.provider>yudao</plugin.provider> | 27 | <plugin.provider>yudao</plugin.provider> |
| 28 | <plugin.description>${project.artifactId}-${project.version}</plugin.description> | 28 | <plugin.description>${project.artifactId}-${project.version}</plugin.description> |
| @@ -121,26 +121,12 @@ | @@ -121,26 +121,12 @@ | ||
| 121 | </build> | 121 | </build> |
| 122 | 122 | ||
| 123 | <dependencies> | 123 | <dependencies> |
| 124 | - <!-- 其他依赖项 --> | ||
| 125 | - <dependency> | ||
| 126 | - <groupId>org.springframework.boot</groupId> | ||
| 127 | - <artifactId>spring-boot-starter-web</artifactId> | ||
| 128 | - </dependency> | ||
| 129 | - <!-- PF4J Spring 集成 --> | ||
| 130 | - <dependency> | ||
| 131 | - <groupId>org.pf4j</groupId> | ||
| 132 | - <artifactId>pf4j-spring</artifactId> | ||
| 133 | - </dependency> | ||
| 134 | <!-- 项目依赖 --> | 124 | <!-- 项目依赖 --> |
| 135 | <dependency> | 125 | <dependency> |
| 136 | <groupId>cn.iocoder.boot</groupId> | 126 | <groupId>cn.iocoder.boot</groupId> |
| 137 | - <artifactId>yudao-module-iot-api</artifactId> | 127 | + <artifactId>yudao-module-iot-plugin-common</artifactId> |
| 138 | <version>${revision}</version> | 128 | <version>${revision}</version> |
| 139 | </dependency> | 129 | </dependency> |
| 140 | - <dependency> | ||
| 141 | - <groupId>org.projectlombok</groupId> | ||
| 142 | - <artifactId>lombok</artifactId> | ||
| 143 | - </dependency> | ||
| 144 | <!-- Vert.x Web --> | 130 | <!-- Vert.x Web --> |
| 145 | <dependency> | 131 | <dependency> |
| 146 | <groupId>io.vertx</groupId> | 132 | <groupId>io.vertx</groupId> |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/assembly/assembly.xml renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-http/src/main/assembly/assembly.xml
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/HttpPluginSpringbootApplication.java renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/plugin/http/HttpPluginSpringbootApplication.java
| 1 | -package cn.iocoder.yudao.module.iot; | 1 | +package cn.iocoder.yudao.module.iot.plugin.http; |
| 2 | 2 | ||
| 3 | import org.springframework.boot.SpringApplication; | 3 | import org.springframework.boot.SpringApplication; |
| 4 | import org.springframework.boot.WebApplicationType; | 4 | import org.springframework.boot.WebApplicationType; |
| 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 6 | 6 | ||
| 7 | -// TODO @haohao:建议包名:cn.iocoder.yudao.module.iot.plugin.${pluginName},例如说 http。然后子包如下: | ||
| 8 | -// config:方配置类,以及 HttpVertxPlugin 初始化 | ||
| 9 | -// service:放 HttpVertxHandler 逻辑; | ||
| 10 | -@SpringBootApplication | 7 | +@SpringBootApplication(scanBasePackages = "cn.iocoder.yudao.module.iot.plugin") |
| 11 | public class HttpPluginSpringbootApplication { | 8 | public class HttpPluginSpringbootApplication { |
| 12 | 9 | ||
| 13 | public static void main(String[] args) { | 10 | public static void main(String[] args) { |
| 14 | -// SpringApplication.run(HttpPluginSpringbootApplication.class, args); | ||
| 15 | SpringApplication application = new SpringApplication(HttpPluginSpringbootApplication.class); | 11 | SpringApplication application = new SpringApplication(HttpPluginSpringbootApplication.class); |
| 16 | application.setWebApplicationType(WebApplicationType.NONE); | 12 | application.setWebApplicationType(WebApplicationType.NONE); |
| 17 | application.run(args); | 13 | application.run(args); |
| 18 | } | 14 | } |
| 19 | 15 | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | -// TODO @haohao:如下是 sdk 的包:cn.iocoder.yudao.module.iot.plugin.sdk | ||
| 23 | -// 1. api 包:实现 DeviceDataApi 接口,通过 resttemplate 调用 | ||
| 24 | -// 2. config 包:初始化 DeviceDataApi 等等 | ||
| 25 | - | ||
| 26 | -// 3. 其中 resttemplate 调用的后端地址,通过每个服务的 application.yaml 进行注入。 | ||
| 27 | \ No newline at end of file | 16 | \ No newline at end of file |
| 17 | +} | ||
| 28 | \ No newline at end of file | 18 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/config/HttpVertxPlugin.java renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/plugin/http/config/HttpVertxPlugin.java
| 1 | -package cn.iocoder.yudao.module.iot.config; | 1 | +package cn.iocoder.yudao.module.iot.plugin.http.config; |
| 2 | 2 | ||
| 3 | import cn.hutool.extra.spring.SpringUtil; | 3 | import cn.hutool.extra.spring.SpringUtil; |
| 4 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; | 4 | import cn.iocoder.yudao.module.iot.api.device.DeviceDataApi; |
| 5 | -import cn.iocoder.yudao.module.iot.service.HttpVertxHandler; | 5 | +import cn.iocoder.yudao.module.iot.plugin.http.service.HttpVertxHandler; |
| 6 | import io.vertx.core.Vertx; | 6 | import io.vertx.core.Vertx; |
| 7 | import io.vertx.ext.web.Router; | 7 | import io.vertx.ext.web.Router; |
| 8 | import io.vertx.ext.web.handler.BodyHandler; | 8 | import io.vertx.ext.web.handler.BodyHandler; |
yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/plugin/http/config/HttpVertxPluginConfiguration.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.plugin.http.config; | ||
| 2 | + | ||
| 3 | +import org.pf4j.DefaultPluginManager; | ||
| 4 | +import org.pf4j.PluginWrapper; | ||
| 5 | +import org.springframework.context.annotation.Bean; | ||
| 6 | +import org.springframework.context.annotation.Configuration; | ||
| 7 | + | ||
| 8 | +@Configuration | ||
| 9 | +public class HttpVertxPluginConfiguration { | ||
| 10 | + | ||
| 11 | + @Bean(initMethod = "start") | ||
| 12 | + public HttpVertxPlugin httpVertxPlugin() { | ||
| 13 | + PluginWrapper pluginWrapper = new PluginWrapper(new DefaultPluginManager(), null, null, null); | ||
| 14 | + return new HttpVertxPlugin(pluginWrapper); | ||
| 15 | + } | ||
| 16 | +} | ||
| 0 | \ No newline at end of file | 17 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/service/HttpVertxHandler.java renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-http/src/main/java/cn/iocoder/yudao/module/iot/plugin/http/service/HttpVertxHandler.java
yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-http/src/main/resources/application.yml
0 → 100644
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/plugin.properties renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-mqtt/plugin.properties
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/pom.xml renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-mqtt/pom.xml
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | http://maven.apache.org/POM/4.0.0 | 4 | http://maven.apache.org/POM/4.0.0 |
| 5 | http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 5 | http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 6 | <parent> | 6 | <parent> |
| 7 | - <artifactId>yudao-module-iot-plugin</artifactId> | 7 | + <artifactId>yudao-module-iot-plugins</artifactId> |
| 8 | <groupId>cn.iocoder.boot</groupId> | 8 | <groupId>cn.iocoder.boot</groupId> |
| 9 | <version>${revision}</version> | 9 | <version>${revision}</version> |
| 10 | </parent> | 10 | </parent> |
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/src/main/assembly/assembly.xml renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-mqtt/src/main/assembly/assembly.xml
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/src/main/java/cn/iocoder/yudao/module/iot/plugin/MqttPlugin.java renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-mqtt/src/main/java/cn/iocoder/yudao/module/iot/plugin/MqttPlugin.java
yudao-module-iot/yudao-module-iot-plugin/yudao-module-iot-plugin-mqtt/src/main/java/cn/iocoder/yudao/module/iot/plugin/MqttServerExtension.java renamed to yudao-module-iot/yudao-module-iot-plugins/yudao-module-iot-plugin-mqtt/src/main/java/cn/iocoder/yudao/module/iot/plugin/MqttServerExtension.java