wifi.sql.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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="wifiSqlMapper">
  4. <sql id="base_column">
  5. t_wifi.id as id,
  6. t_wifi.name as name,
  7. t_wifi.SSID as SSID,
  8. t_wifi.location as location,
  9. t_wifi.apmac as apmac,
  10. t_wifi.address as address,
  11. t_wifi.longitude as longitude,
  12. t_wifi.latitude as latitude,
  13. t_wifi.place as place,
  14. t_wifi.place_id as placeId,
  15. t_wifi.operator_id as operatorId,
  16. t_wifi.status as status,
  17. t_wifi.updated as updated
  18. </sql>
  19. <sql id="base_column2">
  20. id,
  21. location,
  22. address,
  23. longitude,
  24. latitude
  25. </sql>
  26. <select id="countByParamsOperator" parameterType="map" resultType="int">
  27. select count(w.id) from t_wifi w, t_location l
  28. <where>
  29. w.location = l.location and w.status != -1 and w.operator_id = #{operatorId}
  30. <if test="cn != null">
  31. and l.cn = #{cn}
  32. </if>
  33. <if test="cnCity != null">
  34. and l.cn_city = #{cnCity}
  35. </if>
  36. <if test="placeId != null">
  37. and w.place_id = #{placeId}
  38. </if>
  39. <if test="place != null">
  40. and w.place = #{place}
  41. </if>
  42. <if test="searchValue != null">
  43. and (w.address like #{searchValue} or w.name like #{searchValue})
  44. </if>
  45. </where>
  46. </select>
  47. <select id="findByParams" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  48. select
  49. <include refid="base_column" />, t_location.cn as cn, t_location.cn_city as cnCity, t_place.name as placeName
  50. from t_wifi, t_location, t_place
  51. <where>
  52. t_wifi.location = t_location.location and t_wifi.place_id = t_place.id
  53. and t_wifi.status != -1 and t_wifi.operator_id = #{operatorId}
  54. <if test="cn != null">
  55. and t_location.cn = #{cn}
  56. </if>
  57. <if test="cnCity != null">
  58. and t_location.cn_city = #{cnCity}
  59. </if>
  60. <if test="placeId != null">
  61. and t_wifi.place_id = #{placeId}
  62. </if>
  63. <if test="place != null">
  64. and t_wifi.place = #{place}
  65. </if>
  66. <if test="searchValue != null">
  67. and (t_wifi.address like #{searchValue} or t_wifi.name like #{searchValue})
  68. </if>
  69. </where>
  70. limit #{pager.offset}, #{pager.limit}
  71. </select>
  72. <select id="findByParams1" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  73. select
  74. <include refid="base_column" />, t_location.cn as cn, t_location.cn_city as cnCity, t_place.name as placeName
  75. from t_wifi, t_location, t_place
  76. <where>
  77. t_wifi.location = t_location.location and t_wifi.place_id = t_place.id
  78. and t_wifi.status != -1 and t_wifi.operator_id = #{operatorId}
  79. <if test="cn != null">
  80. and t_location.cn = #{cn}
  81. </if>
  82. <if test="cnCity != null">
  83. and t_location.cn_city = #{cnCity}
  84. </if>
  85. <if test="placeId != null">
  86. and t_wifi.place_id = #{placeId}
  87. </if>
  88. <if test="place != null">
  89. and t_wifi.place = #{place}
  90. </if>
  91. <if test="searchValue != null">
  92. and (t_wifi.address like #{searchValue} or t_wifi.name like #{searchValue})
  93. </if>
  94. </where>
  95. </select>
  96. <select id="findById" parameterType="long" resultType="com.cloudcross.ssp.model.Wifi">
  97. select
  98. <include refid="base_column" />, t_location.cn as cn, t_location.cn_city as cnCity, t_place.name as placeName
  99. from t_wifi, t_location, t_place
  100. <where>
  101. t_wifi.location = t_location.location and t_wifi.place_id = t_place.id
  102. and t_wifi.status != -1 and t_wifi.id = #{id}
  103. </where>
  104. </select>
  105. <update id="updateWifiStatus" parameterType="HashMap">
  106. update t_wifi
  107. set status=#{status},updated = #{updated}
  108. where id in
  109. <foreach item="id" collection="idList" open="(" separator=","
  110. close=")">
  111. #{id}
  112. </foreach>
  113. </update>
  114. <update id="editWifi" parameterType="com.cloudcross.ssp.model.Wifi">
  115. update t_wifi set name = #{name},
  116. location = #{location},
  117. address = #{address},
  118. longitude = #{longitude},
  119. latitude = #{latitude},
  120. apmac = #{apmac},
  121. place = #{place},
  122. place_id = #{placeId}
  123. where id = #{id}
  124. </update>
  125. <insert id="add" parameterType="com.cloudcross.ssp.model.Wifi" useGeneratedKeys="true" keyProperty="id">
  126. insert into t_wifi(name, SSID, location, apmac, address, longitude, latitude, place, place_id, operator_id, updated)
  127. values(#{name}, #{SSID}, #{location}, #{apmac}, #{address}, #{longitude}, #{latitude}, #{place}, #{placeId}, #{operatorId}, #{updated})
  128. </insert>
  129. <select id="findAddress" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  130. select
  131. <include refid="base_column2" />
  132. from t_wifi where 1 = 1
  133. <if test="key!=null and value!=null">
  134. <choose>
  135. <when test="key=='address'">
  136. and address like #{value}
  137. </when>
  138. </choose>
  139. </if>
  140. order by id
  141. </select>
  142. <select id="findWifi" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  143. select
  144. <include refid="base_column2" />
  145. from t_wifi where location in (select location from t_wifi where location = #{location})
  146. and latitude &lt;= #{maxlat} and latitude &gt;= #{minlat}
  147. and longitude &lt;= #{maxlng} and longitude &gt;= #{minlng}
  148. </select>
  149. <select id="findLocation" parameterType="String" resultType="com.cloudcross.ssp.model.Wifi">
  150. select
  151. <include refid="base_column2" />
  152. from t_wifi where location = #{location}
  153. </select>
  154. <select id="findAllAdgroupWifi" parameterType="Long" resultType="com.cloudcross.ssp.model.Wifi">
  155. select
  156. <include refid="base_column2" />
  157. from t_wifi where id in (select wifi_id from t_adgroup_wifi where adgroup_id = #{adGroupId})
  158. order by id
  159. </select>
  160. <insert id="addAdgroupWifi" parameterType="map">
  161. insert into
  162. t_adgroup_wifi (adgroup_id,wifi_id)
  163. values (#{adGroupId},#{wifiId})
  164. </insert>
  165. <delete id="deleteAdgroupWifi" parameterType="long">
  166. delete from t_adgroup_wifi where adgroup_id = #{adGroupId}
  167. </delete>
  168. <select id="selectByParams" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  169. select
  170. <include refid="base_column2" />
  171. from t_wifi where 1 = 1
  172. <if test="key!=null and value!=null">
  173. <choose>
  174. <when test="key=='address'">
  175. and address like #{value}
  176. </when>
  177. </choose>
  178. </if>
  179. order by id
  180. limit #{pager.offset}, #{pager.limit}
  181. </select>
  182. <select id="countByParamsAdvertiser" parameterType="map" resultType="int">
  183. select count(id)
  184. from t_wifi where 1 = 1
  185. <if test="key!=null and value!=null">
  186. <choose>
  187. <when test="key=='address'">
  188. and address like #{value}
  189. </when>
  190. </choose>
  191. </if>
  192. </select>
  193. </mapper>