package cn.reghao.oss.store.task;

import cn.reghao.oss.store.db.repository.ObjectRepository;
import cn.reghao.oss.store.model.vo.ObjectResult;
import cn.reghao.oss.store.task.processor.AudioFileProcessor;
import cn.reghao.oss.store.api.dto.ObjectMeta;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author reghao
 * @date 2023-08-29 18:03:39
 */
@Service
@Deprecated
public class FileTask {
    @Autowired
    ObjectRepository objectRepository;
    @Autowired
    AudioFileProcessor audioFileProcessor;

    public void exec() {
    }

    private void execTask() throws Exception {
        List<String> objectNames = List.of(
                "audio/playback/vJPA6ZGzV2.mp3"
        );

        for (String objectName : objectNames) {
            ObjectMeta objectMeta = objectRepository.getObjectMetaByName(objectName);
            String objectId = objectMeta.getObjectId();
            int fileType = 1003;
            String absolutePath = objectMeta.getAbsolutePath();
            ObjectResult objectResult = new ObjectResult(objectName, objectId, fileType, absolutePath);
            audioFileProcessor.process(objectResult);
        }
    }
}
