<?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.ruoyi.model.mapper.AppletOrderItemDateMapper">

    <resultMap type="AppletOrderItemDate" id="AppletOrderItemDateResult">
        <result property="id" column="id"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="serviceDate" column="service_date"/>
        <result property="status" column="status"/>
        <result property="appletOrderId" column="applet_order_id"/>
        <result property="orderId" column="order_id"/>
        <result property="orderSn" column="order_sn"/>
        <result property="cityAddress" column="city_address"/>
        <result property="address" column="address"/>
        <result property="orderServiceId" column="order_service_id"/>
        <result property="userId" column="user_id"/>
    </resultMap>

    <sql id="selectAppletOrderItemDateVo">
        select id, create_time, create_by, update_time, update_by, service_date, status, applet_order_id, order_id, order_sn, city_address, address, order_service_id  from applet_order_item_date
    </sql>


    <select id="selectList" parameterType="AppletOrderItemDate" resultMap="AppletOrderItemDateResult">
        <include refid="selectAppletOrderItemDateVo"/>
        <where>
            <if test="serviceDate != null  and serviceDate != ''"> and service_date = #{serviceDate}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="appletOrderId != null "> and applet_order_id = #{appletOrderId}</if>
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="orderSn != null  and orderSn != ''"> and order_sn = #{orderSn}</if>
            <if test="cityAddress != null  and cityAddress != ''"> and city_address = #{cityAddress}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="orderServiceId != null "> and order_service_id = #{orderServiceId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>

    <select id="selectById" parameterType="Long" resultMap="AppletOrderItemDateResult">
        <include refid="selectAppletOrderItemDateVo"/>
        where id = #{id}
    </select>

    <insert id="insert" parameterType="AppletOrderItemDate" useGeneratedKeys="true" keyProperty="id">
        insert into applet_order_item_date
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="serviceDate != null">service_date,</if>
            <if test="status != null">status,</if>
            <if test="appletOrderId != null">applet_order_id,</if>
            <if test="orderId != null">order_id,</if>
            <if test="orderSn != null">order_sn,</if>
            <if test="cityAddress != null">city_address,</if>
            <if test="address != null">address,</if>
            <if test="orderServiceId != null">order_service_id,</if>
            <if test="userId != null">user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="serviceDate != null">#{serviceDate},</if>
            <if test="status != null">#{status},</if>
            <if test="appletOrderId != null">#{appletOrderId},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="orderSn != null">#{orderSn},</if>
            <if test="cityAddress != null">#{cityAddress},</if>
            <if test="address != null">#{address},</if>
            <if test="orderServiceId != null">#{orderServiceId},</if>
            <if test="userId != null">#{userId},</if>
        </trim>
    </insert>

    <update id="update" parameterType="AppletOrderItemDate">
        update applet_order_item_date
        <trim prefix="SET" suffixOverrides=",">
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="serviceDate != null">service_date = #{serviceDate},</if>
            <if test="status != null">status = #{status},</if>
            <if test="appletOrderId != null">applet_order_id = #{appletOrderId},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="orderSn != null">order_sn = #{orderSn},</if>
            <if test="cityAddress != null">city_address = #{cityAddress},</if>
            <if test="address != null">address = #{address},</if>
            <if test="orderServiceId != null">order_service_id = #{orderServiceId},</if>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteById" parameterType="Long">
        delete from applet_order_item_date where id = #{id}
    </delete>

    <delete id="deleteByIds" parameterType="String">
        delete from applet_order_item_date where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <insert id="insertOrUpdate" parameterType="AppletOrderItemDate" useGeneratedKeys="true" keyProperty="id">
        insert into applet_order_item_date
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            create_time, create_by, update_time, update_by, service_date, status, applet_order_id, order_id, order_sn, city_address, address,

        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id, jdbcType=BIGINT},
            </if>
            #{createTime, jdbcType=TIMESTAMP},#{createBy, jdbcType=INTEGER},#{updateTime, jdbcType=TIMESTAMP},#{updateBy, jdbcType=INTEGER},#{serviceDate, jdbcType=VARCHAR},#{status, jdbcType=INTEGER},#{appletOrderId, jdbcType=BIGINT},#{orderId, jdbcType=BIGINT},#{orderSn, jdbcType=VARCHAR},#{cityAddress, jdbcType=VARCHAR},#{address, jdbcType=VARCHAR},

        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=BIGINT},
            </if>
            create_time = #{createTime, jdbcType=TIMESTAMP},
            create_by = #{createBy, jdbcType=INTEGER},
            update_time = #{updateTime, jdbcType=TIMESTAMP},
            update_by = #{updateBy, jdbcType=INTEGER},
            service_date = #{serviceDate, jdbcType=VARCHAR},
            status = #{status, jdbcType=INTEGER},
            applet_order_id = #{appletOrderId, jdbcType=BIGINT},
            order_id = #{orderId, jdbcType=BIGINT},
            order_sn = #{orderSn, jdbcType=VARCHAR},
            city_address = #{cityAddress, jdbcType=VARCHAR},
            address = #{address, jdbcType=VARCHAR},
        </trim>
    </insert>
</mapper>
