【新增功能】IoT: HTTP 插件模块
This commit is contained in:
@@ -21,6 +21,17 @@
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-common</artifactId>
|
||||
</dependency>
|
||||
<!-- PF4J -->
|
||||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package cn.iocoder.yudao.module.iot.api;
|
||||
|
||||
/**
|
||||
* 设备数据 API
|
||||
*/
|
||||
public interface DeviceDataApi {
|
||||
|
||||
/**
|
||||
* 保存设备数据
|
||||
*
|
||||
* @param productKey 产品 key
|
||||
* @param deviceName 设备名称
|
||||
* @param message 消息
|
||||
*/
|
||||
void saveDeviceData(String productKey, String deviceName, String message);
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.iot.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 服务注册表 - 插架模块使用,无法使用 Spring 注入
|
||||
*/
|
||||
public class ServiceRegistry {
|
||||
private static final Map<Class<?>, Object> services = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 注册服务
|
||||
*
|
||||
* @param serviceClass 服务类
|
||||
* @param serviceImpl 服务实现
|
||||
* @param <T> 服务类
|
||||
*/
|
||||
public static <T> void registerService(Class<T> serviceClass, T serviceImpl) {
|
||||
services.put(serviceClass, serviceImpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得服务
|
||||
*
|
||||
* @param serviceClass 服务类
|
||||
* @param <T> 服务类
|
||||
* @return 服务实现
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getService(Class<T> serviceClass) {
|
||||
return (T) services.get(serviceClass);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user