package com.huiju.estateagents.property.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huiju.estateagents.property.model.TpRoomNo;
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 jobob
 * @since 2019-04-09
 */
@Mapper
public interface TpRoomNoMapper extends BaseMapper<TpRoomNo> {


    /**
     * 根据 小区，期，栋，单元，楼层，房间  查询房间信息
     * @param communityId
     * @param phaseName
     * @param buildingName
     * @param unitName
     * @param levelName
     * @param roomNoName
     * @return
     */
    @ResultType(TpRoomNo.class)
    @Select("select * from tp_room_no " +
            "where community_id = #{communityId} " +
            "and phase_name = #{phaseName} " +
            "and building_name = #{buildingName} " +
            "and unit_name = #{unitName} " +
            "and level_name = #{levelName} " +
            "and name = #{roomNoName}")
    TpRoomNo selectCommunityIdAndAddressName(@Param("communityId") Integer communityId, @Param("phaseName") String phaseName, @Param("buildingName") String buildingName, @Param("unitName") String unitName, @Param("levelName") String levelName, @Param("roomNoName") String roomNoName);

    /**
     * 查询数据，分页
     * @param pageNum
     * @param pageSize
     * @return
     */
    @ResultType(TpRoomNo.class)
    @Select("select * from tp_room_no where community_id = #{communityId} limit #{pageNum},#{pageSize}")
    List<TpRoomNo> selectCommunityIdList(@Param("communityId") Integer communityId, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);

    /**
     * 查询数据，分页
     * @param communityId
     * @return
     */
    @ResultType(Long.class)
    @Select("select count(1) from tp_room_no where community_id = #{communityId}")
    Long selectCommunityIdCount(@Param("communityId") Integer communityId);

}
