Browse Source

党建声音-上传Pdf

dev_shibei_match
jianjun 4 years ago
parent
commit
73d3928664
  1. 42
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java
  2. 4
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java
  3. 9
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftContentFromDTO.java

42
epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java

@ -205,25 +205,43 @@ public class OssController {
return ossService.uploadImg(file, null);
}
/**
* desc: 党建声音模块 上传图片2M或附件5M
*
* @param file
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.UploadImgResultDTO>
* @author LiuJanJun
* @date 2021/3/29 4:56 下午
*/
@PostMapping("article/upload")
public Result<UploadImgResultDTO> uploadArticleImg(@RequestParam("file") MultipartFile file) {
// 校验文件类型
if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType()) && !MediaType.IMAGE_JPEG_VALUE.equals(file.getContentType())
&& !ModuleConstant.FILE_CONTENT_TYPE_JPG.equals(file.getContentType()) ) {
log.error("uploadArticleImg file type:{} is not support 2 upload",file.getContentType() == null? null:file.getContentType());
// 校验文件类型 图片或pdf
if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())
&& !MediaType.IMAGE_JPEG_VALUE.equals(file.getContentType())
&& !ModuleConstant.FILE_CONTENT_TYPE_JPG.equals(file.getContentType())
&& !ModuleConstant.FILE_CONTENT_TYPE_PDF.equals(file.getContentType())) {
log.error("uploadArticleImg file type:{} is not support 2 upload", file.getContentType());
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode()
, EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg());
}
// 校验文件体积,不超过2m
long maxSize = 2 * 1024 * 1024;
long size = file.getSize();
if (size > maxSize) {
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode()
, EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg());
if (ModuleConstant.FILE_CONTENT_TYPE_PDF.equals(file.getContentType())) {
// 校验文件体积,不超过2m
long maxSize = 5 * 1024 * 1024;
long size = file.getSize();
if (size > maxSize) {
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode()
, EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg());
}
} else {
// 校验文件体积,不超过2m
long maxSize = 2 * 1024 * 1024;
long size = file.getSize();
if (size > maxSize) {
throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode()
, EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg());
}
}
return ossService.uploadImg(file, null);
}

4
epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/utils/ModuleConstant.java

@ -26,6 +26,10 @@ public interface ModuleConstant extends Constant {
* jpg文件类型
*/
String FILE_CONTENT_TYPE_JPG = "image/jpg";
/**
* pdf文件类型
*/
String FILE_CONTENT_TYPE_PDF = "application/pdf";
/**
* 项目附件-允许上传的文件类型

9
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DraftContentFromDTO.java

@ -67,14 +67,19 @@ public class DraftContentFromDTO implements Serializable {
*/
private String draftContentId;
/**
* 内容
* 内容 当为非文字时存放oss链接地址
*/
@Length(max = 1000, message = "每段文字最长为1000个字")
private String content;
/**
* 内容类型 图片img文字text
* 内容类型 图片img文字text附件attachment
*/
private String contentType;
/**
* 附件名称
*/
private String attachmentName;
}
}
Loading…
Cancel
Save