Commit 50bbdd4d authored by liqin's avatar liqin 💬

Merge branch 'master' of http://111.203.232.171:8888/lee/chnmuseum-party into master

parents 280a25ea 2def731a
...@@ -105,7 +105,7 @@ public class FileUploadController { ...@@ -105,7 +105,7 @@ public class FileUploadController {
@ApiOperation(value = "资料上传", notes = "资料上传") @ApiOperation(value = "资料上传", notes = "资料上传")
public ResponseEntity<BatchUploadResVO> uploadFile(@RequestPart(value = "file", required = false) MultipartFile[] files) throws IOException { public ResponseEntity<BatchUploadResVO> uploadFile(@RequestPart(value = "file", required = false) MultipartFile[] files) throws IOException {
if (files.length == 0) { if (files.length == 0) {
throw new InterfaceException(RESPONSE_CODE_ENUM.REQUEST_PARAMS_ERROR.getResultCode(), "没有文件可供上传"); throw new InterfaceException(RESPONSE_CODE_ENUM.SERVER_ERROR.getResultCode(), "没有文件可供上传");
} }
int successCount = 0; int successCount = 0;
int failureCount = 0; int failureCount = 0;
...@@ -152,7 +152,7 @@ public class FileUploadController { ...@@ -152,7 +152,7 @@ public class FileUploadController {
batchUploadResVO.setTotal(files.length); batchUploadResVO.setTotal(files.length);
batchUploadResVO.setHandleList(handleList); batchUploadResVO.setHandleList(handleList);
batchUploadResVO.setUrlList(videoUrlList); batchUploadResVO.setUrlList(videoUrlList);
return ResponseEntity.status(HttpStatus.CREATED).body(batchUploadResVO); return ResponseEntity.ok(batchUploadResVO);
} }
@PostMapping(value = "/image/upload", headers = "content-type=multipart/form-data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/image/upload", headers = "content-type=multipart/form-data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
...@@ -160,16 +160,16 @@ public class FileUploadController { ...@@ -160,16 +160,16 @@ public class FileUploadController {
@ApiOperation(value = "单图片上传", notes = "单图片上传") @ApiOperation(value = "单图片上传", notes = "单图片上传")
public ResponseEntity<ImageUploadResult> uploadImage(@RequestParam(value = "file") MultipartFile uploadFile) throws Exception { public ResponseEntity<ImageUploadResult> uploadImage(@RequestParam(value = "file") MultipartFile uploadFile) throws Exception {
if (uploadFile == null || uploadFile.getSize() == 0) { if (uploadFile == null || uploadFile.getSize() == 0) {
throw new InterfaceException(RESPONSE_CODE_ENUM.REQUEST_PARAMS_ERROR.getResultCode(), "没有文件可供上传"); throw new InterfaceException(RESPONSE_CODE_ENUM.SERVER_ERROR.getResultCode(), "没有文件可供上传");
} }
String fileName = uploadFile.getOriginalFilename(); String fileName = uploadFile.getOriginalFilename();
String extension = FilenameUtils.getExtension(fileName); String extension = FilenameUtils.getExtension(fileName);
if (StringUtils.isBlank(extension)) { if (StringUtils.isBlank(extension)) {
throw new InterfaceException(RESPONSE_CODE_ENUM.REQUEST_PARAMS_ERROR.getResultCode(), "文件格式不支持"); throw new InterfaceException(RESPONSE_CODE_ENUM.SERVER_ERROR.getResultCode(), "文件格式不支持");
} }
boolean anyMatch = Arrays.stream(IMAGE_TYPE).anyMatch(s -> Objects.equals(s, extension.toUpperCase())); boolean anyMatch = Arrays.stream(IMAGE_TYPE).anyMatch(s -> Objects.equals(s, extension.toUpperCase()));
if (!anyMatch) { if (!anyMatch) {
throw new InterfaceException(RESPONSE_CODE_ENUM.REQUEST_PARAMS_ERROR.getResultCode(), "文件格式不支持"); throw new InterfaceException(RESPONSE_CODE_ENUM.SERVER_ERROR.getResultCode(), "文件格式不支持");
} }
String url = FastDFSUtils.uploadFile(uploadFile.getInputStream(), uploadFile.getSize(), fileName); String url = FastDFSUtils.uploadFile(uploadFile.getInputStream(), uploadFile.getSize(), fileName);
...@@ -178,7 +178,7 @@ public class FileUploadController { ...@@ -178,7 +178,7 @@ public class FileUploadController {
imageUploadResult.setFileExtName(extension); imageUploadResult.setFileExtName(extension);
imageUploadResult.setFileSize(uploadFile.getSize()); imageUploadResult.setFileSize(uploadFile.getSize());
imageUploadResult.setUrl(url); imageUploadResult.setUrl(url);
return ResponseEntity.status(HttpStatus.CREATED).body(imageUploadResult); return ResponseEntity.ok(imageUploadResult);
} }
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -188,12 +188,12 @@ public class FileUploadController { ...@@ -188,12 +188,12 @@ public class FileUploadController {
@RequiresPermissions("audio:upload") @RequiresPermissions("audio:upload")
@ApiOperation(value = "多音频上传", notes = "多音频上传") @ApiOperation(value = "多音频上传", notes = "多音频上传")
public ResponseEntity<BatchUploadResVO> uploadAudio(@RequestPart(value = "file", required = false) MultipartFile[] files) throws IOException { public ResponseEntity<BatchUploadResVO> uploadAudio(@RequestPart(value = "file", required = false) MultipartFile[] files) throws IOException {
if (files.length == 0) { if (files == null || files.length == 0) {
throw new InterfaceException(RESPONSE_CODE_ENUM.REQUEST_PARAMS_ERROR.getResultCode(), "没有文件可供上传"); throw new InterfaceException(RESPONSE_CODE_ENUM.SERVER_ERROR.getResultCode(), "没有文件可供上传");
} }
final boolean existChineseAudio = Arrays.stream(files).anyMatch(s -> Objects.requireNonNull(s.getOriginalFilename()).contains("汉语")); final boolean existChineseAudio = Arrays.stream(files).anyMatch(s -> Objects.requireNonNull(s.getOriginalFilename()).contains("汉语"));
if (!existChineseAudio) { if (!existChineseAudio) {
throw new InterfaceException(RESPONSE_CODE_ENUM.REQUEST_PARAMS_ERROR.getResultCode(), "必须包含汉语音频"); throw new InterfaceException(RESPONSE_CODE_ENUM.SERVER_ERROR.getResultCode(), "必须包含汉语音频");
} }
int successCount = 0; int successCount = 0;
...@@ -241,7 +241,7 @@ public class FileUploadController { ...@@ -241,7 +241,7 @@ public class FileUploadController {
batchUploadResVO.setTotal(files.length); batchUploadResVO.setTotal(files.length);
batchUploadResVO.setHandleList(handleList); batchUploadResVO.setHandleList(handleList);
batchUploadResVO.setUrlList(videoUrlList); batchUploadResVO.setUrlList(videoUrlList);
return ResponseEntity.status(HttpStatus.CREATED).body(batchUploadResVO); return ResponseEntity.ok(batchUploadResVO);
} }
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -250,13 +250,13 @@ public class FileUploadController { ...@@ -250,13 +250,13 @@ public class FileUploadController {
@PostMapping(value = "/video/upload", headers = "content-type=multipart/form-data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/video/upload", headers = "content-type=multipart/form-data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@RequiresPermissions("video:upload") @RequiresPermissions("video:upload")
@ApiOperation(value = "多视频上传", notes = "多视频上传") @ApiOperation(value = "多视频上传", notes = "多视频上传")
public ResponseEntity<BatchUploadResVO> uploadVideo(@RequestPart(value = "file", required = false) MultipartFile[] files) throws IOException { public ResponseEntity<BatchUploadResVO> uploadVideo(@RequestPart(value = "file", required = true) MultipartFile[] files) throws IOException {
if (files == null || files.length == 0) { if (files == null || files.length == 0) {
throw new InterfaceException(RESPONSE_CODE_ENUM.REQUEST_PARAMS_ERROR.getResultCode(), "没有文件可供上传"); throw new InterfaceException(RESPONSE_CODE_ENUM.SERVER_ERROR.getResultCode(), "没有文件可供上传");
} }
final boolean matchChinese = Arrays.stream(files).anyMatch(s -> Objects.requireNonNull(s.getOriginalFilename()).contains("汉语")); final boolean matchChinese = Arrays.stream(files).anyMatch(s -> Objects.requireNonNull(s.getOriginalFilename()).contains("汉语"));
if (!matchChinese) { if (!matchChinese) {
throw new InterfaceException(RESPONSE_CODE_ENUM.REQUEST_PARAMS_ERROR.getResultCode(), "必须包含汉语视频"); throw new InterfaceException(RESPONSE_CODE_ENUM.SERVER_ERROR.getResultCode(), "必须包含汉语视频");
} }
int successCount = 0; int successCount = 0;
...@@ -304,7 +304,7 @@ public class FileUploadController { ...@@ -304,7 +304,7 @@ public class FileUploadController {
batchUploadResVO.setTotal(files.length); batchUploadResVO.setTotal(files.length);
batchUploadResVO.setHandleList(handleList); batchUploadResVO.setHandleList(handleList);
batchUploadResVO.setUrlList(videoUrlList); batchUploadResVO.setUrlList(videoUrlList);
return ResponseEntity.status(HttpStatus.CREATED).body(batchUploadResVO); return ResponseEntity.ok(batchUploadResVO);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment