From bbaaacc3e36dc422a6cc7bcd3e83b282c890c1fa Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 2 Mar 2026 14:27:40 +0800 Subject: [PATCH] =?UTF-8?q?banner=20=E6=96=B0=E5=A2=9Etypes=20=E5=8C=BA?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/app/sys/AppConfigRestController.java | 5 +++-- .../other/app/command/sys/query/BannerQryExe.java | 13 ++++++++----- .../other/app/service/sys/AppConfigServiceImpl.java | 4 ++-- .../other/app/service/sys/AppConfigService.java | 2 +- .../cache/service/other/BannerCacheService.java | 2 +- .../service/other/impl/BannerCacheServiceImpl.java | 11 ++++++----- .../rds/service/sys/BannerConfigService.java | 2 +- .../service/sys/impl/BannerConfigServiceImpl.java | 4 +++- 8 files changed, 25 insertions(+), 18 deletions(-) diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/sys/AppConfigRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/sys/AppConfigRestController.java index a5b3629e..2e150a43 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/sys/AppConfigRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/sys/AppConfigRestController.java @@ -1,5 +1,6 @@ package com.red.circle.other.adapter.app.sys; +import cn.hutool.core.collection.ListUtil; import com.red.circle.common.business.core.ControllerRedisKeyConstant; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.framework.core.dto.AppCommand; @@ -184,8 +185,8 @@ public class AppConfigRestController extends BaseController { * @eo.request-type formdata */ @GetMapping("/banner") - public List listBanner(AppExtCommand cmd) { - return appConfigService.listBanner(cmd); + public List listBanner(AppExtCommand cmd, String[] types) { + return appConfigService.listBanner(cmd, types == null ? Collections.emptyList() : Arrays.stream(types).toList()); } /** diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/BannerQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/BannerQryExe.java index 419412e8..dd6e0bb7 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/BannerQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/sys/query/BannerQryExe.java @@ -16,6 +16,8 @@ import com.red.circle.other.infra.database.rds.entity.sys.BannerConfig; import com.red.circle.other.infra.database.rds.service.sys.BannerConfigService; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.text.StringUtils; + +import java.util.Arrays; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -38,16 +40,17 @@ public class BannerQryExe { private final OrderPurchaseHistoryClient orderPurchaseHistoryClient; private final UserProfileGateway userProfileGateway; - public List execute(AppExtCommand cmd) { + public List execute(AppExtCommand cmd, List typeList) { UserProfile userProfile = userProfileGateway.getByUserId(cmd.requiredReqUserId()); String regionId = userRegionGateway.getRegionId(cmd.requiredReqUserId()); ResponseAssert.notBlank(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR, regionId); String reqClient = cmd.getReqClient().getClientName(); String sysOrigin = cmd.requireReqSysOrigin(); String countryCode = userProfile.getCountryCode(); + List types = typeList == null || typeList.isEmpty() ? Arrays.asList("H5", "APP") : typeList; - List list = bannerCacheService.listBannerCacheBySysOrigin(sysOrigin, reqClient, countryCode, () -> { - List configs = listEffectiveCache(sysOrigin, reqClient, countryCode); + List list = bannerCacheService.listBannerCacheBySysOrigin(sysOrigin, reqClient, countryCode, types, () -> { + List configs = listEffectiveCache(sysOrigin, reqClient, countryCode, types); if (CollectionUtils.isEmpty(configs)) { return Lists.newArrayList(); } @@ -60,8 +63,8 @@ public class BannerQryExe { } - private List listEffectiveCache(String sysOrigin, String platform, String countryCode) { - return bannerConfigService.listEffective(sysOrigin, platform, countryCode); + private List listEffectiveCache(String sysOrigin, String platform, String countryCode, List types) { + return bannerConfigService.listEffective(sysOrigin, platform, countryCode, types); } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/sys/AppConfigServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/sys/AppConfigServiceImpl.java index b9d4adb9..e6113b8c 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/sys/AppConfigServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/sys/AppConfigServiceImpl.java @@ -87,8 +87,8 @@ public class AppConfigServiceImpl implements AppConfigService { } @Override - public List listBanner(AppExtCommand cmd) { - return bannerQryExe.execute(cmd); + public List listBanner(AppExtCommand cmd, List types) { + return bannerQryExe.execute(cmd, types); } @Override diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/sys/AppConfigService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/sys/AppConfigService.java index a16a6a1e..b7e0a251 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/sys/AppConfigService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/sys/AppConfigService.java @@ -35,7 +35,7 @@ public interface AppConfigService { UserProfileDTO getCustomerService(AppExtCommand cmd); - List listBanner(AppExtCommand cmd); + List listBanner(AppExtCommand cmd, List types); List listAppPageStart(AppExtCommand cmd); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/BannerCacheService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/BannerCacheService.java index 4c9011dc..4ee667a7 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/BannerCacheService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/BannerCacheService.java @@ -19,7 +19,7 @@ public interface BannerCacheService { * @return banner */ List listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode, - VoidCallable> orElsePut); + List types, VoidCallable> orElsePut); /** * 移除banner. diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/BannerCacheServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/BannerCacheServiceImpl.java index 676ed428..53fdd381 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/BannerCacheServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/BannerCacheServiceImpl.java @@ -27,15 +27,16 @@ public class BannerCacheServiceImpl implements BannerCacheService { private final RedisService redisService; - private String getBannerKey(String sysOrigin, String reqClient, String countryCode) { - return String.join("_", BannerKeys.BANNER.name(), sysOrigin, reqClient, countryCode); + private String getBannerKey(String sysOrigin, String reqClient, String countryCode, List types) { + String typesKey = (types == null || types.isEmpty()) ? "ALL" : types.toString(); + return String.join("_", BannerKeys.BANNER.name(), sysOrigin, reqClient, countryCode, typesKey); } @Override - public List listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode, VoidCallable> orElsePut) { + public List listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode, List types, VoidCallable> orElsePut) { return Optional - .ofNullable(redisService.hashGet(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin, reqClient, countryCode), + .ofNullable(redisService.hashGet(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin, reqClient, countryCode, types), new TypeReference>() { })) .map(bannerCaches -> bannerCaches.stream() @@ -49,7 +50,7 @@ public class BannerCacheServiceImpl implements BannerCacheService { .orElseGet(() -> { List bannerCaches = orElsePut.apply(); if (CollectionUtils.isNotEmpty(bannerCaches)) { - redisService.hashPut(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin, reqClient, countryCode), + redisService.hashPut(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin, reqClient, countryCode, types), bannerCaches); } return bannerCaches; diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/BannerConfigService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/BannerConfigService.java index 5d26d5be..b9ca1de0 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/BannerConfigService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/BannerConfigService.java @@ -22,7 +22,7 @@ public interface BannerConfigService extends BaseService { * @param sysOrigin 来源系统 * @return ignore */ - List listEffective(String sysOrigin, String platform, String countryCode); + List listEffective(String sysOrigin, String platform, String countryCode, List types); PageResult pageBanner(SysBannerConfigQryCmd query); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/BannerConfigServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/BannerConfigServiceImpl.java index 376e81c4..3e93c2fe 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/BannerConfigServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/sys/impl/BannerConfigServiceImpl.java @@ -7,6 +7,7 @@ import com.red.circle.other.infra.database.rds.dao.sys.BannerConfigDAO; import com.red.circle.other.infra.database.rds.entity.sys.BannerConfig; import com.red.circle.other.infra.database.rds.service.sys.BannerConfigService; import com.red.circle.other.inner.model.cmd.sys.SysBannerConfigQryCmd; +import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.text.StringUtils; import java.time.LocalDateTime; @@ -28,9 +29,10 @@ public class BannerConfigServiceImpl extends BaseServiceImpl implements BannerConfigService { @Override - public List listEffective(String sysOrigin, String platform, String countryCode) { + public List listEffective(String sysOrigin, String platform, String countryCode, List types) { return query() .eq(BannerConfig::getSysOrigin, sysOrigin) + .in(CollectionUtils.isNotEmpty(types),BannerConfig::getType, types) .and(StringUtils.isNotBlank(platform), wrapper -> wrapper.in(BannerConfig::getPlatform, "", platform) )