package cn.besteam.modules.system.controller; import cn.besteam.common.api.vo.Result; import cn.besteam.common.constant.ErrorCode; import cn.besteam.common.exception.BusinessException; import cn.besteam.modules.system.service.IOssService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @RestController @RequestMapping("/file") @Api(value = "文件管理") public class FileController { @Autowired private IOssService ossService; @PostMapping("/upload") @ApiOperation(value = "上传文件") public Result upload(MultipartFile file) { if (file == null) { throw new BusinessException(ErrorCode.SYSTEM_REQUEST_PARAM_ERROR); } String fileUrl = ossService.upload(file); return Result.ok(fileUrl); } }