Skip to content

Commit a96b6f5

Browse files
authored
[QUZ-113][FEATURE] 매칭 서비스와 게임, 퀴즈 서비스 연동
[QUZ-113][FEATURE] 매칭 서비스와 게임, 퀴즈 서비스 연동
2 parents 1c0cebb + 6ca5d79 commit a96b6f5

File tree

29 files changed

+466
-57
lines changed

29 files changed

+466
-57
lines changed

matching-service/matching-application/app-api/src/main/kotlin/com/grepp/quizy/matching/MatchingServiceApplication.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package com.grepp.quizy.matching
33
import org.springframework.boot.autoconfigure.SpringBootApplication
44
import org.springframework.boot.runApplication
55

6-
@SpringBootApplication class MatchingServiceApplication
6+
@SpringBootApplication(scanBasePackages = ["com.grepp.quizy"])
7+
class MatchingServiceApplication
78

89
fun main(args: Array<String>) {
910
runApplication<MatchingServiceApplication>(*args)

matching-service/matching-application/app-api/src/main/kotlin/com/grepp/quizy/matching/api/sse/SseConnector.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class SseConnector(
3434
}
3535

3636
fun disconnect(userId: UserId) {
37+
emitterRepository.findById(userId.value)?.complete()
3738
emitterRepository.remove(userId.value)
3839
matchingPoolManager.remove(userId)
3940
}

matching-service/matching-application/app-api/src/main/kotlin/com/grepp/quizy/matching/api/sse/SseSender.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SseSender(
3333
}
3434

3535
private fun closeEmitter(userId: Long) {
36+
emitterRepository.findById(userId)?.complete()
3637
emitterRepository.remove(userId)
3738
matchingPoolManager.remove(UserId(userId))
3839
}

matching-service/matching-domain/src/main/kotlin/com/grepp/quizy/matching/domain/game/GameFetcher.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ import com.grepp.quizy.matching.domain.user.UserId
55

66
interface GameFetcher {
77
fun requestGameRoomId(userIds: List<UserId>, subject: InterestCategory): GameRoomId
8+
9+
fun requestGameRating(userId: UserId): GameRating
810
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
package com.grepp.quizy.matching.domain.game
22

33
@JvmInline value class GameRoomId(val value: Long)
4+
5+
enum class GameRating(val index: Int) {
6+
BRONZE(0),
7+
SILVER(1),
8+
GOLD(2),
9+
PLATINUM(3),
10+
DIAMOND(4),
11+
MASTER(5);
12+
13+
companion object {
14+
15+
fun fromRatingValue(rating: Int): GameRating {
16+
return when {
17+
rating < 500 -> BRONZE
18+
rating in 501..1000 -> SILVER
19+
rating in 1001..1500 -> GOLD
20+
rating in 1501..2000 -> PLATINUM
21+
rating in 2001..2500 -> DIAMOND
22+
else -> MASTER
23+
}
24+
}
25+
}
26+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.grepp.quizy.matching.domain.user
2+
3+
class MatchingUser(
4+
val id: UserId,
5+
val interests: List<InterestCategory>
6+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.grepp.quizy.matching.domain.user
2+
3+
import com.grepp.quizy.matching.domain.user.exception.MatchingUserException
4+
import org.springframework.stereotype.Component
5+
6+
@Component
7+
class MatchingUserReader(
8+
private val matchingUserRepository: MatchingUserRepository
9+
) {
10+
11+
fun read(id: UserId): MatchingUser =
12+
matchingUserRepository.findById(id) ?: throw MatchingUserException.NotFound
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.grepp.quizy.matching.domain.user
2+
3+
interface MatchingUserRepository {
4+
fun findById(id: UserId): MatchingUser?
5+
}

matching-service/matching-domain/src/main/kotlin/com/grepp/quizy/matching/domain/user/UserFetcher.kt

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

matching-service/matching-domain/src/main/kotlin/com/grepp/quizy/matching/domain/user/UserVO.kt

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,6 @@ package com.grepp.quizy.matching.domain.user
44

55
@JvmInline value class UserVector(val value: FloatArray)
66

7-
enum class GameRating(val index: Int) {
8-
BRONZE(0),
9-
SILVER(1),
10-
GOLD(2),
11-
PLATINUM(3),
12-
DIAMOND(4),
13-
MASTER(5);
14-
15-
companion object {
16-
17-
fun fromRatingValue(rating: Int): GameRating {
18-
return when {
19-
rating < 500 -> BRONZE
20-
rating in 501..1000 -> SILVER
21-
rating in 1001..1500 -> GOLD
22-
rating in 1501..2000 -> PLATINUM
23-
rating in 2001..2500 -> DIAMOND
24-
else -> MASTER
25-
}
26-
}
27-
}
28-
}
29-
307
enum class InterestCategory(val index: Int) {
318
ALGORITHM(0),
329
PROGRAMMING_LANGUAGE(1),
@@ -44,6 +21,6 @@ enum class InterestCategory(val index: Int) {
4421
fun commonInterest(indexes: List<Int>) =
4522
if (indexes.isEmpty()) entries.random() else InterestCategory.of(indexes.random() - VECTOR_START_INDEX)
4623

47-
fun of(index: Int) = entries.first { it.index == index }
24+
private fun of(index: Int) = entries.first { it.index == index }
4825
}
4926
}

0 commit comments

Comments
 (0)