package com.huiju.estateagents.property.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huiju.estateagents.property.model.TpBuildingOwnerInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 楼栋业主资料信息表 Mapper 接口
 * </p>
 *
 * @author weiximei
 * @since 2018-12-18
 */
@Mapper
public interface TpBuildingOwnerInfoMapper extends BaseMapper<TpBuildingOwnerInfo> {
    /**
     * 获取已认证通过的
     * @param
     * @return
     */
    IPage<TpBuildingOwnerInfo> selectUserApprove(Page page, @Param("ownerName") String r, @Param("ownerTel") String ownerTel, @Param("VerifyStatus") String VerifyStatus, @Param("CommunityId") Integer CommunityId);

    int batchInsert(List<TpBuildingOwnerInfo> list);

    int batchUpdate(List<TpBuildingOwnerInfo> list);

	List<TpBuildingOwnerInfo> selectListByParams(Page page, @Param("tpBuildingOwnerInfo") TpBuildingOwnerInfo tpBuildingOwnerInfo);

    /**
     * 更具 小区、期、楼栋、单元、楼层、户号、手机号 查询
     * @param communityId
     * @param phaseId
     * @param buildingId
     * @param unitId
     * @param levelId
     * @param roomNoId
     * @param ownerTel
     * @return
     */
	@ResultType(TpBuildingOwnerInfo.class)
	@Select("select * FROM tp_building_owner_info tpio " +
            "WHERE tpio.community_id = #{communityId} " +
            "and tpio.phase_id = #{phaseId} " +
            "and tpio.building_id = #{buildingId} " +
            "and tpio.unit_id = #{unitId} " +
            "and tpio.level_id = #{levelId} " +
            "AND tpio.room_no_id = #{roomNoId} " +
            "AND tpio.owner_tel = #{ownerTel}")
    TpBuildingOwnerInfo selectCommunityIdAndAddress(@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("ownerTel") String ownerTel);


    /**
     * 更具 小区、期、楼栋、单元、楼层、户号、手机号 查询
     * @param communityId
     * @param phaseName
     * @param buildingName
     * @param unitName
     * @param levelName
     * @param roomNoName
     * @param ownerTel
     * @return
     */
    @ResultType(TpBuildingOwnerInfo.class)
    @Select("select * FROM tp_building_owner_info tpio " +
            "WHERE tpio.community_id = #{communityId} " +
            "and tpio.phase_name = #{phaseName} " +
            "and tpio.building_name = #{buildingName} " +
            "and tpio.unit_name = #{unitName} " +
            "and tpio.level_name = #{levelName} " +
            "AND tpio.room_no_name = #{roomNoName} " +
            "AND tpio.owner_tel = #{ownerTel}")
    TpBuildingOwnerInfo selectCommunityIdAndAddressName(@Param("communityId") Integer communityId, @Param("phaseName") String phaseName, @Param("buildingName") Integer buildingName, @Param("unitName") Integer unitName, @Param("levelName") Integer levelName, @Param("roomNoName") Integer roomNoName, @Param("ownerTel") String ownerTel);


}
