<?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.willalp.flow.mapper.ReserveConsumingRecordMapper">

    <resultMap type="com.willalp.flow.domain.ReserveConsumingRecord" id="ReserveConsumingRecordResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="applyDepartment" column="apply_department"/>
        <result property="reserveType" column="reserve_type"/>
        <result property="reserveName" column="reserve_name"/>
        <result property="reserveModelNo" column="reserve_model_no"/>
        <result property="applyAmount" column="apply_amount"/>
        <result property="applyUserId" column="apply_user_id"/>
        <result property="applyUserName" column="apply_user_name"/>
        <result property="applyReason" column="apply_reason"/>
        <result property="applyDate" column="apply_date"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectReserveConsumingRecordVo">
        select id,
               title,
               apply_department,
               reserve_type,
               reserve_name,
               reserve_model_no,
               apply_amount,
               apply_user_id,
               apply_user_name,
               apply_reason,
               apply_date,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from reserve_consuming_record
    </sql>

    <select id="selectReserveConsumingRecordList" parameterType="ReserveConsumingRecord"
            resultMap="ReserveConsumingRecordResult">
        <include refid="selectReserveConsumingRecordVo"/>
        <where>
            is_delete = 0
            <if test="title != null  and title != ''">
                and title = #{title}
            </if>
            <if test="applyDepartment != null  and applyDepartment != ''">
                and apply_department = #{applyDepartment}
            </if>
            <if test="reserveType != null  and reserveType != ''">
                and reserve_type = #{reserveType}
            </if>
            <if test="reserveName != null  and reserveName != ''">
                and reserve_name like concat('%', #{reserveName}, '%')
            </if>
            <if test="reserveModelNo != null  and reserveModelNo != ''">
                and reserve_model_no = #{reserveModelNo}
            </if>
            <if test="applyAmount != null ">
                and apply_amount = #{applyAmount}
            </if>
            <if test="applyUserId != null  and applyUserId != ''">
                and apply_user_id = #{applyUserId}
            </if>
            <if test="applyUserName != null  and applyUserName != ''">
                and apply_user_name like concat('%', #{applyUserName}, '%')
            </if>
            <if test="applyReason != null  and applyReason != ''">
                and apply_reason = #{applyReason}
            </if>
            <if test="applyDate != null ">
                and apply_date = #{applyDate}
            </if>
        </where>
    </select>
</mapper>
