From 7400ace65d693bb7bcc564b9211d8bab2af3ac01 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 25 二月 2022 20:33:02 +0800 Subject: [PATCH] 规范数据库,解决bug --- src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java index 37c86a8..6d3be95 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java @@ -21,22 +21,22 @@ * 鏌ヨ鍒楄〃閲屽凡缁忓叧鑱旂殑 */ @Select("<script> "+ - "SELECT deviceAndChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + - "<foreach collection='deviceAndChannelIds' open='(' item='id_' separator=',' close=')'> '${id_}'</foreach> ORDER BY deviceAndChannelId ASC" + + "SELECT deviceChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" + + "<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> '${item.id}'</foreach>" + "</script>") - List<String> findChannelRelatedPlatform(String platformId, List<String> deviceAndChannelIds); + List<Integer> findChannelRelatedPlatform(String platformId, List<ChannelReduce> channelReduces); @Insert("<script> "+ - "INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId, catalogId) VALUES" + + "INSERT INTO platform_gb_channel (platformId, deviceChannelId, catalogId) VALUES" + "<foreach collection='channelReducesToAdd' item='item' separator=','>" + - " ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' , '${item.catalogId}' )" + + " ('${platformId}', '${item.id}' , '${item.catalogId}' )" + "</foreach>" + "</script>") int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd); @Delete("<script> "+ - "DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + - "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.deviceId}_${item.channelId}'</foreach>" + + "DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" + + "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.id}'</foreach>" + "</script>") int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel); @@ -79,8 +79,10 @@ "parent_platform pp " + "left join platform_gb_channel pgc on " + "pp.serverGBId = pgc.platformId " + + "left join device_channel dc on " + + "dc.id = pgc.deviceChannelId " + "WHERE " + - "pgc.channelId = #{channelId} and pp.status = true " + + "dc.channelId = #{channelId} and pp.status = true " + "AND pp.serverGBId IN" + "<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + "</script> ") -- Gitblit v1.8.0