StreamPushMapper.java 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package com.genersoft.iot.vmp.streamPush.dao;
  2. import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
  3. import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis;
  4. import org.apache.ibatis.annotations.*;
  5. import org.springframework.stereotype.Repository;
  6. import java.util.List;
  7. import java.util.Map;
  8. import java.util.Set;
  9. @Mapper
  10. @Repository
  11. public interface StreamPushMapper {
  12. @Insert("INSERT INTO wvp_stream_push (app, stream, media_server_id, server_id, push_time, update_time, create_time, pushing, start_offline_push) VALUES" +
  13. "(#{app}, #{stream}, #{mediaServerId} , #{serverId} , #{pushTime} ,#{updateTime}, #{createTime}, #{pushing}, #{startOfflinePush})")
  14. @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
  15. int add(StreamPush streamPushItem);
  16. @Update(value = {" <script>" +
  17. "UPDATE wvp_stream_push " +
  18. "SET update_time=#{updateTime}" +
  19. "<if test=\"app != null\">, app=#{app}</if>" +
  20. "<if test=\"stream != null\">, stream=#{stream}</if>" +
  21. "<if test=\"mediaServerId != null\">, media_server_id=#{mediaServerId}</if>" +
  22. "<if test=\"serverId != null\">, server_id=#{serverId}</if>" +
  23. "<if test=\"pushTime != null\">, push_time=#{pushTime}</if>" +
  24. "<if test=\"pushing != null\">, pushing=#{pushing}</if>" +
  25. "<if test=\"startOfflinePush != null\">, start_offline_push=#{startOfflinePush}</if>" +
  26. "WHERE id = #{id}"+
  27. " </script>"})
  28. int update(StreamPush streamPushItem);
  29. @Delete("DELETE FROM wvp_stream_push WHERE id=#{id}")
  30. int del(@Param("id") int id);
  31. @Select(value = {" <script>" +
  32. " SELECT " +
  33. " st.*, " +
  34. " st.id as stream_push_id, " +
  35. " wdc.*, " +
  36. " wdc.id as gb_id" +
  37. " from " +
  38. " wvp_stream_push st " +
  39. " LEFT join wvp_device_channel wdc " +
  40. " on st.id = wdc.stream_push_id " +
  41. " WHERE " +
  42. " 1=1 " +
  43. " <if test='query != null'> AND (st.app LIKE concat('%',#{query},'%') escape '/' OR st.stream LIKE concat('%',#{query},'%') escape '/' " +
  44. " OR wdc.gb_device_id LIKE concat('%',#{query},'%') escape '/' OR wdc.gb_name LIKE concat('%',#{query},'%') escape '/')</if> " +
  45. " <if test='pushing == true' > AND st.pushing=1</if>" +
  46. " <if test='pushing == false' > AND st.pushing=0 </if>" +
  47. " <if test='mediaServerId != null' > AND st.media_server_id=#{mediaServerId} </if>" +
  48. " order by st.create_time desc" +
  49. " </script>"})
  50. List<StreamPush> selectAll(@Param("query") String query, @Param("pushing") Boolean pushing, @Param("mediaServerId") String mediaServerId);
  51. @Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.app=#{app} AND st.stream=#{stream}")
  52. StreamPush selectByAppAndStream(@Param("app") String app, @Param("stream") String stream);
  53. @Insert("<script>" +
  54. "Insert INTO wvp_stream_push ( " +
  55. " app, stream, media_server_id, server_id, push_time, update_time, create_time, pushing, start_offline_push) " +
  56. " VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
  57. " ( #{item.app}, #{item.stream}, #{item.mediaServerId},#{item.serverId} ,#{item.pushTime}, #{item.updateTime}, #{item.createTime}, #{item.pushing}, #{item.startOfflinePush} )" +
  58. " </foreach>" +
  59. " </script>")
  60. @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
  61. int addAll(List<StreamPush> streamPushItems);
  62. @Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.media_server_id=#{mediaServerId}")
  63. List<StreamPush> selectAllByMediaServerId(String mediaServerId);
  64. @Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.media_server_id=#{mediaServerId} and wdc.gb_device_id is null")
  65. List<StreamPush> selectAllByMediaServerIdWithOutGbID(String mediaServerId);
  66. @Update("UPDATE wvp_stream_push " +
  67. "SET pushing=#{pushing} " +
  68. "WHERE id=#{id}")
  69. int updatePushStatus(@Param("id") int id, @Param("pushing") boolean pushing);
  70. @Select("<script> "+
  71. "SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id " +
  72. "where (st.app, st.stream) in (" +
  73. "<foreach collection='offlineStreams' item='item' separator=','>" +
  74. "(#{item.app}, #{item.stream}) " +
  75. "</foreach>" +
  76. ")</script>")
  77. List<StreamPush> getListFromRedis(List<StreamPushItemFromRedis> offlineStreams);
  78. @Select("SELECT CONCAT(app,stream) from wvp_stream_push")
  79. List<String> getAllAppAndStream();
  80. @Select("select count(1) from wvp_stream_push ")
  81. int getAllCount();
  82. @Select(value = {" <script>" +
  83. " select count(1) from wvp_stream_push where pushing = true" +
  84. " </script>"})
  85. int getAllPushing(Boolean usePushingAsStatus);
  86. @MapKey("uniqueKey")
  87. @Select("SELECT CONCAT(wsp.app, wsp.stream) as unique_key, wsp.*, wsp.* , wdc.id as gb_id " +
  88. " from wvp_stream_push wsp " +
  89. " LEFT join wvp_device_channel wdc on wsp.id = wdc.stream_push_id")
  90. Map<String, StreamPush> getAllAppAndStreamMap();
  91. @MapKey("gbDeviceId")
  92. @Select("SELECT wdc.gb_device_id, wsp.id as stream_push_id, wsp.*, wsp.* , wdc.id as gb_id " +
  93. " from wvp_stream_push wsp " +
  94. " LEFT join wvp_device_channel wdc on wsp.id = wdc.stream_push_id")
  95. Map<String, StreamPush> getAllGBId();
  96. @Select("SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id WHERE st.id=#{id}")
  97. StreamPush queryOne(@Param("id") int id);
  98. @Select("<script> "+
  99. "SELECT st.*, st.id as stream_push_id, wdc.*, wdc.id as gb_id FROM wvp_stream_push st LEFT join wvp_device_channel wdc on st.id = wdc.stream_push_id " +
  100. " where st.id in (" +
  101. " <foreach collection='ids' item='item' separator=','>" +
  102. " #{item} " +
  103. " </foreach>" +
  104. " )</script>")
  105. List<StreamPush> selectInSet(Set<Integer> ids);
  106. @Delete("<script> "+
  107. "DELETE FROM wvp_stream_push WHERE" +
  108. " id in (" +
  109. "<foreach collection='streamPushList' item='item' separator=','>" +
  110. " #{item.id} " +
  111. "</foreach>" +
  112. ")</script>")
  113. void batchDel(List<StreamPush> streamPushList);
  114. @Update({"<script>" +
  115. "<foreach collection='streamPushItemForUpdate' item='item' separator=';'>" +
  116. " UPDATE" +
  117. " wvp_stream_push" +
  118. " SET update_time=#{item.updateTime}" +
  119. ", app=#{item.app}" +
  120. ", stream=#{item.stream}" +
  121. ", media_server_id=#{item.mediaServerId}" +
  122. ", server_id=#{item.serverId}" +
  123. ", push_time=#{item.pushTime}" +
  124. ", pushing=#{item.pushing}" +
  125. ", start_offline_push=#{item.startOfflinePush}" +
  126. " WHERE id=#{item.id}" +
  127. "</foreach>" +
  128. "</script>"})
  129. int batchUpdate(List<StreamPush> streamPushItemForUpdate);
  130. }