tjf před 21 hodinami
rodič
revize
31982070c5

+ 0 - 14
pom.xml

@@ -21,7 +21,6 @@
         <spring-boot.version>2.5.15</spring-boot.version>
         <druid.version>1.2.23</druid.version>
         <bitwalker.version>1.21</bitwalker.version>
-        <swagger.version>3.0.0</swagger.version>
         <kaptcha.version>2.3.3</kaptcha.version>
         <pagehelper.boot.version>1.4.7</pagehelper.boot.version>
         <fastjson.version>2.0.53</fastjson.version>
@@ -129,19 +128,6 @@
                 <version>${oshi.version}</version>
             </dependency>
 
-            <!-- Swagger3依赖 -->
-            <dependency>
-                <groupId>io.springfox</groupId>
-                <artifactId>springfox-boot-starter</artifactId>
-                <version>${swagger.version}</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>io.swagger</groupId>
-                        <artifactId>swagger-models</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-
             <!-- io常用工具类 -->
             <dependency>
                 <groupId>commons-io</groupId>

+ 0 - 13
ruoyi-admin/pom.xml

@@ -40,19 +40,6 @@
             <optional>true</optional> <!-- 表示依赖不会传递 -->
         </dependency>
 
-        <!-- swagger3-->
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-boot-starter</artifactId>
-        </dependency>
-
-        <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
-        <dependency>
-            <groupId>io.swagger</groupId>
-            <artifactId>swagger-models</artifactId>
-            <version>1.6.2</version>
-        </dependency>
-
         <!-- Mysql驱动包 -->
         <dependency>
             <groupId>mysql</groupId>

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/ChannelNumberController.java

@@ -96,6 +96,6 @@ public class ChannelNumberController extends BaseController {
     @Log(title = "通道管理", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{channelIds}")
     public AjaxResult remove(@PathVariable Long[] channelIds) {
-        return toAjax(channelNumberService.deleteChannelNumberByChannelIds(channelIds));
+        return channelNumberService.deleteChannelNumberByChannelIds(channelIds);
     }
 }

+ 0 - 183
ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java

@@ -1,183 +0,0 @@
-package com.ruoyi.web.controller.tool;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.R;
-import com.ruoyi.common.utils.StringUtils;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import io.swagger.annotations.ApiOperation;
-
-/**
- * swagger 用户测试方法
- * 
- * @author ruoyi
- */
-@Api("用户信息管理")
-@RestController
-@RequestMapping("/test/user")
-public class TestController extends BaseController
-{
-    private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
-    {
-        users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
-        users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
-    }
-
-    @ApiOperation("获取用户列表")
-    @GetMapping("/list")
-    public R<List<UserEntity>> userList()
-    {
-        List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
-        return R.ok(userList);
-    }
-
-    @ApiOperation("获取用户详细")
-    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
-    @GetMapping("/{userId}")
-    public R<UserEntity> getUser(@PathVariable Integer userId)
-    {
-        if (!users.isEmpty() && users.containsKey(userId))
-        {
-            return R.ok(users.get(userId));
-        }
-        else
-        {
-            return R.fail("用户不存在");
-        }
-    }
-
-    @ApiOperation("新增用户")
-    @ApiImplicitParams({
-        @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
-        @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
-        @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
-        @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
-    })
-    @PostMapping("/save")
-    public R<String> save(UserEntity user)
-    {
-        if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
-        {
-            return R.fail("用户ID不能为空");
-        }
-        users.put(user.getUserId(), user);
-        return R.ok();
-    }
-
-    @ApiOperation("更新用户")
-    @PutMapping("/update")
-    public R<String> update(@RequestBody UserEntity user)
-    {
-        if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
-        {
-            return R.fail("用户ID不能为空");
-        }
-        if (users.isEmpty() || !users.containsKey(user.getUserId()))
-        {
-            return R.fail("用户不存在");
-        }
-        users.remove(user.getUserId());
-        users.put(user.getUserId(), user);
-        return R.ok();
-    }
-
-    @ApiOperation("删除用户信息")
-    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
-    @DeleteMapping("/{userId}")
-    public R<String> delete(@PathVariable Integer userId)
-    {
-        if (!users.isEmpty() && users.containsKey(userId))
-        {
-            users.remove(userId);
-            return R.ok();
-        }
-        else
-        {
-            return R.fail("用户不存在");
-        }
-    }
-}
-
-@ApiModel(value = "UserEntity", description = "用户实体")
-class UserEntity
-{
-    @ApiModelProperty("用户ID")
-    private Integer userId;
-
-    @ApiModelProperty("用户名称")
-    private String username;
-
-    @ApiModelProperty("用户密码")
-    private String password;
-
-    @ApiModelProperty("用户手机")
-    private String mobile;
-
-    public UserEntity()
-    {
-
-    }
-
-    public UserEntity(Integer userId, String username, String password, String mobile)
-    {
-        this.userId = userId;
-        this.username = username;
-        this.password = password;
-        this.mobile = mobile;
-    }
-
-    public Integer getUserId()
-    {
-        return userId;
-    }
-
-    public void setUserId(Integer userId)
-    {
-        this.userId = userId;
-    }
-
-    public String getUsername()
-    {
-        return username;
-    }
-
-    public void setUsername(String username)
-    {
-        this.username = username;
-    }
-
-    public String getPassword()
-    {
-        return password;
-    }
-
-    public void setPassword(String password)
-    {
-        this.password = password;
-    }
-
-    public String getMobile()
-    {
-        return mobile;
-    }
-
-    public void setMobile(String mobile)
-    {
-        this.mobile = mobile;
-    }
-}

+ 37 - 15
ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java

@@ -1,3 +1,4 @@
+/*
 package com.ruoyi.web.core.config;
 
 import java.util.ArrayList;
@@ -22,29 +23,39 @@ import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spi.service.contexts.SecurityContext;
 import springfox.documentation.spring.web.plugins.Docket;
 
+*/
 /**
  * Swagger2的接口配置
  * 
  * @author ruoyi
- */
+ *//*
+
 @Configuration
 public class SwaggerConfig
 {
-    /** 系统基础配置 */
+    */
+/** 系统基础配置 *//*
+
     @Autowired
     private RuoYiConfig ruoyiConfig;
 
-    /** 是否开启swagger */
+    */
+/** 是否开启swagger *//*
+
     @Value("${swagger.enabled}")
     private boolean enabled;
 
-    /** 设置请求的统一前缀 */
+    */
+/** 设置请求的统一前缀 *//*
+
     @Value("${swagger.pathMapping}")
     private String pathMapping;
 
-    /**
+    */
+/**
      * 创建API
-     */
+     *//*
+
     @Bean
     public Docket createRestApi()
     {
@@ -62,15 +73,19 @@ public class SwaggerConfig
                 // 扫描所有 .apis(RequestHandlerSelectors.any())
                 .paths(PathSelectors.any())
                 .build()
-                /* 设置安全模式,swagger可以设置访问token */
+                */
+/* 设置安全模式,swagger可以设置访问token *//*
+
                 .securitySchemes(securitySchemes())
                 .securityContexts(securityContexts())
                 .pathMapping(pathMapping);
     }
 
-    /**
+    */
+/**
      * 安全模式,这里指定token通过Authorization头请求头传递
-     */
+     *//*
+
     private List<SecurityScheme> securitySchemes()
     {
         List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
@@ -78,9 +93,11 @@ public class SwaggerConfig
         return apiKeyList;
     }
 
-    /**
+    */
+/**
      * 安全上下文
-     */
+     *//*
+
     private List<SecurityContext> securityContexts()
     {
         List<SecurityContext> securityContexts = new ArrayList<>();
@@ -92,9 +109,11 @@ public class SwaggerConfig
         return securityContexts;
     }
 
-    /**
+    */
+/**
      * 默认的安全上引用
-     */
+     *//*
+
     private List<SecurityReference> defaultAuth()
     {
         AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
@@ -105,9 +124,11 @@ public class SwaggerConfig
         return securityReferences;
     }
 
-    /**
+    */
+/**
      * 添加摘要信息
-     */
+     *//*
+
     private ApiInfo apiInfo()
     {
         // 用ApiInfoBuilder进行定制
@@ -123,3 +144,4 @@ public class SwaggerConfig
                 .build();
     }
 }
+*/

+ 5 - 7
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java

@@ -1,19 +1,17 @@
 package com.ruoyi.framework.config;
 
-import java.util.concurrent.TimeUnit;
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.http.CacheControl;
 import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
 import org.springframework.web.filter.CorsFilter;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-import com.ruoyi.common.config.RuoYiConfig;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
 
 /**
  * 通用配置
@@ -33,10 +31,10 @@ public class ResourcesConfig implements WebMvcConfigurer
         registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
                 .addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
 
-        /** swagger配置 */
+/*        *//** swagger配置 *//*
         registry.addResourceHandler("/swagger-ui/**")
                 .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
-                .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());
+                .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());*/
     }
 
     /**

+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -114,7 +114,7 @@ public class SecurityConfig
                 requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
                     // 静态资源,可匿名访问
                     .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
-                    .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
+                    .antMatchers("/webjars/**",  "/druid/**").permitAll()
                     // 除上面外的所有请求全部需要鉴权认证
                     .anyRequest().authenticated();
             })

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/manage/service/IChannelNumberService.java

@@ -52,7 +52,7 @@ public interface IChannelNumberService
      * @param channelIds 需要删除的通道管理主键集合
      * @return 结果
      */
-    public int deleteChannelNumberByChannelIds(Long[] channelIds);
+    public AjaxResult deleteChannelNumberByChannelIds(Long[] channelIds);
 
     /**
      * 删除通道管理信息

+ 14 - 4
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/ChannelNumberServiceImpl.java

@@ -15,6 +15,7 @@ import com.ruoyi.mqtt.service.MqttService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
@@ -108,7 +109,7 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
         String videoAddress = channelNumber.getVideoAddress();
         if (StringUtils.isNotEmpty(videoAddress)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, channelId + "_" + videoAddress);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, ZERO + "#" + channelId + "#" + videoAddress);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_RTSP);
@@ -145,7 +146,7 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
         String videoAddress = channelNumber.getVideoAddress();
         if (StringUtils.isNotEmpty(videoAddress)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, channelId + "_" + videoAddress);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, ONE + "#" + channelId + "#" + videoAddress);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_RTSP);
@@ -163,8 +164,17 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
      * @return 结果
      */
     @Override
-    public int deleteChannelNumberByChannelIds(Long[] channelIds) {
-        return channelNumberMapper.deleteChannelNumberByChannelIds(channelIds);
+    public AjaxResult deleteChannelNumberByChannelIds(Long[] channelIds) {
+        int row = channelNumberMapper.deleteChannelNumberByChannelIds(channelIds);
+        if (channelIds != null && channelIds.length > 0) {
+            try {
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, TWO + "#" + Arrays.toString(channelIds));
+                future.get(10, TimeUnit.SECONDS);
+            } catch (InterruptedException | ExecutionException | TimeoutException e) {
+                return AjaxResult.error("发布消息失败:" + DETECTION_RTSP);
+            }
+        }
+        return row > 0 ? AjaxResult.success() : AjaxResult.error();
     }
 
     /**