package com.huiju.estateagents.property.dao;

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

import java.util.List;

/**
 * <p>
 * 小区楼层资料表 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2019-04-01
 */
@Mapper
public interface TpLevelMapper extends BaseMapper<TpLevel> {
    /**
     * 根据 小区id，期id，楼栋id，单元id 进行查询
     * @param orgId
     * @param phaseId
     * @param buildingId
     * @param unitId
     * @return
     */
    @ResultType(TpLevel.class)
    @Select("select * from tp_level where org_id=#{orgId} and phase_id=#{phaseId} and building_id=#{buildingId} and unit_id=#{unitId}")
    List<TpLevel> selectByAddress(Integer orgId, Integer phaseId, Integer buildingId, Integer unitId);

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

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

    @Update("update tp_level set unit_name = #{unitName} where org_id=#{orgId} and unit_id=#{unitId}")
    int updateUnitName(@Param("orgId") Integer orgId, @Param("unitId") Integer unitId, @Param("unitName") String unitName);
}
