package com.ard.web.controller.inspection;
|
|
import com.ard.common.annotation.Log;
|
import com.ard.common.core.controller.BaseController;
|
import com.ard.common.core.domain.AjaxResult;
|
import com.ard.common.enums.BusinessType;
|
import com.ard.inspection.service.IBigFileUploadService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import io.swagger.annotations.Api;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.util.*;
|
|
/**
|
* @author xia
|
*/
|
@Api(tags = "大文件上传")
|
@RestController
|
@RequestMapping("/inspection/bigfile")
|
@Slf4j
|
public class BigFileUploadController extends BaseController {
|
|
@Autowired
|
private IBigFileUploadService bigFileUploadService;
|
|
//@Value(value = "${inspection.profile}")
|
private String uploadPath;
|
|
//@Value(value = "${inspection.chunk.path}")
|
private String chunkPath;
|
|
/**
|
* 检查分片是否存在
|
*/
|
@GetMapping("/chunks/{fileMd5}")
|
public AjaxResult checkChunk(@PathVariable String fileMd5) {
|
Map<String, Object> result = bigFileUploadService.checkChunk(fileMd5,chunkPath);
|
return AjaxResult.success(result);
|
}
|
|
/**
|
* 上传分片
|
*/
|
@PostMapping("/chunk")
|
public AjaxResult uploadChunk(@RequestParam("file") MultipartFile file,
|
@RequestParam("chunkNumber") Integer chunkNumber,
|
@RequestParam("fileMd5") String fileMd5) {
|
Map<String, Object> result = bigFileUploadService.uploadChunk(file, chunkNumber, fileMd5, chunkPath);
|
return AjaxResult.success(result);
|
}
|
|
/**
|
* 合并切片
|
*/
|
@Log(title = "合并切片", businessType = BusinessType.IMPORT)
|
@PostMapping("/merge")
|
public AjaxResult mergeChunks(@RequestParam("md5") String md5,
|
@RequestParam("fileName") String fileName) {
|
Map<String, Object> result = bigFileUploadService.mergeChunks(md5, fileName, uploadPath);
|
return AjaxResult.success(result);
|
}
|
|
}
|