-
Notifications
You must be signed in to change notification settings - Fork 3
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
[REFACTOR] entity 추가, dataStore 추가 #99
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b0e46ac
[FIX/#21] activityViewModel로 수정
gaeun5744 840c52d
[REFACTOR/#68] 회고상세조회 뷰 Dto -> Entity 변경
gaeun5744 aa600c4
[REFACTOR/#68] 초대코드 api Dto -> Entity 변경
gaeun5744 418aeaf
[REFACTOR/#68] 프로젝트 참여하기 requestDto -> entity
gaeun5744 387da7e
[RENAME/#68] RequestInvitationCode -> RequestJoinProject 로 파일명 변경
gaeun5744 96237a0
[DELETE] 불필요한 변수 제거
gaeun5744 a629c2d
[REFACTOR/#21] viewModelProvider -> activityViewModel
gaeun5744 ff9ba77
[DELETE] 불필요한 import 제거
gaeun5744 fc99262
[REFACTOR/#21] viewModelProvider -> activityViewModel
gaeun5744 783ebae
[REFACTOR/#68] 프로젝트 회고조회 api Dto -> Entity
gaeun5744 347003f
[REFACTOR/#68] 회고 주기 조회 api Dto -> Entity
gaeun5744 2314170
[FIX] git 충돌 해결
gaeun5744 d17ce8f
[FIX] import 주소 수정
gaeun5744 2afdfe1
Merge pull request #15 from gaeun5744/refactor/#68-allview-Dto
gaeun5744 b25ac87
[ADD] implement dataStore 추가
gaeun5744 e8dc8df
Merge branch 'develop' of github.com:gaeun5744/Puzzling_Android into …
gaeun5744 54852af
[FEAT] KeyStore를 이용한 암호화 service 구현
gaeun5744 f54a139
[FIX] import 수정
gaeun5744 94b2f52
[ADD/#40] Token entity 추가
gaeun5744 4817595
[ADD/#40] Token dataSource 추가
gaeun5744 57e4c46
[FEAT/#40] encrypted datastore data layer까지 구현
gaeun5744 d0c98a4
[RENAME] Login -> Auth 파일명 변경
gaeun5744 d58bfa7
[FEAT/#40] kakaoLogin DI 적용
gaeun5744 9a70255
[FEAT/#40] dataStore UseCase 구현
gaeun5744 3f1a6ea
Merge pull request #16 from gaeun5744/refactor/#40-source-dataStore
gaeun5744 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
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/puzzling/puzzlingaos/data/datasource/local/TokenDataSource.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,41 @@ | ||
package com.puzzling.puzzlingaos.data.datasource.local | ||
|
||
import android.os.Build | ||
import androidx.annotation.RequiresApi | ||
import androidx.datastore.core.Serializer | ||
import com.puzzling.puzzlingaos.data.entity.Token | ||
import com.puzzling.puzzlingaos.data.service.CryptoService | ||
import kotlinx.serialization.json.Json | ||
import org.apache.commons.lang3.SerializationException | ||
import java.io.InputStream | ||
import java.io.OutputStream | ||
import javax.inject.Inject | ||
|
||
@RequiresApi(Build.VERSION_CODES.M) | ||
class TokenDataSource @Inject constructor(private val cryptoService: CryptoService) : Serializer<Token> { | ||
override val defaultValue: Token | ||
get() = Token() | ||
|
||
override suspend fun readFrom(input: InputStream): Token { | ||
val decryptedBytes = cryptoService.decrypt(input) | ||
return try { | ||
Json.decodeFromString( | ||
deserializer = Token.serializer(), | ||
string = decryptedBytes.decodeToString(), | ||
) | ||
} catch (e: SerializationException) { | ||
e.printStackTrace() | ||
defaultValue | ||
} | ||
} | ||
|
||
override suspend fun writeTo(t: Token, output: OutputStream) { | ||
cryptoService.encrypt( | ||
bytes = Json.encodeToString( | ||
serializer = Token.serializer(), | ||
value = t, | ||
).encodeToByteArray(), | ||
outputStream = output, | ||
) | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/puzzling/puzzlingaos/data/entity/Token.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,8 @@ | ||
package com.puzzling.puzzlingaos.data.entity | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class Token( | ||
val accessToken: String? = null, | ||
) |
9 changes: 8 additions & 1 deletion
9
...ta/model/request/RequestInvitationCode.kt → .../data/model/request/RequestJoinProject.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,14 +1,21 @@ | ||
package com.puzzling.puzzlingaos.data.model.request | ||
|
||
import com.puzzling.puzzlingaos.domain.entity.JoinProjectInfo | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestInvitationCode( | ||
data class RequestJoinProject( | ||
@SerialName("projectId") | ||
val projectId: Int, | ||
@SerialName("memberProjectNickname") | ||
val memberProjectNickname: String, | ||
@SerialName("memberProjectRole") | ||
val memberProjectRole: String, | ||
) | ||
|
||
fun JoinProjectInfo.toRequestJoinProjectDto() = RequestJoinProject( | ||
projectId, | ||
memberProjectNickname, | ||
memberProjectRole, | ||
) |
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
23 changes: 16 additions & 7 deletions
23
app/src/main/java/com/puzzling/puzzlingaos/data/repository/MyPageRepositoryImpl.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,23 +1,32 @@ | ||
package com.puzzling.puzzlingaos.data.repository | ||
|
||
import com.puzzling.puzzlingaos.data.datasource.remote.MyPageDataSource | ||
import com.puzzling.puzzlingaos.data.model.response.ResponseDetailRetroDto | ||
import com.puzzling.puzzlingaos.data.model.response.ResponseMyRetroListDto | ||
import com.puzzling.puzzlingaos.domain.entity.DetailRetro | ||
import com.puzzling.puzzlingaos.domain.entity.ProjectReview | ||
import com.puzzling.puzzlingaos.domain.repository.MyPageRepository | ||
import javax.inject.Inject | ||
|
||
class MyPageRepositoryImpl @Inject constructor(private val myPageDataSource: MyPageDataSource) : | ||
MyPageRepository { | ||
override suspend fun getMyProjectReview(memberId: Int, projectId: Int): ResponseMyRetroListDto { | ||
return myPageDataSource.getMyProjectReview(memberId, projectId) | ||
} | ||
override suspend fun getMyProjectReview( | ||
memberId: Int, | ||
projectId: Int, | ||
): Result<List<ProjectReview>> = | ||
runCatching { | ||
myPageDataSource.getMyProjectReview(memberId, projectId).toProjectReview() | ||
} | ||
|
||
override suspend fun getMyDetailReview( | ||
memberId: Int, | ||
projectId: Int, | ||
startDate: String, | ||
endDate: String, | ||
): ResponseDetailRetroDto { | ||
return myPageDataSource.getMyDetailReview(memberId, projectId, startDate, endDate) | ||
): Result<List<DetailRetro>> = runCatching { | ||
myPageDataSource.getMyDetailReview( | ||
memberId, | ||
projectId, | ||
startDate, | ||
endDate, | ||
).data.toDetailRetro() | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/puzzling/puzzlingaos/data/repository/TokenRepositoryImpl.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.puzzling.puzzlingaos.data.repository | ||
|
||
import androidx.datastore.core.DataStore | ||
import com.puzzling.puzzlingaos.data.entity.Token | ||
import com.puzzling.puzzlingaos.domain.repository.TokenRepository | ||
import kotlinx.coroutines.flow.first | ||
import javax.inject.Inject | ||
|
||
class TokenRepositoryImpl @Inject constructor(private val dataStore: DataStore<Token>) : | ||
TokenRepository { | ||
override suspend fun setToken(token: String) { | ||
dataStore.updateData { Token(token) } | ||
} | ||
|
||
override suspend fun getToken(): Token = dataStore.data.first() | ||
} |
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.
👍