#namespace("DouYin")
    #sql("updateStatus")
        UPDATE t_douyin_record 
        SET status = #para(status)
        #if(error_msg)
            , error_msg = #para(error_msg)
        #end
        WHERE id = #para(id)
    #end

    #sql("updateRecord")
        UPDATE t_douyin_record 
        SET video_name = #para(title), 
            obs_url = #para(obs_url), 
            transcript = #para(transcript), 
            status = #para(status)
        WHERE id = #para(id)
    #end

    #sql("insertRecord")
        INSERT INTO t_douyin_record (id, original_text, status, create_time)
        VALUES (#para(id), #para(url), 'PENDING', #para(create_time))
    #end

    #sql("getRecords")
        SELECT * FROM t_douyin_record 
        ORDER BY create_time DESC 
        LIMIT #para(limit)
    #end

    #sql("deleteRecord")
        DELETE FROM t_douyin_record WHERE id = #para(id)
    #end

    #sql("getTranscriptsByIds")
        SELECT video_name, transcript 
        FROM t_douyin_record 
        WHERE id IN (#para(ids)) 
        AND status = 'COMPLETED'
    #end

    #sql("getLatestTranscripts")
        SELECT video_name, transcript 
        FROM t_douyin_record 
        WHERE status = 'COMPLETED' 
        ORDER BY create_time DESC 
        LIMIT #para(limit)
    #end

    #sql("getInterruptedTasks")
        SELECT id, original_text, status 
        FROM t_douyin_record 
        WHERE status IN ('PENDING', 'PROCESSING') 
        ORDER BY create_time DESC 
        LIMIT #para(limit)
    #end
#end
