<?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.estate.mapper.UserAccessPermissionsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="userAccessPermissionsResultMap" type="org.springblade.estate.entity.UserAccessPermissions">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="user_id" property="userId"/>
        <result column="user_name" property="userName"/>
        <result column="user_type" property="userType"/>
        <result column="user_face" property="userFace"/>
        <result column="device_serial_num" property="deviceSerialNum"/>
        <result column="device_name" property="deviceName"/>
        <result column="device_address" property="deviceAddress"/>
        <result column="agency_id" property="agencyId"/>
        <result column="residential_id" property="residentialId"/>
        <result column="building_id" property="buildingId"/>
        <result column="unit_id" property="unitId"/>
        <result column="floor_id" property="floorId"/>
        <result column="room_id" property="roomId"/>
        <result column="enterprise_id" property="enterpriseId"/>
        <result column="device_factory" property="deviceFactory"/>
        <result column="permissions" property="permissions"/>
    </resultMap>


    <select id="selectUserAccessPermissionsPage" resultMap="userAccessPermissionsResultMap">
        select * from estate_user_access_permissions where is_deleted = 0
    </select>

    <delete id="deleteUserAccessPermissions">
        delete from estate_user_access_permissions
		WHERE device_serial_num = #{authorizeRecords.deviceSerialNum} and user_id = #{authorizeRecords.userId} and tenant_id = #{authorizeRecords.tenantId}
    </delete>

</mapper>
