package com.sky.ioc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.ioc.entity.domain.space.BuildingSpace;
import com.sky.ioc.entity.params.IocParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface BuildingSpaceMapper extends BaseMapper<BuildingSpace> {

    @Select("<script>" +
            "SELECT used_station as usedStation,lead_area as leadArea,meeting_area as meetingArea," +
            "work_area as workArea,print_area as printArea,other_area as otherArea,station_count as stationCount," +
            "tier as tier FROM building_space where 1=1 " +
            "<if test='iocParam!=null and iocParam.floorId != null  '>" +
            " and tier=#{iocParam.floorId} " +
            "</if>"+
            " limit 1 </script>")
    BuildingSpace getByTier(@Param("iocParam")IocParam iocParam);

    @Select("<script>" +
            "SELECT used_station as usedStation,lead_area as leadArea,meeting_area as meetingArea," +
            "work_area as workArea,print_area as printArea,other_area as otherArea,station_count as stationCount," +
            "tier as tier FROM building_space where 1=1 " +
            "<if test='iocParam!=null and iocParam.floorId != null  '>" +
            " and tier=#{iocParam.floorId} " +
            "</if>"+
            " order by tier </script>")
    List<BuildingSpace> getListByTier(@Param("iocParam")IocParam iocParam);

    @Select("<script>" +
            "SELECT sum(meeting_area) as meetingArea,sum(work_area) as workArea,sum(other_area) as otherArea " +
            " FROM building_space where 1=1 " +
            " limit 1 </script>")
    BuildingSpace getSumByTier();
}
