package com.kym.mapper.admin;

import com.kym.entity.admin.EquipmentRelation;
import com.kym.mapper.mybatisplus.MyBaseMapper;
import org.apache.ibatis.annotations.Select;

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

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author skyline
 * @since 2023-08-07
 */
public interface EquipmentRelationMapper extends MyBaseMapper<EquipmentRelation> {
    @Select("SELECT t.station_id as stationId, t.connector_id as connectorId " +
            "FROM ( " +
            "    SELECT station_id, connector_id, " +
            "           ROW_NUMBER() OVER (PARTITION BY station_id ORDER BY id DESC) AS row_num " +
            "    FROM t_equipment_relation " +
            ") AS t " +
            "WHERE t.row_num = 1")
    List<Map<String, String>> selectLatestConnectorByStation();

}
