<?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.sb.multi.mybatis.mapper.one.FileMetaMapper">
    <update id="updateSetDelete">
        update file_meta
        set deleted=1
        where content_id=#{contentId}
    </update>
    <update id="updateSetDeleteByObjectId">
        update file_meta
        set deleted=1
        where object_id=#{objectId}
    </update>

    <delete id="deleteFileMetas">
        delete from file_meta
        where deleted=1
    </delete>

    <select id="findAll" resultType="cn.reghao.tnb.sb.multi.mybatis.model.one.FileMeta">
        select *
        from file_meta
        where deleted=0 and file_type=1002 and object_name like 'video/cam/%'
        order by size desc
        limit 10000
    </select>
    <select id="findByContentId" resultType="cn.reghao.tnb.sb.multi.mybatis.model.one.FileMeta">
        select *
        from file_meta
        where deleted=0 and content_id=#{contentId}
    </select>
    <select id="findByObjectId" resultType="cn.reghao.tnb.sb.multi.mybatis.model.one.FileMeta">
        select *
        from file_meta
        where deleted=0 and object_id=#{objectId}
    </select>
    <select id="findByPrefix" resultType="cn.reghao.tnb.sb.multi.mybatis.model.one.FileMeta">
        select *
        from file_meta
        where deleted=0 and object_name like 'video/playback%'
    </select>
    <select id="findByDeleted" resultType="cn.reghao.tnb.sb.multi.mybatis.model.one.FileMeta">
        select *
        from file_meta
        where deleted=1
    </select>
</mapper>
