wifi.sql.xml 12 KB

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