File tree 7 files changed +33
-0
lines changed
git-application/src/main/kotlin/com/xquare/v1servicegit/git
git-infrastructure/src/main/kotlin/com/xquare/v1servicegit
7 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.xquare.v1servicegit.git.dto.response
2
+
3
+ data class IsConnectedGithubOauthResponse (
4
+ val isConnected : Boolean ,
5
+ )
Original file line number Diff line number Diff line change @@ -9,4 +9,5 @@ interface QueryGitPort {
9
9
suspend fun getGitByUserId (userId : UUID ): Git ?
10
10
suspend fun getGitByUsername (username : String ): Git ?
11
11
suspend fun getContributionCount (username : String ): Int
12
+ suspend fun isExistGitUserByUserId (userId : UUID ): Boolean
12
13
}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import com.xquare.v1servicegit.common.annotations.UseCase
4
4
import com.xquare.v1servicegit.git.Git
5
5
import com.xquare.v1servicegit.git.dto.request.FindUserInfoRequest
6
6
import com.xquare.v1servicegit.git.dto.response.FindAllUserResponse
7
+ import com.xquare.v1servicegit.git.dto.response.IsConnectedGithubOauthResponse
7
8
import com.xquare.v1servicegit.git.dto.response.toUserElement
8
9
import com.xquare.v1servicegit.git.exceptions.GitExceptions
9
10
import com.xquare.v1servicegit.git.port.CommandGitPort
@@ -71,4 +72,10 @@ class GitUseCase(
71
72
)
72
73
}
73
74
}
75
+
76
+ suspend fun isConnectedGithubOauthByUserId (userId : UUID ): IsConnectedGithubOauthResponse =
77
+ when (queryGitPort.isExistGitUserByUserId(userId)) {
78
+ true -> IsConnectedGithubOauthResponse (true )
79
+ false -> IsConnectedGithubOauthResponse (false )
80
+ }
74
81
}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class SecurityConfiguration {
27
27
.pathMatchers(HttpMethod .POST , " /gits" ).permitAll()
28
28
.pathMatchers(HttpMethod .GET , " /gits" ).permitAll()
29
29
.pathMatchers(HttpMethod .GET , " /gits/all" ).permitAll()
30
+ .pathMatchers(HttpMethod .GET , " /gits/exist" ).permitAll()
30
31
.pathMatchers(HttpMethod .PATCH , " /gits" ).permitAll()
31
32
.anyExchange().authenticated()
32
33
.and ()
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import com.linecorp.kotlinjdsl.query.HibernateMutinyReactiveQueryFactory
5
5
import com.linecorp.kotlinjdsl.query.singleQueryOrNull
6
6
import com.linecorp.kotlinjdsl.querydsl.expression.col
7
7
import com.linecorp.kotlinjdsl.selectQuery
8
+ import com.linecorp.kotlinjdsl.singleQueryOrNull
8
9
import com.xquare.v1servicegit.git.port.GitPort
9
10
import io.smallrye.mutiny.coroutines.awaitSuspending
10
11
import kotlinx.coroutines.CoroutineScope
@@ -134,4 +135,15 @@ class GitPersistenceAdapter(
134
135
}
135
136
}.awaitAll().associate { (userId, contribution) -> userId to contribution }
136
137
}
138
+
139
+ override suspend fun isExistGitUserByUserId (userId : UUID ): Boolean =
140
+ reactiveQueryFactory.withFactory { _, reactiveQueryFactory ->
141
+ reactiveQueryFactory.singleQueryOrNull<UUID > {
142
+ select(col(GitEntity ::userId))
143
+ from(entity(GitEntity ::class ))
144
+ where(
145
+ col(GitEntity ::userId).equal(userId),
146
+ )
147
+ } != null
148
+ }
137
149
}
Original file line number Diff line number Diff line change @@ -37,4 +37,10 @@ class GitHandler(
37
37
gitUseCase.updateGitInfo()
38
38
return ServerResponse .noContent().buildAndAwait()
39
39
}
40
+
41
+ suspend fun isConnectedGithubOauthByUserId (serverRequest : ServerRequest ): ServerResponse {
42
+ val currentUserId = requestHeaderAspect.getCurrentUserId(serverRequest)
43
+ val isConnectedGithubOauth = gitUseCase.isConnectedGithubOauthByUserId(currentUserId)
44
+ return ServerResponse .ok().bodyValueAndAwait(isConnectedGithubOauth)
45
+ }
40
46
}
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ class GitRouter {
14
14
POST (" " , gitHandler::saveGithubUserInfo)
15
15
GET (" /all" , gitHandler::getAllGithubInfo)
16
16
GET (" " , gitHandler::getMyGithubInfo)
17
+ GET (" /exist" , gitHandler::isConnectedGithubOauthByUserId)
17
18
PATCH (" " , gitHandler::updateContributions)
18
19
}
19
20
}
You canβt perform that action at this time.
0 commit comments