修改文件ID类型问题和上传问题

This commit is contained in:
wenc000 2019-07-29 17:14:10 +08:00
parent b57c568437
commit 15b7ab0a74
4 changed files with 61 additions and 42 deletions

View File

@ -39,7 +39,7 @@ public class FileController extends AbstractController {
* @return
*/
@PostMapping("uploadfile")
public SuccessResultData<Long> uploadFile(@RequestParam("file") MultipartFile file) throws SystemException {
public SuccessResultData<String> uploadFile(@RequestParam("file") MultipartFile file) throws SystemException {
Map<String, Object> params = requestParams();
return uploadSingle(file, UploadTypeEnum.FILE, params);
}
@ -51,7 +51,7 @@ public class FileController extends AbstractController {
* @return
*/
@PostMapping("uploadimage")
public SuccessResultData<Long> uploadImage(@RequestParam("image") MultipartFile image) throws SystemException {
public SuccessResultData<String> uploadImage(@RequestParam("image") MultipartFile image) throws SystemException {
Map<String, Object> params = requestParams();
return uploadSingle(image, UploadTypeEnum.IMAGE, params);
}
@ -63,7 +63,7 @@ public class FileController extends AbstractController {
* @return
*/
@PostMapping("uploadvideo")
public SuccessResultData<Long> uploadVideo(@RequestParam("video") MultipartFile video) throws SystemException {
public SuccessResultData<String> uploadVideo(@RequestParam("video") MultipartFile video) throws SystemException {
Map<String, Object> params = requestParams();
return uploadSingle(video, UploadTypeEnum.VIDEO, params);
}
@ -76,7 +76,7 @@ public class FileController extends AbstractController {
* @throws SystemException
*/
@PostMapping("uploadaudio")
public SuccessResultData<Long> uploadAudio(@RequestParam("audio") MultipartFile audio) throws SystemException {
public SuccessResultData<String> uploadAudio(@RequestParam("audio") MultipartFile audio) throws SystemException {
Map<String, Object> params = requestParams();
return uploadSingle(audio, UploadTypeEnum.AUDIO, params);
}
@ -88,7 +88,7 @@ public class FileController extends AbstractController {
* @param params
* @return
*/
private SuccessResultData<Long> uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException {
private SuccessResultData<String> uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException {
return fileService.uploadSingle(uploadFile, uploadTypeEnum, params);
}

View File

@ -82,7 +82,7 @@ public interface IFileService {
* @return
* @throws SystemException
*/
SuccessResultData<Long> uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException;
SuccessResultData<String> uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException;
/**
* 文件上传

View File

@ -57,9 +57,9 @@ public class FileServiceImpl extends AbstractService implements IFileService {
private String[] fileTypes;
@Override
public SuccessResultData<Long> uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException {
public SuccessResultData<String> uploadSingle(MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> 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));

View File

@ -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();
}
}