refactor(update): 移除包名校验逻辑简化版本检查接口
- 移除了 AppVersionController 中的 packageName 参数验证 - 简化了 resolveAndValidate 方法的参数列表 - 删除了包名校验相关的业务逻辑和异常抛出 - 移除了对 tenantClient 平台信息的包名校验调用 - 更新了方法签名以减少参数传递复杂度
这个提交包含在:
父节点
978f919e4c
当前提交
e75aa66747
@ -60,11 +60,10 @@ public class AppVersionController {
|
|||||||
@RequestParam(required = false) String appKey,
|
@RequestParam(required = false) String appKey,
|
||||||
@RequestParam AppVersionEntity.Platform platform,
|
@RequestParam AppVersionEntity.Platform platform,
|
||||||
@RequestParam int currentVersionCode,
|
@RequestParam int currentVersionCode,
|
||||||
@RequestParam @jakarta.validation.constraints.NotBlank String packageName,
|
|
||||||
@RequestParam(required = false) String licenseFile,
|
@RequestParam(required = false) String licenseFile,
|
||||||
@RequestParam(required = false) String userId) {
|
@RequestParam(required = false) String userId) {
|
||||||
|
|
||||||
String resolvedAppKey = resolveAndValidate(appKey, platform, packageName, licenseFile);
|
String resolvedAppKey = resolveAndValidate(appKey, platform, licenseFile);
|
||||||
boolean allowAnonymousCheck = publishConfigService.allowAnonymousUpdateCheck(resolvedAppKey);
|
boolean allowAnonymousCheck = publishConfigService.allowAnonymousUpdateCheck(resolvedAppKey);
|
||||||
|
|
||||||
Optional<AppVersionEntity> latest = versionRepository
|
Optional<AppVersionEntity> latest = versionRepository
|
||||||
@ -494,26 +493,14 @@ public class AppVersionController {
|
|||||||
return currentStatus == AppVersionEntity.PublishStatus.PUBLISHED ? "PUBLISH" : "SAVE_DRAFT";
|
return currentStatus == AppVersionEntity.PublishStatus.PUBLISHED ? "PUBLISH" : "SAVE_DRAFT";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveAndValidate(String appKey, AppVersionEntity.Platform platform, String packageName, String licenseFile) {
|
private String resolveAndValidate(String appKey, AppVersionEntity.Platform platform, String licenseFile) {
|
||||||
if (hasText(licenseFile)) {
|
if (hasText(licenseFile)) {
|
||||||
LicenseFileCrypto.LicensePayload payload = LicenseFileCrypto.decrypt(licenseFile);
|
LicenseFileCrypto.LicensePayload payload = LicenseFileCrypto.decrypt(licenseFile);
|
||||||
if (!payload.matchesPackageName(packageName)) {
|
|
||||||
throw new BusinessException(403, "包名与应用配置不匹配");
|
|
||||||
}
|
|
||||||
return payload.appKey();
|
return payload.appKey();
|
||||||
}
|
}
|
||||||
if (!hasText(appKey)) {
|
if (!hasText(appKey)) {
|
||||||
throw new BusinessException(400, "appKey 或 licenseFile 必须提供其中一个");
|
throw new BusinessException(400, "appKey 或 licenseFile 必须提供其中一个");
|
||||||
}
|
}
|
||||||
UpdateTenantClient.PlatformInfo info = tenantClient.getPlatformInfo(appKey);
|
|
||||||
String registered = switch (platform) {
|
|
||||||
case IOS -> info.iosBundleId();
|
|
||||||
case HARMONY -> info.harmonyBundleName();
|
|
||||||
default -> info.androidPackageName();
|
|
||||||
};
|
|
||||||
if (hasText(registered) && !registered.equals(packageName)) {
|
|
||||||
throw new BusinessException(403, "包名与应用配置不匹配");
|
|
||||||
}
|
|
||||||
return appKey;
|
return appKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户