wifi.sql.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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="countByParamsBack" parameterType="map" resultType="int">
  27. SELECT
  28. count(tw.id)
  29. FROM
  30. t_wifi tw LEFT JOIN t_location tl on tl.location = tw.location
  31. LEFT JOIN t_place tp on tp.id = tw.place_id
  32. LEFT JOIN t_place_class tpc on tp.id = tpc.place_id
  33. LEFT JOIN t_place_class_info tpci on tpci.id = tpc.class_id
  34. where tw.status != -1
  35. <if test="cn != null">
  36. and tl.cn = #{cn}
  37. </if>
  38. <if test="cnCity != null">
  39. and tl.cn_city = #{cnCity}
  40. </if>
  41. <if test="place != null">
  42. and tw.place = #{place}
  43. </if>
  44. <if test="operatorId != null">
  45. and tw.operator_id = #{operatorId}
  46. </if>
  47. <if test="placeClassId != null">
  48. and tpci.id = #{placeClassId}
  49. </if>
  50. <if test="mac != null">
  51. and tw.apmac like #{mac}
  52. </if>
  53. </select>
  54. <select id="findByParamsBack" parameterType="map" resultType="Wifi">
  55. SELECT
  56. tw.id id,
  57. tw.NAME name,
  58. tw.SSID SSID,
  59. tl.cn cn,
  60. tl.cn_city cnCity,
  61. tw.address address,
  62. tw.longitude longitude,
  63. tw.latitude latitude,
  64. tw.apmac apmac,
  65. tw.place place,
  66. tp.name placeName,
  67. tpci.name as placeClassName,
  68. tw.updated updated,
  69. tw.status status,
  70. tw.operator_id operatorId
  71. FROM
  72. t_wifi tw LEFT JOIN t_location tl on tl.location = tw.location
  73. LEFT JOIN t_place tp on tp.id = tw.place_id
  74. LEFT JOIN t_place_class tpc on tp.id = tpc.place_id
  75. LEFT JOIN t_place_class_info tpci on tpci.id = tpc.class_id
  76. where tw.status != -1
  77. <if test="cn != null">
  78. and tl.cn = #{cn}
  79. </if>
  80. <if test="cnCity != null">
  81. and tl.cn_city = #{cnCity}
  82. </if>
  83. <if test="place != null">
  84. and tw.place = #{place}
  85. </if>
  86. <if test="operatorId != null">
  87. and tw.operator_id = #{operatorId}
  88. </if>
  89. <if test="placeClassId != null">
  90. and tpci.id = #{placeClassId}
  91. </if>
  92. <if test="mac != null">
  93. and tw.apmac like #{mac}
  94. </if>
  95. order by tw.id asc
  96. limit #{pager.offset}, #{pager.limit}
  97. </select>
  98. <select id="findByParams1Back" parameterType="map" resultType="Wifi">
  99. SELECT
  100. tw.id id,
  101. tw.NAME name,
  102. tw.SSID SSID,
  103. tl.cn cn,
  104. tl.cn_city cnCity,
  105. tw.address address,
  106. tw.longitude longitude,
  107. tw.latitude latitude,
  108. tw.apmac apmac,
  109. tw.place place,
  110. tp.name placeName,
  111. tpci.name as placeClassName,
  112. tw.updated updated,
  113. tw.status status,
  114. tw.operator_id operatorId
  115. FROM
  116. t_wifi tw LEFT JOIN t_location tl on tl.location = tw.location
  117. LEFT JOIN t_place tp on tp.id = tw.place_id
  118. LEFT JOIN t_place_class tpc on tp.id = tpc.place_id
  119. LEFT JOIN t_place_class_info tpci on tpci.id = tpc.class_id
  120. where tw.status != -1
  121. <if test="cn != null">
  122. and tl.cn = #{cn}
  123. </if>
  124. <if test="cnCity != null">
  125. and tl.cn_city = #{cnCity}
  126. </if>
  127. <if test="place != null">
  128. and tw.place = #{place}
  129. </if>
  130. <if test="operatorId != null">
  131. and tw.operator_id = #{operatorId}
  132. </if>
  133. <if test="placeClassId != null">
  134. and tpci.id = #{placeClassId}
  135. </if>
  136. <if test="mac != null">
  137. and tw.apmac like #{mac}
  138. </if>
  139. order by tw.id asc
  140. </select>
  141. <select id="countByParamsOperator" parameterType="map" resultType="int">
  142. select count(w.id) from t_wifi w, t_location l
  143. <where>
  144. w.location = l.location and w.status != -1 and w.operator_id = #{operatorId}
  145. <if test="cn != null">
  146. and l.cn = #{cn}
  147. </if>
  148. <if test="cnCity != null">
  149. and l.cn_city = #{cnCity}
  150. </if>
  151. <if test="placeId != null">
  152. and w.place_id = #{placeId}
  153. </if>
  154. <if test="place != null">
  155. and w.place = #{place}
  156. </if>
  157. <if test="searchValue != null">
  158. and (w.address like #{searchValue} or w.name like #{searchValue})
  159. </if>
  160. </where>
  161. </select>
  162. <select id="findByParams" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  163. select
  164. <include refid="base_column" />, t_location.cn as cn, t_location.cn_city as cnCity, t_place.name as placeName
  165. from t_wifi, t_location, t_place
  166. <where>
  167. t_wifi.location = t_location.location and t_wifi.place_id = t_place.id
  168. and t_wifi.status != -1 and t_wifi.operator_id = #{operatorId}
  169. <if test="cn != null">
  170. and t_location.cn = #{cn}
  171. </if>
  172. <if test="cnCity != null">
  173. and t_location.cn_city = #{cnCity}
  174. </if>
  175. <if test="placeId != null">
  176. and t_wifi.place_id = #{placeId}
  177. </if>
  178. <if test="place != null">
  179. and t_wifi.place = #{place}
  180. </if>
  181. <if test="searchValue != null">
  182. and (t_wifi.address like #{searchValue} or t_wifi.name like #{searchValue})
  183. </if>
  184. </where>
  185. limit #{pager.offset}, #{pager.limit}
  186. </select>
  187. <select id="findByParams1" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  188. select
  189. <include refid="base_column" />, t_location.cn as cn, t_location.cn_city as cnCity, t_place.name as placeName
  190. from t_wifi, t_location, t_place
  191. <where>
  192. t_wifi.location = t_location.location and t_wifi.place_id = t_place.id
  193. and t_wifi.status != -1 and t_wifi.operator_id = #{operatorId}
  194. <if test="cn != null">
  195. and t_location.cn = #{cn}
  196. </if>
  197. <if test="cnCity != null">
  198. and t_location.cn_city = #{cnCity}
  199. </if>
  200. <if test="placeId != null">
  201. and t_wifi.place_id = #{placeId}
  202. </if>
  203. <if test="place != null">
  204. and t_wifi.place = #{place}
  205. </if>
  206. <if test="searchValue != null">
  207. and (t_wifi.address like #{searchValue} or t_wifi.name like #{searchValue})
  208. </if>
  209. </where>
  210. </select>
  211. <select id="findById" parameterType="long" resultType="com.cloudcross.ssp.model.Wifi">
  212. select
  213. <include refid="base_column" />, t_location.cn as cn, t_location.cn_city as cnCity, t_place.name as placeName
  214. from t_wifi, t_location, t_place
  215. <where>
  216. t_wifi.location = t_location.location and t_wifi.place_id = t_place.id
  217. and t_wifi.status != -1 and t_wifi.id = #{id}
  218. </where>
  219. </select>
  220. <update id="updateWifiStatus" parameterType="HashMap">
  221. update t_wifi
  222. set status=#{status},updated = #{updated}
  223. where id in
  224. <foreach item="id" collection="idList" open="(" separator=","
  225. close=")">
  226. #{id}
  227. </foreach>
  228. </update>
  229. <update id="editWifi" parameterType="com.cloudcross.ssp.model.Wifi">
  230. update t_wifi set name = #{name},
  231. location = #{location},
  232. address = #{address},
  233. longitude = #{longitude},
  234. latitude = #{latitude},
  235. apmac = #{apmac},
  236. place = #{place},
  237. place_id = #{placeId}
  238. where id = #{id}
  239. </update>
  240. <insert id="add" parameterType="com.cloudcross.ssp.model.Wifi" useGeneratedKeys="true" keyProperty="id">
  241. insert into t_wifi(name, SSID, location, apmac, address, longitude, latitude, place, place_id, operator_id, updated)
  242. values(#{name}, #{SSID}, #{location}, #{apmac}, #{address}, #{longitude}, #{latitude}, #{place}, #{placeId}, #{operatorId}, #{updated})
  243. </insert>
  244. <select id="findAddress" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  245. select
  246. <include refid="base_column2" />
  247. from t_wifi where 1 = 1
  248. <if test="key!=null and value!=null">
  249. <choose>
  250. <when test="key=='address'">
  251. and address like #{value}
  252. </when>
  253. </choose>
  254. </if>
  255. order by id
  256. </select>
  257. <select id="findWifi" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  258. select
  259. <include refid="base_column2" />
  260. from t_wifi where location in (select location from t_wifi where location = #{location})
  261. and latitude &lt;= #{maxlat} and latitude &gt;= #{minlat}
  262. and longitude &lt;= #{maxlng} and longitude &gt;= #{minlng}
  263. </select>
  264. <select id="findLocation" parameterType="String" resultType="com.cloudcross.ssp.model.Wifi">
  265. select
  266. <include refid="base_column2" />
  267. from t_wifi where location = #{location}
  268. </select>
  269. <select id="findAllAdgroupWifi" parameterType="Long" resultType="com.cloudcross.ssp.model.Wifi">
  270. select
  271. <include refid="base_column2" />
  272. from t_wifi where id in (select wifi_id from t_adgroup_wifi where adgroup_id = #{adGroupId})
  273. order by id
  274. </select>
  275. <insert id="addAdgroupWifi" parameterType="map">
  276. insert into
  277. t_adgroup_wifi (adgroup_id,wifi_id)
  278. values (#{adGroupId},#{wifiId})
  279. </insert>
  280. <delete id="deleteAdgroupWifi" parameterType="long">
  281. delete from t_adgroup_wifi where adgroup_id = #{adGroupId}
  282. </delete>
  283. <select id="selectByParams" parameterType="map" resultType="com.cloudcross.ssp.model.Wifi">
  284. select
  285. <include refid="base_column2" />
  286. from t_wifi where 1 = 1
  287. <if test="key!=null and value!=null">
  288. <choose>
  289. <when test="key=='address'">
  290. and address like #{value}
  291. </when>
  292. </choose>
  293. </if>
  294. order by id
  295. limit #{pager.offset}, #{pager.limit}
  296. </select>
  297. <select id="countByParamsAdvertiser" parameterType="map" resultType="int">
  298. select count(id)
  299. from t_wifi where 1 = 1
  300. <if test="key!=null and value!=null">
  301. <choose>
  302. <when test="key=='address'">
  303. and address like #{value}
  304. </when>
  305. </choose>
  306. </if>
  307. </select>
  308. <select id="queryWifiGroupCount" parameterType="java.util.Map" resultType="java.lang.Integer">
  309. SELECT count(wifi.id) FROM t_wifi wifi,t_wifi_group wg,t_wifi_group_info wgi
  310. WHERE wg.wifi_id = wifi.id AND wg.group_id = wgi.id
  311. and wifi.operator_id = #{operatorId} and wgi.name = #{name}
  312. <if test="apmac != null">
  313. and wifi.apmac = #{apmac}
  314. </if>
  315. </select>
  316. <select id="queryWifiGroup" parameterType="java.util.Map" resultType="com.cloudcross.ssp.model.Wifi">
  317. SELECT
  318. wifi.id id,
  319. wifi.operator_id operatorId,
  320. wifi.name name,
  321. wifi.SSID SSID,
  322. wifi.location location,
  323. wifi.apmac apmac,
  324. wifi.address adderss,
  325. wifi.longitude longitude,
  326. wifi.latitude latitude,
  327. wgi.name groupName,
  328. wg.supdated supdated,
  329. wg.status status
  330. FROM
  331. t_wifi wifi,
  332. t_wifi_group wg,
  333. t_wifi_group_info wgi
  334. WHERE
  335. wg.wifi_id = wifi.id
  336. AND wg.group_id = wgi.id
  337. and wifi.operator_id = #{operatorId}
  338. and wgi.name = #{name}
  339. <if test="apmac != null">
  340. and wifi.apmac = #{apmac}
  341. </if>
  342. </select>
  343. <select id="queryWifiByCondition" parameterType="java.util.Map" resultType="com.cloudcross.ssp.model.Wifi">
  344. SELECT
  345. wifi.id id,
  346. wifi.NAME name,
  347. wifi.SSID SSID,
  348. wifi.location location,
  349. wifi.apmac apmac,
  350. wifi.address address,
  351. wifi.longitude longitude,
  352. wifi.latitude latitude,
  353. loc.cn cn,
  354. loc.cn_city cnCity
  355. FROM
  356. t_wifi wifi,
  357. t_location loc
  358. WHERE
  359. wifi.place_id = loc.id
  360. <if test="operatorId != null">
  361. and wifi.operator_id = #{operatorId}
  362. </if>
  363. <if test="apmac != null">
  364. and wifi.apmac = #{apmac}
  365. </if>
  366. <if test="cn != null">
  367. and loc.cn = #{cn}
  368. </if>
  369. <if test="cnCity != null">
  370. and loc.cn_city = #{cnCity}
  371. </if>
  372. limit #{pager.offset}, #{pager.limit}
  373. </select>
  374. <select id="queryWifiCountByCondition" parameterType="java.util.Map" resultType="java.lang.Integer">
  375. SELECT count(wifi.id) FROM t_wifi wifi,t_location loc WHERE
  376. wifi.place_id = loc.id
  377. <if test="operatorId != null">
  378. and wifi.operator_id = #{operatorId}
  379. </if>
  380. <if test="apmac != null">
  381. and wifi.apmac = #{apmac}
  382. </if>
  383. <if test="cn != null">
  384. and loc.cn = #{cn}
  385. </if>
  386. <if test="cnCity != null">
  387. and loc.cn_city = #{cnCity}
  388. </if>
  389. </select>
  390. </mapper>