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

import api.common.pojo.param.algorithm.AlgorithmParameter;
import api.common.pojo.param.project.MultiSimulationProjectParam;
import api.common.pojo.param.project.SimulationManualProjectParam;
import api.common.pojo.po.algorithm.AlgorithmPO;
import api.common.pojo.po.project.MultiSimulationProjectPO;
import api.common.pojo.vo.algorithm.AlgorithmVO;
import api.common.pojo.vo.algorithm.RunningProjectVO;
import api.common.pojo.vo.project.MultiSimulationProjectVO;
import api.common.pojo.vo.project.SimulationManualProjectVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MultiSimulationProjectMapper {
    @Select("<script>" +
        "select id,project_key,project_name,project_status,create_time from multi_simulation_project where deleted = 0 " +
        "<if test='projectKey != null'> " +
        " AND project_key = #{projectKey}" +
        "</if>" +
        "<if test='projectName != null'> " +
        " AND project_name = #{projectName}" +
        "</if>" +
        "<if test='projectStatus != null'> " +
        " AND project_status = #{projectStatus}" +
        "</if>" +
        "<if test='projectId != null'> " +
        " AND id = #{projectId}" +
        "</if>" +
        "order by create_time desc" +
        "</script>")
    List<MultiSimulationProjectVO> selectProjectList(MultiSimulationProjectParam param);


    @Insert("insert into multi_simulation_project (id,project_key,project_name,project_description,project_max_seconds,project_status,project_user_id) values" +
        "(#{id},#{projectKey},#{projectName},#{projectDescription},#{projectMaxSeconds},#{projectStatus},#{projectUserId})")
    int  addMultiSimulationProject(MultiSimulationProjectPO projectPO);

    @Select("select id,project_key,project_name,project_status,create_time from multi_simulation_project where deleted = 0 " +
        "and project_name = #{projectName} limit 1")
    MultiSimulationProjectVO selectMultiSimulationProjectByName(@Param("projectName") String projectName);

    @Delete("delete from multi_simulation_project where id = #{id}")
    int deleteMultiSimulationProject(@Param("id") String id);

    @Update("update multi_simulation_project set project_name = #{projectName}, project_description = #{projectDescription}," +
        "project_max_seconds = #{projectMaxSeconds}, project_user_id = #{projectUserId} where id = #{projectId}")
    int updateMultiSimulationProject(MultiSimulationProjectParam param);

    @Update("update multi_simulation_project set project_status = #{projectStatus} " +
        "where id = #{projectId}")
    int updateMultiSimulationProjectStatus(MultiSimulationProjectParam param);

    @Select("select id,project_key,project_name,project_status,create_time,project_description,project_max_seconds from multi_simulation_project where deleted = 0 " +
        "and id = #{id} limit 1")
    MultiSimulationProjectVO selectMultiSimulationProjectById(@Param("id") String projectId);
}
