文档库--上传文件限制
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);
|
||||
public OSSFile uploadLocal(MultipartFile mf, String bizPath,String state);
|
||||
|
||||
|
||||
public List<OSSFile> getFileInfos(String id);
|
||||
|
||||
+19
-1
@@ -30,6 +30,12 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
@Value(value = "${jero.path.upload}")
|
||||
private String uploadpath;
|
||||
|
||||
/**
|
||||
* 文件后缀黑名单
|
||||
*/
|
||||
@Value(value="${jero.fileSuffixLimits}")
|
||||
private String[] fileSuffixLimits;
|
||||
|
||||
@Override
|
||||
public void upload(MultipartFile multipartFile) throws IOException {
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
@@ -51,7 +57,7 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public OSSFile uploadLocal(MultipartFile mf, String bizPath) {
|
||||
public OSSFile uploadLocal(MultipartFile mf, String bizPath,String state) {
|
||||
|
||||
//处理文件大小,大于100M抛出异常
|
||||
long fileSize = mf.getSize() / 1024 / 1024;
|
||||
@@ -78,7 +84,19 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
|
||||
}
|
||||
|
||||
fileType = orgName.substring(orgName.lastIndexOf("."));
|
||||
String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF";
|
||||
//判断文件类型
|
||||
if("0".equals(state)){
|
||||
//固定文件
|
||||
if(!fileTypeStr.contains(fileType)){
|
||||
throw new JeroBootException("只能够上传pdf,word,excel类型的文件。请重新选择文件!");
|
||||
}
|
||||
}else{
|
||||
if (CommonUtils.limitFileSuffix(orgName, fileSuffixLimits)) {
|
||||
throw new JeroBootException("不能上传"+StringUtils.join(fileSuffixLimits, ",")+"类型的文件。请重新选择文件!");
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(fileType)) {
|
||||
String[] fileTypeArr = {".doc",".DOC",".txt",".TXT", ".docx",".DOCX",
|
||||
".xls", ".XLS",".xlsx",".XLSX", ".pdf",".PDF", ".png",".PNG",
|
||||
|
||||
+2
-2
@@ -137,7 +137,7 @@ public class CommonController {
|
||||
*/
|
||||
@ApiOperation(value="文件上传统一方法", notes="文件上传统一方法")
|
||||
@PostMapping(value = "/upload")
|
||||
public Result<?> upload(HttpServletRequest request, HttpServletResponse response) {
|
||||
public Result<?> upload(HttpServletRequest request, HttpServletResponse response,String state) {
|
||||
Result<OSSFile> result = new Result<>();
|
||||
String bizPath = request.getParameter("biz");
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
@@ -150,7 +150,7 @@ public class CommonController {
|
||||
bizPath = "";
|
||||
}
|
||||
}
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath);
|
||||
OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath,state);
|
||||
if (oConvertUtils.isNotEmpty(oSSFile)) {
|
||||
result.setResult(oSSFile);
|
||||
result.setSuccess(true);
|
||||
|
||||
+7
-1
@@ -394,7 +394,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
//字段属性
|
||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(flag);
|
||||
//文件类型字段
|
||||
List<OnlCgformField> fieldFileList = fieldList.stream().filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
List<OnlCgformField> onlCgformFieldList = fieldList.stream().filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
List<String> fieldFileList = onlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
//过滤出字段为树形结构的
|
||||
|
||||
if (fieldList.size() != 0) {
|
||||
@@ -458,6 +459,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
mapPut(cut, map, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, sysCategoryTreeVOList);
|
||||
map.put("field_must_input", onlCgformField.getFieldMustInput());//是否必填
|
||||
map.put("db_length", onlCgformField.getDbLength());//字段长度
|
||||
if(fieldFileList.contains(onlCgformField.getDbFieldName()) && onlCgformField.getIsReadOnly()==1){
|
||||
map.put("flag", "1");//固定文件标识
|
||||
}else if(fieldFileList.contains(onlCgformField.getDbFieldName()) && onlCgformField.getIsReadOnly()==0){
|
||||
map.put("flag", "0");//非固定文件字段
|
||||
}
|
||||
result.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user