fix: 修复静态资源映射错误
This commit is contained in:
parent
cd97ea8873
commit
224f4504d9
@ -42,6 +42,7 @@ import top.charles7c.continew.admin.system.model.resp.FileResp;
|
|||||||
import top.charles7c.continew.admin.system.model.resp.StorageDetailResp;
|
import top.charles7c.continew.admin.system.model.resp.StorageDetailResp;
|
||||||
import top.charles7c.continew.admin.system.service.FileService;
|
import top.charles7c.continew.admin.system.service.FileService;
|
||||||
import top.charles7c.continew.admin.system.service.StorageService;
|
import top.charles7c.continew.admin.system.service.StorageService;
|
||||||
|
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||||
import top.charles7c.continew.starter.core.util.URLUtils;
|
import top.charles7c.continew.starter.core.util.URLUtils;
|
||||||
import top.charles7c.continew.starter.core.util.validate.CheckUtils;
|
import top.charles7c.continew.starter.core.util.validate.CheckUtils;
|
||||||
import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl;
|
import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl;
|
||||||
@ -106,7 +107,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
|||||||
// 处理本地存储文件 URL
|
// 处理本地存储文件 URL
|
||||||
FileInfo fileInfo = uploadPretreatment.upload();
|
FileInfo fileInfo = uploadPretreatment.upload();
|
||||||
fileInfo.setUrl(StorageTypeEnum.LOCAL.equals(storage.getType())
|
fileInfo.setUrl(StorageTypeEnum.LOCAL.equals(storage.getType())
|
||||||
? URLUtil.normalize(storage.getDomain() + fileInfo.getUrl()) : fileInfo.getUrl());
|
? URLUtil.normalize(storage.getDomain() + StringConstants.SLASH + fileInfo.getUrl()) : fileInfo.getUrl());
|
||||||
return fileInfo;
|
return fileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
|||||||
protected void fill(Object baseObj) {
|
protected void fill(Object baseObj) {
|
||||||
if (baseObj instanceof FileResp fileResp && !URLUtils.isHttpUrl(fileResp.getUrl())) {
|
if (baseObj instanceof FileResp fileResp && !URLUtils.isHttpUrl(fileResp.getUrl())) {
|
||||||
StorageDetailResp storage = storageService.get(fileResp.getStorageId());
|
StorageDetailResp storage = storageService.get(fileResp.getStorageId());
|
||||||
fileResp.setUrl(URLUtil.normalize(storage.getDomain() + fileResp.getUrl()));
|
fileResp.setUrl(URLUtil.normalize(storage.getDomain() + StringConstants.SLASH + fileResp.getUrl()));
|
||||||
}
|
}
|
||||||
super.fill(baseObj);
|
super.fill(baseObj);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,6 @@ public class StorageServiceImpl
|
|||||||
ValidationUtils.throwIfBlank(bucketName, "存储路径不能为空");
|
ValidationUtils.throwIfBlank(bucketName, "存储路径不能为空");
|
||||||
ValidationUtils.throwIfBlank(domain, "自定义域名不能为空");
|
ValidationUtils.throwIfBlank(domain, "自定义域名不能为空");
|
||||||
ValidationUtils.throwIf(!URLUtils.isHttpUrl(domain), "自定义域名格式错误");
|
ValidationUtils.throwIf(!URLUtils.isHttpUrl(domain), "自定义域名格式错误");
|
||||||
req.setDomain(StrUtil.appendIfMissing(domain, StringConstants.SLASH));
|
|
||||||
req.setBucketName(StrUtil.appendIfMissing(
|
req.setBucketName(StrUtil.appendIfMissing(
|
||||||
bucketName.replace(StringConstants.BACKSLASH, StringConstants.SLASH), StringConstants.SLASH));
|
bucketName.replace(StringConstants.BACKSLASH, StringConstants.SLASH), StringConstants.SLASH));
|
||||||
FileStorageProperties.LocalPlusConfig config = new FileStorageProperties.LocalPlusConfig();
|
FileStorageProperties.LocalPlusConfig config = new FileStorageProperties.LocalPlusConfig();
|
||||||
|
@ -20,5 +20,5 @@ VALUES
|
|||||||
INSERT IGNORE INTO `sys_storage`
|
INSERT IGNORE INTO `sys_storage`
|
||||||
(`id`, `name`, `code`, `type`, `access_key`, `secret_key`, `endpoint`, `bucket_name`, `domain`, `description`, `is_default`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`)
|
(`id`, `name`, `code`, `type`, `access_key`, `secret_key`, `endpoint`, `bucket_name`, `domain`, `description`, `is_default`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file/', '本地存储', b'1', 1, 1, 1, NOW(), NULL, NULL),
|
(1, '开发环境', 'local_dev', 2, NULL, NULL, NULL, 'C:/continew-admin/data/file/', 'http://localhost:8000/file', '本地存储', b'1', 1, 1, 1, NOW(), NULL, NULL),
|
||||||
(2, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.charles7c.top/file/', '本地存储', b'0', 2, 2, 1, NOW(), NULL, NULL);
|
(2, '生产环境', 'local_prod', 2, NULL, NULL, NULL, '../data/file/', 'http://api.charles7c.top/file', '本地存储', b'0', 2, 2, 1, NOW(), NULL, NULL);
|
Loading…
Reference in New Issue
Block a user