package com.css.simulation.resource.scheduler.infra.db.mysql.mapper;

import com.css.simulation.resource.scheduler.infra.entity.OgtEntity;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface SensorOgtMapper {

    @Results(id = "Ogt", value = {
            @Result(column = "sensor_name", property = "sensor_name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "fov_h_left", property = "sensor_fovHLeft", jdbcType = JdbcType.DECIMAL),
            @Result(column = "fov_h_right", property = "sensor_fovHRight", jdbcType = JdbcType.DECIMAL),
            @Result(column = "fov_v_top", property = "sensor_fovVTop", jdbcType = JdbcType.DECIMAL),
            @Result(column = "fov_v_bottom", property = "sensor_fovVBottom", jdbcType = JdbcType.DECIMAL),
            @Result(column = "near_distance", property = "sensor_near", jdbcType = JdbcType.DECIMAL),
            @Result(column = "far_distance", property = "sensor_far", jdbcType = JdbcType.DECIMAL),
            @Result(column = "sensor_x", property = "sensor_x", jdbcType = JdbcType.DECIMAL),
            @Result(column = "sensor_y", property = "sensor_y", jdbcType = JdbcType.DECIMAL),
            @Result(column = "sensor_z", property = "sensor_z", jdbcType = JdbcType.DECIMAL),
            @Result(column = "sensor_h", property = "sensor_h", jdbcType = JdbcType.DECIMAL),
            @Result(column = "sensor_p", property = "sensor_p", jdbcType = JdbcType.DECIMAL),
            @Result(column = "sensor_r", property = "sensor_r", jdbcType = JdbcType.DECIMAL),
            @Result(column = "target_filter", property = "sensor_filter", jdbcType = JdbcType.VARCHAR),
            @Result(column = "range_display", property = "sensor_display", jdbcType = JdbcType.BOOLEAN),
            @Result(column = "max_objects", property = "sensor_maxObjects", jdbcType = JdbcType.INTEGER),
            @Result(column = "sensor_port", property = "sensor_port", jdbcType = JdbcType.INTEGER),
    })
    @Select("select mso.sensor_name,\n" +
            "       mso.fov_h_left,\n" +
            "       mso.fov_h_right,\n" +
            "       mso.fov_v_top,\n" +
            "       mso.fov_v_bottom,\n" +
            "       mso.near_distance,\n" +
            "       mso.far_distance,\n" +
            "       mso.target_filter,\n" +
            "       mso.range_display,\n" +
            "       mso.max_objects,\n" +
            "       rcs.sensor_x,\n" +
            "       rcs.sensor_y,\n" +
            "       rcs.sensor_z,\n" +
            "       rcs.sensor_h,\n" +
            "       rcs.sensor_p,\n" +
            "       rcs.sensor_r,\n" +
            "       rcs.sensor_port\n" +
            "from model_sensor_ogt mso left join relation_config_sensor rcs on mso.id = rcs.sensor_id\n" +
            "where mso.is_deleted = '0' and rcs.is_deleted = '0'\n" +
            "   and rcs.config_id = #{vehicleConfigId}")
    List<OgtEntity> selectOgtByVehicleId(@Param("vehicleConfigId") String vehicleConfigId);
}
