<?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.ho.business.mapper.TopologyJumpConfigMapper">

    <sql id="Base_Column_List">
        id,station_id,src_id,topology_id
    </sql>

    <insert id="insertOne" parameterType="com.ho.business.entity.TopologyJumpConfig">
        insert into topology_jump_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stationId != null">station_id,</if>
            <if test="srcId != null">src_id,</if>
            <if test="topologyId != null">topology_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stationId != null">#{stationId},</if>
            <if test="srcId != null">#{srcId},</if>
            <if test="topologyId != null">#{topologyId},</if>
        </trim>
    </insert>

    <insert id="insertList" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
        insert into topology_jump_config (station_id,src_id,topology_id)
        values
        <foreach item="item" collection="list" index="index" separator=",">
            (
             #{item.stationId},#{item.srcId},#{item.topologyId}
            )
        </foreach>

    </insert>

    <update id="updateById" parameterType="com.ho.business.entity.TopologyJumpConfig">
        update topology_jump_config
        <set>
            <if test="stationId != null">station_id = #{stationId},</if>
            <if test="srcId != null">src_id = #{srcId},</if>
            <if test="topologyId != null">topology_id = #{topologyId},</if>
        </set>
        where id = #{id}
    </update>

    <select id="selectByParam" resultType="com.ho.business.entity.TopologyJumpConfig">
        SELECT
        <include refid="Base_Column_List"/>
        FROM topology_jump_config
        <where>
            <if test="stationId != null">station_id = #{stationId}</if>
            <if test="ids != null and ids.size() != 0">
                and topology_id in
                <foreach collection="ids" open="(" close=")" separator="," item="item">
                    #{item}
                </foreach>
            </if>

        </where>
    </select>

    <delete id="deleteByList">
        delete
        from topology_jump_config
        <where>
            <if test="ids != null and ids.size() != 0">
                and id in
                <foreach collection="ids" open="(" close=")" separator="," item="item">
                    #{item}
                </foreach>
            </if>
        </where>
    </delete>

</mapper>
