<?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.oss.store.db.mapper.FilePartMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into file_part
        (`content_id`,`chunk_number`,`current_chunk_size`)
        values
        (#{contentId},#{chunkNumber},#{currentChunkSize})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into file_part
        (`content_id`,`chunk_number`,`current_chunk_size`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.contentId},#{item.chunkNumber},#{item.currentChunkSize})
        </foreach>
    </insert>

    <select id="findByContentId" resultType="cn.reghao.tnb.oss.store.model.po.FilePart">
        select *
        from file_part
        where content_id=#{contentId}
    </select>
</mapper>
