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

import api.common.pojo.param.map.SimulationMapParam;
import api.common.pojo.param.project.MultiSimulationProjectParam;
import api.common.pojo.po.map.SimulationMapPO;
import api.common.pojo.vo.map.SimulationMapVO;
import api.common.pojo.vo.project.MultiSimulationProjectVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SimulationMapMapper {
    @Insert("insert into simulation_map (id,map_code,map_name,map_json,map_osgb_path,map_path,map_description,path_num) values" +
        "(#{id},#{mapCode},#{mapName},#{mapJson},#{mapOsgbPath},#{mapPath},#{mapDescription},#{pathNum})")
    int addSimulationMap(SimulationMapPO scenePO);

    @Select("select id,path_num,map_name,map_osgb_path,map_path,map_description,create_time from simulation_map where id = #{id} and deleted = 0")
    SimulationMapVO selectMapByMapId(@Param("id") String mapId);

    @Update("update simulation_map set deleted = 1 where id = #{mapId}")
    int deleteMultiSimulationScene(SimulationMapParam param);

    @Update("update simulation_map set path_num = #{pathNum},map_description = #{mapDescription} where id = #{mapId}")
    int updateMultiSimulationScene(SimulationMapParam param);


//
//    @Select("<script>" +
//        "select id,project_id,scene_name,map_id,create_time from multi_simulation_scene where deleted = 0 " +
//        "and project_id = #{projectId}" +
//        "order by create_time desc" +
//        "</script>")
//    List<MultiSimulationSceneVO> selectSceneList(MultiSimulationSceneParam param);

    @Select("<script>" +
        "select id,map_name,map_description,path_num,create_time from simulation_map where deleted = 0 " +
        "<if test='mapName != null'> " +
        " AND map_name = #{mapName}" +
        "</if>" +
        "<if test='mapDescription != null'> " +
        " AND map_description = #{mapDescription}" +
        "</if>" +
        "order by create_time desc" +
        "</script>")
    List<SimulationMapVO> selectSimulationMapList(SimulationMapParam param);

}
