package com.persagy.dmp.file.controller;

import cn.hutool.core.util.StrUtil;
import com.persagy.dmp.common.constant.ResponseCode;
import com.persagy.dmp.common.constant.ValidEnum;
import com.persagy.dmp.common.exception.BusinessException;
import com.persagy.dmp.common.lang.PsDateTime;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.common.utils.ResultHelper;
import com.persagy.dmp.file.domain.FileRequestData;
import com.persagy.dmp.file.model.FileInfo;
import com.persagy.dmp.file.service.FileUploadService;
import com.persagy.dmp.file.service.IFileService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 文件管理Controller
 * @author Charlie Yu
 * @date 2021-05-15
 */
@RestController
@RequestMapping("/upload/")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class FileUploadController {

    private final FileUploadService fileUploadService;
    /***
     * Description: 初始化大文件上传
     * @param requestData : 请求参数
     * @return : com.persagy.dmp.common.model.response.CommonResult<com.persagy.dmp.file.model.FileInfo>  
     * @author : lijie
     * @date :2021/10/9 20:12
     * Update By lijie 2021/10/9 20:12
     */
    @PostMapping("/initChunkUpload")
    public CommonResult<List<FileInfo>> initChunkUpload(@RequestBody FileRequestData requestData) {
        return ResultHelper.multi(fileUploadService.initChunkUpload(requestData));
    }
}
