<?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.yudao.module.jx.mapper.DriveSchoolCourseOrderMapper">

    <resultMap type="cn.iocoder.yudao.module.jx.domain.DriveSchoolCourseOrder" id="DriveSchoolCourseOrderResult">
        <result property="id"    column="id"    />
        <result property="orderNo"    column="order_no"    />
        <result property="deptId"    column="dept_id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="userPhone"    column="user_phone"    />
        <result property="userNo"    column="user_no"    />
        <result property="userSex"    column="user_sex"    />
        <result property="courseId"    column="course_id"    />
        <result property="courseName"    column="course_name"    />
        <result property="reserveMoney"    column="reserve_money"    />
        <result property="restMoney"    column="rest_money"    />
        <result property="isSign"    column="is_sign"    />
        <result property="paymentStatus"    column="payment_status"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
    </resultMap>

    <sql id="selectDriveSchoolCourseOrderVo">
        select id, order_no, dept_id, user_id,rest_money,is_sign, user_name, user_phone, user_no, user_sex, course_id, course_name, reserve_money, payment_status, create_time, creator, update_time, updater from drive_school_course_order
    </sql>

    <select id="selectDriveSchoolCourseOrderList" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCourseOrder" resultMap="DriveSchoolCourseOrderResult">
        <include refid="selectDriveSchoolCourseOrderVo"/>
        <where>
            deleted = 0
            <if test="entity.orderNo != null  and entity.orderNo != ''"> and order_no = #{entity.orderNo}</if>
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId}</if>
            <if test="entity.userId != null "> and user_id = #{entity.userId}</if>
            <if test="entity.userName != null  and entity.userName != ''"> and user_name like concat('%', #{entity.userName}, '%')</if>
            <if test="entity.userPhone != null  and entity.userPhone != ''"> and user_phone = #{entity.userPhone}</if>
            <if test="entity.userNo != null  and entity.userNo != ''"> and user_no = #{entity.userNo}</if>
            <if test="entity.userSex != null  and entity.userSex != ''"> and user_sex = #{entity.userSex}</if>
            <if test="entity.courseId != null "> and course_id = #{entity.courseId}</if>
            <if test="entity.courseName != null  and entity.courseName != ''"> and course_name like concat('%', #{entity.courseName}, '%')</if>
            <if test="entity.reserveMoney != null "> and reserve_money = #{entity.reserveMoney}</if>
            <if test="entity.restMoney != null "> and rest_money = #{entity.restMoney}</if>
            <if test="entity.isSign != null "> and is_sign = #{entity.isSign}</if>
            <if test="entity.paymentStatus != null  and entity.paymentStatus != ''"> and payment_status = #{entity.paymentStatus}</if>
        </where>
    </select>

    <select id="selectDriveSchoolCourseOrderById" parameterType="Long" resultMap="DriveSchoolCourseOrderResult">
        <include refid="selectDriveSchoolCourseOrderVo"/>
        where id = #{id}
    </select>

    <insert id="insertDriveSchoolCourseOrder" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCourseOrder" useGeneratedKeys="true" keyProperty="id">
        insert into drive_school_course_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">order_no,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="userPhone != null">user_phone,</if>
            <if test="userNo != null">user_no,</if>
            <if test="userSex != null">user_sex,</if>
            <if test="courseId != null">course_id,</if>
            <if test="courseName != null">course_name,</if>
            <if test="reserveMoney != null">reserve_money,</if>
            <if test="isSign != null">is_sign,</if>
            <if test="restMoney != null">rest_money,</if>
            <if test="paymentStatus != null">payment_status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updater != null">updater,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">#{orderNo},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="userPhone != null">#{userPhone},</if>
            <if test="userNo != null">#{userNo},</if>
            <if test="userSex != null">#{userSex},</if>
            <if test="courseId != null">#{courseId},</if>
            <if test="courseName != null">#{courseName},</if>
            <if test="reserveMoney != null">#{reserveMoney},</if>
            <if test="isSign != null">#{isSign},</if>
            <if test="restMoney != null">#{restMoney},</if>
            <if test="paymentStatus != null">#{paymentStatus},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updater != null">#{updater},</if>
         </trim>
    </insert>

    <update id="updateDriveSchoolCourseOrder" parameterType="cn.iocoder.yudao.module.jx.domain.DriveSchoolCourseOrder">
        update drive_school_course_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderNo != null">order_no = #{orderNo},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="userPhone != null">user_phone = #{userPhone},</if>
            <if test="userNo != null">user_no = #{userNo},</if>
            <if test="userSex != null">user_sex = #{userSex},</if>
            <if test="courseId != null">course_id = #{courseId},</if>
            <if test="courseName != null">course_name = #{courseName},</if>
            <if test="reserveMoney != null">reserve_money = #{reserveMoney},</if>
            <if test="isSign != null">is_sign = #{isSign},</if>
            <if test="restMoney != null">rest_money = #{restMoney},</if>
            <if test="paymentStatus != null">payment_status = #{paymentStatus},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updater != null">updater = #{updater},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriveSchoolCourseOrderById" parameterType="Long">
        delete from drive_school_course_order where id = #{id}
    </delete>

    <delete id="deleteDriveSchoolCourseOrderByIds" parameterType="String">
        delete from drive_school_course_order where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
