OrderLogisticsMapper.xml 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
<?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="cn.iocoder.mall.order.dao.OrderLogisticsMapper">

    <sql id="FIELDS">
        id, area_no, `name`, mobile, address, logistics_no
    </sql>

    <!--
        插入数据
    -->
    <insert id="insert" parameterType="OrderLogisticsDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
        INSERT INTO `order_logistics` (
sin's avatar
sin committed
14
            area_no, `name`, mobile, address, logistics_no, create_time, update_time
15 16
        ) VALUES (
             #{areaNo}, #{name}, #{mobile}, #{address},
sin's avatar
sin committed
17
             #{logisticsNo}, #{createTime}, #{updateTime}
18 19 20
        )
    </insert>

sin's avatar
sin committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
    <!--
        可更新字段
    -->
    <sql id="updateFieldSql" >
        <set>
            <if test="areaNo != null">
                , area_no = #{areaNo}
            </if>
            <if test="name != null">
                , `name` = #{name}
            </if>
            <if test="mobile != null">
                , mobile = #{mobile}
            </if>
            <if test="address != null">
                , address = #{address}
            </if>
            <if test="logisticsNo != null">
                , logistics_no = #{logisticsNo}
            </if>
        </set>
    </sql>

    <!--
        更新 - 根据id
    -->
    <update id="updateById">
        UPDATE `order_logistics`
        <include refid="updateFieldSql" />
        WHERE id = #{id}
    </update>
52
</mapper>