-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from playkuround/feat/appVersion
Supports app version check for each OS
- Loading branch information
Showing
7 changed files
with
155 additions
and
16 deletions.
There are no files selected for viewing
36 changes: 28 additions & 8 deletions
36
src/main/java/com/playkuround/playkuroundserver/domain/common/AppVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,38 @@ | ||
package com.playkuround.playkuroundserver.domain.common; | ||
|
||
public abstract class AppVersion { | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
private AppVersion() { | ||
} | ||
import static java.util.stream.Collectors.toMap; | ||
|
||
public enum AppVersion { | ||
|
||
ANDROID("2.0.2"), | ||
IOS("2.0.0"); | ||
|
||
private static String CURRENT_VERSION = "2.0.2"; | ||
private static final Map<String, AppVersion> stringToEnum = | ||
Stream.of(values()) | ||
.collect(toMap(Object::toString, e -> e)); | ||
private String latest_updated_version; | ||
|
||
AppVersion(String latest_updated_version) { | ||
this.latest_updated_version = latest_updated_version; | ||
} | ||
|
||
public static boolean isCurrentVersion(String version) { | ||
return CURRENT_VERSION.equals(version); | ||
public static boolean isLatestUpdatedVersion(String os, String version) { | ||
AppVersion appVersion = stringToEnum.get(os.toUpperCase()); | ||
if (appVersion == null) { | ||
throw new NotSupportOSException(); | ||
} | ||
return appVersion.latest_updated_version.equals(version); | ||
} | ||
|
||
public static void changeAppVersion(String version) { | ||
CURRENT_VERSION = version; | ||
public static void changeLatestUpdatedVersion(String os, String version) { | ||
AppVersion appVersion = stringToEnum.get(os.toUpperCase()); | ||
if (appVersion == null) { | ||
throw new NotSupportOSException(); | ||
} | ||
appVersion.latest_updated_version = version; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/playkuround/playkuroundserver/domain/common/NotSupportOSException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.playkuround.playkuroundserver.domain.common; | ||
|
||
import com.playkuround.playkuroundserver.global.error.ErrorCode; | ||
import com.playkuround.playkuroundserver.global.error.exception.BusinessException; | ||
|
||
public class NotSupportOSException extends BusinessException { | ||
|
||
public NotSupportOSException() { | ||
super(ErrorCode.NOT_SUPPORT_OS); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters