123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <?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="com.kmall.admin.dao.AdDao">
- <resultMap type="com.kmall.admin.entity.AdEntity" id="adMap">
- <result property="id" column="id"/>
- <result property="adPositionId" column="ad_position_id"/>
- <result property="mediaType" column="media_type"/>
- <result property="name" column="name"/>
- <result property="storeId" column="store_id"/>
- <result property="merchSn" column="merch_sn"/>
- <result property="link" column="link"/>
- <result property="imageUrl" column="image_url"/>
- <result property="content" column="content"/>
- <result property="endTime" column="end_time"/>
- <result property="enabled" column="enabled"/>
- <result property="sortOrder" column="sort_order"/>
- <result property="tickDiscId" column="tick_disc_id"/>
- <result property="storeTopicId" column="store_topic_id"/>
- </resultMap>
- <select id="queryObject" resultType="com.kmall.admin.entity.AdEntity">
- select
- id,
- ad_position_id,
- media_type,
- name,
- store_id,
- merch_sn,
- link,
- image_url,
- sort_order,
- content,
- end_time,
- enabled
- from mall_ad
- where id = #{id}
- </select>
- <select id="queryAdByTickDiscId" resultType="com.kmall.admin.entity.AdEntity">
- select
- id,
- ad_position_id,
- media_type,
- name,
- store_id,
- merch_sn,
- link,
- image_url,
- sort_order,
- content,
- end_time,
- enabled
- from mall_ad
- where tick_disc_id = #{tickDiscId}
- </select>
- <select id="queryAdByStoreTopicId" resultType="com.kmall.admin.entity.AdEntity">
- select
- id,
- ad_position_id,
- media_type,
- name,
- store_id,
- merch_sn,
- link,
- image_url,
- sort_order,
- content,
- end_time,
- enabled
- from mall_ad
- where store_topic_id = #{storeTopicId}
- </select>
- <select id="queryList" resultType="com.kmall.admin.entity.AdEntity">
- select
- mall_ad.id,
- mall_ad.ad_position_id,
- mall_ad.media_type,
- mall_ad.name,
- mall_ad.store_id,
- mall_ad.merch_sn,
- mall_ad.link,
- mall_ad.image_url,
- mall_ad.sort_order,
- mall_ad.content,
- mall_ad.end_time,
- mall_ad.enabled,
- mall_ad_position.name ad_Position_Name
- from mall_ad LEFT JOIN mall_ad_position on mall_ad.ad_position_id = mall_ad_position.id
- left join mall_store s on mall_ad.store_id = s.id
- where 1=1
- <if test="storeId != null and storeId != ''">
- AND mall_ad.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- AND mall_ad.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="name != null and name.trim() != ''">
- AND mall_ad.name LIKE concat('%',#{name},'%')
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by mall_ad.id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryTotal" resultType="int">
- select count(*) from mall_ad
- left join mall_store s on mall_ad.store_id = s.id
- WHERE 1=1
- <if test="storeId != null and storeId != ''">
- AND mall_ad.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- AND mall_ad.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="name != null and name.trim() != ''">
- AND name LIKE concat('%',#{name},'%')
- </if>
- </select>
- <insert id="save" parameterType="com.kmall.admin.entity.AdEntity" useGeneratedKeys="true" keyProperty="id">
- insert into mall_ad(
- `ad_position_id`,
- `media_type`,
- `name`,
- `store_id`,
- `merch_sn`,
- tick_disc_id,
- store_topic_id,
- `link`,
- `image_url`,
- `sort_order`,
- `content`,
- `end_time`,
- `enabled`)
- values(
- #{adPositionId},
- #{mediaType},
- #{name},
- #{storeId},
- #{merchSn},
- #{tickDiscId},
- #{storeTopicId},
- #{link},
- #{imageUrl},
- #{sortOrder},
- #{content},
- #{endTime},
- #{enabled})
- </insert>
- <update id="update" parameterType="com.kmall.admin.entity.AdEntity">
- update mall_ad
- <set>
- <if test="adPositionId != null">`ad_position_id` = #{adPositionId},</if>
- <if test="mediaType != null">`media_type` = #{mediaType},</if>
- <if test="name != null">`name` = #{name},</if>
- <if test="storeId != null">`store_id` = #{storeId}, </if>
- <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
- <if test="tickDiscId != null">`tick_disc_id` = #{tickDiscId}, </if>
- <if test="storeTopicId != null">`store_topic_id` = #{storeTopicId}, </if>
- <if test="link != null">`link` = #{link},</if>
- <if test="imageUrl != null">`image_url` = #{imageUrl},</if>
- <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
- <if test="content != null">`content` = #{content},</if>
- <if test="endTime != null">`end_time` = #{endTime},</if>
- <if test="enabled != null">`enabled` = #{enabled}</if>
- </set>
- where id = #{id}
- </update>
- <delete id="delete">
- delete from mall_ad where id = #{value}
- </delete>
- <delete id="deleteBatch">
- delete from mall_ad where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|