package com.huiju.estateagents.property.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huiju.estateagents.property.model.TpUnit;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 小区单元资料表 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2019-04-01
 */
@Mapper
public interface TpUnitMapper extends BaseMapper<TpUnit> {

    /**
     * 根据 小区id，期id，楼栋id 查询
     * @param orgId
     * @param phaseId
     * @param buildingId
     * @return
     */
    @ResultType(TpUnit.class)
    @Select("select * from tp_unit where org_id =#{orgId} and phase_id=#{phaseId} and building_id=#{buildingId}")
    List<TpUnit> selectByAddress(Integer orgId, Integer phaseId, Integer buildingId);

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

    @Update("update tp_unit 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);

    @Update("update tp_unit set building_name = #{buildingName} where org_id=#{orgId} and building_id=#{buildingId}")
    int updateBuildingName(@Param("orgId") Integer orgId, @Param("buildingId") Integer buildingId, @Param("buildingName") String buildingName);
}
