banner-template.sql.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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="bannerTemplateSqlMapper">
  4. <sql id="base_columnadvertiser">
  5. t_banner_template.id,
  6. agent_id as agentId,
  7. advertiser_id as advertiserId,
  8. name,
  9. path,
  10. path_small as pathSmall,
  11. type,
  12. width,
  13. height,
  14. t_banner_template.status,
  15. t_banner_template.updated
  16. </sql>
  17. <sql id="base_columnoperator">
  18. id,
  19. advertiser_id as advertiserId,
  20. name,
  21. path,
  22. type,
  23. width,
  24. height,
  25. status,
  26. updated
  27. </sql>
  28. <select id="countByParams" parameterType="map" resultType="int">
  29. select count(id)
  30. from t_banner_template
  31. <where>
  32. id in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
  33. and status!=-1
  34. <if test="key!=null and value!=null">
  35. <choose>
  36. <when test="key=='name'">
  37. and name like #{value}
  38. </when>
  39. </choose>
  40. </if>
  41. </where>
  42. </select>
  43. <select id="countByParams3operator" parameterType="map" resultType="int">
  44. select count(id)
  45. from t_banner_template
  46. <where>
  47. id not in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
  48. and status != -1
  49. <if test="advertiserId != null">
  50. and advertiser_id=#{advertiserId}
  51. </if>
  52. </where>
  53. </select>
  54. <select id="countByParams3advertiser" parameterType="map" resultType="int">
  55. select count(id)
  56. from t_banner_template
  57. <where>
  58. id not in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
  59. and t_banner_template.status != -1
  60. <if test="advertiserId != null">
  61. and advertiser_id=#{advertiserId}
  62. </if>
  63. <if test="type != null">
  64. and type=#{type}
  65. </if>
  66. <if test="height != null">
  67. and height=#{height}
  68. </if>
  69. <if test="width != null">
  70. and width=#{width}
  71. </if>
  72. <if test="value != null">
  73. and name like #{value}
  74. </if>
  75. </where>
  76. </select>
  77. <select id="findByParams" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
  78. select t_banner_template.id as id, t_banner_template.advertiser_id as advertiser_id,t_banner_template.name as name,
  79. t_banner_template.path as path,t_banner_template.type as type,t_banner_template.width as width,t_banner_template.height as height,
  80. t_banner_template.status as status,t_banner_template.updated as updated,t_banner.id as TBannerId from t_banner_template left join t_banner on t_banner_template.id = t_banner.banner_template_id
  81. <where>
  82. t_banner.adgroup_id = #{adGroupId}
  83. and status!=-1
  84. <if test="key!=null and value!=null">
  85. <choose>
  86. <when test="key=='name'">
  87. and name like #{value}
  88. </when>
  89. </choose>
  90. </if>
  91. </where>
  92. order by id desc
  93. limit #{pager.offset}, #{pager.limit}
  94. </select>
  95. <select id="findById" parameterType="long" resultType="com.cloudcross.ssp.model.BannerTemplate">
  96. select
  97. <include refid="base_columnoperator"/>
  98. from t_banner_template
  99. <where>
  100. id = #{id}
  101. </where>
  102. </select>
  103. <update id="updateBannerTemplateStatus" parameterType="HashMap">
  104. update t_banner_template
  105. set status=#{status},updated = #{updated}
  106. where id in
  107. <foreach item="id" collection="idList" open="(" separator=","
  108. close=")">
  109. #{id}
  110. </foreach>
  111. </update>
  112. <update id="updateBannerTime" parameterType="HashMap">
  113. update t_banner
  114. set supdated=#{updataTime}
  115. where banner_template_id in
  116. <foreach item="id" collection="idList" open="(" separator=","
  117. close=")">
  118. #{id}
  119. </foreach>
  120. </update>
  121. <!-- 模板状态改变,更形t_banner_operator时间 -->
  122. <update id="updateBannerOperatorTime" parameterType="HashMap">
  123. update t_banner_operator
  124. set supdated=#{updataTime}
  125. where banner_id in (select id from t_banner
  126. where t_banner.banner_template_id in
  127. <foreach item="id" collection="idList" open="(" separator=","
  128. close=")">
  129. #{id}
  130. </foreach>)
  131. </update>
  132. <update id="updataDeleteBannerTemplateStatus" parameterType="HashMap">
  133. update t_banner_template
  134. set status=#{status},
  135. updated = #{updated}
  136. where id in
  137. <foreach item="id" collection="idList" open="(" separator=","
  138. close=")">
  139. #{id}
  140. </foreach>
  141. </update>
  142. <update id="updataDeleteBannerStatus" parameterType="HashMap">
  143. update t_banner
  144. set status=#{status},
  145. updated = #{updated},supdated = #{updated}
  146. where banner_template_id in
  147. <foreach item="id" collection="idList" open="(" separator=","
  148. close=")">
  149. #{id}
  150. </foreach>
  151. </update>
  152. <update id="updataDeleteBannerTemplateOperatorStatus" parameterType="HashMap">
  153. update t_banner_operator
  154. set checked =3,
  155. supdated=#{updated}
  156. where banner_id in (select id from t_banner
  157. where t_banner.banner_template_id in
  158. <foreach item="id" collection="idList" open="(" separator=","
  159. close=")">
  160. #{id}
  161. </foreach>)
  162. </update>
  163. <select id="findByCampaignId" parameterType="long" resultType="com.cloudcross.ssp.model.AdGroup">
  164. select
  165. <include refid="base_columnadvertiser"/>
  166. from t_adgroup
  167. where campaign_id=#{campaignId} and t_adgroup.status!=-1
  168. </select>
  169. <update id="alterName" parameterType="map">
  170. update t_banner_template set name = #{name} , updated = now() where id = #{id}
  171. </update>
  172. <update id="editadvertiser" parameterType="com.cloudcross.ssp.model.BannerTemplate">
  173. update t_banner_template
  174. set name = #{name},
  175. path = #{path},
  176. path_small = #{pathSmall},
  177. width = #{width},
  178. height = #{height},
  179. type = ${type},
  180. updated = #{updated}
  181. WHERE id = #{id}
  182. </update>
  183. <!-- 替换素材对应创意审核状态更新 -->
  184. <update id="updataBannerReplace" parameterType="map">
  185. update t_banner
  186. set checked = 0,
  187. updated = #{supdated},
  188. supdated = #{supdated}
  189. where banner_template_id = #{id}
  190. </update>
  191. <update id="updataBannerOperatorReplace" parameterType="map">
  192. update t_banner_operator
  193. set checked = 0,
  194. supdated = #{supdated}
  195. where banner_id in (select id from t_banner where banner_template_id =#{id})
  196. </update>
  197. <update id="updataIds" parameterType="com.cloudcross.ssp.model.BannerTemplate">
  198. update t_banner_template a
  199. set a.advertiser_id = #{advertiserId},
  200. a.agent_id = #{agentId}
  201. WHERE a.id = #{id}
  202. </update>
  203. <update id="editoperator" parameterType="com.cloudcross.ssp.model.BannerTemplate">
  204. update t_banner_template a,t_banner b
  205. set a.name = #{name},
  206. a.updated = #{updated},
  207. b.visit_address = #{banner.visitAddress},
  208. b.click_address = #{banner.clickAddress},
  209. b.impression_address = #{banner.impressionAddress}
  210. WHERE a.id = b.banner_template_id and a.id = #{id}
  211. </update>
  212. <select id="countByParams2advertiser" parameterType="map" resultType="int">
  213. select count(t_banner_template.id)
  214. from t_banner_template
  215. <where>
  216. <if test="status != null">
  217. t_banner_template.status=#{status}
  218. </if>
  219. <if test="status == null">
  220. t_banner_template.status in (0,1)
  221. </if>
  222. <if test="agentId != null">
  223. and agent_id = #{agentId}
  224. </if>
  225. <if test="type != null">
  226. and type=#{type}
  227. </if>
  228. <if test="height != null">
  229. and height=#{height}
  230. </if>
  231. <if test="width != null">
  232. and width=#{width}
  233. </if>
  234. <if test="advertiserId != null">
  235. and advertiser_id = #{advertiserId}
  236. </if>
  237. <if test="value != null">
  238. and name like #{value}
  239. </if>
  240. </where>
  241. </select>
  242. <select id="countByParams2operator" parameterType="map" resultType="int">
  243. select count(id)
  244. from t_banner_template
  245. <where>
  246. <if test="status != null">
  247. status=#{status}
  248. </if>
  249. <if test="status == null">
  250. status in (0,1)
  251. </if>
  252. <!-- <if test="advertiserId != null"> and advertiser_id=#{advertiserId}
  253. </if> -->
  254. <if test="type != null">
  255. and type=#{type}
  256. </if>
  257. <if test="height != null">
  258. and height=#{height}
  259. </if>
  260. <if test="width != null">
  261. and width=#{width}
  262. </if>
  263. <if test="value != null">
  264. and name like #{value}
  265. </if>
  266. </where>
  267. </select>
  268. <select id="findByParams2advertiser" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
  269. select <include refid="base_columnadvertiser"/>
  270. from t_banner_template
  271. <where>
  272. <if test="status != null">
  273. t_banner_template.status=#{status}
  274. </if>
  275. <if test="status == null">
  276. t_banner_template.status in (0,1)
  277. </if>
  278. <if test="agentId != null">
  279. and agent_id = #{agentId}
  280. </if>
  281. <if test="type != null">
  282. and type=#{type}
  283. </if>
  284. <if test="height != null">
  285. and height=#{height}
  286. </if>
  287. <if test="width != null">
  288. and width=#{width}
  289. </if>
  290. <if test="advertiserId != null">
  291. and advertiser_id = #{advertiserId}
  292. </if>
  293. <if test="value != null">
  294. and name like #{value}
  295. </if>
  296. </where>
  297. order by t_banner_template.id desc
  298. limit #{pager.offset}, #{pager.limit}
  299. </select>
  300. <select id="findByParams2Operator" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
  301. select
  302. <include refid="base_columnoperator" />
  303. from t_banner_template
  304. <where>
  305. <if test="status != null">
  306. status=#{status}
  307. </if>
  308. <if test="status == null">
  309. status in (0,1)
  310. </if>
  311. <!-- <if test="advertiserId != null"> and advertiser_id=#{advertiserId}
  312. </if> -->
  313. <if test="type != null">
  314. and type=#{type}
  315. </if>
  316. <if test="height != null">
  317. and height=#{height}
  318. </if>
  319. <if test="width != null">
  320. and width=#{width}
  321. </if>
  322. <if test="value != null">
  323. and name like #{value}
  324. </if>
  325. </where>
  326. order by id desc
  327. limit #{pager.offset}, #{pager.limit}
  328. </select>
  329. <select id="findByParams4advertiser" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
  330. select
  331. <include refid="base_columnadvertiser"/>
  332. from t_banner_template
  333. <where>
  334. id not in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
  335. and t_banner_template.status != -1
  336. <if test="advertiserId != null">
  337. and advertiser_id=#{advertiserId}
  338. </if>
  339. <if test="type != null">
  340. and type = #{type}
  341. </if>
  342. <if test="height != null">
  343. and height = #{height}
  344. </if>
  345. <if test="width != null">
  346. and width = #{width}
  347. </if>
  348. <if test="value != null">
  349. and name like #{value}
  350. </if>
  351. </where>
  352. order by id desc
  353. limit #{pager.offset}, #{pager.limit}
  354. </select>
  355. <select id="findByParams4operator" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
  356. select
  357. <include refid="base_columnoperator"/>
  358. from t_banner_template
  359. <where>
  360. id not in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
  361. and status != -1
  362. <if test="advertiserId != null">
  363. and advertiser_id=#{advertiserId}
  364. </if>
  365. </where>
  366. order by id desc
  367. limit #{pager.offset}, #{pager.limit}
  368. </select>
  369. <insert id="addBannerTemplate" parameterType="com.cloudcross.ssp.model.BannerTemplate" useGeneratedKeys="true"
  370. keyProperty="id">
  371. insert into t_banner_template (agent_id,advertiser_id,name,path,path_small,type,width,height,status,updated)
  372. values(#{agentId},#{advertiserId},#{name},#{path},#{pathSmall},#{type},#{width},#{height},#{status},#{updated})
  373. </insert>
  374. </mapper>