diff --git a/pom.xml b/pom.xml index 5b3e945d..5f077f10 100644 --- a/pom.xml +++ b/pom.xml @@ -162,22 +162,17 @@ 1.4.6 + org.springdoc springdoc-openapi-ui - 1.7.0 - - - org.yaml - snakeyaml - - + 1.6.10 - org.yaml - snakeyaml - 2.2 + org.springdoc + springdoc-openapi-security + 1.6.10 diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java index 587518f1..0a472f82 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java @@ -1,9 +1,12 @@ package com.genersoft.iot.vmp.conf; +import com.genersoft.iot.vmp.conf.security.JwtUtils; +import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; import org.springframework.core.annotation.Order; import org.springdoc.core.GroupedOpenApi; import org.springframework.beans.factory.annotation.Value; @@ -26,10 +29,14 @@ public class SpringDocConfig { contact.setName("pan"); contact.setEmail("648540858@qq.com"); return new OpenAPI() + .components(new Components() + .addSecuritySchemes(JwtUtils.HEADER, new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .bearerFormat("JWT"))) .info(new Info().title("WVP-PRO 接口文档") .contact(contact) .description("开箱即用的28181协议视频平台") - .version("v2.0") + .version("v3.1.0") .license(new License().name("Apache 2.0").url("http://springdoc.org"))); } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java index 3df75936..fcd19461 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java @@ -28,7 +28,7 @@ public class JwtUtils implements InitializingBean { private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class); - private static final String HEADER = "access-token"; + public static final String HEADER = "access-token"; private static final String AUDIENCE = "Audience"; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java index 2f4686a1..afc81050 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java @@ -68,6 +68,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { matchers.add("/"); matchers.add("/#/**"); matchers.add("/static/**"); + matchers.add("/swagger-ui.html"); + matchers.add("/swagger-ui/"); matchers.add("/index.html"); matchers.add("/doc.html"); matchers.add("/webjars/**"); @@ -77,6 +79,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { matchers.add("/api/device/query/snap/**"); matchers.add("/record_proxy/*/**"); matchers.add("/api/emit"); + matchers.add("/favicon.ico"); // 可以直接访问的静态数据 web.ignoring().antMatchers(matchers.toArray(new String[0])); } @@ -113,7 +116,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { .authorizeRequests() .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() .antMatchers(userSetting.getInterfaceAuthenticationExcludes().toArray(new String[0])).permitAll() - .antMatchers("/api/user/login","/index/hook/**","/zlm_Proxy/FhTuMYqB2HeCuNOb/record/t/1/2023-03-25/16:35:07-16:35:16-9353.mp4").permitAll() + .antMatchers("/api/user/login", "/index/hook/**", "/swagger-ui/**", "/doc.html").permitAll() .anyRequest().authenticated() // 异常处理器 .and() diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java index e614b9fd..14640d80 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.utils.DateUtil; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.dom4j.Attribute; import org.dom4j.Document; @@ -214,8 +215,11 @@ public class XmlUtil { return deviceChannel; } Element nameElement = itemDevice.element("Name"); - if (nameElement != null) { + // 当通道名称为空时,设置通道名称为通道编码,避免级联时因通道名称为空导致上级接收通道失败 + if (nameElement != null && StringUtils.isNotBlank(nameElement.getText())) { deviceChannel.setName(nameElement.getText()); + } else { + deviceChannel.setName(channelId); } if(channelId.length() <= 8) { deviceChannel.setHasAudio(false); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 1ff0d29f..608bc277 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import org.apache.ibatis.annotations.*; -import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -31,7 +30,7 @@ public interface DeviceChannelMapper { @Update(value = {"