<?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="org.springblade.community.houseuser.mapper.HouseuserMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="houseuserResultMap" type="org.springblade.community.houseuser.entity.Houseuser">
        <result column="id" property="id"/>
        <result column="status" property="status"/>
        <result column="name" property="name"/>
        <result column="room_id" property="roomId"/>
        <result column="room_name" property="roomName"/>
        <result column="agency_id" property="agencyId"/>
        <result column="agency_name" property="agencyName"/>
        <result column="org_position" property="orgPosition"/>
        <result column="estate_position" property="estatePosition"/>
        <result column="check_state" property="checkState"/>
        <result column="check_opinion" property="checkOpinion"/>
        <result column="type" property="type"/>
        <result column="person_type" property="personType"/>
        <result column="tel" property="tel"/>
        <result column="nationality" property="nationality"/>
        <result column="id_card" property="idCard"/>
        <result column="birth_place" property="birthPlace"/>
        <result column="passport_img_uri" property="passportImgUri"/>
        <result column="entry_img_uri" property="entryImgUri"/>
        <result column="sex" property="sex"/>
        <result column="remark" property="remark"/>
        <result column="image_uri" property="imageUri"/>
        <result column="face_code" property="faceCode"/>
        <result column="create_face_image_type" property="createFaceImageType"/>
        <result column="build_id" property="buildId"/>
        <result column="build_name" property="buildName"/>
        <result column="unit_id" property="unitId"/>
        <result column="unit_name" property="unitName"/>
        <result column="floor_id" property="floorId"/>
        <result column="floor_name" property="floorName"/>
        <result column="residential_id" property="residentialId"/>
        <result column="residential_name" property="residentialName"/>
        <result column="region_province" property="regionProvince"/>
        <result column="region_city" property="regionCity"/>
        <result column="region_area" property="regionArea"/>
        <result column="root_org_id" property="rootOrgId"/>
        <result column="create_type" property="createType"/>
        <result column="create_id" property="createId"/>
        <result column="create_date" property="createDate"/>
        <result column="face_begin_date" property="faceBeginDate"/>
        <result column="face_end_date" property="faceEndDate"/>
        <result column="face_enable" property="faceEnable"/>
        <result column="is_member" property="isMember"/>
        <result column="building_id" property="buildingId"/>
        <result column="car_number" property="carNumber"/>
        <result column="nation" property="nation"/>
        <result column="political" property="political"/>
        <result column="education" property="education"/>
        <result column="old_id" property="oldId"/>
        <result column="inhabitant_id" property="inhabitantId"/>
        <result column="user_room_inhabitant_id" property="userRoomInhabitantId"/>
        <result column="encrypt" property="encrypt"/>
    </resultMap>

    <resultMap id="houseuserVOResultMap" type="org.springblade.community.houseuser.vo.HouseuserVO" extends="houseuserResultMap">
        <result column="elderly_type" property="elderlyType"/>
    </resultMap>

    <select id="selectHouseuserPage" resultMap="houseuserVOResultMap">
        SELECT houseuser.*, car.number as car_number FROM estate_houseuser houseuser
        left join yc_car car on houseuser.id = car.person_id
        WHERE houseuser.is_deleted = 0
        <if test="houseuser != null">
            <if test="houseuser.name!=null and houseuser.name.trim()!='' ">
                AND houseuser.name like '%${houseuser.name}%'
            </if>
            <if test="houseuser.idCard!=null and houseuser.idCard.trim()!='' ">
                AND houseuser.id_card like '%${houseuser.idCard}%'
            </if>
            <if test="houseuser.carNumber!=null and houseuser.carNumber.trim()!='' ">
                AND car.number like '%${houseuser.carNumber}%'
            </if>
        </if>
    </select>

    <delete id="deletePhysical">
        DELETE FROM estate_houseuser WHERE id = #{id}
    </delete>

</mapper>
