package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface MediaServerMapper {
    @Insert("INSERT INTO media_server (" +
            "id, " +
            "ip, " +
            "hookIp, " +
            "sdpIp, " +
            "streamIp, " +
            "httpPort, " +
            "httpSSlPort, " +
            "rtmpPort, " +
            "rtmpSSlPort, " +
            "rtpProxyPort, " +
            "rtspPort, " +
            "rtspSSLPort, " +
            "autoConfig, " +
            "secret, " +
            "streamNoneReaderDelayMS, " +
            "rtpEnable, " +
            "rtpPortRange, " +
            "sendRtpPortRange, " +
            "recordAssistPort, " +
            "defaultServer, " +
            "createTime, " +
            "updateTime" +
            ") VALUES " +
            "(" +
            "'${id}', " +
            "'${ip}', " +
            "'${hookIp}', " +
            "'${sdpIp}', " +
            "'${streamIp}', " +
            "${httpPort}, " +
            "${httpSSlPort}, " +
            "${rtmpPort}, " +
            "${rtmpSSlPort}, " +
            "${rtpProxyPort}, " +
            "${rtspPort}, " +
            "${rtspSSLPort}, " +
            "${autoConfig}, " +
            "'${secret}', " +
            "${streamNoneReaderDelayMS}, " +
            "${rtpEnable}, " +
            "'${rtpPortRange}', " +
            "'${sendRtpPortRange}', " +
            "${recordAssistPort}, " +
            "${defaultServer}, " +
            "'${createTime}', " +
            "'${updateTime}')")
    int add(MediaServerItem mediaServerItem);
    @Update(value = {" "})
    int update(MediaServerItem mediaServerItem);
    @Select("SELECT * FROM media_server WHERE id='${id}'")
    MediaServerItem queryOne(String id);
    @Select("SELECT * FROM media_server")
    List queryAll();
    @Select("DELETE FROM media_server WHERE id='${id}'")
    void delOne(String id);
    @Select("DELETE FROM media_server WHERE ip='${host}' and httpPort=${port}")
    void delOneByIPAndPort(String host, int port);
    @Select("DELETE FROM media_server WHERE defaultServer=1;")
    void delDefault();
    @Select("SELECT * FROM media_server WHERE ip='${host}' and httpPort=${port}")
    MediaServerItem queryOneByHostAndPort(String host, int port);
}