banner 新增types 区分
This commit is contained in:
parent
84f4cdf57f
commit
bbaaacc3e3
@ -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<BannerCO> listBanner(AppExtCommand cmd) {
|
||||
return appConfigService.listBanner(cmd);
|
||||
public List<BannerCO> listBanner(AppExtCommand cmd, String[] types) {
|
||||
return appConfigService.listBanner(cmd, types == null ? Collections.emptyList() : Arrays.stream(types).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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<BannerCO> execute(AppExtCommand cmd) {
|
||||
public List<BannerCO> execute(AppExtCommand cmd, List<String> 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<String> types = typeList == null || typeList.isEmpty() ? Arrays.asList("H5", "APP") : typeList;
|
||||
|
||||
List<BannerCache> list = bannerCacheService.listBannerCacheBySysOrigin(sysOrigin, reqClient, countryCode, () -> {
|
||||
List<BannerConfig> configs = listEffectiveCache(sysOrigin, reqClient, countryCode);
|
||||
List<BannerCache> list = bannerCacheService.listBannerCacheBySysOrigin(sysOrigin, reqClient, countryCode, types, () -> {
|
||||
List<BannerConfig> configs = listEffectiveCache(sysOrigin, reqClient, countryCode, types);
|
||||
if (CollectionUtils.isEmpty(configs)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
@ -60,8 +63,8 @@ public class BannerQryExe {
|
||||
|
||||
}
|
||||
|
||||
private List<BannerConfig> listEffectiveCache(String sysOrigin, String platform, String countryCode) {
|
||||
return bannerConfigService.listEffective(sysOrigin, platform, countryCode);
|
||||
private List<BannerConfig> listEffectiveCache(String sysOrigin, String platform, String countryCode, List<String> types) {
|
||||
return bannerConfigService.listEffective(sysOrigin, platform, countryCode, types);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -87,8 +87,8 @@ public class AppConfigServiceImpl implements AppConfigService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BannerCO> listBanner(AppExtCommand cmd) {
|
||||
return bannerQryExe.execute(cmd);
|
||||
public List<BannerCO> listBanner(AppExtCommand cmd, List<String> types) {
|
||||
return bannerQryExe.execute(cmd, types);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -35,7 +35,7 @@ public interface AppConfigService {
|
||||
|
||||
UserProfileDTO getCustomerService(AppExtCommand cmd);
|
||||
|
||||
List<BannerCO> listBanner(AppExtCommand cmd);
|
||||
List<BannerCO> listBanner(AppExtCommand cmd, List<String> types);
|
||||
|
||||
List<AppStartPageCO> listAppPageStart(AppExtCommand cmd);
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ public interface BannerCacheService {
|
||||
* @return banner
|
||||
*/
|
||||
List<BannerCache> listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode,
|
||||
VoidCallable<List<BannerCache>> orElsePut);
|
||||
List<String> types, VoidCallable<List<BannerCache>> orElsePut);
|
||||
|
||||
/**
|
||||
* 移除banner.
|
||||
|
||||
@ -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<String> types) {
|
||||
String typesKey = (types == null || types.isEmpty()) ? "ALL" : types.toString();
|
||||
return String.join("_", BannerKeys.BANNER.name(), sysOrigin, reqClient, countryCode, typesKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BannerCache> listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode, VoidCallable<List<BannerCache>> orElsePut) {
|
||||
public List<BannerCache> listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode, List<String> types, VoidCallable<List<BannerCache>> 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<List<BannerCache>>() {
|
||||
}))
|
||||
.map(bannerCaches -> bannerCaches.stream()
|
||||
@ -49,7 +50,7 @@ public class BannerCacheServiceImpl implements BannerCacheService {
|
||||
.orElseGet(() -> {
|
||||
List<BannerCache> 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;
|
||||
|
||||
@ -22,7 +22,7 @@ public interface BannerConfigService extends BaseService<BannerConfig> {
|
||||
* @param sysOrigin 来源系统
|
||||
* @return ignore
|
||||
*/
|
||||
List<BannerConfig> listEffective(String sysOrigin, String platform, String countryCode);
|
||||
List<BannerConfig> listEffective(String sysOrigin, String platform, String countryCode, List<String> types);
|
||||
|
||||
PageResult<BannerConfig> pageBanner(SysBannerConfigQryCmd query);
|
||||
|
||||
|
||||
@ -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<BannerConfigDAO, BannerConfig> implements BannerConfigService {
|
||||
|
||||
@Override
|
||||
public List<BannerConfig> listEffective(String sysOrigin, String platform, String countryCode) {
|
||||
public List<BannerConfig> listEffective(String sysOrigin, String platform, String countryCode, List<String> types) {
|
||||
return query()
|
||||
.eq(BannerConfig::getSysOrigin, sysOrigin)
|
||||
.in(CollectionUtils.isNotEmpty(types),BannerConfig::getType, types)
|
||||
.and(StringUtils.isNotBlank(platform), wrapper ->
|
||||
wrapper.in(BannerConfig::getPlatform, "", platform)
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user