BroadcastMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.welampiot.dao.BroadcastDao">
  4. <select id="getDevListByBroadcastDTO" resultType="BroadcastDTO">
  5. select b.id,b.name,b.dev_id devId,b.address,b.online,b.vol,bi.name as proName,b.isPlay,
  6. lp.name as lampPoleName,b.type,b.install_date installDate,b.expiration_date expirationDate
  7. from broadcast b left join broadcast_item bi on bi.broadcastId = b.id
  8. left join lamp_pole lp on b.lamp_pole_id = lp.id
  9. where b.lamp_pole_id != 0
  10. <if test="sectionList != null and !sectionList.isEmpty()">
  11. and lp.sectionid in
  12. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  13. #{dto}
  14. </foreach>
  15. </if>
  16. <choose>
  17. <when test="onlineState == 0">
  18. and b.online = 0
  19. </when>
  20. <when test="onlineState == 1">
  21. and b.online = 1
  22. </when>
  23. </choose>
  24. order by convert(lp.number using gbk) asc,
  25. convert(b.name using gbk) asc,b.id desc
  26. </select>
  27. <select id="getTotalBySectionList" resultType="Integer">
  28. select count(b.id) as total from broadcast b
  29. left join lamp_pole lp on b.lamp_pole_id = lp.id
  30. <if test="sectionList != null and !sectionList.isEmpty()">
  31. where lp.sectionid in
  32. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  33. #{dto}
  34. </foreach>
  35. </if>
  36. </select>
  37. <select id="getOnlineTotalBySectionList" resultType="Integer">
  38. select count(b.id) as total from broadcast b
  39. left join lamp_pole lp on b.lamp_pole_id = lp.id
  40. where b.online = 1
  41. <if test="sectionList != null and !sectionList.isEmpty()">
  42. and lp.sectionid in
  43. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  44. #{dto}
  45. </foreach>
  46. </if>
  47. </select>
  48. <select id="getUserIdByUserName" resultType="Integer">
  49. select u.id from user u
  50. where u.username = #{username}
  51. </select>
  52. <!-- 音乐列表 -->
  53. <select id="getProListByDTO" resultType="BroadcastProListDTO">
  54. select b.id,b.name,b.url
  55. from broadcast_pro_list b
  56. where b.userId = #{userId}
  57. </select>
  58. <!-- 节目列表 -->
  59. <select id="getItemListByDTO" resultType="BroadcastItemDTO">
  60. select b.id,b.name,b.proType,b.broadcastId,b.status,b.createTime,b1.name as broadcastStr
  61. from broadcast_item b left join broadcast b1 on b.broadcastId = b1.id
  62. left join lamp_pole lp on lp.id = b1.lamp_pole_id
  63. left join section s on lp.sectionid = s.id
  64. where b.userId = #{userId}
  65. <if test="devId != null and devId != 0">
  66. and b.broadcastId = #{devId}
  67. </if>
  68. </select>
  69. <delete id="deleteBroadcastById">
  70. delete
  71. from broadcast
  72. where id = #{id};
  73. </delete>
  74. <select id="getBroadcastById" resultType="BroadcastDTO">
  75. select b.lamp_pole_id as lampPoleId,lp.sectionid as sectionId,b.address,b.type,b.dev_id as devId,b.name,
  76. from broadcast b
  77. left join lamp_pole lp on lp.id = b.lamp_pole_id
  78. left join section s on lp.sectionid = s.id
  79. where b.id = #{id}
  80. </select>
  81. <select id="getBroadcastCountByLampPoleId" resultType="Integer">
  82. select count(*)
  83. from broadcast b
  84. where b.lamp_pole_id = #{lampPoleId}
  85. </select>
  86. <select id="getBroadcastDTOByLampPoleId" resultType="BroadcastDTO">
  87. select b.lamp_pole_id,lp.sectionid as sectionId,b.id,b.itemId as proId,
  88. b2.name as proName,b3.time,b.online
  89. from broadcast b
  90. left join lamp_pole lp on lp.id = b.lamp_pole_id
  91. left join broadcast_pro_list b3 on b3.id = b.proId
  92. left join broadcast_item b2 on b2.id = b.itemId
  93. left join section s on lp.sectionid = s.id
  94. where b.lamp_pole_id = #{lampPoleId}
  95. </select>
  96. <select id="checkBroadcastData" resultType="Integer">
  97. select count(*)
  98. from broadcast b
  99. where 1=1
  100. <if test="address != null and address != ''">
  101. and b.address = #{address}
  102. </if>
  103. <if test="lampPoleId != null and lampPoleId != 0">
  104. and b.lamp_pole_id != #{lampPoleId}
  105. </if>
  106. <if test="name != null and name != ''">
  107. and b.name = #{name}
  108. </if>
  109. <if test="id != null and id != 0">
  110. and b.id != #{id}
  111. </if>
  112. </select>
  113. <update id="updateLampPoleBroadcastData" parameterType="BroadcastDTO">
  114. update
  115. broadcast e
  116. set
  117. <if test="installDate != null and installDate != ''">e.install_date = #{installDate},</if>
  118. <if test="expirationDate != null and installDate != ''">e.expiration_date = #{expirationDate},</if>
  119. <if test="address != null and address != ''">e.address = #{address},</if>
  120. e.type = #{type},
  121. e.name = #{name}
  122. where 1=1
  123. <if test="lampPoleId != null and lampPoleId != 0">
  124. and e.lamp_pole_id = #{lampPoleId}
  125. </if>
  126. <if test="id != null and id != 0">
  127. and e.id = #{id}
  128. </if>
  129. </update>
  130. <update id="updateBroadcastById" parameterType="BroadcastDTO">
  131. update
  132. broadcast e
  133. set
  134. <if test="vol != null and vol != ''">e.vol = #{vol},</if>
  135. <if test="policyId != null and policyId != ''">e.policy_id = #{policyId},</if>
  136. <if test="itemId != null and itemId != ''">e.itemId = #{itemId},</if>
  137. e.id = #{id}
  138. where e.id = #{id}
  139. </update>
  140. <select id="getListByIds" resultType="com.welampiot.dto.BroadcastDTO" parameterType="String">
  141. select address,online,dev_id as devId,type,vol
  142. from broadcast b
  143. where id in (#{ids})
  144. </select>
  145. </mapper>