Skip to content

Commit 60c6743

Browse files
authored
Merge pull request #178 from YAPP-Github/refactor/#177-ui-mapper
[Refactor/#177] domain, presentation 계층간 model mapper를 구현합니다.
2 parents e1664ed + a0544e1 commit 60c6743

File tree

187 files changed

+903
-1121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+903
-1121
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.threegap.bitnagil.data.auth.datasource
22

3-
import com.threegap.bitnagil.data.auth.model.request.LoginRequestDto
4-
import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequestDto
5-
import com.threegap.bitnagil.data.auth.model.response.LoginResponseDto
3+
import com.threegap.bitnagil.data.auth.model.request.LoginRequest
4+
import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequest
5+
import com.threegap.bitnagil.data.auth.model.response.LoginResponse
66

77
interface AuthRemoteDataSource {
8-
suspend fun login(socialAccessToken: String, loginRequestDto: LoginRequestDto): Result<LoginResponseDto>
9-
suspend fun submitAgreement(termsAgreementRequestDto: TermsAgreementRequestDto): Result<Unit>
8+
suspend fun login(socialAccessToken: String, loginRequest: LoginRequest): Result<LoginResponse>
9+
suspend fun submitAgreement(termsAgreementRequest: TermsAgreementRequest): Result<Unit>
1010
suspend fun logout(): Result<Unit>
1111
suspend fun withdrawal(reason: String): Result<Unit>
12-
suspend fun reissueToken(refreshToken: String): Result<LoginResponseDto>
12+
suspend fun reissueToken(refreshToken: String): Result<LoginResponse>
1313
}

data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.threegap.bitnagil.data.auth.datasourceimpl
22

33
import com.threegap.bitnagil.data.auth.datasource.AuthRemoteDataSource
4-
import com.threegap.bitnagil.data.auth.model.request.LoginRequestDto
5-
import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequestDto
4+
import com.threegap.bitnagil.data.auth.model.request.LoginRequest
5+
import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequest
66
import com.threegap.bitnagil.data.auth.model.request.WithdrawalReasonRequest
7-
import com.threegap.bitnagil.data.auth.model.response.LoginResponseDto
7+
import com.threegap.bitnagil.data.auth.model.response.LoginResponse
88
import com.threegap.bitnagil.data.auth.service.AuthService
99
import com.threegap.bitnagil.data.common.safeApiCall
1010
import com.threegap.bitnagil.data.common.safeUnitApiCall
@@ -13,14 +13,14 @@ import javax.inject.Inject
1313
class AuthRemoteDataSourceImpl @Inject constructor(
1414
private val authService: AuthService,
1515
) : AuthRemoteDataSource {
16-
override suspend fun login(socialAccessToken: String, loginRequestDto: LoginRequestDto): Result<LoginResponseDto> =
16+
override suspend fun login(socialAccessToken: String, loginRequest: LoginRequest): Result<LoginResponse> =
1717
safeApiCall {
18-
authService.postLogin(socialAccessToken, loginRequestDto)
18+
authService.postLogin(socialAccessToken, loginRequest)
1919
}
2020

21-
override suspend fun submitAgreement(termsAgreementRequestDto: TermsAgreementRequestDto): Result<Unit> =
21+
override suspend fun submitAgreement(termsAgreementRequest: TermsAgreementRequest): Result<Unit> =
2222
safeUnitApiCall {
23-
authService.submitAgreement(termsAgreementRequestDto)
23+
authService.submitAgreement(termsAgreementRequest)
2424
}
2525

2626
override suspend fun logout(): Result<Unit> =
@@ -33,7 +33,7 @@ class AuthRemoteDataSourceImpl @Inject constructor(
3333
authService.postWithdrawal(WithdrawalReasonRequest(reason))
3434
}
3535

36-
override suspend fun reissueToken(refreshToken: String): Result<LoginResponseDto> =
36+
override suspend fun reissueToken(refreshToken: String): Result<LoginResponse> =
3737
safeApiCall {
3838
authService.postReissueToken(refreshToken)
3939
}

data/src/main/java/com/threegap/bitnagil/data/auth/mapper/AuthMapper.kt

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

data/src/main/java/com/threegap/bitnagil/data/auth/model/request/LoginRequestDto.kt renamed to data/src/main/java/com/threegap/bitnagil/data/auth/model/request/LoginRequest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import kotlinx.serialization.SerialName
44
import kotlinx.serialization.Serializable
55

66
@Serializable
7-
data class LoginRequestDto(
7+
data class LoginRequest(
88
@SerialName("socialType")
99
val socialType: String,
1010
)

data/src/main/java/com/threegap/bitnagil/data/auth/model/request/TermsAgreementRequestDto.kt renamed to data/src/main/java/com/threegap/bitnagil/data/auth/model/request/TermsAgreementRequest.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
package com.threegap.bitnagil.data.auth.model.request
22

3+
import com.threegap.bitnagil.domain.auth.model.TermsAgreement
34
import kotlinx.serialization.SerialName
45
import kotlinx.serialization.Serializable
56

67
@Serializable
7-
data class TermsAgreementRequestDto(
8+
data class TermsAgreementRequest(
89
@SerialName("agreedToTermsOfService")
910
val agreedToTermsOfService: Boolean,
1011
@SerialName("agreedToPrivacyPolicy")
1112
val agreedToPrivacyPolicy: Boolean,
1213
@SerialName("isOverFourteen")
1314
val isOverFourteen: Boolean,
1415
)
16+
17+
internal fun TermsAgreement.toDto() =
18+
TermsAgreementRequest(
19+
agreedToTermsOfService = this.agreedToTermsOfService,
20+
agreedToPrivacyPolicy = this.agreedToPrivacyPolicy,
21+
isOverFourteen = this.isOverFourteen,
22+
)

data/src/main/java/com/threegap/bitnagil/data/auth/model/response/LoginResponseDto.kt renamed to data/src/main/java/com/threegap/bitnagil/data/auth/model/response/LoginResponse.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
package com.threegap.bitnagil.data.auth.model.response
22

3+
import com.threegap.bitnagil.domain.auth.model.AuthSession
34
import com.threegap.bitnagil.domain.auth.model.UserRole
45
import kotlinx.serialization.SerialName
56
import kotlinx.serialization.Serializable
67

78
@Serializable
8-
data class LoginResponseDto(
9+
data class LoginResponse(
910
@SerialName("accessToken")
1011
val accessToken: String,
1112
@SerialName("refreshToken")
1213
val refreshToken: String,
1314
@SerialName("role")
1415
val role: UserRole,
1516
)
17+
18+
internal fun LoginResponse.toDomain() =
19+
AuthSession(
20+
accessToken = this.accessToken,
21+
refreshToken = this.refreshToken,
22+
role = this.role,
23+
)

data/src/main/java/com/threegap/bitnagil/data/auth/repositoryimpl/AuthRepositoryImpl.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package com.threegap.bitnagil.data.auth.repositoryimpl
22

33
import com.threegap.bitnagil.data.auth.datasource.AuthLocalDataSource
44
import com.threegap.bitnagil.data.auth.datasource.AuthRemoteDataSource
5-
import com.threegap.bitnagil.data.auth.mapper.toDomain
6-
import com.threegap.bitnagil.data.auth.mapper.toDto
7-
import com.threegap.bitnagil.data.auth.model.request.LoginRequestDto
5+
import com.threegap.bitnagil.data.auth.model.request.LoginRequest
6+
import com.threegap.bitnagil.data.auth.model.request.toDto
7+
import com.threegap.bitnagil.data.auth.model.response.toDomain
88
import com.threegap.bitnagil.domain.auth.model.AuthSession
99
import com.threegap.bitnagil.domain.auth.model.TermsAgreement
1010
import com.threegap.bitnagil.domain.auth.repository.AuthRepository
@@ -15,7 +15,7 @@ class AuthRepositoryImpl @Inject constructor(
1515
private val authLocalDataSource: AuthLocalDataSource,
1616
) : AuthRepository {
1717
override suspend fun login(socialAccessToken: String, socialType: String): Result<AuthSession> =
18-
authRemoteDataSource.login(socialAccessToken, LoginRequestDto(socialType))
18+
authRemoteDataSource.login(socialAccessToken, LoginRequest(socialType))
1919
.map { it.toDomain() }
2020

2121
override suspend fun submitAgreement(termsAgreement: TermsAgreement): Result<Unit> =

data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.threegap.bitnagil.data.auth.service
22

3-
import com.threegap.bitnagil.data.auth.model.request.LoginRequestDto
4-
import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequestDto
3+
import com.threegap.bitnagil.data.auth.model.request.LoginRequest
4+
import com.threegap.bitnagil.data.auth.model.request.TermsAgreementRequest
55
import com.threegap.bitnagil.data.auth.model.request.WithdrawalReasonRequest
6-
import com.threegap.bitnagil.data.auth.model.response.LoginResponseDto
6+
import com.threegap.bitnagil.data.auth.model.response.LoginResponse
77
import com.threegap.bitnagil.network.model.BaseResponse
88
import retrofit2.http.Body
99
import retrofit2.http.Header
@@ -15,12 +15,12 @@ interface AuthService {
1515
@Headers("No-Service-Token: true")
1616
suspend fun postLogin(
1717
@Header("SocialAccessToken") socialAccessToken: String,
18-
@Body loginRequestDto: LoginRequestDto,
19-
): BaseResponse<LoginResponseDto>
18+
@Body loginRequest: LoginRequest,
19+
): BaseResponse<LoginResponse>
2020

2121
@POST("/api/v1/auth/agreements")
2222
suspend fun submitAgreement(
23-
@Body termsAgreementRequestDto: TermsAgreementRequestDto,
23+
@Body termsAgreementRequest: TermsAgreementRequest,
2424
): BaseResponse<Unit>
2525

2626
@POST("/api/v1/auth/withdrawal")
@@ -33,5 +33,5 @@ interface AuthService {
3333
@Headers("No-Service-Token: true", "Auto-Login: true")
3434
suspend fun postReissueToken(
3535
@Header("Refresh-Token") refreshToken: String,
36-
): BaseResponse<LoginResponseDto>
36+
): BaseResponse<LoginResponse>
3737
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.threegap.bitnagil.data.emotion.datasource
22

33
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
4+
import com.threegap.bitnagil.data.emotion.model.response.DailyEmotionResponse
45
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
5-
import com.threegap.bitnagil.data.emotion.model.response.TodayEmotionResponseDto
66

77
interface EmotionDataSource {
88
suspend fun getEmotions(): Result<List<EmotionDto>>
99
suspend fun registerEmotion(emotion: String): Result<RegisterEmotionResponse>
10-
suspend fun fetchTodayEmotion(currentDate: String): Result<TodayEmotionResponseDto>
10+
suspend fun fetchDailyEmotion(currentDate: String): Result<DailyEmotionResponse>
1111
}

data/src/main/java/com/threegap/bitnagil/data/emotion/datasourceImpl/EmotionDataSourceImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import com.threegap.bitnagil.data.common.safeApiCall
44
import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
55
import com.threegap.bitnagil.data.emotion.model.dto.EmotionDto
66
import com.threegap.bitnagil.data.emotion.model.request.RegisterEmotionRequest
7+
import com.threegap.bitnagil.data.emotion.model.response.DailyEmotionResponse
78
import com.threegap.bitnagil.data.emotion.model.response.RegisterEmotionResponse
8-
import com.threegap.bitnagil.data.emotion.model.response.TodayEmotionResponseDto
99
import com.threegap.bitnagil.data.emotion.service.EmotionService
1010
import javax.inject.Inject
1111

@@ -25,8 +25,8 @@ class EmotionDataSourceImpl @Inject constructor(
2525
}
2626
}
2727

28-
override suspend fun fetchTodayEmotion(currentDate: String): Result<TodayEmotionResponseDto> =
28+
override suspend fun fetchDailyEmotion(currentDate: String): Result<DailyEmotionResponse> =
2929
safeApiCall {
30-
emotionService.fetchTodayEmotion(currentDate)
30+
emotionService.fetchDailyEmotion(currentDate)
3131
}
3232
}

0 commit comments

Comments
 (0)