PromotionDao.xml 8.64 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.diligrp.mobsite.man.dao.impl.PromotionDaoImpl">
    <resultMap id="PromotionRM" type="com.diligrp.mobsite.man.domain.Promotion">
            <id property="id" column="id"/>
            <result property="marketId" column="market_id"/>
            <result property="title" column="title"/>
            <result property="content" column="content"/>
            <result property="deviceType" column="device_type"/>
            <result property="receiveCrowd" column="receive_crowd"/>
            <result property="sendType" column="send_type"/>
            <result property="sendTime" column="send_time"/>
            <result property="openType" column="open_type"/>
            <result property="openUrl" column="open_url"/>
            <result property="sendFlag" column="send_flag"/>
            <result property="creatorId" column="creator_id"/>
            <result property="sendId" column="send_id"/>
            <result property="yn" column="yn"/>
            <result property="created" column="created"/>
            <result property="modified" column="modified"/>
    </resultMap>


	<select id="getById" parameterType="Long" resultMap="PromotionRM">
		<![CDATA[
		SELECT
		    id
		    ,market_id
		    ,title
		    ,content
		    ,device_type
		    ,receive_crowd
		    ,send_type
		    ,send_time
		    ,open_type
		    ,open_url
		    ,send_flag
		    ,creator_id
		    ,send_id
		    ,yn
		    ,created
		    ,modified
		FROM T_PROMOTION

		WHERE id=#{pk}
		and (yn is null or yn = 1)
		]]>
	</select>

	<insert id="save" parameterType="com.diligrp.mobsite.man.domain.Promotion">
        <selectKey keyProperty="id" resultType="long" order="AFTER">
            SELECT LAST_INSERT_ID();
        </selectKey>
		<![CDATA[
		INSERT INTO T_PROMOTION(
                    market_id
                    ,title
                    ,content
                    ,device_type
                    ,receive_crowd
                    ,send_type
                    ,send_time
                    ,open_type
                    ,open_url
                    ,send_flag
                    ,creator_id
                    ,send_id
		) VALUES
		]]>
        <foreach collection="marketIds" item="mId" separator=",">
            (
            #{mId}
            ,#{title}
            ,#{content}
            ,#{deviceType}
            ,#{receiveCrowd}
            ,#{sendType}
            ,#{sendTime}
            ,#{openType}
            ,#{openUrl}
            ,#{sendFlag}
            ,#{creatorId}
            ,#{sendId}
            )
        </foreach>
	</insert>

    <update id="update" parameterType="com.diligrp.mobsite.man.domain.Promotion">
    <![CDATA[
            UPDATE T_PROMOTION set
                        market_id=#{marketId}
                        ,title=#{title}
                        ,content=#{content}
                        ,device_type=#{deviceType}
                        ,receive_crowd=#{receiveCrowd}
                        ,send_type=#{sendType}
                        ,send_time=#{sendTime}
                        ,open_type=#{openType}
                        ,open_url=#{openUrl}
                        ,send_flag=#{sendFlag}
                        ,creator_id=#{creatorId}
                        ,send_id=#{sendId}

            where id = #{id}
            ]]>
    </update>

	<select id="countByCondition" parameterType="Query" resultType="Integer">
		<![CDATA[
		SELECT count(1) FROM T_PROMOTION where 1=1
		]]>
        <if test="param != null">
            <if test="param.id != null and param.id != ''">
            and id = #{param.id}
            </if>
            <if test="param.marketId != null and param.marketId != ''">
            and market_id = #{param.marketId}
            </if>
            <if test="param.title != null and param.title != ''">
            and title like #{param.title}"%"
            </if>
            <if test="param.content != null and param.content != ''">
            and content = #{param.content}
            </if>
            <if test="param.deviceType != null and param.deviceType != ''">
            and device_type = #{param.deviceType}
            </if>
            <if test="param.receiveCrowd != null and param.receiveCrowd != ''">
            and receive_crowd = #{param.receiveCrowd}
            </if>
            <if test="param.sendType != null and param.sendType != ''">
            and send_type = #{param.sendType}
            </if>
            <if test="param.sendTime != null and param.sendTime != ''">
            and send_time = #{param.sendTime}
            </if>
            <if test="param.openType != null and param.openType != ''">
            and open_type = #{param.openType}
            </if>
            <if test="param.openUrl != null and param.openUrl != ''">
            and open_url = #{param.openUrl}
            </if>
            <if test="param.sendFlag != null and param.sendFlag != ''">
            and send_flag = #{param.sendFlag}
            </if>
            <if test="param.creatorId != null and param.creatorId != ''">
            and creator_id = #{param.creatorId}
            </if>
            <if test="param.sendId != null and param.sendId != ''">
            and send_id = #{param.sendId}
            </if>
            <![CDATA[
                    and (yn is null or yn = 1)
                    ]]>
            <if test="param.created != null and param.created != ''">
            and created = #{param.created}
            </if>
            <if test="param.modified != null and param.modified != ''">
            and modified = #{param.modified}
            </if>
        </if>
	</select>

	<select id="listByCondition" parameterType="Query" resultMap="PromotionRM">
		<![CDATA[
		SELECT
		    id
		    ,market_id
		    ,title
		    ,content
		    ,device_type
		    ,receive_crowd
		    ,send_type
		    ,send_time
		    ,open_type
		    ,open_url
		    ,send_flag
		    ,creator_id
		    ,send_id
		    ,yn
		    ,created
		    ,modified
		FROM T_PROMOTION where 1=1
		]]>
        <if test="param != null">
                <if test="param.id != null and param.id != ''">
                    and id = #{param.id}
                </if>
                <if test="param.marketId != null and param.marketId != ''">
                    and market_id = #{param.marketId}
                </if>
                <if test="param.title != null and param.title != ''">
                    and title like #{param.title}"%"
                </if>
                <if test="param.content != null and param.content != ''">
                    and content = #{param.content}
                </if>
                <if test="param.deviceType != null and param.deviceType != ''">
                    and device_type = #{param.deviceType}
                </if>
                <if test="param.receiveCrowd != null and param.receiveCrowd != ''">
                    and receive_crowd = #{param.receiveCrowd}
                </if>
                <if test="param.sendType != null and param.sendType != ''">
                    and send_type = #{param.sendType}
                </if>
                <if test="param.sendTime != null and param.sendTime != ''">
                    and send_time = #{param.sendTime}
                </if>
                <if test="param.openType != null and param.openType != ''">
                    and open_type = #{param.openType}
                </if>
                <if test="param.openUrl != null and param.openUrl != ''">
                    and open_url = #{param.openUrl}
                </if>
                <if test="param.sendFlag != null and param.sendFlag != ''">
                    and send_flag = #{param.sendFlag}
                </if>
                <if test="param.creatorId != null and param.creatorId != ''">
                    and creator_id = #{param.creatorId}
                </if>
                <if test="param.sendId != null and param.sendId != ''">
                    and send_id = #{param.sendId}
                </if>
                <![CDATA[
                and (yn is null or yn = 1)
                ]]>
                <if test="param.created != null and param.created != ''">
                    and created = #{param.created}
                </if>
                <if test="param.modified != null and param.modified != ''">
                    and modified = #{param.modified}
                </if>
        </if>
        order by send_time desc
		<![CDATA[
		limit #{startRow},#{pageSize}
		]]>
	</select>


    <update id="deleteById" parameterType="Long">
    <![CDATA[
        update T_PROMOTION set
        yn = 2
        where 1 = 1
        and id = #{id}
    ]]>
    </update>

</mapper>