dspBanner.sql.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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="dspBannerSqlMapper">
  4. <sql id="base_column">
  5. id,
  6. dsp_id as dspId,
  7. advertiser_id as advertiserId,
  8. path,
  9. height,
  10. width,
  11. rheight,
  12. rwidth,
  13. state,
  14. memo,
  15. updated
  16. </sql>
  17. <insert id="add" parameterType="java.util.List">
  18. insert into t_dsp_banner(dsp_id,advertiser_id,path,height,width,rheight,rwidth,state,memo,updated) values
  19. <foreach collection="dspBannerList" item="item" index="index" separator=",">
  20. ( #{item.dspId}, #{item.advertiserId}, #{item.path}, #{item.height}, #{item.width},
  21. #{item.rheight}, #{item.rwidth}, 1, "", NOW() )
  22. </foreach>
  23. </insert>
  24. <update id="update" parameterType="java.util.List">
  25. <foreach collection="dspBannerList" item="item" index="index" open="" close="" separator=";">
  26. update t_dsp_banner set path = #{item.path},height = #{item.height},width = #{item.width},
  27. rheight = #{item.rheight}, rwidth = #{item.rwidth}, state = #{item.state},
  28. <if test="item.memo != null and item.memo != '' ">
  29. memo = #{item.memo},
  30. </if>
  31. updated = NOW()
  32. where id=#{item.id} and dsp_id = #{item.dspId} and advertiser_id = #{item.advertiserId}
  33. </foreach>
  34. </update>
  35. <select id="getAll" parameterType="java.util.Map" resultType="com.cloudcross.ssp.model.DspBanner">
  36. select <include refid="base_column"/>
  37. from t_dsp_banner where advertiser_id in
  38. <foreach item="advertiserId" collection="advertiserIdList" open="(" separator="," close=")">
  39. #{advertiserId}
  40. </foreach>
  41. and dsp_id = #{dspId}
  42. </select>
  43. <select id="get" parameterType="java.util.Map" resultType="com.cloudcross.ssp.model.DspBanner">
  44. select
  45. <include refid="base_column"/>
  46. from t_dsp_banner where id in
  47. <foreach item="bannerId" collection="bannerIdList" open="(" separator="," close=")">
  48. #{bannerId}
  49. </foreach>
  50. <if test="dspId != null and dspId != '' ">
  51. and dsp_id = #{dspId}
  52. </if>
  53. <if test="advertiserId != null and advertiserId != '' ">
  54. and advertiser_id = #{advertiserId}
  55. </if>
  56. </select>
  57. <select id="selectMaxId" parameterType="java.util.Map" resultType="java.lang.Long">
  58. select id from t_dsp_banner where dsp_id = #{dspId} and advertiser_id = #{advertiserId}
  59. <if test="bannerId != null and bannerId != '' ">
  60. and id != #{bannerId}
  61. </if>
  62. </select>
  63. <select id="queryState" parameterType="java.util.Map" resultType="java.util.Map">
  64. select id as bannerId,dsp_id as dspId,advertiser_id as advertiserId,state,memo as refuseReason
  65. from t_dsp_banner where id in
  66. <foreach item="bannerId" collection="bannerIdList" open="(" separator="," close=")">
  67. #{bannerId}
  68. </foreach>
  69. <if test="dspId != null and dspId != '' ">
  70. and dsp_id = #{dspId}
  71. </if>
  72. <if test="advertiserId != null and advertiserId != '' ">
  73. and advertiser_id = #{advertiserId}
  74. </if>
  75. </select>
  76. <select id="countByParams" parameterType="java.util.Map" resultType="int">
  77. select count(*)
  78. from t_dsp_banner a ,t_dsp_agent b
  79. <where>
  80. a.dsp_id = b.id
  81. <if test="searchValue !=null">
  82. and b.name like #{searchValue}
  83. </if>
  84. <if test="backState !=null">
  85. and a.state = #{backState}
  86. </if>
  87. </where>
  88. </select>
  89. <select id="findByParams" parameterType="java.util.Map" resultType="java.util.Map">
  90. select a.id,a.dsp_id,a.path,a.width,a.height,a.rwidth,a.rheight,a.state,a.memo,a.updated,b.name
  91. from t_dsp_banner a,t_dsp_agent b
  92. <where>
  93. a.dsp_id = b.id
  94. <if test="searchValue !=null">
  95. and b.name like #{searchValue}
  96. </if>
  97. <if test="backState !=null">
  98. and a.state = #{backState}
  99. </if>
  100. </where>
  101. order by a.id desc
  102. limit #{pager.offset}, #{pager.limit}
  103. </select>
  104. <update id="updateBackPass" parameterType="HashMap">
  105. update t_dsp_banner a ,t_dsp_banner_operator b
  106. set a.state=#{state},a.updated=#{updated},
  107. b.checked=0,b.supdated=#{supdated}
  108. where a.id = b.banner_id and a.id in
  109. <foreach item="id" collection="auditIdList" open="(" separator=","
  110. close=")">
  111. #{id}
  112. </foreach>
  113. </update>
  114. <update id="updateBackNoPass" parameterType="HashMap">
  115. update t_dsp_banner a ,t_dsp_banner_operator b
  116. set a.state=#{state},a.updated=#{updated},a.memo=#{memo},
  117. b.checked=3,b.supdated=#{supdated}
  118. where a.id = b.banner_id and a.id in
  119. <foreach item="id" collection="auditIdList" open="(" separator=","
  120. close=")">
  121. #{id}
  122. </foreach>
  123. </update>
  124. <select id="findByParamMap" parameterType="java.util.Map" resultType="java.util.Map">
  125. select a.id,a.dsp_id,a.path,a.width,a.height,a.rwidth,a.rheight,a.state,a.memo,a.updated,b.name
  126. from t_dsp_banner a,t_dsp_agent b
  127. <where>
  128. a.dsp_id = b.id
  129. <if test="searchValue !=null">
  130. and b.name like #{searchValue}
  131. </if>
  132. <if test="backState !=null">
  133. and a.state = #{backState}
  134. </if>
  135. </where>
  136. </select>
  137. <!-- ssssss后台审核通过后续判断是否t_dsp_operator有没有则添加 -->
  138. <select id="countByParamsOperator" parameterType="java.util.Map" resultType="int">
  139. select count(*)
  140. from t_dsp_banner a
  141. INNER JOIN t_dsp_agent b on a.dsp_id = b.id
  142. LEFT JOIN t_dsp_banner_operator c on a.id = c.banner_id and a.dsp_id = c.dsp_id
  143. <where>
  144. a.state =0
  145. <if test="zoneList.size()>0">
  146. and
  147. <foreach item="zone" collection="zoneList"
  148. open="(" separator="or" close=")" >
  149. a.rwidth &lt;= #{zone.rwidth} and a.rheight &lt;= #{zone.rheight}
  150. </foreach>
  151. </if>
  152. <if test="searchValue !=null">
  153. and b.name like #{searchValue}
  154. </if>
  155. <if test="operatorChecked !=null">
  156. and c.checked = #{operatorChecked}
  157. </if>
  158. </where>
  159. </select>
  160. <select id="findByParamsOperator" parameterType="java.util.Map" resultType="java.util.Map">
  161. select a.id,a.dsp_id,a.path,a.width,a.height,a.rwidth,a.rheight,a.state,a.memo,c.checked,c.supdated,b.name
  162. from t_dsp_banner a
  163. INNER JOIN t_dsp_agent b on a.dsp_id = b.id
  164. LEFT JOIN t_dsp_banner_operator c on a.id = c.banner_id and a.dsp_id = c.dsp_id
  165. <where>
  166. a.state =0
  167. <if test="zoneList.size()>0">
  168. and
  169. <foreach item="zone" collection="zoneList"
  170. open="(" separator="or" close=")" >
  171. a.rwidth &lt;= #{zone.rwidth} and a.rheight &lt;= #{zone.rheight}
  172. </foreach>
  173. </if>
  174. <if test="searchValue !=null">
  175. and b.name like #{searchValue}
  176. </if>
  177. <if test="operatorChecked !=null">
  178. and c.checked = #{operatorChecked}
  179. </if>
  180. </where>
  181. order by a.id desc
  182. limit #{pager.offset}, #{pager.limit}
  183. </select>
  184. <update id="updateOperatorPass" parameterType="HashMap">
  185. update t_dsp_banner a ,t_dsp_banner_operator b
  186. set a.updated=#{updated},
  187. b.checked=#{checked},b.supdated=#{supdated}
  188. where a.id = b.banner_id and a.id =#{bannerId}
  189. </update>
  190. <update id="updateOperatorNoPass" parameterType="HashMap">
  191. update t_dsp_banner a ,t_dsp_banner_operator b
  192. set a.updated=#{updated},a.memo=#{memo},
  193. b.checked=#{checked},b.supdated=#{supdated}
  194. where a.id = b.banner_id and a.id =#{bannerId}
  195. </update>
  196. <select id="getState" parameterType="HashMap" resultType="int">
  197. select IFNULL(checked,-1) as checked from t_dsp_banner_operator
  198. where operator_id=#{operatorId} and banner_id = #{bannerId}
  199. </select>
  200. <select id="findById" parameterType="int" resultType="DspBanner">
  201. select <include refid="base_column"/> from t_dsp_banner where id = #{id}
  202. </select>
  203. <insert id="addBannerOperator" parameterType="HashMap">
  204. insert t_dsp_banner_operator set
  205. operator_id = #{operatorId},
  206. dsp_id = #{dspId},
  207. banner_id = #{bannerId},
  208. checked = 0,
  209. supdated = #{supdated}
  210. </insert>
  211. </mapper>