This commit is contained in:
dzc committed 2026-02-04 10:39:55 +08:00
commit 5e089029a0
5 files changed
+52 -5

No files matched your search

@@ -28,9 +28,6 @@ public class SysBannerAppVo {
@Schema(description = "跳转值(页面路径/外部链接)")
private String jumpValue;
@Schema(description = "跳转参数JSON格式")
private String params;
@Schema(description = "富文本内容(跳转到自编辑富文本页面时使用)")
private String richTextContent;
@@ -0,0 +1,24 @@
package com.bsd.pjcloud.integrated.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* 轮播图 App/外部接口配置
*
* @author pjcloud
* @date 2025-01-27
*/
@Data
@Component
@ConfigurationProperties(prefix = "pjcloud.banner-app")
public class BannerAppConfig {
/**
* 图片地址统一基础路径(如 https://cdn.example.com 或 https://your-domain.com/admin)
* 接口返回时会将 imageUrl 与此拼接:最终地址 = imageBaseUrl + imageUrl
* 不配置则不拼接,直接返回原始 imageUrl
*/
private String imageBaseUrl = "";
}
@@ -8,6 +8,7 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.integrated.config.BannerAppConfig;
import com.bsd.pjcloud.integrated.config.ExternalAppConfig;
import com.bsd.pjcloud.integrated.entity.SysBannerEntity;
import com.bsd.pjcloud.integrated.service.SysBannerService;
@@ -40,6 +41,7 @@ public class SysBannerController {
private final SysBannerService sysBannerService;
private final ExternalAppConfig externalAppConfig;
private final BannerAppConfig bannerAppConfig;
/**
* 分页查询
@@ -134,9 +136,28 @@ public class SysBannerController {
return R.failed("无效的应用ID或密钥");
}
String imageBaseUrl = bannerAppConfig.getImageBaseUrl();
boolean needPrefix = StrUtil.isNotBlank(imageBaseUrl);
String baseUrl = needPrefix ? imageBaseUrl.trim() : "";
List<SysBannerEntity> list = sysBannerService.listAppBanners();
List<SysBannerAppVo> voList = list.stream()
.map(e -> BeanUtils.toBean(e, SysBannerAppVo.class))
.map(e -> {
SysBannerAppVo vo = BeanUtils.toBean(e, SysBannerAppVo.class);
// imageUrl 前拼接统一基础路径
if (needPrefix && StrUtil.isNotBlank(e.getImageUrl())) {
String path = e.getImageUrl().trim();
if (!path.startsWith("http://") && !path.startsWith("https://")) {
String sep = baseUrl.endsWith("/") || path.startsWith("/") ? "" : "/";
vo.setImageUrl(baseUrl + sep + (path.startsWith("/") ? path.substring(1) : path));
} else {
vo.setImageUrl(path);
}
} else {
vo.setImageUrl(e.getImageUrl());
}
return vo;
})
.collect(Collectors.toList());
return R.ok(voList);
}
@@ -25,7 +25,7 @@ public class SysBannerEntity extends Model<SysBannerEntity> {
/**
* 主键ID
*/
@TableId(type = IdType.AUTO)
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键ID")
private Long id;
@@ -34,3 +34,8 @@ pjcloud:
appSecret: "550e8400-e29b-41d4-a716-446655440001"
appName: "通知公告"
enabled: true
banner-app:
# 图片基础路径,例如网关/域名,末尾可带或不带 /
image-base-url: "https://stgl.pj.gov.cn/api/"
# 或
# image-base-url: https://cdn.example.com/