audit-banner.sql.xml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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="auditBannerSqlMapper">
  4. <sql id="base_column_banner">
  5. a.id as id,
  6. a.banner_template_id as bannerTemplateId,
  7. a.order_id as orderId,
  8. a.campaign_id as campaignId,
  9. a.adgroup_id as adGroupId,
  10. a.visit_address as visitAddress,
  11. a.click_address as clickAddress,
  12. a.impression_address as impressionAddress,
  13. a.status as status1,
  14. a.checked as checked,
  15. a.updated as updated,
  16. a.supdated as supdated,
  17. a.memo as memo
  18. </sql>
  19. <sql id="base_column_bannertemplate">
  20. b.id as bannerTemplateId,
  21. b.agent_id as agentId,
  22. b.advertiser_id as advertiserId,
  23. b.agent_id as agentId,
  24. b.name as name,
  25. b.path as path,
  26. b.path_small as pathSmall,
  27. b.type as type,
  28. b.width as width,
  29. b.height as height,
  30. b.status as status,
  31. b.updated as updated
  32. </sql>
  33. <select id="countByParams" parameterType="map" resultType="int">
  34. select count(a.id) from t_banner a ,t_banner_template b
  35. <where>
  36. b.status != -1
  37. and a.banner_template_id = b.id
  38. <if test="key!=null and value!=null">
  39. <choose>
  40. <when test="key=='name'">
  41. and b.name like #{value}
  42. </when>
  43. </choose>
  44. </if>
  45. <if test="checked !=null">
  46. and a.checked like #{checked}
  47. </if>
  48. </where>
  49. </select>
  50. <select id="findByParams" parameterType="map" resultMap="AuditBanner">
  51. select <include refid="base_column_banner"/> ,
  52. <include refid="base_column_bannertemplate"/>,
  53. (select name from t_advertiser where id=b.advertiser_id) as advertiserName,(select name from t_industry where id = (select industry_id from t_advertiser where id=b.advertiser_id)) as industryName from t_banner a
  54. left join t_banner_template b on a.banner_template_id=b.id
  55. left join t_order c on a.order_id= c.id
  56. left JOIN t_advertiser d on c.advertiser_id = d.id
  57. left join t_industry e on d.industry_id = e.id
  58. <where>
  59. b.status != -1
  60. <if test="key!=null and value!=null">
  61. <choose>
  62. <when test="key=='name'">
  63. and b.name like #{value}
  64. </when>
  65. </choose>
  66. </if>
  67. <if test="checked !=null">
  68. and a.checked like #{checked}
  69. </if>
  70. </where>
  71. order by a.id desc
  72. limit #{pager.offset}, #{pager.limit}
  73. </select>
  74. <select id="findAudit" parameterType="map" resultMap="AuditBanner">
  75. select <include refid="base_column_banner"/> ,
  76. <include refid="base_column_bannertemplate"/>,
  77. (select name from t_advertiser where id=b.advertiser_id) as advertiserName,(select name from t_industry where id = (select industry_id from t_advertiser where id=b.advertiser_id)) as industryName from t_banner a
  78. left join t_banner_template b on a.banner_template_id=b.id
  79. left join t_order c on a.order_id= c.id
  80. left JOIN t_advertiser d on c.advertiser_id = d.id
  81. left join t_industry e on d.industry_id = e.id
  82. <where>
  83. b.status != -1
  84. <if test="key!=null and value!=null">
  85. <choose>
  86. <when test="key=='name'">
  87. and b.name like #{value}
  88. </when>
  89. </choose>
  90. </if>
  91. <if test="checked !=null">
  92. and a.checked like #{checked}
  93. </if>
  94. </where>
  95. order by a.id desc
  96. </select>
  97. <resultMap type="com.cloudcross.ssp.model.AuditBanner" id="AuditBanner">
  98. <id property="id" column="id"/>
  99. <result property="bannerTemplateId" column="bannerTemplateId"/>
  100. <result property="orderId" column="orderId"/>
  101. <result property="campaignId" column="campaignId"/>
  102. <result property="adGroupId" column="adGroupId"/>
  103. <result property="visitAddress" column="visitAddress"/>
  104. <result property="clickAddress" column="clickAddress"/>
  105. <result property="impressionAddress" column="impressionAddress"/>
  106. <result property="checked" column="checked"/>
  107. <result property="updated" column="updated"/>
  108. <result property="memo" column="memo"/>
  109. <result property="operatorChecked" column="operatorChecked"/>
  110. <result property="industryName" column="industryName"/>
  111. <result property="advertiserName" column="advertiserName"/>
  112. <association property="bannerTemplate" javaType="com.cloudcross.ssp.model.BannerTemplate" resultMap="bannerTemplate"/>
  113. </resultMap>
  114. <resultMap type="com.cloudcross.ssp.model.BannerTemplate" id="bannerTemplate">
  115. <id property="id" column="bannerTemplateId"/>
  116. <result property="advertiserId" column="advertiserId"/>
  117. <result property="name" column="name"/>
  118. <result property="path" column="path"/>
  119. <result property="pathSmall" column="pathSmall"/>
  120. <result property="type" column="type"/>
  121. <result property="width" column="width"/>
  122. <result property="height" column="height"/>
  123. <result property="status" column="status"/>
  124. <result property="updated" column="updated"/>
  125. </resultMap>
  126. <update id="updateBannerStatus" parameterType="HashMap">
  127. update t_banner a,t_banner_template b
  128. set a.checked=#{checked},b.updated = #{updated},a.updated = #{updated}
  129. <if test="memo != null">
  130. ,a.memo = #{memo}
  131. </if>
  132. where
  133. a.banner_template_id = b.id and
  134. a.id in
  135. <foreach item="id" collection="auditBannerIdList" open="(" separator=","
  136. close=")">
  137. #{id}
  138. </foreach>
  139. </update>
  140. <update id="updateOperatorBannerTime" parameterType="HashMap">
  141. update t_banner_operator
  142. set supdated = #{supdated}
  143. where banner_id in
  144. <foreach item="id" collection="auditBannerIdList" open="(" separator=","
  145. close=")">
  146. #{id}
  147. </foreach>
  148. </update>
  149. <select id="countByZoneSizeOperator" parameterType="HashMap" resultType="int">
  150. select count(*)
  151. from t_banner a
  152. inner join t_banner_template b
  153. on a.banner_template_id = b.id
  154. where b.status != -1
  155. and checked != 2
  156. and checked !=0
  157. <if test="zoneList.size()>0">
  158. and
  159. <foreach item="zone" collection="zoneList"
  160. open="(" separator="or" close=")" >
  161. b.width &lt;= #{zone.width} and b.height &lt;= #{zone.height}
  162. </foreach>
  163. </if>
  164. <if test="searchKey!=null and searchValue!=null">
  165. and b.name like #{searchValue}
  166. </if>
  167. <if test="checked!=null">
  168. and a.checked like #{checked}
  169. </if>
  170. </select>
  171. <select id="findByZoneSizeOperator" parameterType="HashMap" resultMap="AuditBanner">
  172. select <include refid="base_column_banner"/> ,
  173. <include refid="base_column_bannertemplate"/>,
  174. IFNULL(bo.checked,-1) as operatorChecked
  175. from t_banner a
  176. inner join t_banner_template b
  177. on a.banner_template_id = b.id
  178. where b.status != -1
  179. and checked != 2
  180. and checked !=0
  181. <if test="zoneList.size()>0">
  182. and
  183. <foreach item="zone" collection="zoneList"
  184. open="(" separator="or" close=")" >
  185. b.width &lt;= #{zone.width} and b.height &lt;= #{zone.height}
  186. </foreach>
  187. </if>
  188. <if test="searchKey!=null and searchValue!=null">
  189. and b.name like #{searchValue}
  190. </if>
  191. <if test="checked!=null">
  192. and a.checked like #{checked}
  193. </if>
  194. order by a.id desc
  195. <if test="pager!=null">
  196. limit #{pager.offset}, #{pager.limit}
  197. </if>
  198. </select>
  199. <select id="findByIdOperator" parameterType="int" resultMap="AuditBanner">
  200. select <include refid="base_column_banner"/> ,
  201. <include refid="base_column_bannertemplate"/>,
  202. IFNULL(bo.checked,-1) as operatorChecked
  203. from t_banner a
  204. inner join t_banner_template b
  205. on a.banner_template_id = b.id
  206. left join t_banner_operator bo
  207. on a.id=bo.banner_id where a.id=#{id}
  208. </select>
  209. <select id="countByOperator" parameterType="HashMap" resultType="int">
  210. select count(*)
  211. from t_banner a
  212. inner join t_banner_template b
  213. on a.banner_template_id = b.id
  214. left join t_banner_operator bo
  215. on a.id=bo.banner_id
  216. and bo.operator_id=#{operatorId}
  217. where a.status = 0
  218. and b.status = 0
  219. and a.checked = 1
  220. <if test="zoneList.size()>0">
  221. and
  222. <foreach item="zone" collection="zoneList"
  223. open="(" separator="or" close=")" >
  224. b.width &lt;= #{zone.width} and b.height &lt;= #{zone.height}
  225. </foreach>
  226. </if>
  227. <if test="value!=null">
  228. and b.name like #{value}
  229. </if>
  230. <if test="operatorChecked!=null">
  231. <choose>
  232. <when test="operatorChecked == 0">
  233. and ISNULL(bo.checked) or bo.checked =0
  234. </when>
  235. <otherwise>
  236. and bo.checked=#{operatorChecked}
  237. </otherwise>
  238. </choose>
  239. </if>
  240. </select>
  241. <select id="findByOpertor" parameterType="HashMap" resultMap="AuditBanner">
  242. select <include refid="base_column_banner"/> ,
  243. <include refid="base_column_bannertemplate"/>,
  244. IFNULL(bo.checked,-1) as operatorChecked
  245. from t_banner a
  246. inner join t_banner_template b
  247. on a.banner_template_id = b.id
  248. left join t_banner_operator bo
  249. on a.id=bo.banner_id
  250. and bo.operator_id=#{operatorId}
  251. where a.status = 0
  252. and b.status = 0
  253. and a.checked = 1
  254. <if test="zoneList.size()>0">
  255. and
  256. <foreach item="zone" collection="zoneList"
  257. open="(" separator="or" close=")" >
  258. b.width &lt;= #{zone.width} and b.height &lt;= #{zone.height}
  259. </foreach>
  260. </if>
  261. <if test="value!=null">
  262. and b.name like #{value}
  263. </if>
  264. <if test="operatorChecked!=null">
  265. <choose>
  266. <when test="operatorChecked == 0">
  267. and ISNULL(bo.checked) or bo.checked =0
  268. </when>
  269. <otherwise>
  270. and bo.checked=#{operatorChecked}
  271. </otherwise>
  272. </choose>
  273. </if>
  274. order by a.id desc
  275. <if test="pager!=null">
  276. limit #{pager.offset}, #{pager.limit}
  277. </if>
  278. </select>
  279. <update id="updateBannerStatusOperator" parameterType="HashMap">
  280. update t_banner
  281. set checked = #{checked},
  282. updated = #{updated}
  283. where id in
  284. <foreach item="bannerId" collection="bannerIdList"
  285. open="(" separator="," close=")">
  286. #{bannerId}
  287. </foreach>
  288. </update>
  289. <insert id="addOperatorBanner" parameterType="HashMap">
  290. insert into t_banner_operator
  291. (operator_id,banner_id,checked,supdated)
  292. values(#{operatorId},#{bannerId},#{operatorChecked},#{supdated})
  293. </insert>
  294. <update id="updateOperatorBanner" parameterType="HashMap">
  295. update t_banner_operator
  296. set operator_id=#{operatorId},checked = #{operatorChecked},supdated = #{supdated}
  297. where banner_id = #{bannerId}
  298. </update>
  299. </mapper>