Skip to content

Commit

Permalink
[add] : AuthDomainRepository 생성, AuthDataSourceImpl 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
chanubc committed Jan 3, 2024
1 parent 0406712 commit 305a3ac
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.sopt.dosopttemplate.data.datasourceimpl.remote

import org.sopt.dosopttemplate.data.datasource.remote.AuthDataSource
import org.sopt.dosopttemplate.data.dto.remote.request.RequestLoginDto
import org.sopt.dosopttemplate.data.dto.remote.request.RequestSignUpDto
import org.sopt.dosopttemplate.data.dto.remote.respose.ResponseLoginDto
import org.sopt.dosopttemplate.data.service.AuthService

class AuthDataSourceImpl(private val authService: AuthService) : AuthDataSource {
override suspend fun login(request: RequestLoginDto): ResponseLoginDto =
authService.postLogin(request)

override suspend fun signUp(request: RequestSignUpDto): Unit =
authService.postSignUp(request)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.sopt.dosopttemplate.data.repositoryimpl

import org.sopt.dosopttemplate.data.datasource.remote.AuthDataSource
import org.sopt.dosopttemplate.data.dto.remote.request.RequestLoginDto
import org.sopt.dosopttemplate.data.dto.remote.request.RequestSignUpDto
import org.sopt.dosopttemplate.domain.entity.UserEntity
import org.sopt.dosopttemplate.domain.entity.UserRequestEntity
import org.sopt.dosopttemplate.domain.repository.AuthDomainRepository

class AuthRepositoryImpl(private val authDataSource: AuthDataSource) : AuthDomainRepository {
override suspend fun login(userRequestEntity: UserRequestEntity): Result<UserEntity> =
kotlin.runCatching {
authDataSource.login(
RequestLoginDto(
userRequestEntity.userName,
userRequestEntity.passWord,
),
).toUserEntity()
}

override suspend fun signUp(userEntity: UserEntity): Result<Unit> =
kotlin.runCatching {
authDataSource.signUp(
RequestSignUpDto(
userEntity.id,
userEntity.pwd,
userEntity.nickName,
),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.dosopttemplate.domain.repository

import org.sopt.dosopttemplate.domain.entity.UserEntity
import org.sopt.dosopttemplate.domain.entity.UserRequestEntity

interface AuthDomainRepository {
suspend fun login(userRequestEntity: UserRequestEntity): Result<UserEntity>
suspend fun signUp(userEntity: UserEntity): Result<Unit>
}

0 comments on commit 305a3ac

Please sign in to comment.