mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
feat(支持springboot3): 支持springboot3框架
This commit is contained in:
@@ -2,11 +2,10 @@ package com.fastbee.base.core.hanler;
|
||||
|
||||
import com.fastbee.common.core.protocol.Message;
|
||||
import com.fastbee.base.session.Session;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 基础处理类
|
||||
@@ -34,8 +33,9 @@ public abstract class BaseHandler {
|
||||
this.targetMethod = targetMethod;
|
||||
this.returnVoid = targetMethod.getReturnType().isAssignableFrom(Void.TYPE);
|
||||
this.async = async;
|
||||
if (desc == null || desc.isEmpty())
|
||||
if (desc == null || desc.isEmpty()) {
|
||||
desc = targetMethod.getName();
|
||||
}
|
||||
this.desc = desc;
|
||||
|
||||
Type[] types = targetMethod.getGenericParameterTypes();
|
||||
@@ -44,8 +44,21 @@ public abstract class BaseHandler {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
Type type = types[i];
|
||||
Class<?> clazz;
|
||||
if (type instanceof ParameterizedTypeImpl) {
|
||||
clazz = (Class<?>) ((ParameterizedTypeImpl) type).getActualTypeArguments()[0];
|
||||
if (type instanceof ParameterizedType) {
|
||||
ParameterizedType pt = (ParameterizedType) type;
|
||||
// 检查是否为List/Collection等容器类型
|
||||
if (pt.getRawType() instanceof Class &&
|
||||
((Class<?>) pt.getRawType()).isArray() ||
|
||||
Collection.class.isAssignableFrom((Class<?>) pt.getRawType())) {
|
||||
Type[] actualTypes = pt.getActualTypeArguments();
|
||||
if (actualTypes.length > 0) {
|
||||
clazz = (Class<?>) actualTypes[0];
|
||||
} else {
|
||||
clazz = Object.class; // 默认类型
|
||||
}
|
||||
} else {
|
||||
clazz = (Class<?>) pt.getRawType(); // 处理非容器类型的参数化类型
|
||||
}
|
||||
} else {
|
||||
clazz = (Class<?>) type;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 客户端认证
|
||||
@@ -49,7 +49,9 @@ public class AuthService {
|
||||
*/
|
||||
public boolean auth(String clientId, String username, String password) {
|
||||
//不需要账号密码校验,直接返回true
|
||||
if (!mustPass) return true;
|
||||
if (!mustPass) {
|
||||
return true;
|
||||
}
|
||||
if (StringUtils.isEmpty(clientId) || StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
|
||||
log.error("=>客户端参数缺少,clientId:{},username:{},password:{}", clientId, username, password);
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.fastbee.mqtt.handler;
|
||||
|
||||
import com.fastbee.common.constant.FastBeeConstant;
|
||||
import com.fastbee.common.core.redis.RedisCache;
|
||||
import com.fastbee.common.enums.ServerType;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
@@ -21,7 +20,7 @@ import io.netty.util.CharsetUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import io.netty.handler.codec.mqtt.*;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import io.netty.handler.codec.mqtt.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -117,6 +117,7 @@ public class DataHandlerImpl implements IDataHandler {
|
||||
/**
|
||||
* 上报设备信息
|
||||
*/
|
||||
@Override
|
||||
public void reportDevice(ReportDataBo bo) {
|
||||
try {
|
||||
// 设备实体
|
||||
|
||||
@@ -19,7 +19,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ import com.fastbee.ruleEngine.context.MsgContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.mqtt.*;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
|
||||
<!-- ttl -->
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.fastbee.sip.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.text.Collator;
|
||||
import java.util.Comparator;
|
||||
@Data
|
||||
|
||||
@@ -19,7 +19,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -155,6 +155,7 @@ public class VideoMqttService implements IMqttService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishChannelsProperty(String DeviceSipId, List<SipDeviceChannel> channels) {
|
||||
SipConfig sipConfig = sipConfigService.selectSipConfigBydeviceSipId(DeviceSipId);
|
||||
if (null != sipConfig) {
|
||||
@@ -180,6 +181,7 @@ public class VideoMqttService implements IMqttService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishProperty(Long productId, String deviceNum, List<ThingsModelSimpleItem> thingsList, int delay) {
|
||||
String pre = "";
|
||||
if (delay > 0) {
|
||||
|
||||
Reference in New Issue
Block a user