banner 新增types 区分
This commit is contained in:
parent
84f4cdf57f
commit
bbaaacc3e3
@ -1,5 +1,6 @@
|
|||||||
package com.red.circle.other.adapter.app.sys;
|
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.core.ControllerRedisKeyConstant;
|
||||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||||
import com.red.circle.framework.core.dto.AppCommand;
|
import com.red.circle.framework.core.dto.AppCommand;
|
||||||
@ -184,8 +185,8 @@ public class AppConfigRestController extends BaseController {
|
|||||||
* @eo.request-type formdata
|
* @eo.request-type formdata
|
||||||
*/
|
*/
|
||||||
@GetMapping("/banner")
|
@GetMapping("/banner")
|
||||||
public List<BannerCO> listBanner(AppExtCommand cmd) {
|
public List<BannerCO> listBanner(AppExtCommand cmd, String[] types) {
|
||||||
return appConfigService.listBanner(cmd);
|
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.other.infra.database.rds.service.sys.BannerConfigService;
|
||||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||||
import com.red.circle.tool.core.text.StringUtils;
|
import com.red.circle.tool.core.text.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -38,16 +40,17 @@ public class BannerQryExe {
|
|||||||
private final OrderPurchaseHistoryClient orderPurchaseHistoryClient;
|
private final OrderPurchaseHistoryClient orderPurchaseHistoryClient;
|
||||||
private final UserProfileGateway userProfileGateway;
|
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());
|
UserProfile userProfile = userProfileGateway.getByUserId(cmd.requiredReqUserId());
|
||||||
String regionId = userRegionGateway.getRegionId(cmd.requiredReqUserId());
|
String regionId = userRegionGateway.getRegionId(cmd.requiredReqUserId());
|
||||||
ResponseAssert.notBlank(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR, regionId);
|
ResponseAssert.notBlank(CommonErrorCode.REGION_NOT_SUPPORTED_ERROR, regionId);
|
||||||
String reqClient = cmd.getReqClient().getClientName();
|
String reqClient = cmd.getReqClient().getClientName();
|
||||||
String sysOrigin = cmd.requireReqSysOrigin();
|
String sysOrigin = cmd.requireReqSysOrigin();
|
||||||
String countryCode = userProfile.getCountryCode();
|
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<BannerCache> list = bannerCacheService.listBannerCacheBySysOrigin(sysOrigin, reqClient, countryCode, types, () -> {
|
||||||
List<BannerConfig> configs = listEffectiveCache(sysOrigin, reqClient, countryCode);
|
List<BannerConfig> configs = listEffectiveCache(sysOrigin, reqClient, countryCode, types);
|
||||||
if (CollectionUtils.isEmpty(configs)) {
|
if (CollectionUtils.isEmpty(configs)) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
@ -60,8 +63,8 @@ public class BannerQryExe {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BannerConfig> listEffectiveCache(String sysOrigin, String platform, String countryCode) {
|
private List<BannerConfig> listEffectiveCache(String sysOrigin, String platform, String countryCode, List<String> types) {
|
||||||
return bannerConfigService.listEffective(sysOrigin, platform, countryCode);
|
return bannerConfigService.listEffective(sysOrigin, platform, countryCode, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,8 +87,8 @@ public class AppConfigServiceImpl implements AppConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BannerCO> listBanner(AppExtCommand cmd) {
|
public List<BannerCO> listBanner(AppExtCommand cmd, List<String> types) {
|
||||||
return bannerQryExe.execute(cmd);
|
return bannerQryExe.execute(cmd, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public interface AppConfigService {
|
|||||||
|
|
||||||
UserProfileDTO getCustomerService(AppExtCommand cmd);
|
UserProfileDTO getCustomerService(AppExtCommand cmd);
|
||||||
|
|
||||||
List<BannerCO> listBanner(AppExtCommand cmd);
|
List<BannerCO> listBanner(AppExtCommand cmd, List<String> types);
|
||||||
|
|
||||||
List<AppStartPageCO> listAppPageStart(AppExtCommand cmd);
|
List<AppStartPageCO> listAppPageStart(AppExtCommand cmd);
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public interface BannerCacheService {
|
|||||||
* @return banner
|
* @return banner
|
||||||
*/
|
*/
|
||||||
List<BannerCache> listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode,
|
List<BannerCache> listBannerCacheBySysOrigin(String sysOrigin, String reqClient, String countryCode,
|
||||||
VoidCallable<List<BannerCache>> orElsePut);
|
List<String> types, VoidCallable<List<BannerCache>> orElsePut);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除banner.
|
* 移除banner.
|
||||||
|
|||||||
@ -27,15 +27,16 @@ public class BannerCacheServiceImpl implements BannerCacheService {
|
|||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
|
|
||||||
|
|
||||||
private String getBannerKey(String sysOrigin, String reqClient, String countryCode) {
|
private String getBannerKey(String sysOrigin, String reqClient, String countryCode, List<String> types) {
|
||||||
return String.join("_", BannerKeys.BANNER.name(), sysOrigin, reqClient, countryCode);
|
String typesKey = (types == null || types.isEmpty()) ? "ALL" : types.toString();
|
||||||
|
return String.join("_", BannerKeys.BANNER.name(), sysOrigin, reqClient, countryCode, typesKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
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>>() {
|
new TypeReference<List<BannerCache>>() {
|
||||||
}))
|
}))
|
||||||
.map(bannerCaches -> bannerCaches.stream()
|
.map(bannerCaches -> bannerCaches.stream()
|
||||||
@ -49,7 +50,7 @@ public class BannerCacheServiceImpl implements BannerCacheService {
|
|||||||
.orElseGet(() -> {
|
.orElseGet(() -> {
|
||||||
List<BannerCache> bannerCaches = orElsePut.apply();
|
List<BannerCache> bannerCaches = orElsePut.apply();
|
||||||
if (CollectionUtils.isNotEmpty(bannerCaches)) {
|
if (CollectionUtils.isNotEmpty(bannerCaches)) {
|
||||||
redisService.hashPut(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin, reqClient, countryCode),
|
redisService.hashPut(BannerKeys.BANNER.getKey(), getBannerKey(sysOrigin, reqClient, countryCode, types),
|
||||||
bannerCaches);
|
bannerCaches);
|
||||||
}
|
}
|
||||||
return bannerCaches;
|
return bannerCaches;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public interface BannerConfigService extends BaseService<BannerConfig> {
|
|||||||
* @param sysOrigin 来源系统
|
* @param sysOrigin 来源系统
|
||||||
* @return ignore
|
* @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);
|
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.entity.sys.BannerConfig;
|
||||||
import com.red.circle.other.infra.database.rds.service.sys.BannerConfigService;
|
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.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.date.TimestampUtils;
|
||||||
import com.red.circle.tool.core.text.StringUtils;
|
import com.red.circle.tool.core.text.StringUtils;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -28,9 +29,10 @@ public class BannerConfigServiceImpl extends
|
|||||||
BaseServiceImpl<BannerConfigDAO, BannerConfig> implements BannerConfigService {
|
BaseServiceImpl<BannerConfigDAO, BannerConfig> implements BannerConfigService {
|
||||||
|
|
||||||
@Override
|
@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()
|
return query()
|
||||||
.eq(BannerConfig::getSysOrigin, sysOrigin)
|
.eq(BannerConfig::getSysOrigin, sysOrigin)
|
||||||
|
.in(CollectionUtils.isNotEmpty(types),BannerConfig::getType, types)
|
||||||
.and(StringUtils.isNotBlank(platform), wrapper ->
|
.and(StringUtils.isNotBlank(platform), wrapper ->
|
||||||
wrapper.in(BannerConfig::getPlatform, "", platform)
|
wrapper.in(BannerConfig::getPlatform, "", platform)
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user