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));
|
}
|
|
}
|