修改文件ID类型问题和上传问题
This commit is contained in:
parent
b57c568437
commit
15b7ab0a74
@ -39,7 +39,7 @@ public class FileController extends AbstractController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("uploadfile")
|
@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();
|
Map<String, Object> params = requestParams();
|
||||||
return uploadSingle(file, UploadTypeEnum.FILE, params);
|
return uploadSingle(file, UploadTypeEnum.FILE, params);
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ public class FileController extends AbstractController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("uploadimage")
|
@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();
|
Map<String, Object> params = requestParams();
|
||||||
return uploadSingle(image, UploadTypeEnum.IMAGE, params);
|
return uploadSingle(image, UploadTypeEnum.IMAGE, params);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class FileController extends AbstractController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("uploadvideo")
|
@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();
|
Map<String, Object> params = requestParams();
|
||||||
return uploadSingle(video, UploadTypeEnum.VIDEO, params);
|
return uploadSingle(video, UploadTypeEnum.VIDEO, params);
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class FileController extends AbstractController {
|
|||||||
* @throws SystemException
|
* @throws SystemException
|
||||||
*/
|
*/
|
||||||
@PostMapping("uploadaudio")
|
@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();
|
Map<String, Object> params = requestParams();
|
||||||
return uploadSingle(audio, UploadTypeEnum.AUDIO, params);
|
return uploadSingle(audio, UploadTypeEnum.AUDIO, params);
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ public class FileController extends AbstractController {
|
|||||||
* @param params
|
* @param params
|
||||||
* @return
|
* @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);
|
return fileService.uploadSingle(uploadFile, uploadTypeEnum, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public interface IFileService {
|
|||||||
* @return
|
* @return
|
||||||
* @throws SystemException
|
* @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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传
|
* 文件上传
|
||||||
|
@ -57,9 +57,9 @@ public class FileServiceImpl extends AbstractService implements IFileService {
|
|||||||
private String[] fileTypes;
|
private String[] fileTypes;
|
||||||
|
|
||||||
@Override
|
@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);
|
uploadFile(uploadFile, uploadTypeEnum, params);
|
||||||
return new SuccessResultData<>(Long.parseLong(params.get("fileId").toString()));
|
return new SuccessResultData<>(params.get("fileId").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -97,6 +97,7 @@ public class FileServiceImpl extends AbstractService implements IFileService {
|
|||||||
if (!uploadFile(uploadFile, uploadPath, uploadFileName)) {
|
if (!uploadFile(uploadFile, uploadPath, uploadFileName)) {
|
||||||
throw new SaveException("文件上传失败");
|
throw new SaveException("文件上传失败");
|
||||||
}
|
}
|
||||||
|
params.put("fileId", UUIDUtil.getUUID());
|
||||||
params.put("fileName", fileName);
|
params.put("fileName", fileName);
|
||||||
params.put("filePath", String.format("%s/%s", uploadPath, uploadFileName));
|
params.put("filePath", String.format("%s/%s", uploadPath, uploadFileName));
|
||||||
params.put("fileUrl", String.format("files/%s/%s", uploadPath.replace(fileProperties.getUploadPath(), ""), uploadFileName));
|
params.put("fileUrl", String.format("files/%s/%s", uploadPath.replace(fileProperties.getUploadPath(), ""), uploadFileName));
|
||||||
|
@ -9,7 +9,7 @@ package com.cm.common.pojo.pos;
|
|||||||
**/
|
**/
|
||||||
public class FilePO {
|
public class FilePO {
|
||||||
|
|
||||||
private Long fileId;
|
private String fileId;
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private String filePath;
|
private String filePath;
|
||||||
private String fileUrl;
|
private String fileUrl;
|
||||||
@ -17,76 +17,68 @@ public class FilePO {
|
|||||||
private String fileSize;
|
private String fileSize;
|
||||||
private String fileSummary;
|
private String fileSummary;
|
||||||
private Integer isBack;
|
private Integer isBack;
|
||||||
private Long creator;
|
private String creator;
|
||||||
private String gmtCreate;
|
private String gmtCreate;
|
||||||
private Long modifier;
|
private String modifier;
|
||||||
private String gmtModified;
|
private String gmtModified;
|
||||||
private Integer isDelete;
|
private Integer isDelete;
|
||||||
|
|
||||||
|
public String getFileId() {
|
||||||
public Long getFileId() {
|
return fileId == null ? "" : fileId.trim();
|
||||||
return fileId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileId(Long fileId) {
|
public void setFileId(String fileId) {
|
||||||
this.fileId = fileId;
|
this.fileId = fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return fileName;
|
return fileName == null ? "" : fileName.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileName(String fileName) {
|
public void setFileName(String fileName) {
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getFilePath() {
|
public String getFilePath() {
|
||||||
return filePath;
|
return filePath == null ? "" : filePath.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilePath(String filePath) {
|
public void setFilePath(String filePath) {
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getFileUrl() {
|
public String getFileUrl() {
|
||||||
return fileUrl;
|
return fileUrl == null ? "" : fileUrl.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileUrl(String fileUrl) {
|
public void setFileUrl(String fileUrl) {
|
||||||
this.fileUrl = fileUrl;
|
this.fileUrl = fileUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getFileType() {
|
public String getFileType() {
|
||||||
return fileType;
|
return fileType == null ? "" : fileType.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileType(String fileType) {
|
public void setFileType(String fileType) {
|
||||||
this.fileType = fileType;
|
this.fileType = fileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getFileSize() {
|
public String getFileSize() {
|
||||||
return fileSize;
|
return fileSize == null ? "" : fileSize.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileSize(String fileSize) {
|
public void setFileSize(String fileSize) {
|
||||||
this.fileSize = fileSize;
|
this.fileSize = fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getFileSummary() {
|
public String getFileSummary() {
|
||||||
return fileSummary;
|
return fileSummary == null ? "" : fileSummary.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileSummary(String fileSummary) {
|
public void setFileSummary(String fileSummary) {
|
||||||
this.fileSummary = fileSummary;
|
this.fileSummary = fileSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getIsBack() {
|
public Integer getIsBack() {
|
||||||
return isBack;
|
return isBack;
|
||||||
}
|
}
|
||||||
@ -95,43 +87,38 @@ public class FilePO {
|
|||||||
this.isBack = isBack;
|
this.isBack = isBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCreator() {
|
||||||
public Long getCreator() {
|
return creator == null ? "" : creator.trim();
|
||||||
return creator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreator(Long creator) {
|
public void setCreator(String creator) {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getGmtCreate() {
|
public String getGmtCreate() {
|
||||||
return gmtCreate;
|
return gmtCreate == null ? "" : gmtCreate.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGmtCreate(String gmtCreate) {
|
public void setGmtCreate(String gmtCreate) {
|
||||||
this.gmtCreate = gmtCreate;
|
this.gmtCreate = gmtCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getModifier() {
|
||||||
public Long getModifier() {
|
return modifier == null ? "" : modifier.trim();
|
||||||
return modifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModifier(Long modifier) {
|
public void setModifier(String modifier) {
|
||||||
this.modifier = modifier;
|
this.modifier = modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getGmtModified() {
|
public String getGmtModified() {
|
||||||
return gmtModified;
|
return gmtModified == null ? "" : gmtModified.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGmtModified(String gmtModified) {
|
public void setGmtModified(String gmtModified) {
|
||||||
this.gmtModified = gmtModified;
|
this.gmtModified = gmtModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getIsDelete() {
|
public Integer getIsDelete() {
|
||||||
return isDelete;
|
return isDelete;
|
||||||
}
|
}
|
||||||
@ -140,5 +127,36 @@ public class FilePO {
|
|||||||
this.isDelete = isDelete;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user