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


import api.common.pojo.po.scheduler.SchedulerProjectPO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface AutoSubProjectMapper {

    @Results(id = "project", value = {
            @Result(column = "id", property = "id", jdbcType = JdbcType.VARCHAR),
            @Result(column = "scene", property = "scenePackageId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_user_id", property = "createUserId", jdbcType = JdbcType.VARCHAR),
            @Result(column = "parallelism", property = "parallelism", jdbcType = JdbcType.VARCHAR),
            @Result(column = "project_type", property = "projectType", jdbcType = JdbcType.VARCHAR)
    })
    @Select("select sas.id, sap.scene, sas.create_user_id\n" +
            "from simulation_automatic_subproject sas\n" +
            "         left join simulation_automatic_project sap on sas.parent_id = sap.id\n" +
            "where sas.id = #{projectId}")
    SchedulerProjectPO selectById(@Param("projectId") String projectId);

    @Update("update simulation_automatic_subproject\n" +
            "set evaluation_level = #{evaluationLevel}\n" +
            "where id = #{projectId}")
    void updateEvaluationLevel(@Param("projectId") String projectId, @Param("evaluationLevel") String evaluationLevel);

    @Update("update simulation_automatic_subproject\n" +
            "set details = #{details}\n" +
            "where id = #{projectId}")
    void updateDetailsById(@Param("projectId") String projectId, @Param("details") String details);

}
