轮播图

This commit is contained in:
zjf committed 2026-02-03 22:01:11 +08:00
1 parent 32702677fd
commit 8cadef4bcd
4 files changed
+28 -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;
@@ -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/