xiaoyi
2026-10-29 81c76ca9e4741b71747b16eec61d0a00bec9f1f3
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
package cn.iocoder.yudao.module.mes.controller.admin.safety;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.mes.service.safety.SafetyFileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.List;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
/**
 * 安全生产 - 移动端现场拍照上传
 *
 * <p>巡检、隐患上报、作业票、演练等环节的照片统一走此接口,
 * 返回可访问 URL,前端拼成逗号串写入业务表。</p>
 *
 * @author 超级管理员
 */
@Tag(name = "管理后台 - 安全生产-附件上传")
@RestController
@RequestMapping("/safety/file")
@Validated
public class SafetyFileController {
 
    @Resource
    private SafetyFileService fileService;
 
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @Operation(summary = "上传单个附件(移动端拍照)")
    @Parameter(name = "file", description = "文件", required = true)
    @PreAuthorize("@ss.hasPermission('safety:file:upload')")
    public CommonResult<String> upload(@RequestPart("file") MultipartFile file,
                                       @RequestParam(value = "bizType", required = false) String bizType) {
        return success(fileService.upload(file, bizType));
    }
 
    @PostMapping(value = "/upload-batch", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @Operation(summary = "批量上传附件(移动端一次多张)")
    @PreAuthorize("@ss.hasPermission('safety:file:upload')")
    public CommonResult<List<String>> uploadBatch(@RequestPart("files") List<MultipartFile> files,
                                                  @RequestParam(value = "bizType", required = false) String bizType) {
        return success(fileService.uploadBatch(files, bizType));
    }
 
}