feat 把后台的img path改为 adminapi

This commit is contained in:
damonyuan 2024-10-31 00:02:25 +08:00
parent 1d56225895
commit 340e049c9a
16 changed files with 87 additions and 43 deletions

View File

@ -72,7 +72,7 @@ public class ArticleServiceImpl implements IArticleService {
mpjQueryWrapper);
for (ArticleListedVo vo : iPage.getRecords()) {
vo.setImage(UrlUtils.toAbsoluteUrl(vo.getImage()));
vo.setImage(UrlUtils.toAdminAbsoluteUrl(vo.getImage()));
Integer clickActual = vo.getClickActual() != null ? vo.getClickActual() : 0;
@ -109,7 +109,7 @@ public class ArticleServiceImpl implements IArticleService {
ArticleDetailVo vo = new ArticleDetailVo();
BeanUtils.copyProperties(model, vo);
vo.setContent(StringUtils.isNull(model.getContent()) ? "" : model.getContent());
vo.setImage(UrlUtils.toAbsoluteUrl(model.getImage()));
vo.setImage(UrlUtils.toAdminAbsoluteUrl(model.getImage()));
vo.setCreateTime(TimeUtils.timestampToDate(model.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(model.getUpdateTime()));

View File

@ -32,7 +32,7 @@ public class ChannelMpConfigServiceImpl implements IChannelMpConfigService {
vo.setOriginalId(config.getOrDefault("original_id", ""));
vo.setAppId(envStatus ? "******" : config.getOrDefault("app_id", ""));
vo.setAppSecret(envStatus ? "******" : config.getOrDefault("app_secret", ""));
vo.setQrCode(UrlUtils.toAbsoluteUrl(config.getOrDefault("qr_code", "")));
vo.setQrCode(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("qr_code", "")));
String domain = RequestUtils.domain();
vo.setRequestDomain(domain);

View File

@ -29,7 +29,7 @@ public class ChannelOaConfigServiceImpl implements IChannelOaConfigService {
boolean envStatus = StringUtils.isNotNull(env) && env.equals("true");
String domain = RequestUtils.domain();
vo.setQrCode(UrlUtils.toAbsoluteUrl(config.getOrDefault("qr_code", "")));
vo.setQrCode(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("qr_code", "")));
vo.setName(config.getOrDefault("name", ""));
vo.setOriginalId(config.getOrDefault("original_id", ""));
vo.setAppId(envStatus ? "******" : config.getOrDefault("app_id", ""));

View File

@ -51,7 +51,7 @@ public class DecorateDataServiceImpl implements IDecorateDataService {
for (Article article : articles) {
DecorateDataArticleVo vo = new DecorateDataArticleVo();
BeanUtils.copyProperties(article, vo);
vo.setImage(UrlUtils.toAbsoluteUrl(vo.getImage()));
vo.setImage(UrlUtils.toAdminAbsoluteUrl(vo.getImage()));
Integer clickActual = vo.getClickActual() != null ? vo.getClickActual() : 0;

View File

@ -81,7 +81,7 @@ public class FileServiceImpl implements IFileService {
for (File file : iPage.getRecords()) {
FileVo vo = new FileVo();
BeanUtils.copyProperties(file, vo);
vo.setUrl(UrlUtils.toAbsoluteUrl(file.getUri()));
vo.setUrl(UrlUtils.toAdminAbsoluteUrl(file.getUri()));
if (engine.equals("local")) {
vo.setUri(GlobalConfig.adminPublicPrefix + "/" + file.getUri());

View File

@ -123,7 +123,7 @@ public class FinanceRechargerServiceImpl implements IFinanceRechargerService {
for (FinanceRechargeListVo vo : iPage.getRecords()) {
vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime()));
vo.setPayTime(TimeUtils.timestampToDate(vo.getPayTime()));
vo.setAvatar(UrlUtils.toAbsoluteUrl(vo.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(vo.getAvatar()));
vo.setPayWay(vo.getPayWay());
vo.setPayWayText(PaymentEnum.getPayWayMsg(Integer.parseInt(vo.getPayWay())));
vo.setPayStatusText(PaymentEnum.getPayStatusMsg(vo.getPayStatus()));
@ -390,7 +390,7 @@ public class FinanceRechargerServiceImpl implements IFinanceRechargerService {
.excelType(ExcelTypeEnum.XLSX)
.sheet("充值记录")
.doWrite(excellist);
return UrlUtils.toAbsoluteUrl(path);
return UrlUtils.toAdminAbsoluteUrl(path);
}
private List<FinanceRechargeListExportVo> getExcellist(boolean isAll, PageValidate pageValidate, FinanceRechargeSearchValidate searchValidate) {
@ -430,7 +430,7 @@ public class FinanceRechargerServiceImpl implements IFinanceRechargerService {
for (FinanceRechargeListExportVo vo : retList) {
vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime()));
vo.setPayTime(TimeUtils.timestampToDate(vo.getPayTime()));
vo.setAvatar(UrlUtils.toAbsoluteUrl(vo.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(vo.getAvatar()));
vo.setPayWay(vo.getPayWay());
vo.setPayWayText(PaymentEnum.getPayWayMsg(Integer.parseInt(vo.getPayWay())));
vo.setPayStatusText(PaymentEnum.getPayStatusMsg(vo.getPayStatus()));

View File

@ -63,7 +63,7 @@ public class FinanceWalletServiceImpl implements IFinanceWalletService {
for (FinanceWalletListVo vo : iPage.getRecords()) {
vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime()));
vo.setChangeTypeDesc(LogMoneyEnum.getMsgByCode(Integer.parseInt(vo.getChangeType())));
vo.setAvatar(UrlUtils.toAbsoluteUrl(vo.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(vo.getAvatar()));
}
Map<String, Object> extend = new LinkedHashMap<>();

View File

@ -65,49 +65,49 @@ public class IndexServiceImpl implements IIndexService {
add(new JSONObject() {{
put("name", "管理员");
put("image", UrlUtils.toAbsoluteUrl("/api/static/menu_admin.png"));
put("image", UrlUtils.toAdminAbsoluteUrl("/api/static/menu_admin.png"));
put("url", "/permission/admin");
}});
add(new JSONObject() {{
put("name", "角色管理");
put("image", UrlUtils.toAbsoluteUrl("/api/static/menu_role.png"));
put("image", UrlUtils.toAdminAbsoluteUrl("/api/static/menu_role.png"));
put("url", "/permission/role");
}});
add(new JSONObject() {{
put("name", "部门管理");
put("image", UrlUtils.toAbsoluteUrl("/api/static/menu_dept.png"));
put("image", UrlUtils.toAdminAbsoluteUrl("/api/static/menu_dept.png"));
put("url", "/organization/department");
}});
add(new JSONObject() {{
put("name", "字典管理");
put("image", UrlUtils.toAbsoluteUrl("/api/static/menu_dict.png"));
put("image", UrlUtils.toAdminAbsoluteUrl("/api/static/menu_dict.png"));
put("url", "/dev_tools/dict");
}});
add(new JSONObject() {{
put("name", "代码生成器");
put("image", UrlUtils.toAbsoluteUrl("/api/static/menu_generator.png"));
put("image", UrlUtils.toAdminAbsoluteUrl("/api/static/menu_generator.png"));
put("url", "/dev_tools/code");
}});
add(new JSONObject() {{
put("name", "素材中心");
put("image", UrlUtils.toAbsoluteUrl("/api/static/menu_file.png"));
put("image", UrlUtils.toAdminAbsoluteUrl("/api/static/menu_file.png"));
put("url", "/material/index");
}});
add(new JSONObject() {{
put("name", "菜单权限");
put("image", UrlUtils.toAbsoluteUrl("/api/static/menu_auth.png"));
put("image", UrlUtils.toAdminAbsoluteUrl("/api/static/menu_auth.png"));
put("url", "/permission/menu");
}});
add(new JSONObject() {{
put("name", "网站信息");
put("image", UrlUtils.toAbsoluteUrl("/api/static/menu_website.png"));
put("image", UrlUtils.toAdminAbsoluteUrl("/api/static/menu_website.png"));
put("url", "/setting/website/information");
}});
@ -137,11 +137,11 @@ public class IndexServiceImpl implements IIndexService {
// 网站名称
map.put("web_name", website.getOrDefault("name", ""));
// 网站图标
map.put("web_favicon", UrlUtils.toAbsoluteUrl(website.getOrDefault("web_favicon", "")));
map.put("web_favicon", UrlUtils.toAdminAbsoluteUrl(website.getOrDefault("web_favicon", "")));
// 网站logo
map.put("web_logo", UrlUtils.toAbsoluteUrl(website.getOrDefault("web_logo", "")));
map.put("web_logo", UrlUtils.toAdminAbsoluteUrl(website.getOrDefault("web_logo", "")));
// 登录页
map.put("login_image", UrlUtils.toAbsoluteUrl(website.getOrDefault("login_image", "")));
map.put("login_image", UrlUtils.toAdminAbsoluteUrl(website.getOrDefault("login_image", "")));
// 版权信息
map.put("copyright_config", ListUtils.stringToListAsMapStr(copyright));
return map;

View File

@ -59,7 +59,7 @@ public class SettingPaymentServiceImpl implements ISettingPaymentService {
SettingPaymentMethodVo vo = new SettingPaymentMethodVo();
BeanUtils.copyProperties(devPayWay, vo);
vo.setPayWayName(PaymentEnum.getPayWayMsg(devPayConfig.getPayWay()));
vo.setIcon(UrlUtils.toAbsoluteUrl(devPayConfig.getIcon()));
vo.setIcon(UrlUtils.toAdminAbsoluteUrl(devPayConfig.getIcon()));
switch (devPayWay.getScene()) {
case 1: // 微信小程序
@ -96,7 +96,7 @@ public class SettingPaymentServiceImpl implements ISettingPaymentService {
dev.setPayWayName(dev.getName());
dev.setName(PaymentEnum.getPayWayMsg(dev.getPayWay()));
dev.setConfig(JSONObject.parse("{}"));
dev.setIcon(UrlUtils.toAbsoluteUrl(dev.getIcon()));
dev.setIcon(UrlUtils.toAdminAbsoluteUrl(dev.getIcon()));
}
JSONObject result = new JSONObject() {{
@ -122,7 +122,7 @@ public class SettingPaymentServiceImpl implements ISettingPaymentService {
devPayConfig.setName(PaymentEnum.getPayWayMsg(devPayConfig.getPayWay()));
devPayConfig.setPayWayName(devPayConfig.getName());
devPayConfig.setConfig(JSONObject.parse(devPayConfig.getConfig().toString()));
devPayConfig.setIcon(UrlUtils.toAbsoluteUrl(devPayConfig.getIcon()));
devPayConfig.setIcon(UrlUtils.toAdminAbsoluteUrl(devPayConfig.getIcon()));
return devPayConfig;
}

View File

@ -23,7 +23,7 @@ public class SettingUserServiceImpl implements ISettingUserService {
public SettingUserVo getConfig() {
String defaultAvatar = ConfigUtils.get("default_image", "user_avatar", "");
SettingUserVo vo = new SettingUserVo();
vo.setDefaultAvatar(UrlUtils.toAbsoluteUrl(defaultAvatar));
vo.setDefaultAvatar(UrlUtils.toAdminAbsoluteUrl(defaultAvatar));
return vo;
}

View File

@ -26,17 +26,17 @@ public class SettingWebsiteServiceImpl implements ISettingWebsiteService {
Map<String, String> config = ConfigUtils.get("website");
SettingWebsiteVo vo = new SettingWebsiteVo();
vo.setName(config.getOrDefault("name", ""));
vo.setWebFavicon(UrlUtils.toAbsoluteUrl(config.getOrDefault("web_favicon", "")));
vo.setWebLogo(UrlUtils.toAbsoluteUrl(config.getOrDefault("web_logo", "")));
vo.setLoginImage(UrlUtils.toAbsoluteUrl(config.getOrDefault("login_image", "")));
vo.setWebFavicon(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("web_favicon", "")));
vo.setWebLogo(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("web_logo", "")));
vo.setLoginImage(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("login_image", "")));
vo.setShopName(config.getOrDefault("shop_name", ""));
vo.setShopLogo(UrlUtils.toAbsoluteUrl(config.getOrDefault("shop_logo", "")));
vo.setPcLogo(UrlUtils.toAbsoluteUrl(config.getOrDefault("pc_logo", "")));
vo.setShopLogo(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("shop_logo", "")));
vo.setPcLogo(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("pc_logo", "")));
vo.setPcTitle(config.getOrDefault("pc_title", ""));
vo.setPcIco(UrlUtils.toAbsoluteUrl(config.getOrDefault("pc_ico", "")));
vo.setPcIco(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("pc_ico", "")));
vo.setPcDesc(config.getOrDefault("pc_desc", ""));
vo.setPcKeywords(config.getOrDefault("pc_keywords", ""));
vo.setH5Favicon(UrlUtils.toAbsoluteUrl(config.getOrDefault("h5_favicon", "")));
vo.setH5Favicon(UrlUtils.toAdminAbsoluteUrl(config.getOrDefault("h5_favicon", "")));
return vo;
}

View File

@ -92,7 +92,7 @@ public class UserServiceImpl implements IUserService {
vo.setSex(user.getSex());
vo.setChannel(ClientEnum.getMsgByCode(user.getChannel()));
vo.setAvatar(UrlUtils.toAbsoluteUrl(user.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(user.getAvatar()));
vo.setLoginTime(TimeUtils.timestampToDate(user.getLoginTime()));
vo.setCreateTime(TimeUtils.timestampToDate(user.getCreateTime()));
list.add(vo);
@ -133,7 +133,7 @@ public class UserServiceImpl implements IUserService {
BeanUtils.copyProperties(user, vo);
vo.setSex(user.getSex());
vo.setAvatar(UrlUtils.toAbsoluteUrl(user.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(user.getAvatar()));
vo.setChannel(ClientEnum.getMsgByCode(user.getChannel()));
vo.setCreateTime(TimeUtils.timestampToDate(user.getCreateTime()));
if (user.getLoginTime() <= 0) {
@ -277,7 +277,7 @@ public class UserServiceImpl implements IUserService {
.excelType(ExcelTypeEnum.XLSX)
.sheet("用户记录")
.doWrite(excellist);
return UrlUtils.toAbsoluteUrl(path);
return UrlUtils.toAdminAbsoluteUrl(path);
}
private List<UserListExportVo> getExcellist(boolean isAll, PageValidate pageValidate, UserSearchValidate searchValidate) {
@ -319,7 +319,7 @@ public class UserServiceImpl implements IUserService {
BeanUtils.copyProperties(user, vo);
vo.setSex(user.getSex());
vo.setChannel(ClientEnum.getMsgByCode(user.getChannel()));
vo.setAvatar(UrlUtils.toAbsoluteUrl(user.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(user.getAvatar()));
vo.setLoginTime(TimeUtils.timestampToDate(user.getLoginTime()));
vo.setCreateTime(TimeUtils.timestampToDate(user.getCreateTime()));
retList.add(vo);

View File

@ -164,7 +164,7 @@ public class AdminServiceImpl implements IAdminService {
vo.setDisableDesc(vo.getDisable() != null && vo.getDisable().equals(0) ? "启用" : "禁用");
vo.setAvatar(UrlUtils.toAbsoluteUrl(vo.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(vo.getAvatar()));
vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(vo.getUpdateTime()));
vo.setLoginTime(TimeUtils.timestampToDate(vo.getLoginTime()));
@ -193,7 +193,7 @@ public class AdminServiceImpl implements IAdminService {
SystemAuthAdminInformVo systemAuthAdminInformVo = new SystemAuthAdminInformVo();
BeanUtils.copyProperties(sysAdmin, systemAuthAdminInformVo);
systemAuthAdminInformVo.setAvatar(UrlUtils.toAbsoluteUrl(sysAdmin.getAvatar()));
systemAuthAdminInformVo.setAvatar(UrlUtils.toAdminAbsoluteUrl(sysAdmin.getAvatar()));
systemAuthAdminInformVo.setUpdateTime(TimeUtils.timestampToDate(sysAdmin.getUpdateTime()));
systemAuthAdminInformVo.setCreateTime(TimeUtils.timestampToDate(sysAdmin.getCreateTime()));
systemAuthAdminInformVo.setLastLoginTime(TimeUtils.timestampToDate(sysAdmin.getLoginTime()));
@ -251,7 +251,7 @@ public class AdminServiceImpl implements IAdminService {
SystemAuthAdminDetailVo vo = new SystemAuthAdminDetailVo();
BeanUtils.copyProperties(sysAdmin, vo);
vo.setAvatar(UrlUtils.toAbsoluteUrl(sysAdmin.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(sysAdmin.getAvatar()));
vo.setCreateTime(TimeUtils.timestampToDate(sysAdmin.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(sysAdmin.getUpdateTime()));
vo.setLoginTime(TimeUtils.timestampToDate(sysAdmin.getLoginTime()));
@ -552,7 +552,7 @@ public class AdminServiceImpl implements IAdminService {
.excelType(ExcelTypeEnum.XLSX)
.sheet("管理员记录")
.doWrite(excellist);
return UrlUtils.toAbsoluteUrl(path);
return UrlUtils.toAdminAbsoluteUrl(path);
}
private List<SystemAuthAdminListedExportVo> getExcellist(boolean isAll, PageValidate pageValidate, SystemAdminSearchValidate searchValidate) {
@ -637,7 +637,7 @@ public class AdminServiceImpl implements IAdminService {
vo.setDisableDesc(vo.getDisable() != null && vo.getDisable().equals(0) ? "启用" : "禁用");
vo.setAvatar(UrlUtils.toAbsoluteUrl(vo.getAvatar()));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(vo.getAvatar()));
vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime()));
vo.setUpdateTime(TimeUtils.timestampToDate(vo.getUpdateTime()));
vo.setLoginTime(TimeUtils.timestampToDate(vo.getLoginTime()));

View File

@ -263,7 +263,7 @@ public class JobsServiceImpl implements IJobsService {
.excelType(ExcelTypeEnum.XLSX)
.sheet("用户记录")
.doWrite(excellist);
return UrlUtils.toAbsoluteUrl(path);
return UrlUtils.toAdminAbsoluteUrl(path);
}
private List<JobsExportVo> getExcellist(boolean isAll, PageValidate pageValidate, JobsSearchValidate searchValidate) {
Integer page = pageValidate.getPage_no();

View File

@ -138,7 +138,7 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
SystemLoginVo vo = new SystemLoginVo();
vo.setId(sysAdmin.getId());
vo.setName(sysAdmin.getName());
vo.setAvatar(UrlUtils.toAbsoluteUrl(avatar));
vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(avatar));
vo.setToken(StpUtil.getTokenValue());
vo.setRoleName(ListUtils.listToStringByStr(iSystemRoleService.getRoleNameByAdminId(sysAdmin.getId()), "/"));
return vo;

View File

@ -13,6 +13,7 @@ public class UrlUtils {
* 访问前缀
*/
private static final String uploadPrefix = GlobalConfig.publicPrefix;
private static final String uploadAdminPrefix = GlobalConfig.adminPublicPrefix;
/**
* 转绝对路径
@ -36,6 +37,10 @@ public class UrlUtils {
return RequestUtils.uri() + url;
}
if (url.startsWith("/adminapi/")) {
return RequestUtils.uri() + url.replace("/adminapi/", "/api/");
}
String engine = ConfigUtils.get("storage", "default", "local");
engine = engine.equals("") ? "local" : engine;
if (engine.equals("local")) {
@ -49,6 +54,45 @@ public class UrlUtils {
return url;
}
/**
* 转绝对路径
* 转前: uploads/11.png
* 转后: https://127.0.0.1/uploads/11.png
*
* @author fzr
* @param url 相对路径
* @return String
*/
public static String toAdminAbsoluteUrl(String url) {
if (url == null || url.equals("")) {
return "";
}
if(url.indexOf("/") != 0) {
url = "/" + url;
}
if (url.startsWith("/api/static/")) {
return RequestUtils.uri() + url.replace("/api/static/", "/adminapi/static/");
}
String engine = ConfigUtils.get("storage", "default", "local");
engine = engine.equals("") ? "local" : engine;
if (engine.equals("local")) {
System.out.println(url);
if (url.startsWith("/adminapi/uploads/")) {
return RequestUtils.uri() + url;
} else {
return RequestUtils.uri() + "/" + uploadAdminPrefix + url;
}
}
Map<String, String> config = ConfigUtils.getMap("storage", engine);
if (config != null) {
return config.getOrDefault("domain", "") + url;
}
return url;
}
/**
* 转相对路径
* 转前: https://127.0.0.1/uploads/11.png