<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.css.simulation.resource.server.infra.db.mysql.mapper.SceneGeneralDataMapper">

    <insert id="saveSceneGeneralDataAll" parameterType="java.util.List">

        insert into simulation.scene_general_data
        (id,scene_id,sublist_id,template_id,example_id,osgb_address,xodr_address,xosc_address,
        create_user_id,create_time,modify_time,
        is_deleted) values
        <foreach collection="list" index="index" item="item" separator=",">
            (#{item.id,jdbcType=VARCHAR},#{item.sceneId,jdbcType=VARCHAR},#{item.sublistId,jdbcType=VARCHAR},#{item.templateId,jdbcType=VARCHAR},#{item.exampleId,jdbcType=VARCHAR},#{item.osgbAddress,jdbcType=VARCHAR},#{item.xodrAddress,jdbcType=VARCHAR},
             #{item.xoscAddress},
            #{item.createUserId,jdbcType=VARCHAR},#{item.createTime},#{item.modifyTime},
            #{item.isDeleted,jdbcType=VARCHAR})
        </foreach>
    </insert>

    <select id="querySceneGeneralDataList" parameterType="api.common.pojo.po.scene.SceneGeneralDataPO"
            resultType="api.common.pojo.po.scene.SceneGeneralDataPO">

        select
        id,scene_id,sublit_id,template_id,example_id,osgb_address,xodr_address,xosc_address
        from simulation.scene_general_template
        <where>
        is_deleted = '0'
            <if test="id != null and id != ''">
                and id #{id,jdbcType=VARCHAR}
            </if>
            <if test="sublitId != null and sublitId != ''">
                and sublit_id =#{sublitId,jdbcType=VARCHAR}
            </if>
            <if test="templateId != null and templateId != ''">
                and template_id =#{templateId,jdbcType=VARCHAR}
            </if>
            <if test="exampleId != null and exampleId != ''">
                and example_id =#{exampleId,jdbcType=VARCHAR}
            </if>
        order by modify_time desc
        </where>
    </select>
    <select id="querySceneGeneralDataById" parameterType="java.lang.String"
            resultType="api.common.pojo.po.scene.SceneGeneralDataPO">
        select
         id,scene_id,sublit_id,template_id,example_id,osgb_address,xodr_address,xosc_address
        from simulation.scene_general_data
        where id #{id,jdbcType=VARCHAR}

    </select>


</mapper>
