From 15b7ab0a7409d899d767bf9c8cf3d3f6f1ac0e16 Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Mon, 29 Jul 2019 17:14:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6ID=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=97=AE=E9=A2=98=E5=92=8C=E4=B8=8A=E4=BC=A0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/apis/file/FileController.java | 10 +-- .../plugin/service/file/IFileService.java | 2 +- .../service/file/impl/FileServiceImpl.java | 5 +- .../java/com/cm/common/pojo/pos/FilePO.java | 86 +++++++++++-------- 4 files changed, 61 insertions(+), 42 deletions(-) diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/file/FileController.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/file/FileController.java index cbb70eb..40949e1 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/file/FileController.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/controller/apis/file/FileController.java @@ -39,7 +39,7 @@ public class FileController extends AbstractController { * @return */ @PostMapping("uploadfile") - public SuccessResultData uploadFile(@RequestParam("file") MultipartFile file) throws SystemException { + public SuccessResultData uploadFile(@RequestParam("file") MultipartFile file) throws SystemException { Map params = requestParams(); return uploadSingle(file, UploadTypeEnum.FILE, params); } @@ -51,7 +51,7 @@ public class FileController extends AbstractController { * @return */ @PostMapping("uploadimage") - public SuccessResultData uploadImage(@RequestParam("image") MultipartFile image) throws SystemException { + public SuccessResultData uploadImage(@RequestParam("image") MultipartFile image) throws SystemException { Map params = requestParams(); return uploadSingle(image, UploadTypeEnum.IMAGE, params); } @@ -63,7 +63,7 @@ public class FileController extends AbstractController { * @return */ @PostMapping("uploadvideo") - public SuccessResultData uploadVideo(@RequestParam("video") MultipartFile video) throws SystemException { + public SuccessResultData uploadVideo(@RequestParam("video") MultipartFile video) throws SystemException { Map params = requestParams(); return uploadSingle(video, UploadTypeEnum.VIDEO, params); } @@ -76,7 +76,7 @@ public class FileController extends AbstractController { * @throws SystemException */ @PostMapping("uploadaudio") - public SuccessResultData uploadAudio(@RequestParam("audio") MultipartFile audio) throws SystemException { + public SuccessResultData uploadAudio(@RequestParam("audio") MultipartFile audio) throws SystemException { Map params = requestParams(); return uploadSingle(audio, UploadTypeEnum.AUDIO, params); } @@ -88,7 +88,7 @@ public class FileController extends AbstractController { * @param params * @return */ - private SuccessResultData uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map params) throws SystemException { + private SuccessResultData uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map params) throws SystemException { return fileService.uploadSingle(uploadFile, uploadTypeEnum, params); } diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/IFileService.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/IFileService.java index 7e6a368..e88aa21 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/IFileService.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/IFileService.java @@ -82,7 +82,7 @@ public interface IFileService { * @return * @throws SystemException */ - SuccessResultData uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map params) throws SystemException; + SuccessResultData uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map params) throws SystemException; /** * 文件上传 diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/impl/FileServiceImpl.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/impl/FileServiceImpl.java index 34455ad..a4ab2aa 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/impl/FileServiceImpl.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/impl/FileServiceImpl.java @@ -57,9 +57,9 @@ public class FileServiceImpl extends AbstractService implements IFileService { private String[] fileTypes; @Override - public SuccessResultData uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map params) throws SystemException { + public SuccessResultData uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map params) throws SystemException { uploadFile(uploadFile, uploadTypeEnum, params); - return new SuccessResultData<>(Long.parseLong(params.get("fileId").toString())); + return new SuccessResultData<>(params.get("fileId").toString()); } @Override @@ -97,6 +97,7 @@ public class FileServiceImpl extends AbstractService implements IFileService { if (!uploadFile(uploadFile, uploadPath, uploadFileName)) { throw new SaveException("文件上传失败"); } + params.put("fileId", UUIDUtil.getUUID()); params.put("fileName", fileName); params.put("filePath", String.format("%s/%s", uploadPath, uploadFileName)); params.put("fileUrl", String.format("files/%s/%s", uploadPath.replace(fileProperties.getUploadPath(), ""), uploadFileName)); diff --git a/cloud-common/src/main/java/com/cm/common/pojo/pos/FilePO.java b/cloud-common/src/main/java/com/cm/common/pojo/pos/FilePO.java index b35afcf..12c8d67 100644 --- a/cloud-common/src/main/java/com/cm/common/pojo/pos/FilePO.java +++ b/cloud-common/src/main/java/com/cm/common/pojo/pos/FilePO.java @@ -9,7 +9,7 @@ package com.cm.common.pojo.pos; **/ public class FilePO { - private Long fileId; + private String fileId; private String fileName; private String filePath; private String fileUrl; @@ -17,76 +17,68 @@ public class FilePO { private String fileSize; private String fileSummary; private Integer isBack; - private Long creator; + private String creator; private String gmtCreate; - private Long modifier; + private String modifier; private String gmtModified; private Integer isDelete; - - public Long getFileId() { - return fileId; + public String getFileId() { + return fileId == null ? "" : fileId.trim(); } - public void setFileId(Long fileId) { + public void setFileId(String fileId) { this.fileId = fileId; } - public String getFileName() { - return fileName; + return fileName == null ? "" : fileName.trim(); } public void setFileName(String fileName) { this.fileName = fileName; } - public String getFilePath() { - return filePath; + return filePath == null ? "" : filePath.trim(); } public void setFilePath(String filePath) { this.filePath = filePath; } - public String getFileUrl() { - return fileUrl; + return fileUrl == null ? "" : fileUrl.trim(); } public void setFileUrl(String fileUrl) { this.fileUrl = fileUrl; } - public String getFileType() { - return fileType; + return fileType == null ? "" : fileType.trim(); } public void setFileType(String fileType) { this.fileType = fileType; } - public String getFileSize() { - return fileSize; + return fileSize == null ? "" : fileSize.trim(); } public void setFileSize(String fileSize) { this.fileSize = fileSize; } - public String getFileSummary() { - return fileSummary; + return fileSummary == null ? "" : fileSummary.trim(); } public void setFileSummary(String fileSummary) { this.fileSummary = fileSummary; } - public Integer getIsBack() { return isBack; } @@ -95,43 +87,38 @@ public class FilePO { this.isBack = isBack; } - - public Long getCreator() { - return creator; + public String getCreator() { + return creator == null ? "" : creator.trim(); } - public void setCreator(Long creator) { + public void setCreator(String creator) { this.creator = creator; } - public String getGmtCreate() { - return gmtCreate; + return gmtCreate == null ? "" : gmtCreate.trim(); } public void setGmtCreate(String gmtCreate) { this.gmtCreate = gmtCreate; } - - public Long getModifier() { - return modifier; + public String getModifier() { + return modifier == null ? "" : modifier.trim(); } - public void setModifier(Long modifier) { + public void setModifier(String modifier) { this.modifier = modifier; } - public String getGmtModified() { - return gmtModified; + return gmtModified == null ? "" : gmtModified.trim(); } public void setGmtModified(String gmtModified) { this.gmtModified = gmtModified; } - public Integer getIsDelete() { return isDelete; } @@ -140,5 +127,36 @@ public class FilePO { this.isDelete = isDelete; } - + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"fileId\":") + .append("\"").append(fileId).append("\""); + sb.append(",\"fileName\":") + .append("\"").append(fileName).append("\""); + sb.append(",\"filePath\":") + .append("\"").append(filePath).append("\""); + sb.append(",\"fileUrl\":") + .append("\"").append(fileUrl).append("\""); + sb.append(",\"fileType\":") + .append("\"").append(fileType).append("\""); + sb.append(",\"fileSize\":") + .append("\"").append(fileSize).append("\""); + sb.append(",\"fileSummary\":") + .append("\"").append(fileSummary).append("\""); + sb.append(",\"isBack\":") + .append(isBack); + sb.append(",\"creator\":") + .append("\"").append(creator).append("\""); + sb.append(",\"gmtCreate\":") + .append("\"").append(gmtCreate).append("\""); + sb.append(",\"modifier\":") + .append("\"").append(modifier).append("\""); + sb.append(",\"gmtModified\":") + .append("\"").append(gmtModified).append("\""); + sb.append(",\"isDelete\":") + .append(isDelete); + sb.append('}'); + return sb.toString(); + } }