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

import api.common.pojo.param.scene.SceneDeleteParam;
import api.common.pojo.param.scene.ScenePackageSublistParam;
import api.common.pojo.po.scene.ScenePackageSublistPO;
import api.common.pojo.vo.scene.ScenePackageSublistVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface ScenePackageSublistMapper {

    void saveScenePackageSublist(ScenePackageSublistPO params);
    void saveScenePackageSublistAll(List<ScenePackageSublistPO> treeList);
    void deleteScenePackageSublist(String rootId);
    void deleteScenePackageSublistById(String sublistId);
    List<ScenePackageSublistVO> queryScenePackageSublistList(ScenePackageSublistPO params);
    List<ScenePackageSublistVO> queryBySublistName(ScenePackageSublistPO params);
    List<String> selectPackageIdById(SceneDeleteParam param);
    List<ScenePackageSublistPO> selectPackageFhById(SceneDeleteParam param);
    void updateScenePackageSublistById(SceneDeleteParam param);

    int selectSceneNumByPackageId(@Param("scenePackageId")String scenePackageId);


    List<ScenePackageSublistPO> selectBySceneIds(ScenePackageSublistParam scenePackageSublistParam);

    void update(@Param("indexes")List<ScenePackageSublistPO> indexes);

    @Select("select CASE\n" +
            "           WHEN scene_natural_ids IS NOT NULL AND scene_natural_ids <> '' THEN scene_natural_ids\n" +
            "           WHEN scene_traffic_ids IS NOT NULL AND scene_traffic_ids <> '' THEN scene_traffic_ids\n" +
            "           WHEN scene_statue_ids IS NOT NULL AND scene_statue_ids <> '' THEN scene_statue_ids\n" +
            "           WHEN scene_generalization_ids IS NOT NULL AND scene_generalization_ids <> '' THEN scene_generalization_ids\n" +
            "           END AS scene_id\n" +
            "from scene_package_sublist\n" +
            "where root_id = (select scene\n" +
            "                 from simulation_manual_project\n" +
            "                 where id = #{id})\n" +
            "  and sublist_name like '%B%'")
    String getSceneIdOfBByProjectId(@Param("id") String id);
}
