Skip to content

Commit

Permalink
fix: 优化文件上传,删除冗余文件
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed Nov 22, 2022
1 parent 65d9efe commit 096ab34
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import cn.lili.common.utils.CommonUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.file.entity.File;
import cn.lili.modules.file.plugin.FilePlugin;
import cn.lili.modules.file.plugin.FilePluginFactory;
import cn.lili.modules.file.service.FileService;
import cn.lili.modules.system.entity.dos.Setting;
Expand Down Expand Up @@ -64,11 +63,14 @@ public ResultMessage<Object> upload(MultipartFile file,
if (authUser == null) {
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
}
if (file == null) {
throw new ServiceException(ResultCode.FILE_NOT_EXIST_ERROR);
}
Setting setting = settingService.get(SettingEnum.OSS_SETTING.name());
if (setting == null || CharSequenceUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException(ResultCode.OSS_NOT_EXIST);
}
if (file == null || CharSequenceUtil.isEmpty(file.getContentType())) {
if (CharSequenceUtil.isEmpty(file.getContentType())) {
throw new ServiceException(ResultCode.IMAGE_FILE_EXT_ERROR);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public enum ResultCode {
LIMIT_ERROR(1003, "访问过于频繁,请稍后再试"),
ILLEGAL_REQUEST_ERROR(1004, "非法请求,请重新刷新页面操作"),
IMAGE_FILE_EXT_ERROR(1005, "不支持图片格式"),
FILE_NOT_EXIST_ERROR(1011, "上传文件不能为空"),
FILE_TYPE_NOT_SUPPORT(1010, "不支持上传的文件类型!"),
PLATFORM_NOT_SUPPORTED_IM(1006, "平台未开启IM"),
STORE_NOT_SUPPORTED_IM(1007, "店铺未开启IM"),
Expand Down
Loading

0 comments on commit 096ab34

Please sign in to comment.