fix(deploy): identify development wallet runtime
This commit is contained in:
@@ -7,6 +7,7 @@ x-common: &common
|
|||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
environment: &common-environment
|
environment: &common-environment
|
||||||
|
DEPLOY_ENV: ${DEPLOY_ENV:-test}
|
||||||
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-cn}
|
SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE:-cn}
|
||||||
NACOS_SERVER_ADDR: ${NACOS_SERVER_ADDR}
|
NACOS_SERVER_ADDR: ${NACOS_SERVER_ADDR}
|
||||||
NACOS_USERNAME: ${NACOS_USERNAME}
|
NACOS_USERNAME: ${NACOS_USERNAME}
|
||||||
|
|||||||
@@ -56,14 +56,15 @@ public class FinanceWalletService {
|
|||||||
@Value("${baiyue.security.internal-service-token:}") String internalToken,
|
@Value("${baiyue.security.internal-service-token:}") String internalToken,
|
||||||
@Value("${baiyue.finance.recharge.wechat-qr-code-url:}") String wechatQrCodeUrl,
|
@Value("${baiyue.finance.recharge.wechat-qr-code-url:}") String wechatQrCodeUrl,
|
||||||
@Value("${baiyue.finance.recharge.alipay-qr-code-url:}") String alipayQrCodeUrl,
|
@Value("${baiyue.finance.recharge.alipay-qr-code-url:}") String alipayQrCodeUrl,
|
||||||
@Value("${spring.profiles.active:}") String activeProfiles) {
|
@Value("${spring.profiles.active:}") String activeProfiles,
|
||||||
|
@Value("${DEPLOY_ENV:}") String deployEnvironment) {
|
||||||
this.jdbc = jdbc;
|
this.jdbc = jdbc;
|
||||||
this.objectMapper = objectMapper;
|
this.objectMapper = objectMapper;
|
||||||
this.fileClient = fileClient;
|
this.fileClient = fileClient;
|
||||||
this.numberGenerator = numberGenerator;
|
this.numberGenerator = numberGenerator;
|
||||||
this.internalToken = internalToken;
|
this.internalToken = internalToken;
|
||||||
boolean development = List.of(activeProfiles.split(",")).stream()
|
boolean development = "development".equalsIgnoreCase(deployEnvironment.trim())
|
||||||
.map(String::trim).anyMatch("dev"::equalsIgnoreCase);
|
|| List.of(activeProfiles.split(",")).stream().map(String::trim).anyMatch("dev"::equalsIgnoreCase);
|
||||||
this.wechatQrCodeUrl = rechargeQrCode(wechatQrCodeUrl, development);
|
this.wechatQrCodeUrl = rechargeQrCode(wechatQrCodeUrl, development);
|
||||||
this.alipayQrCodeUrl = rechargeQrCode(alipayQrCodeUrl, development);
|
this.alipayQrCodeUrl = rechargeQrCode(alipayQrCodeUrl, development);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class FinanceWalletBehaviorTest {
|
|||||||
@Test
|
@Test
|
||||||
void developmentProfileUsesTheNonPayableSampleQrCode() {
|
void developmentProfileUsesTheNonPayableSampleQrCode() {
|
||||||
var channels = new FinanceWalletService(mock(JdbcTemplate.class), new ObjectMapper().findAndRegisterModules(),
|
var channels = new FinanceWalletService(mock(JdbcTemplate.class), new ObjectMapper().findAndRegisterModules(),
|
||||||
mock(FinanceFileClient.class), mock(FinanceDocumentNumberGenerator.class), "token", "", "", "dev").channels();
|
mock(FinanceFileClient.class), mock(FinanceDocumentNumberGenerator.class), "token", "", "", "cn", "development").channels();
|
||||||
|
|
||||||
assertThat(channels).allSatisfy(channel -> {
|
assertThat(channels).allSatisfy(channel -> {
|
||||||
assertThat(channel.enabled()).isTrue();
|
assertThat(channel.enabled()).isTrue();
|
||||||
@@ -83,6 +83,6 @@ class FinanceWalletBehaviorTest {
|
|||||||
|
|
||||||
private static FinanceWalletService service(JdbcTemplate jdbc, String wechat, String alipay) {
|
private static FinanceWalletService service(JdbcTemplate jdbc, String wechat, String alipay) {
|
||||||
return new FinanceWalletService(jdbc, new ObjectMapper().findAndRegisterModules(),
|
return new FinanceWalletService(jdbc, new ObjectMapper().findAndRegisterModules(),
|
||||||
mock(FinanceFileClient.class), mock(FinanceDocumentNumberGenerator.class), "token", wechat, alipay, "test");
|
mock(FinanceFileClient.class), mock(FinanceDocumentNumberGenerator.class), "token", wechat, alipay, "test", "test");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user