123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- <?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="bannerSqlMapper">
- <sql id="base_column_advertiser">
- id,
- banner_template_id as bannerTemplateId,
- order_id as orderId,
- campaign_id as campaignId,
- adgroup_id as adGroupId,
- visit_address as visitAddress,
- click_address as clickAddress,
- impression_address as impressionAddress
- status,
- checked,
- updated,
- supdated
- </sql>
-
- <sql id="base_column_operator">
- b.id as bannerId,
- banner_template_id as bannerTemplateId,
- order_id as orderId,
- campaign_id as campaignId,
- adgroup_id as adGroupId,
- visit_address as visitAddress,
- click_address as clickAddress,
- impression_address as impressionAddress,
- b.checked as checked,
- IFNULL(bo.checked,-1) as operatorChecked,
- b.updated as updated,
- memo
- </sql>
-
- <sql id="banner_template_base_column">
- bt.id as banner_templateId,
- advertiser_id as advertiserId,
- name,
- path,
- path_small as pathSmall,
- type,
- width,
- height,
- bt.status as status,
- bt.updated as bannerTemplateUpdated
- </sql>
-
- <delete id="deleteBanner" parameterType="HashMap">
- delete from t_banner where
- id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>
- </delete>
-
- <update id="updateBannerStatus" parameterType="HashMap">
- update t_banner
- set status=#{status},updated = #{updated},supdated = #{supdated}
- where id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateBannerStatusOperator" parameterType="HashMap">
- update t_banner
- set checked = #{checked},updated = #{updated}
- where id in
- <foreach item="bannerId" collection="bannerIdList"
- open="(" separator="," close=")">
- #{bannerId}
- </foreach>
- </update>
- <select id="countByParams" parameterType="map" resultType="int">
- select count(a.id) from t_banner a ,t_banner_template b
- <where>
- a.banner_template_id = b.id and a.adgroup_id=#{adGroupId}
- <if test="value !=null">
- and name like #{value}
- </if>
- </where>
- and a.status != -1
- </select>
-
- <select id="countByAdGroupId" parameterType="long" resultType="int">
- select count(id) from t_banner
- where adgroup_id = #{adGroupId}
- </select>
-
- <select id="findById1" parameterType="long" resultType="com.cloudcross.ssp.model.Banner">
- select
- <include refid="base_column_advertiser"/>
- from t_banner
- <where>
- adgroup_id = #{adGroupId}
- </where>
- </select>
-
- <select id="findByIdAdvertiser" parameterType="long" resultMap="Banner">
- select a.id as id,a.banner_template_id as bannerTemplateId,a.order_id as orderId,a.campaign_id as campaignId,a.adgroup_id as adGroupId,a.visit_address as visitAddress,
- a.click_address as clickAddress,a.impression_address as impressionAddress,a.status as status1,a.checked as checked,a.updated as updated, b.id as bannerTemplateId,b.agent_id as agentId,b.advertiser_id as advertiserId,b.name as name,b.path as path,b.path_small as pathSmall,b.type as type,b.width as width,b.height as height,b.status as status,b.updated as updated from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id
- <where>
- a.id=#{id}
- </where>
- </select>
-
- <select id="findByIdOperator" parameterType="int" resultMap="banner">
- select <include refid="base_column_operator"/> ,<include refid="banner_template_base_column"/>
- from t_banner b inner join t_banner_template bt on b.banner_template_id = bt.id left join t_banner_operator bo
- on b.id=bo.banner_id where b.id=#{id}
- </select>
-
- <select id="findByParams" parameterType="map" resultMap="Banner">
- select a.id as id,a.banner_template_id as bannerTemplateId,a.order_id as orderId,a.campaign_id as campaignId,a.adgroup_id as adGroupId,a.visit_address as visitAddress,
- a.click_address as clickAddress,a.impression_address as impressionAddress,a.status as status1,a.checked as checked,a.updated as updated,a.supdated as supdated,b.id as bannerTemplateId,b.agent_id as agentId,b.advertiser_id as advertiserId,b.agent_id as agentId,b.name as name,b.path as path,b.path_small as pathSmall,b.type as type,b.width as width,b.height as height,b.status as status,b.updated as updated from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id
- <where>
- a.adgroup_id=#{adGroupId}
- <if test="value !=null">
- and name like #{value}
-
- </if>
- </where>
- and a.status != -1
- order by a.id desc
- limit #{pager.offset}, #{pager.limit}
- </select>
-
- <select id="countByZoneSize" parameterType="HashMap" resultType="int">
- select count(*) from t_banner b inner join t_banner_template bt on b.banner_template_id = bt.id
- where bt.status != -1 and checked != 2 and checked !=0
- <if test="zoneList.size()>0">
- and
- <foreach item="zone" collection="zoneList"
- open="(" separator="or" close=")" >
- bt.width <= #{zone.width} and bt.height <= #{zone.height}
- </foreach>
- </if>
- <if test="searchKey!=null and searchValue!=null">
- and bt.name like #{searchValue}
- </if>
- <if test="checked!=null">
- and b.checked like #{checked}
- </if>
- </select>
-
- <select id="findByZoneSize" parameterType="HashMap" resultMap="banner">
- select <include refid="base_column_operator"/> ,<include refid="banner_template_base_column"/>
- from t_banner b inner join t_banner_template bt on b.banner_template_id = bt.id
- where bt.status != -1 and checked != 2 and checked !=0
- <if test="zoneList.size()>0">
- and
- <foreach item="zone" collection="zoneList"
- open="(" separator="or" close=")" >
- bt.width <= #{zone.width} and bt.height <= #{zone.height}
- </foreach>
- </if>
- <if test="searchKey!=null and searchValue!=null">
- and bt.name like #{searchValue}
- </if>
- <if test="checked!=null">
- and b.checked like #{checked}
- </if>
- order by b.id desc
- <if test="pager!=null">
- limit #{pager.offset}, #{pager.limit}
- </if>
- </select>
- <resultMap type="com.cloudcross.ssp.model.Banner" id="Banner">
- <id property="id" column="id"/>
- <result property="bannerTemplateId" column="bannerTemplateId"/>
- <result property="status" column="status1"/>
- <result property="orderId" column="orderId"/>
- <result property="campaignId" column="campaignId"/>
- <result property="adGroupId" column="adGroupId"/>
- <result property="visitAddress" column="visitAddress"/>
- <result property="clickAddress" column="clickAddress"/>
- <result property="impressionAddress" column="impressionAddress"/>
- <result property="checked" column="checked"/>
- <result property="updated" column="updated"/>
- <result property="supdated" column="supdated"/>
- <association property="bannerTemplate" javaType="com.cloudcross.ssp.model.BannerTemplate" resultMap="bannerTemplate"/>
- </resultMap>
- <resultMap type="com.cloudcross.ssp.model.BannerTemplate" id="bannerTemplate">
- <id property="id" column="bannerTemplateId"/>
- <result property="advertiserId" column="advertiserId"/>
- <result property="agentId" column="agentId"/>
- <result property="name" column="name"/>
- <result property="path" column="path"/>
- <result property="pathSmall" column="pathSmall"/>
- <result property="type" column="type"/>
- <result property="width" column="width"/>
- <result property="height" column="height"/>
- <result property="status" column="status"/>
- <result property="updated" column="updated"/>
- </resultMap>
- <resultMap type="com.cloudcross.ssp.model.Banner" id="banneroperator">
- <id property="id" column="bannerId"/>
- <result property="bannerTemplateId" column="bannerTemplateId"/>
- <result property="orderId" column="orderId"/>
- <result property="campaignId" column="campaignId"/>
- <result property="adGroupId" column="adgroupId"/>
- <result property="visitAddress" column="visitAddress"/>
- <result property="clickAddress" column="clickAddress"/>
- <result property="impressionAddress" column="impressionAddress"/>
- <result property="checked" column="checked"/>
- <result property="operatorChecked" column="operatorChecked"/>
- <result property="updated" column="updated"/>
- <result property="memo" column="memo"/>
- <association property="bannerTemplate" resultMap="com.cloudcross.ssp.model.BannerTemplate"/>
- </resultMap>
- <resultMap type="com.cloudcross.ssp.operator.model.BannerTemplate" id="bannerTemplate">
- <id property="id" column="banner_templateId"/>
- <result property="advertiserId" column="advertiserId"/>
- <result property="name" column="name"/>
- <result property="path" column="path"/>
- <result property="pathSmall" column="pathSmall"/>
- <result property="type" column="type"/>
- <result property="width" column="width"/>
- <result property="height" column="height"/>
- <result property="status" column="status"/>
- <result property="updated" column="bannerTemplateUpdated"/>
- </resultMap>
-
- <insert id="addBanner" parameterType="com.cloudcross.ssp.model.Banner" useGeneratedKeys="true"
- keyProperty="id">
- insert into
- t_banner(banner_template_id,order_id,campaign_id,adgroup_id,visit_address,click_address,impression_address,checked,memo,updated,supdated
- )
- values (
- #{bannerTemplateId},#{orderId},#{campaignId},#{adGroupId},#{visitAddress},#{clickAddress},#{impressionAddress},#{checked},#{memo},#{updated},#{supdated}
- )
- </insert>
-
- <update id="editBanner" parameterType="com.cloudcross.ssp.model.Banner">
- update t_banner a,t_banner_template b
- set b.name = #{bannerTemplate.name},
- b.updated = #{bannerTemplate.updated},
- a.visit_address = #{visitAddress},
- a.click_address = #{clickAddress},
- a.impression_address = #{impressionAddress},
- a.checked = 0,
- a.updated = #{updated},
- a.supdated = #{supdated}
- WHERE b.id = a.banner_template_id and a.id = #{id}
- </update>
-
- <update id="updataBanner" parameterType="com.cloudcross.ssp.model.Banner">
- update t_banner a,t_banner_template b
- set a.banner_template_id = #{bannerTemplateId},
- b.name = #{bannerTemplate.name},
- b.updated = #{bannerTemplate.updated},
- a.visit_address = #{visitAddress},
- a.click_address = #{clickAddress},
- a.impression_address = #{impressionAddress},
- a.checked = 0,
- a.updated = #{updated},
- a.supdated = #{supdated}
- WHERE b.id = #{bannerTemplate.id} and a.id = #{id}
- </update>
-
- <update id="updataOperatorBanner" parameterType="HashMap">
- update t_banner_operator
- set checked = 0,supdated = #{supdated}
- WHERE banner_id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>
- </update>
- <!-- 根据adgroupId修改banner的supdated -->
- <update id="updateBannerSupdated" parameterType="HashMap">
- update t_banner
- set t_banner.supdated= #{modifyDate}
- where t_banner.adgroup_id in
- <foreach item="adgroupId" collection="adGroupIdList"
- open="(" separator="," close=")">
- #{adgroupId}
- </foreach>
- </update>
-
- <!-- 根据orderId修改banner的supdated -->
- <update id="updateBannerSupdatedByOrderId" parameterType="HashMap">
- update t_banner
- set t_banner.supdated=#{modifyDate}
- where t_banner.order_id in
- <foreach item="orderId" collection="orderIdList"
- open="(" separator="," close=")">
- #{orderId}
- </foreach>
- </update>
-
- <!-- 根据campaignid修改banner的supdated -->
- <update id="updateBannerSupdatedByCampaignId" parameterType="HashMap">
- update t_banner
- set t_banner.supdated=#{modifyDate}
- where t_banner.campaign_id in
- <foreach item="campaignId" collection="campaignIdList"
- open="(" separator="," close=")">
- #{campaignId}
- </foreach>
- </update>
-
-
- <update id="updateStatusByOrderId" parameterType="HashMap">
- update t_banner a,t_banner_template b
- set b.status=#{status},b.updated = #{modifyDate},a.updated = #{modifyDate}
- where
- a.banner_template_id = b.id and
- a.order_id in
- <foreach item="orderId" collection="orderIdList" open="(" separator="," close=")">
- #{orderId}
- </foreach>
- </update>
-
- <update id="updateStatusByCampaignId" parameterType="HashMap">
- update t_banner a,t_banner_template b
- set b.status=#{status},b.updated = #{modifyDate},a.updated = #{modifyDate}
- where
- a.banner_template_id = b.id and
- a.campaign_id in
- <foreach item="campaignId" collection="campaignIdList" open="(" separator="," close=")">
- #{campaignId}
- </foreach>
- </update>
-
- <update id="updateStatusByAdGroupId" parameterType="HashMap">
- update t_banner a,t_banner_template b
- set b.status=#{status},b.updated = #{modifyDate},a.updated = #{modifyDate}
- where
- a.banner_template_id = b.id and
- a.adgroup_id in
- <foreach item="adGroupId" collection="adGroupIdList" open="(" separator="," close=")">
- #{adGroupId}
- </foreach>
- </update>
-
-
- <select id="countByParams1" parameterType="map" resultType="int">
- select count(a.id)
- from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id
- <where>
- a.status != -1 and b.status != -1
- <if test="orderMark == null">
- and a.order_id = #{orderId}
- </if>
- <if test="campaignMark == null">
- and a.campaign_id = #{campaignId}
- </if>
- <if test="adGroupMark == null">
- and a.adgroup_id = #{adGroupId}
- </if>
- <if test="status!=null">
- and a.status = #{status} and b.status = #{status}
- </if>
- <if test="bannerTemplateName != null">
- and b.name like #{bannerTemplateName}
- </if>
- <if test="agentId!=null">
- and b.agent_id = #{agentId}
- </if>
- <if test="agentId == null">
- and b.advertiser_id = #{advertiserId}
- </if>
- </where>
- </select>
-
- <select id="findByParams1" parameterType="map" resultMap="Banner">
- select a.status as status1,a.id as id,a.banner_template_id as bannerTemplateId,a.order_id as orderId,a.campaign_id as campaignId,a.adgroup_id as adGroupId,a.visit_address as visitAddress,
- a.click_address as clickAddress,a.impression_address as impressionAddress, a.checked as checked,a.updated as updated,b.id as bannerTemplateId,b.agent_id as agentId,b.advertiser_id as advertiserId,b.agent_id as agentId,b.name as name,b.path as path,b.path_small as pathSmall,b.type as type,b.width as width,b.height as height,b.status as status,b.updated as updated from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id
- <where>
- a.status != -1 and b.status != -1
- <if test="orderMark == null">
- and a.order_id = #{orderId}
- </if>
- <if test="campaignMark == null">
- and a.campaign_id = #{campaignId}
- </if>
- <if test="adGroupMark == null">
- and a.adgroup_id = #{adGroupId}
- </if>
- <if test="status!=null">
- and a.status = #{status} and b.status = #{status}
- </if>
- <if test="bannerTemplateName != null">
- and b.name like #{bannerTemplateName}
- </if>
- <if test="agentId!=null">
- and b.agent_id = #{agentId}
- </if>
- <if test="agentId == null">
- and b.advertiser_id = #{advertiserId}
- </if>
- </where>
- order by a.id desc
- limit #{pager.offset}, #{pager.limit}
- </select>
-
-
- <select id="findByParams2" parameterType="map" resultMap="Banner">
- select a.status as status1,a.id as id,a.banner_template_id as bannerTemplateId,a.order_id as orderId,a.campaign_id as campaignId,a.adgroup_id as adGroupId,a.visit_address as visitAddress,
- a.click_address as clickAddress,a.impression_address as impressionAddress, a.checked as checked,a.updated as updated,b.id as bannerTemplateId,b.agent_id as agentId,b.advertiser_id as advertiserId,b.agent_id as agentId,b.name as name,b.path as path,b.path_small as pathSmall,b.type as type,b.width as width,b.height as height,b.status as status,b.updated as updated from t_banner a LEFT JOIN t_banner_template b on a.banner_template_id=b.id
- <where>
- a.status != -1 and b.status != -1
- <if test="orderMark == null">
- and a.order_id = #{orderId}
- </if>
- <if test="campaignMark == null">
- and a.campaign_id = #{campaignId}
- </if>
- <if test="adGroupMark == null">
- and a.adgroup_id = #{adGroupId}
- </if>
- <if test="status!=null">
- and a.status = #{status} and b.status = #{status}
- </if>
- <if test="bannerTemplateName != null">
- and b.name like #{bannerTemplateName}
- </if>
- <if test="agentId!=null">
- and b.agent_id = #{agentId}
- </if>
- <if test="agentId == null">
- and b.advertiser_id = #{advertiserId}
- </if>
- </where>
- order by a.id desc
- </select>
- <update id="updateOperatorBannerTime" parameterType="HashMap">
- update t_banner_operator
- set supdated = #{supdated}
- where banner_id in
- <foreach item="id" collection="idList" open="(" separator=","
- close=")">
- #{id}
- </foreach>
-
- </update>
-
-
- <update id="updateOperatorBanner" parameterType="HashMap">
- update t_banner_operator
- set operator_id=#{operatorId},checked = #{operatorChecked},supdated = #{supdated}
- where banner_id = #{bannerId}
- </update>
- <select id="countByOperator" parameterType="HashMap" resultType="int">
- select count(*) from t_banner b inner join t_banner_template bt on b.banner_template_id = bt.id left join t_banner_operator bo
- on b.id=bo.banner_id and bo.operator_id=#{operatorId}
- where b.status = 0 and bt.status = 0 and b.checked = 1
- <if test="zoneList.size()>0">
- and
- <foreach item="zone" collection="zoneList"
- open="(" separator="or" close=")" >
- bt.width <= #{zone.width} and bt.height <= #{zone.height}
- </foreach>
- </if>
- <if test="searchKey!=null and searchValue!=null">
- and bt.name like #{searchValue}
- </if>
- <if test="operatorChecked!=null">
- <choose>
- <when test="operatorChecked == 0">
- and ISNULL(bo.checked) or bo.checked =0
- </when>
- <otherwise>
- and bo.checked=#{operatorChecked}
- </otherwise>
- </choose>
- </if>
- </select>
- </mapper>
|