IMAdvertMapper.xml 2.7 KB
<?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.sibu.orderHelper.integral.web.dao.IMWebAdvertDao">
    
    <select id="pagerImAdvert" resultMap="listIMAdvert">
    	SELECT
			g.im_advert_id, g.type_id, g.im_product_id, g.name, g.image_url,g.link_url,g.is_show, g.sort_index 
		FROM
			im_advert g
		WHERE
			g.delete_flag = 1
		ORDER BY 
            sort_index asc,IFNULL(update_dt,create_dt) DESC
		LIMIT ${pageNow}, ${pageSize}
    </select>
    
    <select id="listAppImAdvert" resultMap="listIMAdvert">
    	SELECT
			g.im_advert_id, g.type_id, g.im_product_id, g.name, g.image_url,g.link_url 
		FROM
			im_advert g
		WHERE
			g.is_show = 1 and g.delete_flag = 1
		ORDER BY 
			sort_index asc,IFNULL(update_dt,create_dt) DESC
		LIMIT 0,5
    </select>
    
    <select id="countAdvert" resultType="int">
    	select count(*) from im_advert where delete_flag = 1
    </select>
    
    <select id="getAdvert" resultMap="listIMAdvert" parameterType="String">
    	SELECT
			g.im_advert_id, g.type_id, g.im_product_id, g.name, g.image_url,g.link_url,g.is_show, g.sort_index 
		FROM
			im_advert g
		WHERE
			g.im_advert_id = #{advertId} 
		LIMIT 1
    </select>
    
    <insert id="addAdvert" parameterType="IMAdvertBean">
    	insert into im_advert (
    		im_advert_id,
    		type_id,
    		im_product_id,
    		name,
    		image_url,
    		link_url,
    		sort_index,
    		is_show,
    		create_member_id,
    		create_dt
    	) value(#{imAdvertId}, #{typeId}, #{imProductId}, #{name}, #{imageUrl}, #{linkUrl}, #{sortIndex}, #{isShow}, #{createMemberId}, now())
    </insert>
    
    <update id="editAdvert" parameterType="IMAdvertBean">
    	update im_advert set type_id=#{typeId}, im_product_id=#{imProductId}, name=#{name},
    		image_url=#{imageUrl}, link_url=#{linkUrl}, sort_index=#{sortIndex}, is_show=#{isShow},update_dt=#{updateDt} 
    	where im_advert_id=#{imAdvertId}
    </update>
    
    <update id="deleteAdvert" parameterType="String">
    	update im_advert set delete_flag = 0 where im_advert_id=#{imAdvertId}
    </update>
    
	<resultMap type="IMAdvertBean" id="listIMAdvert">
        <result column="im_advert_id" property="imAdvertId" />
        <result column="type_id" property="typeId" />
        <result column="im_product_id" property="imProductId" />
        <result column="name" property="name" />
        <result column="image_url" property="imageUrl" />
        <result column="link_url" property="linkUrl"/>
        <result column="is_show" property="isShow"/>
        <result column="sort_index" property="sortIndex"/>
    </resultMap>
</mapper>