<?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.base.track.mapper.EphDataMapper">

    <insert id="batch">
        insert into base_eph_data_${code} (id,code,eph_time,X,Y,Z,VX,VY,VZ,cir_cle)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.id},
            #{item.code},
            #{item.ephTime},
            #{item.X},
            #{item.Y},
            #{item.Z},
            #{item.VX},
            #{item.VY},
            #{item.VZ},
            #{item.cirCle}
            )
        </foreach>

    </insert>

    <update id="creatTable" parameterType="java.lang.String">

        CREATE TABLE base_eph_data_${code}
        (
            `id`       bigint(100) NOT NULL,
            `code`     varchar(255) NOT NULL,
            `eph_time` datetime(0)   DEFAULT NULL,
            `X`        decimal(20, 3) DEFAULT NULL,
            `Y`        decimal(20, 3) DEFAULT NULL,
            `Z`        decimal(20, 3) DEFAULT NULL,
            `VX`       decimal(20, 3) DEFAULT NULL,
            `VY`       decimal(20, 3) DEFAULT NULL,
            `VZ`       decimal(20, 3) DEFAULT NULL,
            `cir_cle`  varchar(50)   DEFAULT NULL,
            PRIMARY KEY (`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
    </update>

    <select id="getList" parameterType="com.base.track.model.dto.request.QueryEphListDTO" resultType="com.base.track.model.entity.EphData">
        select * from base_eph_data_${dto.code}
        <where>
            <if test="dto.startTime!=null">
                and eph_time &gt;= #{dto.startTime}
            </if>
            <if test="dto.endTime!=null">
                and  eph_time &lt;= #{dto.endTime}
            </if>
        </where>
    </select>

    <delete id="delData" parameterType="com.base.track.model.dto.request.QueryEphListDTO">
        delete from base_eph_data_${dto.code}
        <where>
            <if test="dto.startTime!=null">
                and eph_time &gt;= #{dto.startTime}
            </if>
            <if test="dto.endTime!=null">
                and  eph_time &lt;= #{dto.endTime}
            </if>
        </where>
    </delete>



</mapper>
