From 2157bb0270663df35b7267c3d10c8b594400102e Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 22 二月 2022 11:44:56 +0800 Subject: [PATCH] 规范数据库,给各个标设置主键ID --- src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java index 5d59e2e..f2e9b6f 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java @@ -38,12 +38,13 @@ int del(String app, String stream); @Select("<script> "+ - "SELECT gs.*, pgs.platformId AS platformId, pgs.catalogId AS catalogId FROM gb_stream gs " + - "LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " + + "SELECT gs.* FROM gb_stream gs " + "WHERE " + "1=1 " + - " <if test='catalogId != null'> AND pgs.platformId = #{platformId} AND pgs.catalogId = #{catalogId}</if> " + - " <if test='catalogId == null'> AND pgs.platformId is null AND pgs.catalogId is null</if> " + + " <if test='catalogId != null'> AND gs.id in" + + "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId} and pgs.catalogId=#{catalogId})</if> " + + " <if test='catalogId == null'> AND gs.id not in" + + "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) </if> " + " <if test='query != null'> AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " + " <if test='pushing == true' > AND gs.status=1</if>" + " <if test='pushing == false' > AND gs.status=0</if>" + @@ -59,18 +60,18 @@ List<GbStream> selectByGBId(String gbId); @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + - "LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " + + "LEFT JOIN platform_gb_stream pgs ON gs.id = pgs.catalogId " + "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") GbStream queryStreamInPlatform(String platformId, String gbId); @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + - "LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " + - "WHERE pgs.platformId = '${platformId}'") + "LEFT JOIN platform_gb_stream pgs ON gs.id = pgs.gbStreamId " + + "WHERE pgs.platformId = #{platformId}") List<GbStream> queryGbStreamListInPlatform(String platformId); - @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " + - "ON gs.app = pgs.app and gs.stream = pgs.stream WHERE pgs.app is NULL and pgs.stream is NULL") + @Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " + + "ON gs.id = pgs.gbStreamId WHERE pgs.gbStreamId is NULL") List<GbStream> queryStreamNotInPlatform(); @Update("UPDATE gb_stream " + @@ -124,4 +125,12 @@ "</foreach>" + "</script>"}) int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfos); + + @Select("<script> "+ + "SELECT * FROM gb_stream where " + + "<foreach collection='streamPushItems' item='item' separator='or'>" + + "(app=#{item.app} and stream=#{item.stream}) " + + "</foreach>" + + "</script>") + List<GbStream> selectAllForAppAndStream(List<StreamPushItem> streamPushItems); } -- Gitblit v1.8.0