-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YS-65] feat: 테스트용 토큰 강제 발급 API & AccessToken 갱신 API 구현 #16
Merged
Merged
Changes from 24 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
ee8b4ec
style: add line for EOF
Ji-soo708 3560fb0
chore: update springdoc version
Ji-soo708 871ad82
feat: add generateTestTokenForTestMember method for test
Ji-soo708 225f15b
feat: add UseCase interface
Ji-soo708 c83fe2f
feat: add GenerateTestToken api for test member
Ji-soo708 e66f71f
test: change memberId type from String to Long in test code
Ji-soo708 ec088d0
chore: add mock dependency for test
Ji-soo708 e915406
test: add GenerateTestToken test code
Ji-soo708 2f42a22
test: refactor JwtTokenProviderTest to use Kotest style
Ji-soo708 5ae21ef
style: rename dto name
Ji-soo708 8bfa21a
feat: add @ComponentScan to include UseCase beans in application context
Ji-soo708 2387360
refact: refactor TokenProvider code
Ji-soo708 ef72cda
feat: add dto for SignIn logic
Ji-soo708 63d0863
feat: add GenerateTokenWithRefreshToken
Ji-soo708 83b41c1
test: add GenerateTokenWithRefreshToken test code
Ji-soo708 da69998
refact: rename entity
Ji-soo708 65ffa0c
refact: refactor member domain
Ji-soo708 6387bdb
test: fix test due to changed domain
Ji-soo708 c08fad6
feat: add MemberGateway
Ji-soo708 c207cf8
feat: add GetMemberById usecase
Ji-soo708 065c00b
refact: update MemberRefreshToken response
Ji-soo708 6db0c19
style: add line for eof
Ji-soo708 9abb0c3
Merge branch 'dev' into feature/YS-65
Ji-soo708 6a48fbf
style: update role example
Ji-soo708 eb68e03
[YS-31] feat: 구글 OAuth 로그인 구현 (#13)
chock-cho 36a0d1c
feat: add GenerateTestToken api for test member
Ji-soo708 e26fdbf
test: refactor JwtTokenProviderTest to use Kotest style
Ji-soo708 f5c8cab
feat: add @ComponentScan to include UseCase beans in application context
Ji-soo708 170352d
feat: add GenerateTokenWithRefreshToken
Ji-soo708 0f6b999
refact: rename entity
Ji-soo708 aae3d23
test: fix test due to changed domain
Ji-soo708 a333982
refact: update MemberRefreshToken response
Ji-soo708 93550d8
fix: fix conflicts for merge
Ji-soo708 8538d2c
refact: move usecase file to application
Ji-soo708 edca1e9
refact: refactor OAuthLoginResponse response structure
Ji-soo708 7df78cd
fix: fix conflicts for merge
Ji-soo708 fedb6de
fix: fix conflicts for merge
Ji-soo708 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/com/dobby/backend/DobbyBackendApplication.kt
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
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/dobby/backend/domain/gateway/MemberGateway.kt
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,7 @@ | ||
package com.dobby.backend.domain.gateway | ||
|
||
import com.dobby.backend.domain.model.Member | ||
|
||
interface MemberGateway { | ||
fun getById(memberId: Long): Member | ||
} |
6 changes: 2 additions & 4 deletions
6
src/main/kotlin/com/dobby/backend/domain/gateway/TokenGateway.kt
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,9 +1,7 @@ | ||
package com.dobby.backend.domain.gateway | ||
|
||
import com.dobby.backend.domain.model.Member | ||
|
||
interface TokenGateway { | ||
fun generateAccessToken(member: Member): String | ||
fun generateRefreshToken(member: Member): String | ||
fun generateAccessToken(memberId: Long): String | ||
fun generateRefreshToken(memberId: Long): String | ||
fun extractMemberIdFromRefreshToken(token: String): String | ||
} |
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,21 +1,40 @@ | ||
package com.dobby.backend.domain.model | ||
|
||
import com.dobby.backend.util.generateULID | ||
import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus | ||
import com.dobby.backend.infrastructure.database.entity.enum.ProviderType | ||
import com.dobby.backend.infrastructure.database.entity.enum.RoleType | ||
import java.time.LocalDate | ||
|
||
data class Member( | ||
val memberId: String, | ||
val memberId: Long, | ||
val name: String, | ||
val email: String, | ||
val oauthEmail: String, | ||
val contactEmail: String, | ||
val provider: ProviderType, | ||
val status: MemberStatus, | ||
val role: RoleType, | ||
val birthDate: LocalDate, | ||
) { | ||
|
||
companion object { | ||
fun newMember( | ||
memberId: Long, | ||
name: String, | ||
email: String, | ||
oauthEmail: String, | ||
contactEmail: String, | ||
provider: ProviderType, | ||
status: MemberStatus, | ||
role: RoleType, | ||
birthDate: LocalDate, | ||
) = Member( | ||
memberId = generateULID(), | ||
memberId = memberId, | ||
name = name, | ||
email = email, | ||
oauthEmail = oauthEmail, | ||
contactEmail = contactEmail, | ||
provider = provider, | ||
status = status, | ||
role = role, | ||
birthDate = birthDate, | ||
) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/dobby/backend/domain/usecase/GenerateTestToken.kt
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,24 @@ | ||
package com.dobby.backend.domain.usecase | ||
|
||
import com.dobby.backend.domain.gateway.TokenGateway | ||
|
||
class GenerateTestToken( | ||
private val tokenGateway: TokenGateway | ||
) : UseCase<GenerateTestToken.Input, GenerateTestToken.Output> { | ||
data class Input( | ||
val memberId: Long | ||
) | ||
|
||
data class Output( | ||
val accessToken: String, | ||
val refreshToken: String, | ||
) | ||
|
||
override fun execute(input: Input): Output { | ||
val memberId = input.memberId | ||
return Output( | ||
accessToken = tokenGateway.generateAccessToken(memberId), | ||
refreshToken = tokenGateway.generateRefreshToken(memberId) | ||
) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/com/dobby/backend/domain/usecase/GenerateTokenWithRefreshToken.kt
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,26 @@ | ||
package com.dobby.backend.domain.usecase | ||
|
||
import com.dobby.backend.domain.gateway.TokenGateway | ||
|
||
class GenerateTokenWithRefreshToken( | ||
private val tokenGateway: TokenGateway | ||
) : UseCase<GenerateTokenWithRefreshToken.Input, GenerateTokenWithRefreshToken.Output> { | ||
data class Input( | ||
val refreshToken: String, | ||
) | ||
|
||
data class Output( | ||
val accessToken: String, | ||
val refreshToken: String, | ||
val memberId: Long | ||
) | ||
|
||
override fun execute(input: Input): Output { | ||
val memberId = tokenGateway.extractMemberIdFromRefreshToken(input.refreshToken).toLong() | ||
return Output( | ||
accessToken = tokenGateway.generateAccessToken(memberId), | ||
refreshToken = tokenGateway.generateRefreshToken(memberId), | ||
memberId = memberId | ||
) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/com/dobby/backend/domain/usecase/GetMemberById.kt
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,16 @@ | ||
package com.dobby.backend.domain.usecase | ||
|
||
import com.dobby.backend.domain.gateway.MemberGateway | ||
import com.dobby.backend.domain.model.Member | ||
|
||
class GetMemberById( | ||
private val memberGateway: MemberGateway, | ||
) : UseCase<GetMemberById.Input, Member> { | ||
data class Input( | ||
val memberId: Long, | ||
) | ||
|
||
override fun execute(input: Input): Member { | ||
return memberGateway.getById(input.memberId) | ||
} | ||
} |
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,5 @@ | ||
package com.dobby.backend.domain.usecase | ||
|
||
fun interface UseCase<I, O> { | ||
fun execute(input: I): O | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ package com.dobby.backend.infrastructure.database.entity.enum | |
|
||
enum class ProviderType { | ||
NAVER, GOOGLE | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ package com.dobby.backend.infrastructure.database.entity.enum | |
|
||
enum class RoleType { | ||
RESEARCHER, PARTICIPANT | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/dobby/backend/infrastructure/database/repository/MemberJpaRepository.kt
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,7 @@ | ||
package com.dobby.backend.infrastructure.database.repository | ||
|
||
import com.dobby.backend.infrastructure.database.entity.MemberEntity | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface MemberJpaRepository : JpaRepository<MemberEntity, Long> { | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/com/dobby/backend/infrastructure/gateway/MemberGatewayImpl.kt
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,18 @@ | ||
package com.dobby.backend.infrastructure.gateway | ||
|
||
import com.dobby.backend.domain.gateway.MemberGateway | ||
import com.dobby.backend.domain.model.Member | ||
import com.dobby.backend.infrastructure.database.entity.MemberEntity | ||
import com.dobby.backend.infrastructure.database.repository.MemberJpaRepository | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class MemberGatewayImpl( | ||
private val jpaMemberRepository: MemberJpaRepository, | ||
) : MemberGateway { | ||
override fun getById(memberId: Long): Member { | ||
return jpaMemberRepository | ||
.getReferenceById(memberId) | ||
.let(MemberEntity::toDomain) | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로직을 구현하면서 알았는데 Entity와 model을 한 클래스에서 불러와 구현해야 하는 경우가 있어, 이름으로 구분을 주기 위해 다시 Entity를 뒤에 붙였습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 이 부분이 우려되어서 초반에 네이밍을 달리했었던 기억이 납니다!☺️
좋은 변화라고 생각합니다