<?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="cn.reghao.tnb.content.app.data.db.mapper.AudioFileMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into audio_file
        (`audio_file_id`,`object_id`,`duration`,`codec`,`bit_rate`,`url`)
        values
        (#{audioFileId},#{objectId},#{duration},#{codec},#{bitRate},#{url})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into audio_file
        (`audio_file_id`,`object_id`,`duration`,`codec`,`bit_rate`,`url`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.audioFileId},#{item.objectId},#{item.duration},#{item.codec},#{item.bitRate},#{item.url})
        </foreach>
    </insert>

    <select id="findByAudioFileId" resultType="cn.reghao.tnb.content.app.data.model.po.AudioFile">
        select *
        from audio_file
        where audio_file_id=#{audioFileId}
    </select>
    <select id="findAudioInfo" resultType="cn.reghao.oss.api.dto.media.AudioInfo">
        select audio_file_id,duration,codec,url
        from audio_file
        where audio_file_id=#{audioFileId}
        order by id desc
    </select>
    <select id="findAudioUrl" resultType="cn.reghao.oss.api.dto.media.AudioUrl">
        select audio_file_id,bit_rate,codec,url
        from audio_file
        where audio_file_id=#{audioFileId}
        order by id desc
    </select>
</mapper>
