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

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

import java.util.List;

@Mapper
public interface SensorCameraMapper {

    @Results(id = "camera", value = {
            @Result(column = "sensor_name", property = "sensor_name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "fov_h", property = "sensor_fovH", jdbcType = JdbcType.DECIMAL),
            @Result(column = "fov_v", property = "sensor_fovV", 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 = "resolution", property = "sensor_resolution", jdbcType = JdbcType.VARCHAR),
            @Result(column = "frame_rate", property = "sensor_frameRate", 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),
    })
    @Select("select msc.sensor_name,\n" +
            "       msc.fov_h,\n" +
            "       msc.fov_v,\n" +
            "       msc.near_distance,\n" +
            "       msc.far_distance,\n" +
            "       msc.resolution,\n" +
            "       msc.frame_rate,\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" +
            "from model_sensor_camera msc left join relation_config_sensor rcs on msc.id = rcs.sensor_id\n" +
            "where msc.is_deleted = '0' and rcs.is_deleted = '0'\n" +
            "   and rcs.config_id = #{vehicleConfigId}")
    List<CameraEntity> selectCameraByVehicleConfigId(@Param("vehicleConfigId") String vehicleConfigId);
}
