refactor(update): 移除版本重复检查并修改发布状态逻辑
- 移除了应用包名和版本号的重复上传检查逻辑 - 修改了发布立即生效时的状态变更机制,改为将其他已发布版本标记为废弃状态 - 新增了按应用键、平台和发布状态查询的方法 - 简化了版本上传时的验证流程,移除了APK文件MD5比较相关代码
这个提交包含在:
父节点
e5d9e0da0c
当前提交
24e11794bc
@ -148,28 +148,6 @@ public class AppVersionController {
|
|||||||
if (platform == AppVersionEntity.Platform.ANDROID && !hasText(apkUrl) && (apkFile == null || apkFile.isEmpty())) {
|
if (platform == AppVersionEntity.Platform.ANDROID && !hasText(apkUrl) && (apkFile == null || apkFile.isEmpty())) {
|
||||||
throw new IllegalArgumentException("apkUrl or apkFile is required for ANDROID releases");
|
throw new IllegalArgumentException("apkUrl or apkFile is required for ANDROID releases");
|
||||||
}
|
}
|
||||||
// Duplicate version check
|
|
||||||
if (hasText(resolvedPackageName)) {
|
|
||||||
java.util.Optional<AppVersionEntity> existing = versionRepository
|
|
||||||
.findByAppKeyAndPlatformAndPackageNameAndVersionCode(
|
|
||||||
appKey, platform, resolvedPackageName, resolvedVersionCode);
|
|
||||||
if (existing.isPresent()) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"版本已存在,不能重复上传:" + resolvedVersionName + " · " + resolvedVersionCode);
|
|
||||||
}
|
|
||||||
// Check if same versionCode exists with any store already live
|
|
||||||
java.util.List<AppVersionEntity> sameCodeVersions = versionRepository
|
|
||||||
.findByAppKeyAndPlatformAndPackageNameAndVersionCodeAndPublishStatus(
|
|
||||||
appKey, platform, resolvedPackageName, resolvedVersionCode,
|
|
||||||
AppVersionEntity.PublishStatus.PUBLISHED);
|
|
||||||
if (!sameCodeVersions.isEmpty() && inspected != null) {
|
|
||||||
// If a published version with same code exists, compare APK md5
|
|
||||||
// This is a conservative check; we can't easily compare md5 here without downloading,
|
|
||||||
// so we just block if same versionCode was ever published
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"应用商店已上线相同版本号,不允许重复上传:" + resolvedVersionName + " · " + resolvedVersionCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AppVersionEntity entity = new AppVersionEntity();
|
AppVersionEntity entity = new AppVersionEntity();
|
||||||
entity.setId(UUID.randomUUID().toString());
|
entity.setId(UUID.randomUUID().toString());
|
||||||
entity.setAppKey(appKey);
|
entity.setAppKey(appKey);
|
||||||
@ -254,6 +232,13 @@ public class AppVersionController {
|
|||||||
AppVersionEntity.PublishStatus previousStatus = entity.getPublishStatus();
|
AppVersionEntity.PublishStatus previousStatus = entity.getPublishStatus();
|
||||||
entity.setForceUpdate(forceUpdate);
|
entity.setForceUpdate(forceUpdate);
|
||||||
if (publishImmediately && (scheduledPublishAt == null || scheduledPublishAt.isBlank())) {
|
if (publishImmediately && (scheduledPublishAt == null || scheduledPublishAt.isBlank())) {
|
||||||
|
for (AppVersionEntity live : versionRepository.findByAppKeyAndPlatformAndPublishStatus(
|
||||||
|
entity.getAppKey(), entity.getPlatform(), AppVersionEntity.PublishStatus.PUBLISHED)) {
|
||||||
|
if (!live.getId().equals(entity.getId())) {
|
||||||
|
live.setPublishStatus(AppVersionEntity.PublishStatus.DEPRECATED);
|
||||||
|
versionRepository.save(live);
|
||||||
|
}
|
||||||
|
}
|
||||||
entity.setPublishStatus(AppVersionEntity.PublishStatus.PUBLISHED);
|
entity.setPublishStatus(AppVersionEntity.PublishStatus.PUBLISHED);
|
||||||
entity.setScheduledPublishAt(null);
|
entity.setScheduledPublishAt(null);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -43,7 +43,10 @@ public interface AppVersionRepository extends JpaRepository<AppVersionEntity, St
|
|||||||
List<AppVersionEntity> findByAppKeyAndPlatformAndVersionCodeAndIdNot(
|
List<AppVersionEntity> findByAppKeyAndPlatformAndVersionCodeAndIdNot(
|
||||||
String appKey, AppVersionEntity.Platform platform, int versionCode, String id);
|
String appKey, AppVersionEntity.Platform platform, int versionCode, String id);
|
||||||
|
|
||||||
Optional<AppVersionEntity> findByAppKeyAndPlatformAndPackageNameAndVersionCode(
|
List<AppVersionEntity> findByAppKeyAndPlatformAndPublishStatus(
|
||||||
|
String appKey, AppVersionEntity.Platform platform, AppVersionEntity.PublishStatus status);
|
||||||
|
|
||||||
|
List<AppVersionEntity> findByAppKeyAndPlatformAndPackageNameAndVersionCode(
|
||||||
String appKey, AppVersionEntity.Platform platform, String packageName, int versionCode);
|
String appKey, AppVersionEntity.Platform platform, String packageName, int versionCode);
|
||||||
|
|
||||||
List<AppVersionEntity> findByAppKeyAndPlatformAndPackageNameAndVersionCodeAndPublishStatus(
|
List<AppVersionEntity> findByAppKeyAndPlatformAndPackageNameAndVersionCodeAndPublishStatus(
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户