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.TaUserVerify;
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>
 * app端用户审核表，存放用户的角色还有房产信息 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2019-04-03
 */
@Mapper
public interface TaUserVerifyMapper extends BaseMapper<TaUserVerify> {

    /**
     * 根据 手机号 、用户名、身份证
     * @param page
     * @param phone
     * @param userName
     * @param idCard
     * @return
     */
    IPage<TaUserVerify> selectAllByPhoneAndUserNameAndIdCard(Page page, @Param("phone") String phone, @Param("userName") String userName, @Param("idCard") String idCard, @Param("communityId") Integer communityId);

    /**
     * 根据 小区id 、 小区、期、栋、单元、楼层、户号 进行条件查询出 已审核通过的并且是业主
     * @param communityId
     * @param phaseId
     * @param buildingId
     * @param unitId
     * @param levelId
     * @param roomNoId
     * @return
     */
    TaUserVerify selectCommunityAndAddress(@Param("communityId") Integer communityId, @Param("phaseId") Integer phaseId, @Param("buildingId") Integer buildingId, @Param("unitId") Integer unitId, @Param("levelId") Integer levelId, @Param("roomNoId") Integer roomNoId);

    /**
     * 根据 用户id、小区id 、 小区、期、栋、单元、楼层、户号、角色id 进行条件查询出
     * @param communityId
     * @param phaseId
     * @param buildingId
     * @param unitId
     * @param levelId
     * @param roomNoId
     * @return
     */
    TaUserVerify selectCommunityAndAddressAndRoleId(@Param("userId") Integer userId, @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("roleId") Integer roleId);


    /**
     * 根据 小区id 、 小区、期、栋、单元、楼层、户号 进行条件查询出 已审核通过的并且是业主
     * @param communityId
     * @param phaseName
     * @param buildingName
     * @param unitName
     * @param levelName
     * @param roomNoName
     * @return
     */
    @ResultType(TaUserVerify.class)
    @Select("select  *  from ta_user_verify " +
            "where community_id = #{communityId} " +
            "and phase_name = #{phaseName} " +
            "and building_name = #{buildingName} " +
            "and unit_name = #{unitName} " +
            "and level_name = #{levelName} " +
            "and room_no_name = #{roomNoName} " +
            "and verify_status = 1 " +
            "and role_id = 1")
    TaUserVerify selectCommunityAndAddressName(@Param("communityId") Integer communityId, @Param("phaseName") String phaseName, @Param("buildingName") String buildingName, @Param("unitName") String unitName, @Param("levelName") String levelName, @Param("roomNoName") String roomNoName);


    /**
     * 查询用户审核数据！   小区id，用户id，期id，栋id，单元id，楼层id，房间id，审核状态
     * @param userId
     * @param communityId
     * @param phaseId
     * @param buildingId
     * @param unitId
     * @param levelId
     * @param roomNoId
     * @param verifyStatus
     * @return
     */
    List<TaUserVerify> selectUserVerifyCommunityAndAddress(@Param("userId") Integer userId,
                                                           @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("verifyStatus") Integer verifyStatus);
}
