文件上传--英文提示语
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ public interface IOSSFileService extends IService<OSSFile> {
|
||||
* @param bizPath 自定义路径
|
||||
* @return
|
||||
*/
|
||||
public OSSFile uploadLocal(MultipartFile mf, String bizPath,String state);
|
||||
public OSSFile uploadLocal(MultipartFile mf, String bizPath,String state,String cut);
|
||||
|
||||
|
||||
public List<OSSFile> getFileInfos(String id);
|
||||
|
||||
+22
-6
@@ -2,6 +2,7 @@ package com.jero.modules.oss.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.CommonUtils;
|
||||
@@ -57,13 +58,17 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OSSFile uploadLocal(MultipartFile mf, String bizPath,String state) {
|
||||
public OSSFile uploadLocal(MultipartFile mf, String bizPath,String state,String cut) {
|
||||
|
||||
//处理文件大小,大于100M抛出异常
|
||||
long fileSize = mf.getSize() / 1024 / 1024;
|
||||
String originalFilename = mf.getOriginalFilename();
|
||||
if (fileSize >= 100) {
|
||||
throw new JeroBootException(originalFilename + "文件大小超出100MB限制, 请压缩或降低文件质量!");
|
||||
if(cut.equals(CutEnum.CN.getValue())){
|
||||
throw new JeroBootException(originalFilename + "文件大小超出100MB, 请压缩或降低文件质量!");
|
||||
}else{
|
||||
throw new JeroBootException(originalFilename + "File size out 100MB, Please compress or reduce file quality!");
|
||||
}
|
||||
}
|
||||
|
||||
OSSFile oSSFile = new OSSFile();
|
||||
@@ -89,11 +94,19 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
if("1".equals(state)){
|
||||
//固定文件
|
||||
if(!fileTypeStr.contains(fileType)){
|
||||
throw new JeroBootException("只能够上传pdf,word,excel类型的文件。请重新选择文件!");
|
||||
if(cut.equals(CutEnum.CN.getValue())){
|
||||
throw new JeroBootException("只能够上传pdf,word,excel类型的文件。请重新选择文件!");
|
||||
}else{
|
||||
throw new JeroBootException("Only upload pdf,word,excel type of file Please select the file again!");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (CommonUtils.limitFileSuffix(orgName, fileSuffixLimits)) {
|
||||
throw new JeroBootException("不能上传"+StringUtils.join(fileSuffixLimits, ",")+"类型的文件。请重新选择文件!");
|
||||
if(cut.equals(CutEnum.CN.getValue())){
|
||||
throw new JeroBootException("不能上传"+StringUtils.join(fileSuffixLimits, ",")+"类型的文件。请重新选择文件!");
|
||||
}else{
|
||||
throw new JeroBootException("Can't upload"+StringUtils.join(fileSuffixLimits, ",")+"type of file Please select the file again!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,9 +122,12 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
throw new JeroBootException("只能够上传pdf/word/excel/csv/ppt/txt/zip/rar/静态图片类型的文件。请重新选择文件!");
|
||||
if(cut.equals(CutEnum.CN.getValue())){
|
||||
throw new JeroBootException("只能够上传pdf/word/excel/csv/ppt/txt/zip/rar/静态图片类型的文件。请重新选择文件!");
|
||||
}else{
|
||||
throw new JeroBootException("Only upload pdf/word/excel/csv/ppt/txt/zip/rar/静态图片类型的文件。请重新选择文件!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String savePath = file.getPath() + File.separator + fileName;
|
||||
|
||||
+9
-3
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.api.ISysBaseAPI;
|
||||
import com.jero.common.util.RestUtil;
|
||||
@@ -150,7 +151,8 @@ public class CommonController {
|
||||
@ApiOperation(value="文件上传统一方法", notes="文件上传统一方法")
|
||||
@PostMapping(value = "/upload")
|
||||
public Result<?> upload(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam(value = "state",required = false) String state) {
|
||||
@RequestParam(value = "state",required = false) String state,
|
||||
@RequestParam(value = "cut",required = false) String cut) {
|
||||
Result<OSSFile> result = new Result<>();
|
||||
String bizPath = request.getParameter("biz");
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
@@ -163,12 +165,16 @@ public class CommonController {
|
||||
bizPath = "";
|
||||
}
|
||||
}
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath,state);
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath,state,cut);
|
||||
if (oConvertUtils.isNotEmpty(oSSFile)) {
|
||||
result.setResult(oSSFile);
|
||||
result.setSuccess(true);
|
||||
} else {
|
||||
result.setMessage("上传失败!");
|
||||
if("cut".equals(CutEnum.CN.getValue())){
|
||||
result.setMessage("上传失败!");
|
||||
}else{
|
||||
result.setMessage("fail to upload!");
|
||||
}
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
|
||||
+1
-1
@@ -4030,7 +4030,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
MultipartFile multipartFile =
|
||||
new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input);
|
||||
//文件存入文件表
|
||||
OSSFile ossFile = iOSSFileService.uploadLocal(multipartFile, "", null);
|
||||
OSSFile ossFile = iOSSFileService.uploadLocal(multipartFile, "", null,null);
|
||||
if (ObjectUtils.isNotEmpty(ossFile)) {
|
||||
sb.append(ossFile.getId() + ",");
|
||||
}
|
||||
|
||||
+8
@@ -1,11 +1,14 @@
|
||||
package com.jero.modules.project.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
|
||||
import com.jero.modules.project.mapper.ProjectRelatedPersonnelMapper;
|
||||
import com.jero.modules.project.service.IProjectRelatedPersonnelService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
@@ -86,4 +89,9 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
|
||||
public List<ProjectRelatedPersonnel> queryList() {
|
||||
return list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ProjectRelatedPersonnel> queryPageList(Map<String, Object> params) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1109,7 +1109,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
// if (fileTypeStr.contains(fileSuffix)) {
|
||||
// state = "1";
|
||||
// }
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "",state);
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "",state,null);
|
||||
if(oSSFile!=null){
|
||||
oSSFile = ossFileService.getById(oSSFile.getId());
|
||||
isText = false;
|
||||
@@ -1154,7 +1154,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
// if (fileTypeStr.contains(fileSuffix)) {
|
||||
// state = "1";
|
||||
// }
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "", state);
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "", state,null);
|
||||
oSSFile = ossFileService.getById(oSSFile.getId());
|
||||
if (oSSFile != null) {
|
||||
oSSFile = ossFileService.getById(oSSFile.getId());
|
||||
@@ -1198,7 +1198,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
String url = nowfilelist.get(0).getPath();
|
||||
MultipartFile multipartFile = createMfileByPath(url);
|
||||
String state = "0";
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "", state);
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(multipartFile, "", state,null);
|
||||
oSSFile = ossFileService.getById(oSSFile.getId());
|
||||
if (oSSFile != null) {
|
||||
isText = false;
|
||||
@@ -1920,7 +1920,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
MultipartFile multipartFile =
|
||||
new MockMultipartFile(nowFileList.get(0).getName(), nowFileList.get(0).getName(), "text/plain", input);
|
||||
//文件存入文件表
|
||||
OSSFile ossFile = ossFileService.uploadLocal(multipartFile, "", null);
|
||||
OSSFile ossFile = ossFileService.uploadLocal(multipartFile, "", null,null);
|
||||
if (ObjectUtils.isNotEmpty(ossFile)) {
|
||||
sb.append(ossFile.getId() + ",");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user