123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
- <mapper namespace="bannerTemplateSqlMapper">
- <sql id="base_columnadvertiser">
- t_banner_template.id,
- agent_id as agentId,
- advertiser_id as advertiserId,
- name,
- path,
- path_small as pathSmall,
- type,
- width,
- height,
- t_banner_template.status,
- t_banner_template.updated
- </sql>
-
- <sql id="base_columnoperator">
- id,
- advertiser_id as advertiserId,
- name,
- path,
- type,
- width,
- height,
- status,
- updated
- </sql>
- <select id="countByParams" parameterType="map" resultType="int">
- select count(id)
- from t_banner_template
- <where>
- id in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
- and status!=-1
- <if test="key!=null and value!=null">
- <choose>
- <when test="key=='name'">
- and name like #{value}
- </when>
- </choose>
- </if>
- </where>
- </select>
-
- <select id="countByParams3operator" parameterType="map" resultType="int">
- select count(id)
- from t_banner_template
- <where>
- id not in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
- and status != -1
- <if test="advertiserId != null">
- and advertiser_id=#{advertiserId}
- </if>
- </where>
- </select>
-
- <select id="countByParams3advertiser" parameterType="map" resultType="int">
- select count(id)
- from t_banner_template
- <where>
- id not in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
- and t_banner_template.status != -1
- <if test="advertiserId != null">
- and advertiser_id=#{advertiserId}
- </if>
- <if test="type != null">
- and type=#{type}
- </if>
- <if test="height != null">
- and height=#{height}
- </if>
- <if test="width != null">
- and width=#{width}
- </if>
- <if test="value != null">
- and name like #{value}
- </if>
-
- </where>
- </select>
- <select id="findByParams" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
- select t_banner_template.id as id, t_banner_template.advertiser_id as advertiser_id,t_banner_template.name as name,
- t_banner_template.path as path,t_banner_template.type as type,t_banner_template.width as width,t_banner_template.height as height,
- 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
- <where>
- t_banner.adgroup_id = #{adGroupId}
- and status!=-1
- <if test="key!=null and value!=null">
- <choose>
- <when test="key=='name'">
- and name like #{value}
- </when>
- </choose>
- </if>
- </where>
- order by id desc
- limit #{pager.offset}, #{pager.limit}
- </select>
- <select id="findById" parameterType="long" resultType="com.cloudcross.ssp.model.BannerTemplate">
- select
- <include refid="base_columnoperator"/>
- from t_banner_template
- <where>
- id = #{id}
- </where>
- </select>
-
- <update id="updateBannerTemplateStatus" parameterType="HashMap">
- update t_banner_template
- set status=#{status},updated = #{updated}
- where id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>
- </update>
-
- <update id="updateBannerTime" parameterType="HashMap">
- update t_banner
- set supdated=#{updataTime}
- where banner_template_id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>
- </update>
-
- <!-- 模板状态改变,更形t_banner_operator时间 -->
- <update id="updateBannerOperatorTime" parameterType="HashMap">
- update t_banner_operator
- set supdated=#{updataTime}
- where banner_id in (select id from t_banner
- where t_banner.banner_template_id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>)
- </update>
-
- <update id="updataDeleteBannerTemplateStatus" parameterType="HashMap">
- update t_banner_template
- set status=#{status},
- updated = #{updated}
- where id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>
- </update>
- <update id="updataDeleteBannerStatus" parameterType="HashMap">
- update t_banner
- set status=#{status},
- updated = #{updated},supdated = #{updated}
- where banner_template_id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>
- </update>
- <update id="updataDeleteBannerTemplateOperatorStatus" parameterType="HashMap">
- update t_banner_operator
- set checked =3,
- supdated=#{updated}
- where banner_id in (select id from t_banner
- where t_banner.banner_template_id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>)
- </update>
-
-
- <select id="findByCampaignId" parameterType="long" resultType="com.cloudcross.ssp.model.AdGroup">
- select
- <include refid="base_columnadvertiser"/>
- from t_adgroup
- where campaign_id=#{campaignId} and t_adgroup.status!=-1
- </select>
-
-
- <update id="alterName" parameterType="map">
- update t_banner_template set name = #{name} , updated = now() where id = #{id}
- </update>
-
- <update id="editadvertiser" parameterType="com.cloudcross.ssp.model.BannerTemplate">
- update t_banner_template
- set name = #{name},
- path = #{path},
- path_small = #{pathSmall},
- width = #{width},
- height = #{height},
- type = ${type},
- updated = #{updated}
- WHERE id = #{id}
- </update>
-
- <!-- 替换素材对应创意审核状态更新 -->
- <update id="updataBannerReplace" parameterType="map">
- update t_banner
- set checked = 0,
- updated = #{supdated},
- supdated = #{supdated}
- where banner_template_id = #{id}
- </update>
- <update id="updataBannerOperatorReplace" parameterType="map">
- update t_banner_operator
- set checked = 0,
- supdated = #{supdated}
- where banner_id in (select id from t_banner where banner_template_id =#{id})
- </update>
- <update id="updataIds" parameterType="com.cloudcross.ssp.model.BannerTemplate">
- update t_banner_template a
- set a.advertiser_id = #{advertiserId},
- a.agent_id = #{agentId}
- WHERE a.id = #{id}
- </update>
- <update id="editoperator" parameterType="com.cloudcross.ssp.model.BannerTemplate">
- update t_banner_template a,t_banner b
- set a.name = #{name},
- a.updated = #{updated},
- b.visit_address = #{banner.visitAddress},
- b.click_address = #{banner.clickAddress},
- b.impression_address = #{banner.impressionAddress}
- WHERE a.id = b.banner_template_id and a.id = #{id}
- </update>
- <select id="countByParams2advertiser" parameterType="map" resultType="int">
- select count(t_banner_template.id)
- from t_banner_template
- <where>
- <if test="status != null">
- t_banner_template.status=#{status}
- </if>
- <if test="status == null">
- t_banner_template.status in (0,1)
- </if>
- <if test="agentId != null">
- and agent_id = #{agentId}
- </if>
- <if test="type != null">
- and type=#{type}
- </if>
- <if test="height != null">
- and height=#{height}
- </if>
- <if test="width != null">
- and width=#{width}
- </if>
- <if test="advertiserId != null">
- and advertiser_id = #{advertiserId}
- </if>
- <if test="value != null">
- and name like #{value}
- </if>
- </where>
- </select>
-
- <select id="countByParams2operator" parameterType="map" resultType="int">
- select count(id)
- from t_banner_template
- <where>
- <if test="status != null">
- status=#{status}
- </if>
- <if test="status == null">
- status in (0,1)
- </if>
- <!-- <if test="advertiserId != null"> and advertiser_id=#{advertiserId}
- </if> -->
- <if test="type != null">
- and type=#{type}
- </if>
- <if test="height != null">
- and height=#{height}
- </if>
- <if test="width != null">
- and width=#{width}
- </if>
- <if test="value != null">
- and name like #{value}
- </if>
- </where>
- </select>
- <select id="findByParams2advertiser" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
- select <include refid="base_columnadvertiser"/>
- from t_banner_template
- <where>
- <if test="status != null">
- t_banner_template.status=#{status}
- </if>
- <if test="status == null">
- t_banner_template.status in (0,1)
- </if>
- <if test="agentId != null">
- and agent_id = #{agentId}
- </if>
- <if test="type != null">
- and type=#{type}
- </if>
- <if test="height != null">
- and height=#{height}
- </if>
- <if test="width != null">
- and width=#{width}
- </if>
- <if test="advertiserId != null">
- and advertiser_id = #{advertiserId}
- </if>
- <if test="value != null">
- and name like #{value}
- </if>
- </where>
- order by t_banner_template.id desc
- limit #{pager.offset}, #{pager.limit}
- </select>
- <select id="findByParams2Operator" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
- select
- <include refid="base_columnoperator" />
- from t_banner_template
- <where>
- <if test="status != null">
- status=#{status}
- </if>
- <if test="status == null">
- status in (0,1)
- </if>
- <!-- <if test="advertiserId != null"> and advertiser_id=#{advertiserId}
- </if> -->
- <if test="type != null">
- and type=#{type}
- </if>
- <if test="height != null">
- and height=#{height}
- </if>
- <if test="width != null">
- and width=#{width}
- </if>
- <if test="value != null">
- and name like #{value}
- </if>
- </where>
- order by id desc
- limit #{pager.offset}, #{pager.limit}
- </select>
-
-
- <select id="findByParams4advertiser" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
- select
- <include refid="base_columnadvertiser"/>
- from t_banner_template
- <where>
- id not in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
- and t_banner_template.status != -1
- <if test="advertiserId != null">
- and advertiser_id=#{advertiserId}
- </if>
- <if test="type != null">
- and type = #{type}
- </if>
- <if test="height != null">
- and height = #{height}
- </if>
- <if test="width != null">
- and width = #{width}
- </if>
- <if test="value != null">
- and name like #{value}
- </if>
- </where>
- order by id desc
- limit #{pager.offset}, #{pager.limit}
- </select>
- <select id="findByParams4operator" parameterType="map" resultType="com.cloudcross.ssp.model.BannerTemplate">
- select
- <include refid="base_columnoperator"/>
- from t_banner_template
- <where>
- id not in (select banner_template_id from t_banner where adgroup_id=#{adGroupId})
- and status != -1
- <if test="advertiserId != null">
- and advertiser_id=#{advertiserId}
- </if>
- </where>
- order by id desc
- limit #{pager.offset}, #{pager.limit}
- </select>
- <insert id="addBannerTemplate" parameterType="com.cloudcross.ssp.model.BannerTemplate" useGeneratedKeys="true"
- keyProperty="id">
- insert into t_banner_template (agent_id,advertiser_id,name,path,path_small,type,width,height,status,updated)
- values(#{agentId},#{advertiserId},#{name},#{path},#{pathSmall},#{type},#{width},#{height},#{status},#{updated})
- </insert>
-
- </mapper>
|