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

import api.common.pojo.po.project.MultiSimulationProjectTaskRecordPO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

@Mapper
public interface MultiSimulationProjectTaskRecordMapper {
//    @Results(id = "multiSimulationProjectTaskRecordRes", value = {
//        @Result(column = "id", property = "id", jdbcType = JdbcType.VARCHAR),
//        @Result(column = "scene_id", property = "sceneId", jdbcType = JdbcType.VARCHAR),
//        @Result(column = "project_id", property = "projectId", jdbcType = JdbcType.VARCHAR),
//        @Result(column = "task_body", property = "taskBody", jdbcType = JdbcType.VARCHAR),
//        @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
//        @Result(column = "sort", property = "sort", jdbcType = JdbcType.INTEGER),
//        @Result(column = "deleted", property = "deleted", jdbcType = JdbcType.INTEGER),
//        @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
//        @Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.TIMESTAMP)
//    })

    @Insert("insert into multi_simulation_project_task_record (id,scene_id,project_id,task_body,status,sort) values" +
        "(#{id},#{sceneId},#{projectId},#{taskBody},0,#{sort})")
    int addMultiSimulationProjectTaskRecord(@Param("id") String id, @Param("sceneId") String sceneId, @Param("projectId") String projectId, @Param("taskBody") String taskBody, @Param("sort") Integer sort);

    @Update("update multi_simulation_project_task_record set status = #{status},deleted = #{deleted} " +
        "where id = #{taskId}")
    int updateMultiSimulationProjectTaskRecordStatus(@Param("status") Integer status, @Param("taskId") String taskId, @Param("deleted") Integer deleted);

    @Select("select id,project_id as projectId,scene_id as sceneId,task_body as taskBody,status,sort from multi_simulation_project_task_record where project_id = #{projectId} and deleted = 0")
    List<MultiSimulationProjectTaskRecordPO> selectMultiSimulationProjectTaskRecordList(@Param("projectId") String projectId);

    @Select("select id,project_id as projectId,scene_id as sceneId,task_body as taskBody,status,sort from multi_simulation_project_task_record where id = #{taskId} and deleted = 0")
    MultiSimulationProjectTaskRecordPO selectMultiSimulationProjectTaskRecordById(@Param("taskId") String taskId);

    @Delete("delete from multi_simulation_project_task_record where project_id = #{projectId}")
    int deleteProjectByProjectId(@Param("projectId") String projectId);



}
