动态sql_实际应用

2022/8/24 2:24:56

本文主要是介绍动态sql_实际应用,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

<?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.qfedu.fmmall.dao.OrdersMapper">
    <resultMap id="BaseResultMap" type="com.qfedu.fmmall.entity.Orders">
        <id column="order_id" jdbcType="VARCHAR" property="orderId"/>
        <result column="user_id" jdbcType="VARCHAR" property="userId"/>
        <result column="untitled" jdbcType="VARCHAR" property="untitled"/>
        <result column="receiver_name" jdbcType="VARCHAR" property="receiverName"/>
        <result column="receiver_mobile" jdbcType="VARCHAR" property="receiverMobile"/>
        <result column="receiver_address" jdbcType="VARCHAR" property="receiverAddress"/>
        <result column="total_amount" jdbcType="DECIMAL" property="totalAmount"/>
        <result column="actual_amount" jdbcType="INTEGER" property="actualAmount"/>
        <result column="pay_type" jdbcType="INTEGER" property="payType"/>
        <result column="order_remark" jdbcType="VARCHAR" property="orderRemark"/>
        <result column="status" jdbcType="VARCHAR" property="status"/>
        <result column="delivery_type" jdbcType="VARCHAR" property="deliveryType"/>
        <result column="delivery_flow_id" jdbcType="VARCHAR" property="deliveryFlowId"/>
        <result column="order_freight" jdbcType="DECIMAL" property="orderFreight"/>
        <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
        <result column="delivery_time" jdbcType="TIMESTAMP" property="deliveryTime"/>
        <result column="flish_time" jdbcType="TIMESTAMP" property="flishTime"/>
        <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
        <result column="close_type" jdbcType="INTEGER" property="closeType"/>
    </resultMap>


    <select id="selectOrders">
        select
            o.order_id,
            user_id,
            untitled,
            receiver_name,
            receiver_mobile,
            receiver_address,
            o.total_amount,
            actual_amount,
            pay_type,
            order_remark,
            status,
            delivery_type,
            delivery_flow_id,
            order_freight,
            delete_status,
            create_time,
            pay_time,
            delivery_time
            flish_time,
            cancel_time,
            close_type,

            item_id,
            i.order_id item_order_id,
            product_id,
            product_name,
            product_img,
            sku_id,
            sku_name,
            product_price,
            buy_counts,
            i.total_amount item_total_amount,
            basket_date,
            buy_time,
            is_comment
        from orders o
        inner join order_item i
        on o.order_id = i.order_id
        where o.user_id = #{userId}
        <if test="status != null">
            and o.status=#{status}
        </if>
        and o.status = #{status}
        limit #{start}, #{limit}
    </select>
</mapper>


这篇关于动态sql_实际应用的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程