|
|
|
@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -28,15 +29,21 @@ public class FileController { |
|
|
|
@Resource |
|
|
|
private IFileService fileService; |
|
|
|
|
|
|
|
@MustLogin |
|
|
|
@MustLogingit |
|
|
|
@ApiOperation(value = "上传文件",notes = "文件大小不能超过20M") |
|
|
|
@ApiImplicitParams({ |
|
|
|
}) |
|
|
|
@RequestMapping(value = "upload", method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"}) |
|
|
|
public JsonResponse<List<FileVo.FileInfo>> uploadFile(QueryDto<List<MultipartFile>> params) throws Exception { |
|
|
|
public JsonResponse<List<FileVo.FileInfo>> uploadFile(QueryDto<MultipartFile> params) throws Exception { |
|
|
|
log.info("上传文件:{}",params); |
|
|
|
// MultipartFile f = params.getParam();
|
|
|
|
List<FileVo.FileInfo> fileInfoList = fileService.uploadFile(params.getParam(),params.getUserId()); |
|
|
|
List<MultipartFile> fileList; |
|
|
|
try { |
|
|
|
fileList = (List<MultipartFile>) params.getParam(); |
|
|
|
}catch (Exception e){ |
|
|
|
fileList = new ArrayList<>(); |
|
|
|
fileList.add(params.getParam()); |
|
|
|
} |
|
|
|
List<FileVo.FileInfo> fileInfoList = fileService.uploadFile(fileList,params.getUserId()); |
|
|
|
|
|
|
|
return JsonResponse.newInstance().ok(fileInfoList); |
|
|
|
} |
|
|
|
|