package com.community.huiju.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.community.huiju.model.TaUserVerify;
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-05-16
 */
public interface TaUserVerifyMapper extends BaseMapper<TaUserVerify> {

    /**
     * 根据 小区id 、 期、栋、单元、楼层、户号 进行条件查询出 已审核通过的并且是业主
     * @param communityId
     * @param phaseId
     * @param buildingId
     * @param unitId
     * @param levelId
     * @param roomNoId
     * @return
     */
    @ResultType(TaUserVerify.class)
    @Select("select  *  from ta_user_verify " +
            "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 verify_status = 1 " +
            "and role_id = 1")
    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 、 期、栋、单元、楼层、户号 进行条件查询出 已审核通过的身份
     * @param userId
     * @param communityId
     * @param phaseId
     * @param buildingId
     * @param unitId
     * @param levelId
     * @param roomNoId
     * @return
     */
    @ResultType(TaUserVerify.class)
    @Select("select  *  from ta_user_verify " +
            "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 user_id = #{userId} " +
            "and verify_status = 1 ")
    List<TaUserVerify> selectAddress(@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);

    /**
     * 根据 用户id， 审核id 查询
     * @param userId
     * @param userVerifyId
     * @return
     */
    @ResultType(TaUserVerify.class)
    @Select("select  *  from ta_user_verify " +
            "where user_id = #{userId} " +
            "and id = #{userVerifyId} ")
    TaUserVerify selectByUserIdAndUserVerifyId(Integer userId, Integer userVerifyId);

    /**
     * 根据 用户id、小区id 、 期、栋、单元、楼层、户号、审核状态  进行条件查询
     * @param communityId
     * @param phaseId
     * @param buildingId
     * @param unitId
     * @param levelId
     * @param roomNoId
     * @param verifyStatus
     * @return
     */
    List<TaUserVerify> selectCommunityAndAddressAndVerifyStatus(@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);
}
