<?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.bofeng.dao.QzTaskDao">
    <select id="selectAll" resultType="com.bofeng.entity.QzTask">
    select * from qz_task where uptown_id=#{uptownId}
  </select>

    <select id="queryByTaskId" resultType="com.bofeng.entity.QzTask">
    select * from qz_task where task_id=#{taskId}
  </select>

    <select id="queryByHouseNumber" resultType="com.bofeng.entity.QzTask">
    select * from qz_task where task_status=#{status} and house_number like concat('%', #{houseNumber}, '%')
  </select>

    <update id="updateStatusById">
    update qz_task set task_status=#{status} where task_id=#{taskId}
  </update>

    <select id="queryQzTaskByStatus" resultType="com.bofeng.entity.QzTask">
        select * from qz_task where task_status=#{taskStatus}
    </select>

    <select id="queryQzTask" resultType="com.bofeng.entity.QzTask">
        select * from qz_task
        <where>
            <if test="taskStatus!=null and taskStatus!=''">
                task_status=#{taskStatus}
            </if>
            <if test="taskTitle!=null and taskTitle!=''">
                and task_title like concat('%',#{taskTitle},'%')
            </if>
            <if test="userId!=null and userId!=''">
                and user_id=#{userId}
            </if>
        </where>
        order by time_update desc
    </select>

    <select id="selectUserName" resultType="com.bofeng.entity.QzTask">
        select nick_name as userName from sys_user_open where user_id=#{userId} limit 1
    </select>

    <select id="selectHome" resultType="com.bofeng.entity.QzTask">
        select b.house_id ,b.doorplate as houseNumber,c.uptown_id
        FROM sys_user_role a
        INNER JOIN sys_uptown_house b on a.property_id=b.house_id
        INNER JOIN sys_uptown_unit c on c.unit_id=b.unit_id
        where a.user_id=#{userId} limit 1
    </select>

</mapper>