zone.sql.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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="zoneSqlMapper">
  4. <sql id="base_column">
  5. t_zone.id as id,
  6. operator_id ,
  7. t_zone.name as name,
  8. width,
  9. height,
  10. device,
  11. position,
  12. status,
  13. updated,
  14. supdated,
  15. default_path,
  16. default_url,
  17. recheck,
  18. default_path_small
  19. </sql>
  20. <select id="findZone" parameterType="int" resultType="com.cloudcross.ssp.model.Zone">
  21. select * from t_zone where id=#{zoneId}
  22. </select>
  23. <select id="selectByIdOperator" parameterType="int" resultType="com.cloudcross.ssp.model.Zone">
  24. select *
  25. from t_zone
  26. <where>
  27. t_zone.id = #{id}
  28. </where>
  29. order by t_zone.id desc
  30. </select>
  31. <select id="findByName" parameterType="string" resultType="long">
  32. select t_zone.id from t_zone
  33. <where> name = #{name} </where>
  34. </select>
  35. <resultMap id="zoneResult" type="com.cloudcross.ssp.model.Zone">
  36. <id property="id" column="id" />
  37. <result property="operator_id" column="operator_id" />
  38. <result property="name" column="name" />
  39. <result property="width" column="width" />
  40. <result property="height" column="height" />
  41. <result property="device" column="device" />
  42. <result property="position" column="position" />
  43. <result property="status" column="status" />
  44. <result property="updated" column="updated" />
  45. <result property="supdated" column="supdated" />
  46. </resultMap>
  47. <select id="selectByParams" parameterType="map" resultMap="zoneResult">
  48. select
  49. <include refid="base_column" />
  50. from t_zone
  51. where t_zone.status != -1
  52. <if test="key!=null and value!=null">
  53. <choose>
  54. <when test="key=='name'">
  55. and t_zone.name like #{value}
  56. </when>
  57. <when test="key=='id'">
  58. and t_zone.id like #{value}
  59. </when>
  60. </choose>
  61. </if>
  62. <if test="status != null">
  63. and status like #{status}
  64. </if>
  65. <if test="device != null">
  66. and device like #{device}
  67. </if>
  68. <if test="position != null">
  69. and position like #{position}
  70. </if>
  71. <if test="height != null">
  72. and height like #{height}
  73. </if>
  74. <if test="width != null">
  75. and width like #{width}
  76. </if>
  77. <if test="operatorId != null">
  78. and operator_id = #{operatorId}
  79. </if>
  80. order by t_zone.id desc
  81. limit #{pager.offset}, #{pager.limit}
  82. </select>
  83. <select id="countByParams" parameterType="map" resultType="int">
  84. select count(t_zone.id)
  85. from t_zone
  86. where t_zone.status != -1
  87. <if test="key!=null and value!=null">
  88. <choose>
  89. <when test="key=='id'">
  90. and t_zone.id like #{value}
  91. </when>
  92. <when test="key=='name'">
  93. and t_zone.name = #{value}
  94. </when>
  95. </choose>
  96. </if>
  97. <if test="status != null">
  98. and status like #{status}
  99. </if>
  100. <if test="device != null">
  101. and device like #{device}
  102. </if>
  103. <if test="position != null">
  104. and position like #{position}
  105. </if>
  106. <if test="height != null">
  107. and height like #{height}
  108. </if>
  109. <if test="width != null">
  110. and width like #{width}
  111. </if>
  112. <if test="operatorId != null">
  113. and operator_id = #{operatorId}
  114. </if>
  115. </select>
  116. <insert id="addZone" parameterType="com.cloudcross.ssp.model.Zone" useGeneratedKeys="true"
  117. keyProperty="id">
  118. insert into t_zone(operator_id,name,device,position,width,height,recheck,updated,supdated,default_path,default_url,default_path_small)
  119. values(#{operator_id},#{name},#{device},#{position},#{width},#{height},#{recheck},#{updated},#{supdated},#{default_path},#{default_url},#{default_path_small})
  120. </insert>
  121. <update id="editZone" parameterType="com.cloudcross.ssp.model.Zone">
  122. update t_zone
  123. set name=#{name},device=#{device},position=#{position}, width=#{width}, height=#{height},default_path=#{default_path},default_path_small=#{default_path_small},default_url=#{default_url},recheck=#{recheck},updated=#{updated},supdated=#{supdated}
  124. where id = #{id}
  125. </update>
  126. <update id="updateZoneStatus" parameterType="HashMap">
  127. update t_zone
  128. set status = #{status},updated = #{updated}
  129. where id in
  130. <foreach item="id" collection="zoneIdList"
  131. open="(" separator="," close=")">
  132. #{id}
  133. </foreach>
  134. </update>
  135. <delete id="deleteById" parameterType="int">
  136. delete
  137. from t_zone
  138. <where>
  139. id = #{id}
  140. </where>
  141. </delete>
  142. <!--
  143. <select id="findByDeviceAndPlaceId" parameterType="map" resultType="zone">
  144. select t_zone.id,t_zone.name
  145. from t_zone
  146. <where>
  147. <if test="zoneDevice != null">
  148. 1=1 and t_zone.device = #{zoneDevice}
  149. </if>
  150. <if test="zonePlaceIdList != null">
  151. and t_zone.id in (
  152. select t_zone_place.zone_id from t_zone_place where place_id in
  153. <foreach item="placeId" collection="zonePlaceIdList" open="(" separator="," close=")">
  154. #{placeId}
  155. </foreach>
  156. )
  157. </if>
  158. </where>
  159. </select>
  160. -->
  161. <!-- 广告位排期按在投广告位ID和日期查找 -->
  162. <select id="findAdgroupNameByZoneIdAndSchedule" resultType="string" parameterType="map">
  163. select t.name from t_adgroup t
  164. where
  165. t.id in (select az.adgroup_id from t_adgroup_zone az where az.zone_id = #{zoneId})
  166. and
  167. t.id in (select ac.adgroup_id from t_adgroup_schedule ac where ac.startdate &lt;= #{date} and #{date} &lt;= ac.enddate)
  168. </select>
  169. <!-- 首页中查找设备,暂时只有PC和MoBile -->
  170. <select id="findByDevice" resultType="com.cloudcross.ssp.model.Zone" parameterType="int">
  171. select id,name from t_zone
  172. <where> device = #{device} </where>
  173. order by t_zone.id desc
  174. </select>
  175. <!-- add by Wanfu for banner-audit -->
  176. <select id="findByOperatorIdOperator" resultType="com.cloudcross.ssp.model.Zone" parameterType="int">
  177. select * from t_zone where operator_id = #{operatorId} and recheck = 1 and status=0
  178. </select>
  179. <select id="selectByIdBack" parameterType="long" resultType="com.cloudcross.ssp.model.Zone">
  180. select <include refid="base_column" />
  181. from t_zone
  182. <where>
  183. t_zone.id = #{id}
  184. </where>
  185. order by t_zone.id desc
  186. </select>
  187. <select id="findByOperatorIdBack" resultType="com.cloudcross.ssp.model.Zone" parameterType="long">
  188. select <include refid="base_column" />
  189. from t_zone where operator_id = #{operatorId}
  190. </select>
  191. </mapper>