<?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.FileMultipartMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into file_multipart
        (`content_id`,`sha256sum`,`absolute_path`,`total_size`,`chunk_size`,`total_chunks`,`uploaded`,`upload_by`)
        values
        (#{contentId},#{sha256sum},#{absolutePath},#{totalSize},#{chunkSize},#{totalChunks},#{uploaded},#{uploadBy})
    </insert>

    <update id="updateSetUploaded">
        update file_multipart
        set uploaded=1
        where sha256sum=#{sha256sum}
    </update>

    <select id="findBySha256sumAndUploadBy" resultType="cn.reghao.tnb.oss.store.model.po.FileMultipart">
        select *
        from file_multipart
        where sha256sum=#{sha256sum} and upload_by=#{uploadBy}
    </select>
</mapper>
