Skip to content

Commit c7e73e2

Browse files
authored
Merge pull request #43 from Nexters/feature/42-get-app-version-api
[#42] App 강제 업데이트 지원을 위한 최소 버전 확인 API
2 parents ea7a3ad + b312a50 commit c7e73e2

File tree

5 files changed

+95
-25
lines changed

5 files changed

+95
-25
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package nexters.weski.app_version
2+
3+
import io.swagger.v3.oas.annotations.Operation
4+
import io.swagger.v3.oas.annotations.Parameter
5+
import io.swagger.v3.oas.annotations.tags.Tag
6+
import org.springframework.web.bind.annotation.*
7+
8+
@Tag(name = "App 최소 버전 check API", description = "App 최소 버전 check API")
9+
@RestController
10+
class AppVersionCheckController(
11+
private val appVersionCheckService: AppVersionCheckService,
12+
) {
13+
@Operation(summary = "App 버전 조회 API")
14+
@GetMapping("/api/app-version")
15+
fun getAppVersion(
16+
@Parameter(description = "사용자 App platform", example = "iOS")
17+
@RequestParam platform: String,
18+
@Parameter(description = "사용자 현재 App version", example = "1.0.0")
19+
@RequestParam version: String,
20+
): AppVersionResponseDto {
21+
if (platform.uppercase() !in Platform.entries.map { it.name }) {
22+
throw IllegalArgumentException("platform must be one of ${Platform.entries.joinToString()}")
23+
}
24+
return appVersionCheckService.getAppVersion(
25+
platform = Platform.valueOf(platform.uppercase()),
26+
version = version,
27+
)
28+
}
29+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package nexters.weski.app_version
2+
3+
import org.springframework.stereotype.Service
4+
5+
@Service
6+
class AppVersionCheckService {
7+
companion object {
8+
const val IOS_MIN_VERSION = "3.0.1"
9+
const val ANDROID_MIN_VERSION = "3.0.1"
10+
}
11+
fun getAppVersion(
12+
platform: Platform,
13+
version: String,
14+
): AppVersionResponseDto {
15+
val minVersion = when (platform) {
16+
Platform.IOS -> IOS_MIN_VERSION
17+
Platform.ANDROID -> ANDROID_MIN_VERSION
18+
else -> throw IllegalArgumentException("Unsupported platform: $platform")
19+
}
20+
return AppVersionResponseDto(
21+
platform = platform,
22+
minVersion = minVersion,
23+
isForceUpdate = isForceUpdate(platform, version),
24+
)
25+
}
26+
27+
private fun isForceUpdate(
28+
platform: Platform,
29+
version: String,
30+
): Boolean {
31+
return when (platform) {
32+
Platform.IOS -> isForceUpdateForIOS(version)
33+
Platform.ANDROID -> isForceUpdateForAndroid(version)
34+
else -> throw IllegalArgumentException("Unsupported platform: $platform")
35+
}
36+
}
37+
38+
private fun isForceUpdateForIOS(version: String): Boolean {
39+
return version < IOS_MIN_VERSION
40+
}
41+
42+
private fun isForceUpdateForAndroid(version: String): Boolean {
43+
return version < ANDROID_MIN_VERSION
44+
}
45+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package nexters.weski.app_version
2+
3+
import io.swagger.v3.oas.annotations.media.Schema
4+
5+
@Schema(description = "App 최소 버전, 강제업데이트 flag 데이터")
6+
data class AppVersionResponseDto(
7+
// 예: "android", "ios" 등
8+
val platform: Platform,
9+
// 클라이언트에서 동작 가능한 최소 버전
10+
val minVersion: String,
11+
// true = App 강제 업데이트 대상임을 의미
12+
val isForceUpdate: Boolean = false,
13+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package nexters.weski.app_version
2+
3+
enum class Platform {
4+
IOS,
5+
ANDROID,
6+
WEB,
7+
UNKNOWN,
8+
}

src/main/kotlin/nexters/weski/ski_resort/SkiResortDto.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)