This commit is contained in:
hy001 2026-04-24 13:03:52 +08:00
parent 19adf21dfd
commit 28ae34e2fa
3 changed files with 77 additions and 3 deletions

View File

@ -23,8 +23,11 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
public class RoomRegionFilterCommon {
// account 1001041
private static final Set<Long> ALL_REGION_ROOM_WHITELIST_USER_IDS = Set.of(2044700023064686594L);
// account 1001041, 1001545
private static final Set<Long> ALL_REGION_ROOM_WHITELIST_USER_IDS = Set.of(
2044700023064686594L,
2047206645188063233L
);
private final UserRegionGateway userRegionGateway;

View File

@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
public class BaishunRuntimeConfigResolver {
private static final String DEFAULT_SYS_ORIGIN = SysOriginPlatformEnum.LIKEI.name();
private static final String LUCKY_GIFT_START_GAME_PATH = "/lucky_gift/start_game";
private final BaishunProviderConfigService baishunProviderConfigService;
private final GameBaishunProperties gameBaishunProperties;
@ -51,7 +52,7 @@ public class BaishunRuntimeConfigResolver {
ApiAccount resolved = new ApiAccount();
resolved.setStandardId(base.getStandardId());
resolved.setUrl(base.getUrl());
resolved.setUrl(defaultIfBlank(resolveLuckyGiftApiUrl(config.getPlatformBaseUrl()), base.getUrl()));
resolved.setAppId(defaultIfBlank(config.getAppId(), base.getAppId()));
resolved.setAppChannel(defaultIfBlank(config.getAppChannel(), base.getAppChannel()));
resolved.setAppKey(defaultIfBlank(config.getAppKey(), base.getAppKey()));
@ -83,6 +84,26 @@ public class BaishunRuntimeConfigResolver {
.build();
}
private String resolveLuckyGiftApiUrl(String platformBaseUrl) {
String baseUrl = trim(platformBaseUrl);
if (StringUtils.isBlank(baseUrl)) {
return null;
}
String normalized = trimTrailingSlash(baseUrl);
if (normalized.endsWith(LUCKY_GIFT_START_GAME_PATH)) {
return normalized;
}
return normalized + LUCKY_GIFT_START_GAME_PATH;
}
private String trimTrailingSlash(String value) {
String result = trim(value);
while (StringUtils.isNotBlank(result) && result.endsWith("/")) {
result = result.substring(0, result.length() - 1);
}
return result;
}
private String normalizeSysOrigin(String sysOrigin) {
return StringUtils.isBlank(sysOrigin) ? DEFAULT_SYS_ORIGIN : sysOrigin.trim();
}

View File

@ -0,0 +1,50 @@
package com.red.circle.other.app.service.game;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.red.circle.component.game.baishun.props.GameBaishunProperties;
import com.red.circle.other.infra.config.LuckyGiftApiConfig;
import com.red.circle.other.infra.config.LuckyGiftApiConfig.ApiAccount;
import com.red.circle.other.infra.database.rds.entity.game.BaishunProviderConfig;
import com.red.circle.other.infra.database.rds.service.game.BaishunProviderConfigService;
import org.junit.jupiter.api.Test;
class BaishunRuntimeConfigResolverTest {
@Test
void resolveLuckyGiftApiAccountUsesActiveBaishunProviderConfig() {
BaishunProviderConfigService providerConfigService = mock(BaishunProviderConfigService.class);
GameBaishunProperties gameBaishunProperties = mock(GameBaishunProperties.class);
LuckyGiftApiConfig luckyGiftApiConfig = mock(LuckyGiftApiConfig.class);
BaishunRuntimeConfigResolver resolver = new BaishunRuntimeConfigResolver(
providerConfigService,
gameBaishunProperties,
luckyGiftApiConfig
);
ApiAccount fallback = new ApiAccount();
fallback.setStandardId(99L);
fallback.setUrl("https://legacy.example.com/lucky_gift/start_game");
fallback.setAppId("legacy-app");
fallback.setAppChannel("legacy-channel");
fallback.setAppKey("legacy-key");
when(luckyGiftApiConfig.getConfigByStandardId(99L)).thenReturn(fallback);
when(providerConfigService.getBySysOrigin("LIKEI")).thenReturn(new BaishunProviderConfig()
.setSysOrigin("LIKEI")
.setPlatformBaseUrl("https://provider.example.com/")
.setAppId(4581045902L)
.setAppChannel("yumiparty")
.setAppKey("provider-key"));
ApiAccount resolved = resolver.resolveLuckyGiftApiAccount("LIKEI", 99L);
assertEquals(99L, resolved.getStandardId());
assertEquals("https://provider.example.com/lucky_gift/start_game", resolved.getUrl());
assertEquals("4581045902", resolved.getAppId());
assertEquals("yumiparty", resolved.getAppChannel());
assertEquals("provider-key", resolved.getAppKey());
}
}