package com.community.huiju.dao;

import com.community.huiju.model.TpBuildingOwnerInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TpBuildingOwnerInfoMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(TpBuildingOwnerInfo record);

    int insertSelective(TpBuildingOwnerInfo record);

    TpBuildingOwnerInfo selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(TpBuildingOwnerInfo record);

    int updateByPrimaryKey(TpBuildingOwnerInfo record);

    @ResultMap("BaseResultMap")
    @Select("select * from tp_building_owner_info where community_id=#{communityId} and owner_tel=#{ownerTel}")
    List<TpBuildingOwnerInfo> getByCommunityIdAndOwnerTel(@Param("communityId") Integer communityId, @Param("ownerTel") String ownerTel);

    TpBuildingOwnerInfo updatOwnerTel(Integer communityId,String OwnerTel);

    //根据手机号查询当前信息
    TpBuildingOwnerInfo selectOwnerTel(@Param("ownerTel")String ownerTel);

    /*
     * 根据 小区，期，楼栋，单元，楼层，户号
     * @param communityId
     * @param phase
     * @param building
     * @param unit
     * @param level
     * @param roomNo
     * @return
     */
    @ResultMap("BaseResultMap")
    @Select("select * from tp_building_owner_info where community_id=#{communityId}" +
            " and phase_id=#{phaseId} and building_id=#{buildingId} and unit_id=#{unitId}" +
            " and level_id=#{levelId} and room_no_id=#{roomNoId}")
    TpBuildingOwnerInfo selectCommunityIdAndAddress(@Param("communityId") Integer communityId, @Param("phaseId") Integer phaseId,
                                                    @Param("buildingId") Integer building, @Param("unitId") Integer unitId,
                                                    @Param("levelId") Integer level, @Param("roomNoId") Integer roomNoId);

    /*
     * 根据 小区，期，楼栋，单元，楼层，户号, 手机号
     * @param communityId
     * @param phase
     * @param building
     * @param unit
     * @param level
     * @param roomNo
     * @return
     */
    @ResultMap("BaseResultMap")
    @Select("select * from tp_building_owner_info where community_id=#{communityId}" +
            " and phase_id=#{phaseId} and building_id=#{buildingId} and unit_id=#{unitId}" +
            " and level_id=#{levelId} and room_no_id=#{roomNoId} and owner_tel=#{phone}")
    TpBuildingOwnerInfo selectCommunityAndAddressAndPhone(@Param("communityId") Integer communityId, @Param("phaseId") Integer phaseId,
                                                          @Param("buildingId") Integer buildingId, @Param("unitId") Integer unitId,
                                                          @Param("levelId") Integer levelId, @Param("roomNoId") Integer roomNoId,
                                                          @Param("phone") String phone);

    /**
     * 根据 审核id 查询楼栋资料信息
     * @param userVerifyId
     * @return
     */
    @ResultMap("BaseResultMap")
    @Select("select * from tp_building_owner_info where ta_user_verify_id = #{userVerifyId}")
    TpBuildingOwnerInfo selectByUserVerifyId(@Param("userVerifyId") Integer userVerifyId);
}