修复Excel转PDF转换边界问题
This commit is contained in:
@@ -2,10 +2,12 @@ package cn.nianxx.thhotel.platform.documentconversion.control;
|
||||
|
||||
import cn.nianxx.thhotel.platform.documentconversion.common.result.DocumentConversionErrorResponse;
|
||||
import cn.nianxx.thhotel.platform.documentconversion.service.DocumentConversionException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||
import org.springframework.web.multipart.support.MissingServletRequestPartException;
|
||||
|
||||
/**
|
||||
@@ -34,4 +36,16 @@ public class DocumentConversionControllerAdvice {
|
||||
"DOCUMENT_CONVERSION_FILE_REQUIRED",
|
||||
"请上传 Excel 文件。"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换 Spring multipart 框架层上传大小超限异常。
|
||||
*/
|
||||
@ExceptionHandler(MaxUploadSizeExceededException.class)
|
||||
public ResponseEntity<DocumentConversionErrorResponse> handleMaxUploadSizeExceeded(
|
||||
MaxUploadSizeExceededException exception) {
|
||||
return ResponseEntity.status(HttpStatus.PAYLOAD_TOO_LARGE)
|
||||
.body(new DocumentConversionErrorResponse(
|
||||
"DOCUMENT_CONVERSION_FILE_TOO_LARGE",
|
||||
"上传的 Excel 文件超过大小限制。"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user