Browse Source

国标级联支持搜索

648540858 1 year ago
parent
commit
0416b76ed0

+ 7 - 5
src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java

@@ -70,13 +70,15 @@ public class PlatformController {
         }
     }
 
-    @GetMapping("/query/{count}/{page}")
+    @GetMapping("/query")
     @Operation(summary = "分页查询级联平台", security = @SecurityRequirement(name = JwtUtils.HEADER))
-    @Parameter(name = "page", description = "当前页", required = true)
-    @Parameter(name = "count", description = "每页条数", required = true)
-    public PageInfo<Platform> platforms(@PathVariable int page, @PathVariable int count) {
+    @Parameter(name = "page", description = "当前页")
+    @Parameter(name = "count", description = "每页查询数量")
+    @Parameter(name = "query", description = "查询内容")
+    public PageInfo<Platform> platforms(int page, int count,
+                                        @RequestParam(required = false) String query) {
 
-        PageInfo<Platform> parentPlatformPageInfo = platformService.queryPlatformList(page, count);
+        PageInfo<Platform> parentPlatformPageInfo = platformService.queryPlatformList(page, count, query);
         if (parentPlatformPageInfo != null && !parentPlatformPageInfo.getList().isEmpty()) {
             for (Platform platform : parentPlatformPageInfo.getList()) {
                 platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null);

+ 7 - 4
src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java

@@ -62,15 +62,18 @@ public interface PlatformMapper {
     @Delete("DELETE FROM wvp_platform WHERE id=#{id}")
     int delete(@Param("id") Integer id);
 
-    @Select(" SELECT pp.*, " +
+    @Select(" <script>" +
+            " SELECT pp.*, " +
             " ( (SELECT count(0) FROM wvp_platform_channel pc WHERE pc.platform_id = pp.id ) + " +
             "  (SELECT count(0) FROM wvp_platform_group pg WHERE pg.platform_id = pp.id ) * pp.catalog_with_group  + " +
             "  (SELECT count(0) FROM wvp_platform_region pr WHERE pr.platform_id = pp.id ) * pp.catalog_with_region + " +
             "  pp.catalog_with_platform " +
             "    ) as channel_count" +
-            " FROM wvp_platform pp "
-    )
-    List<Platform> queryList();
+            " FROM wvp_platform pp where 1=1 " +
+            " <if test='query != null'> " +
+            " AND (pp.name LIKE concat('%',#{query},'%') OR pp.server_gb_id  LIKE concat('%',#{query},'%') )</if> " +
+            " </script>")
+    List<Platform> queryList(@Param("query") String query);
 
     @Select("SELECT * FROM wvp_platform WHERE enable=#{enable} ")
     List<Platform> getEnableParentPlatformList(boolean enable);

+ 1 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java

@@ -29,7 +29,7 @@ public interface IPlatformService {
      * @param count
      * @return
      */
-    PageInfo<Platform> queryPlatformList(int page, int count);
+    PageInfo<Platform> queryPlatformList(int page, int count, String query);
 
     /**
      * 添加级联平台

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java

@@ -156,9 +156,9 @@ public class PlatformServiceImpl implements IPlatformService {
     }
 
     @Override
-    public PageInfo<Platform> queryPlatformList(int page, int count) {
+    public PageInfo<Platform> queryPlatformList(int page, int count, String query) {
         PageHelper.startPage(page, count);
-        List<Platform> all = platformMapper.queryList();
+        List<Platform> all = platformMapper.queryList(query);
         return new PageInfo<>(all);
     }
 

+ 13 - 6
web_src/src/components/PlatformList.vue

@@ -4,6 +4,9 @@
       <div class="page-header">
         <div class="page-title">上级平台列表</div>
         <div class="page-header-btn">
+          搜索:
+          <el-input @input="getPlatformList" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
+                    prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
           <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary"
                      @click="addParentPlatform">添加
           </el-button>
@@ -111,6 +114,7 @@ export default {
       platform: null,
       pushChannelLoading: false,
       winHeight: window.innerHeight - 260,
+      searchSrt: "",
       currentPage: 1,
       count: 15,
       total: 0
@@ -258,15 +262,18 @@ export default {
       this.getPlatformList();
     },
     getPlatformList: function () {
-      let that = this;
-
       this.$axios({
         method: 'get',
-        url: `/api/platform/query/${that.count}/${that.currentPage}`
-      }).then(function (res) {
+        url: `/api/platform/query`,
+        params: {
+          count: this.count,
+          page: this.currentPage,
+          query: this.searchSrt
+        }
+      }).then((res)=> {
         if (res.data.code === 0) {
-          that.total = res.data.data.total;
-          that.platformList = res.data.data.list;
+          this.total = res.data.data.total;
+          this.platformList = res.data.data.list;
         }
 
       }).catch(function (error) {