heheng
5 天以前 3341599719e0ae63889b6bfb4eea3cf4521b0ab8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.gkhy.exam.admin.controller.system;
 
import com.gkhy.exam.common.annotation.RepeatSubmit;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.system.domain.vo.UploadObjectVO;
import com.gkhy.exam.system.service.SysCommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
@Api(tags = "通用接口前端控制器")
@RestController
@RequestMapping("/system/common")
public class SysCommonController {
    @Autowired
    private SysCommonService commonService;
 
    @RepeatSubmit
    @ApiOperation(value = "上传图片/文件(存本地)")
    @PostMapping("/uploadFile")
    public CommonResult<UploadObjectVO> uploadFile(MultipartFile file){
        return CommonResult.success(commonService.uploadFile(file));
    }
 
 
    @ApiOperation(value = "删除图片(存本地)")
    @DeleteMapping("/removeFile")
    public CommonResult removeFile(@RequestParam(required = true) String path){
        return CommonResult.success(commonService.removeFile(path));
    }
 
 
//    @ApiOperation(value = "资源管理视频文件上传(不分片)")
//    @PostMapping("/uploadVideo")
//    public CommonResult uploadVideo(@RequestPart("file") MultipartFile file) throws Exception { ;
//        return CommonResult.success(commonService.uploadVideo2M3u8(file));
//    }
 
    @ApiOperation(value = "资源管理文件上传(分片)(存minio)")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "fileMd5", dataType = "int", required = true, value = "文件md5"),
            @ApiImplicitParam(paramType = "body", name = "chunkName", dataType = "int", required = true, value = "分片文件名"),
            @ApiImplicitParam(paramType = "body", name = "file", dataType = "file", required = true, value = "文件对象")
    })
    @PostMapping("/uploadSlice")
    public CommonResult uploadSlice(@RequestParam(value = "fileMd5",required = true) String fileMd5,@RequestParam(value = "chunkName",required = true) String chunkName,@RequestParam(value = "file",required = true) MultipartFile file){
        commonService.uploadSlice(fileMd5,chunkName,file);
        return CommonResult.success();
    }
 
    @ApiOperation(value = "资源管理文件分片合并(存minio)")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "fileMd5", dataType = "int", required = true, value = "文件md5"),
            @ApiImplicitParam(paramType = "body", name = "fileName", dataType = "int", required = true, value = "文件名称(必须有后缀名)")
    })
    @PostMapping("/uploadMerge")
    public CommonResult uploadMerge(@RequestParam(value = "fileMd5",required = true) String fileMd5,@RequestParam(value = "fileName",required = true)String fileName) throws Exception {
        return CommonResult.success(commonService.uploadMerge(fileMd5,fileName));
    }
 
    @ApiOperation(value = "删除视频/文件(minio)")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "resourceId", dataType = "long", required = false, value = "资源id(已创建资源后进行删除,需要传id)"),
            @ApiImplicitParam(paramType = "query", name = "path", dataType = "int", required = true, value = "文件路径")
    })
    @DeleteMapping("/removeMinioFile")
    public CommonResult removeMinioFile(@RequestParam(required = false) Long resourceId,@RequestParam(required = true) String path){
        commonService.removeMinioFile(resourceId,path);
        return CommonResult.success();
    }
 
 
 
 
    @GetMapping("/importExcel")
    public CommonResult importExcel() throws Exception {
        commonService.importStudent();
        return CommonResult.success();
    }
}