<?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.izouma.awesomeadmin.dao.SeeOrderMapper">
    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.SeeOrder">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
        <result column="user_id" property="userId" jdbcType="INTEGER"/>
        <result column="house_id" property="houseId" jdbcType="INTEGER"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="housekeeper" property="housekeeper" jdbcType="INTEGER"/>
        <result column="contact" property="contact" jdbcType="VARCHAR"/>
        <result column="telephone" property="telephone" jdbcType="VARCHAR"/>
        <result column="leave_message" property="leaveMessage" jdbcType="VARCHAR"/>
        <result column="order_time" property="orderTime" jdbcType="TIMESTAMP"/>
        <result column="time_interval" property="timeInterval" jdbcType="VARCHAR"/>
        <result column="order_status" property="orderStatus" jdbcType="INTEGER"/>
        <result column="see_time" property="seeTime" jdbcType="TIMESTAMP"/>
        <result column="show_flag" property="showFlag" jdbcType="CHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
            id,            del_flag,            user_id,            house_id,            create_time,            update_time,            housekeeper,            contact,            telephone,            leave_message,            order_time,            time_interval,            order_status,            see_time,            show_flag        </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from see_order
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from see_order
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.SeeOrder" useGeneratedKeys="true"
            keyProperty="id">
        insert into see_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!= null">
                id,
            </if>
            <if test="delFlag!= null">
                del_flag,
            </if>
            <if test="userId!= null">
                user_id,
            </if>
            <if test="houseId!= null">
                house_id,
            </if>
            <if test="createTime!= null">
                create_time,
            </if>
            <if test="updateTime!= null">
                update_time,
            </if>
            <if test="housekeeper!= null">
                housekeeper,
            </if>
            <if test="contact!= null">
                contact,
            </if>
            <if test="telephone!= null">
                telephone,
            </if>
            <if test="leaveMessage!= null">
                leave_message,
            </if>
            <if test="orderTime!= null">
                order_time,
            </if>
            <if test="timeInterval!= null">
                time_interval,
            </if>
            <if test="orderStatus!= null">
                order_status,
            </if>
            <if test="seeTime!= null">
                see_time,
            </if>
            <if test="showFlag!= null">
                show_flag,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
            <if test="userId != null">
                #{userId,jdbcType=INTEGER},
            </if>
            <if test="houseId != null">
                #{houseId,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="housekeeper != null">
                #{housekeeper,jdbcType=INTEGER},
            </if>
            <if test="contact != null">
                #{contact,jdbcType=VARCHAR},
            </if>
            <if test="telephone != null">
                #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="leaveMessage != null">
                #{leaveMessage,jdbcType=VARCHAR},
            </if>
            <if test="orderTime != null">
                #{orderTime,jdbcType=TIMESTAMP},
            </if>
            <if test="timeInterval != null">
                #{timeInterval,jdbcType=VARCHAR},
            </if>
            <if test="orderStatus != null">
                #{orderStatus,jdbcType=INTEGER},
            </if>
            <if test="seeTime != null">
                #{seeTime,jdbcType=TIMESTAMP},
            </if>
            <if test="showFlag != null">
                #{showFlag,jdbcType=CHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.SeeOrder">
        update see_order
        <set>
            <if test="id != null">
                id= #{id,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag= #{delFlag,jdbcType=CHAR},
            </if>
            <if test="userId != null">
                user_id= #{userId,jdbcType=INTEGER},
            </if>
            <if test="houseId != null">
                house_id= #{houseId,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                create_time= #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time= #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="housekeeper != null">
                housekeeper= #{housekeeper,jdbcType=INTEGER},
            </if>
            <if test="contact != null">
                contact= #{contact,jdbcType=VARCHAR},
            </if>
            <if test="telephone != null">
                telephone= #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="leaveMessage != null">
                leave_message= #{leaveMessage,jdbcType=VARCHAR},
            </if>
            <if test="orderTime != null">
                order_time= #{orderTime,jdbcType=TIMESTAMP},
            </if>
            <if test="timeInterval != null">
                time_interval= #{timeInterval,jdbcType=VARCHAR},
            </if>
            <if test="orderStatus != null">
                order_status= #{orderStatus,jdbcType=INTEGER},
            </if>
            <if test="seeTime != null">
                see_time= #{seeTime,jdbcType=TIMESTAMP},
            </if>
            <if test="showFlag != null">
                show_flag= #{showFlag,jdbcType=CHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <select id="querySeeOrderByPage" parameterType="java.util.Map" resultMap="PageResultMap">
        select
        <include refid="Base_Column_List"/>
        from see_order
        <where>
            and del_flag = 'N'
            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
                and del_flag = #{record.delFlag}
            </if>
            <if test="record.userId != null and !&quot;&quot;.equals(record.userId)">
                and user_id = #{record.userId}
            </if>
            <if test="record.houseId != null and !&quot;&quot;.equals(record.houseId)">
                and house_id = #{record.houseId}
            </if>
            <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
                and create_time = #{record.createTime}
            </if>
            <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
                and update_time = #{record.updateTime}
            </if>
            <if test="record.housekeeper != null and !&quot;&quot;.equals(record.housekeeper)">
                and housekeeper = #{record.housekeeper}
            </if>
            <if test="record.contact != null and !&quot;&quot;.equals(record.contact)">
                and contact = #{record.contact}
            </if>
            <if test="record.telephone != null and !&quot;&quot;.equals(record.telephone)">
                and telephone = #{record.telephone}
            </if>
            <if test="record.leaveMessage != null and !&quot;&quot;.equals(record.leaveMessage)">
                and leave_message = #{record.leaveMessage}
            </if>
            <if test="record.orderTime != null and !&quot;&quot;.equals(record.orderTime)">
                and order_time = #{record.orderTime}
            </if>
            <if test="record.timeInterval != null and !&quot;&quot;.equals(record.timeInterval)">
                and time_interval = #{record.timeInterval}
            </if>
            <if test="record.orderStatus != null and !&quot;&quot;.equals(record.orderStatus)">
                and order_status = #{record.orderStatus}
            </if>
            <if test="record.seeTime != null and !&quot;&quot;.equals(record.seeTime)">
                and see_time = #{record.seeTime}
            </if>
            <if test="record.showFlag != null and !&quot;&quot;.equals(record.showFlag)">
                and show_flag = #{record.showFlag}
            </if>
            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                <trim prefix="and (" suffix=")" prefixOverrides="OR">
                    OR user_id LIKE concat('%',#{record.searchKey},'%')
                    OR house_id LIKE concat('%',#{record.searchKey},'%')
                    OR housekeeper LIKE concat('%',#{record.searchKey},'%')
                    OR contact LIKE concat('%',#{record.searchKey},'%')
                    OR telephone LIKE concat('%',#{record.searchKey},'%')
                    OR leave_message LIKE concat('%',#{record.searchKey},'%')
                </trim>
            </if>
        </where>
        order by id desc
    </select>
    <select id="queryAllSeeOrder" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SeeOrder">
        select
        <include refid="Base_Column_List"/>
        from see_order
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="userId != null and !&quot;&quot;.equals(userId)">
                and user_id = #{userId}
            </if>
            <if test="houseId != null and !&quot;&quot;.equals(houseId)">
                and house_id = #{houseId}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
            <if test="housekeeper != null and !&quot;&quot;.equals(housekeeper)">
                and housekeeper = #{housekeeper}
            </if>
            <if test="contact != null and !&quot;&quot;.equals(contact)">
                and contact = #{contact}
            </if>
            <if test="telephone != null and !&quot;&quot;.equals(telephone)">
                and telephone = #{telephone}
            </if>
            <if test="leaveMessage != null and !&quot;&quot;.equals(leaveMessage)">
                and leave_message = #{leaveMessage}
            </if>
            <if test="orderTime != null and !&quot;&quot;.equals(orderTime)">
                and order_time = #{orderTime}
            </if>
            <if test="timeInterval != null and !&quot;&quot;.equals(timeInterval)">
                and time_interval = #{timeInterval}
            </if>
            <if test="orderStatus != null and !&quot;&quot;.equals(orderStatus)">
                and order_status = #{orderStatus}
            </if>
            <if test="seeTime != null and !&quot;&quot;.equals(seeTime)">
                and see_time = #{seeTime}
            </if>
            <if test="showFlag != null and !&quot;&quot;.equals(showFlag)">
                and show_flag = #{showFlag}
            </if>
        </where>
        order by id desc
    </select>
    <select id="querySeeOrder" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SeeOrder">
        select
        <include refid="Base_Column_List"/>
        from see_order
        <where>
            and del_flag = 'N'
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                and del_flag = #{delFlag}
            </if>
            <if test="userId != null and !&quot;&quot;.equals(userId)">
                and user_id = #{userId}
            </if>
            <if test="houseId != null and !&quot;&quot;.equals(houseId)">
                and house_id = #{houseId}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
            <if test="housekeeper != null and !&quot;&quot;.equals(housekeeper)">
                and housekeeper = #{housekeeper}
            </if>
            <if test="contact != null and !&quot;&quot;.equals(contact)">
                and contact = #{contact}
            </if>
            <if test="telephone != null and !&quot;&quot;.equals(telephone)">
                and telephone = #{telephone}
            </if>
            <if test="leaveMessage != null and !&quot;&quot;.equals(leaveMessage)">
                and leave_message = #{leaveMessage}
            </if>
            <if test="orderTime != null and !&quot;&quot;.equals(orderTime)">
                and order_time = #{orderTime}
            </if>
            <if test="timeInterval != null and !&quot;&quot;.equals(timeInterval)">
                and time_interval = #{timeInterval}
            </if>
            <if test="orderStatus != null and !&quot;&quot;.equals(orderStatus)">
                and order_status = #{orderStatus}
            </if>
            <if test="seeTime != null and !&quot;&quot;.equals(seeTime)">
                and see_time = #{seeTime}
            </if>
            <if test="showFlag != null and !&quot;&quot;.equals(showFlag)">
                and show_flag = #{showFlag}
            </if>

        </where>
        LIMIT 1
    </select>
    <update id="delete">
        UPDATE see_order SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>
    <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.SeeOrder">
        select
        <include refid="Base_Column_List"/>
        from see_order
        <where>
            and del_flag = 'N'
        </where>
        order by id desc
    </select>

    <resultMap id="PageResultMap" type="com.izouma.awesomeadmin.model.SeeOrder" extends="BaseResultMap">
        <association property="houseInfo" javaType="com.izouma.awesomeadmin.model.HouseInfo"
                     select="com.izouma.awesomeadmin.dao.HouseInfoMapper.queryHouseInfo" column="{id = house_id}">
        </association>
        <association property="keeper" javaType="com.izouma.awesomeadmin.model.HouseKeeper"
                     select="com.izouma.awesomeadmin.dao.HouseKeeperMapper.queryHouseKeeper"
                     column="{id = housekeeper}">
        </association>
        <association property="userInfo" javaType="com.izouma.awesomeadmin.model.UserInfo"
                     select="com.izouma.awesomeadmin.dao.UserInfoMapper.querySingleUserInfo" column="{id = user_id}">
        </association>
    </resultMap>
</mapper>

