|
|
|
|
@ -14,6 +14,7 @@ import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.SpringUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.core.utils.file.FileUtils;
|
|
|
|
|
import org.dromara.common.json.utils.JsonUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
import org.dromara.common.oss.core.OssClient;
|
|
|
|
|
@ -21,6 +22,7 @@ import org.dromara.common.oss.entity.UploadResult;
|
|
|
|
|
import org.dromara.common.oss.enums.AccessPolicyType;
|
|
|
|
|
import org.dromara.common.oss.factory.OssFactory;
|
|
|
|
|
import org.dromara.resource.domain.SysOss;
|
|
|
|
|
import org.dromara.resource.domain.SysOssExt;
|
|
|
|
|
import org.dromara.resource.domain.bo.SysOssBo;
|
|
|
|
|
import org.dromara.resource.domain.vo.SysOssVo;
|
|
|
|
|
import org.dromara.resource.mapper.SysOssMapper;
|
|
|
|
|
@ -177,8 +179,11 @@ public class SysOssServiceImpl implements ISysOssService {
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new ServiceException(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
SysOssExt ext1 = new SysOssExt();
|
|
|
|
|
ext1.setFileSize(file.getSize());
|
|
|
|
|
ext1.setContentType(file.getContentType());
|
|
|
|
|
// 保存文件信息
|
|
|
|
|
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult);
|
|
|
|
|
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult, ext1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -193,17 +198,20 @@ public class SysOssServiceImpl implements ISysOssService {
|
|
|
|
|
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
|
|
|
|
|
OssClient storage = OssFactory.instance();
|
|
|
|
|
UploadResult uploadResult = storage.uploadSuffix(file, suffix);
|
|
|
|
|
SysOssExt ext1 = new SysOssExt();
|
|
|
|
|
ext1.setFileSize(file.length());
|
|
|
|
|
// 保存文件信息
|
|
|
|
|
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult);
|
|
|
|
|
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult, ext1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SysOssVo buildResultEntity(String originalfileName, String suffix, String configKey, UploadResult uploadResult) {
|
|
|
|
|
private SysOssVo buildResultEntity(String originalfileName, String suffix, String configKey, UploadResult uploadResult, SysOssExt ext1) {
|
|
|
|
|
SysOss oss = new SysOss();
|
|
|
|
|
oss.setUrl(uploadResult.getUrl());
|
|
|
|
|
oss.setFileSuffix(suffix);
|
|
|
|
|
oss.setFileName(uploadResult.getFilename());
|
|
|
|
|
oss.setOriginalName(originalfileName);
|
|
|
|
|
oss.setService(configKey);
|
|
|
|
|
oss.setExt1(JsonUtils.toJsonString(ext1));
|
|
|
|
|
baseMapper.insert(oss);
|
|
|
|
|
SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class);
|
|
|
|
|
return this.matchingUrl(sysOssVo);
|
|
|
|
|
|