mybatis的一些有趣用法

<sql id="Base_Column_List">
		id,
		app_version,
		order_sub_no,
		create_time
	</sql>
	<insert id="insertOrderAppExpand" parameterType="orderAppExpand">
		insert into tbl_order_app_expand (
		<include refid="Base_Column_List" />
		)
		values (
		#{id,jdbcType=VARCHAR},
		#{appVersion,jdbcType=VARCHAR},
		#{orderSubNo,jdbcType=VARCHAR},
		#{createTime,jdbcType=TIMESTAMP}
		)
	</insert>


<insert id="insertOerAppExps" parameterType="java.util.List">
    insert into tdeppand(id,app_version,order_sub_no,create_time)
    values 
    <foreach collection="list" item="item" index="index" separator="," >
        (#{item.id,jdbcType=VARCHAR},
            #{item.appVersion,jdbcType=VARCHAR},
            #{item.orderSubNo,jdbcType=VARCHAR},
            #{item.createTime,jdbcType=TIMESTAMP})
    </foreach>
</insert>






<select id="getOrrDetailsLirams" resultMap="Ordeail4subMap"
        parameterType="map">
        select
        <include refid="Base_Column_List" />
        from tbl_order_detail4sub t 
        <where>
            <if test="orderSubId!=null and orderSubId!=''"> and t.order_sub_id=#{orderSubId}</if>
            <if test="id!=null and id!=''"> and t.id=#{id}</if>
            <if test="orderMainNo!=null and orderMainNo!=''"> and t.order_main_no=#{orderMainNo}</if>
            <if test="usableNum!=null"><![CDATA[and t.usable_num > #{usableNum}]]></if>
        </where>
        limit 0,2000
    </select>



<if
            test="orderCreateTime!=null and orderCreateTime!='' and orderCreateTime=1">
            <![CDATA[
            and TO_DAYS(NOW()) - TO_DAYS(m.create_time) <= 30 
            ]]>
        </if>

你可能感兴趣的:(mybatis)