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.TpBuilding;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TpBuildingMapper extends BaseMapper<TpBuilding> {

    /**
     * 楼栋资料库列表
     * @param page
     * @param tpBuilding
     * @return
     */
    IPage<TpBuilding> buildinglist(Page<TpBuilding> page, @Param("tpBuilding") TpBuilding tpBuilding);

    /**
     * 根据小区id，期id
     * @param orgId
     * @param phaseId
     * @return
     */
    @ResultType(TpBuilding.class)
    @Select("select * from tp_building where org_id=#{orgId} and phase_id=#{phaseId}")
    List<TpBuilding> selectByAddress(@Param("orgId") Integer orgId, @Param("phaseId") Integer phaseId);

    @Update("update tp_building set `name` = #{name} where id = #{id}")
    int updateName(@Param("orgId") Integer orgId, @Param("id") Integer id, @Param("name") String name);

    @Update("update tp_building set phase_name = #{phaseName} where org_id=#{orgId} and phase_id=#{phaseId}")
    int updatePhaseName(@Param("orgId") Integer orgId,  @Param("phaseId") Integer phaseId, @Param("phaseName") String phaseName);

}