updated QrCodeSettings to have custom app store links

This commit is contained in:
dashevchenko 2024-10-22 17:17:06 +03:00
parent 73e93c2968
commit 101e46d547
3 changed files with 17 additions and 6 deletions

View File

@ -179,12 +179,12 @@ public class QrCodeSettingsController extends BaseController {
QrCodeSettings qrCodeSettings = qrCodeSettingService.findQrCodeSettings(TenantId.SYS_TENANT_ID);
boolean useDefaultApp = qrCodeSettings.isUseDefaultApp();
if (userAgent.contains("Android")) {
String googlePlayLink = useDefaultApp ? qrCodeSettings.getDefaultGooglePlayLink() : getStoreLink(qrCodeSettings.getMobileAppBundleId(), ANDROID);
String googlePlayLink = useDefaultApp ? qrCodeSettings.getGooglePlayLink() : getStoreLink(qrCodeSettings.getMobileAppBundleId(), ANDROID);
return ResponseEntity.status(HttpStatus.FOUND)
.header("Location", googlePlayLink)
.build();
} else if (userAgent.contains("iPhone") || userAgent.contains("iPad")) {
String appStoreLink = useDefaultApp ? qrCodeSettings.getDefaultAppStoreLink() : getStoreLink(qrCodeSettings.getMobileAppBundleId(), IOS);
String appStoreLink = useDefaultApp ? qrCodeSettings.getAppStoreLink() : getStoreLink(qrCodeSettings.getMobileAppBundleId(), IOS);
return ResponseEntity.status(HttpStatus.FOUND)
.header("Location", appStoreLink)
.build();

View File

@ -44,10 +44,10 @@ public class QrCodeSettings extends BaseData<QrCodeSettingsId> implements HasTen
private QRCodeConfig qrCodeConfig;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String defaultGooglePlayLink;
private String googlePlayLink;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private String defaultAppStoreLink;
private String appStoreLink;
public QrCodeSettings() {
}

View File

@ -31,6 +31,8 @@ import org.thingsboard.server.dao.service.DataValidator;
import java.util.Map;
import static org.thingsboard.server.common.data.oauth2.PlatformType.ANDROID;
import static org.thingsboard.server.common.data.oauth2.PlatformType.IOS;
import static org.thingsboard.server.dao.service.Validator.validateId;
@Service
@ -112,8 +114,17 @@ public class QrCodeSettingServiceImpl extends AbstractCachedEntityService<Tenant
qrCodeSettings.setMobileAppBundleId(qrCodeSettings.getMobileAppBundleId());
}
if (qrCodeSettings.isUseDefaultApp()) {
qrCodeSettings.setDefaultGooglePlayLink(googlePlayLink);
qrCodeSettings.setDefaultAppStoreLink(appStoreLink);
qrCodeSettings.setGooglePlayLink(googlePlayLink);
qrCodeSettings.setAppStoreLink(appStoreLink);
} else {
MobileApp androidApp = mobileAppService.findByBundleIdAndPlatformType(qrCodeSettings.getTenantId(), qrCodeSettings.getMobileAppBundleId(), ANDROID);
MobileApp iosApp = mobileAppService.findByBundleIdAndPlatformType(qrCodeSettings.getTenantId(), qrCodeSettings.getMobileAppBundleId(), IOS);
if (androidApp != null && androidApp.getStoreInfo() != null && androidApp.getStoreInfo().isEnabled()) {
qrCodeSettings.setGooglePlayLink(androidApp.getStoreInfo().getStoreLink());
}
if (iosApp != null && iosApp.getStoreInfo() != null && iosApp.getStoreInfo().isEnabled()) {
qrCodeSettings.setAppStoreLink(iosApp.getStoreInfo().getStoreLink());
}
}
return qrCodeSettings;
}