Skip to content

Commit

Permalink
[chore] #9 - 파일 구조 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
sayyyho committed Dec 8, 2024
1 parent dd450f5 commit b766625
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.api
package org.sopt.and.data.api

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import dagger.Module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.sopt.and.api
package org.sopt.and.data.api

import org.sopt.and.dto.RequestLoginData
import org.sopt.and.dto.RequestUserRegistrationData
import org.sopt.and.dto.ResponseLogin
import org.sopt.and.dto.ResponseUserRegistration
import org.sopt.and.data.api.dto.RequestLoginData
import org.sopt.and.data.api.dto.RequestUserRegistrationData
import org.sopt.and.data.api.dto.ResponseLogin
import org.sopt.and.data.api.dto.ResponseUserRegistration
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.POST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sopt.and.api
package org.sopt.and.data.api

import org.sopt.and.dto.ResponseMyHobbyData
import org.sopt.and.data.api.dto.ResponseMyHobbyData
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Header
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.and.data.datasource

import org.sopt.and.data.model.response.MyHobbyResponseDto
import org.sopt.and.data.service.UserService

class MyHobbyDataSource(
private val userService: UserService
) {
suspend fun getMyHobby(): MyHobbyResponseDto = userService.getMyHobby()
}
13 changes: 13 additions & 0 deletions app/src/main/java/org/sopt/and/data/datasource/SignInDataSource.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.and.data.datasource

import org.sopt.and.data.model.request.SignInRequestDto
import org.sopt.and.data.model.response.SignInResponseDto
import org.sopt.and.data.service.UserService
import retrofit2.Response

class SignInDataSource(
private val userService: UserService
) {
suspend fun signIn(request: SignInRequestDto): Response<SignInResponseDto> =
userService.signIn(request = request)
}
13 changes: 13 additions & 0 deletions app/src/main/java/org/sopt/and/data/datasource/SignUpDataSource.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.and.data.datasource

import org.sopt.and.data.model.request.SignUpRequestDto
import org.sopt.and.data.model.response.SignUpResponseDto
import org.sopt.and.data.service.UserService
import retrofit2.Response

class SignUpDataSource(
private val userService: UserService
) {
suspend fun signUp(request: SignUpRequestDto): Response<SignUpResponseDto> =
userService.signUp(request = request)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.dto
package org.sopt.and.data.api.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.dto
package org.sopt.and.data.api.dto


import kotlinx.serialization.SerialName
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.and.data.model.request

import kotlinx.serialization.Serializable

@Serializable
data class SignInRequestDto(
val username: String,
val password: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.and.data.model.request

import kotlinx.serialization.Serializable

@Serializable
data class SignUpRequestDto(
val username: String,
val password: String,
val hobby: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.sopt.and.data.model.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class MyHobbyResponseDto(
val result: MyHobbyResponseResultDto? = null,
val code: String? = null
)

@Serializable
data class MyHobbyResponseResultDto(
@SerialName("hobby")
val myHobby: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.and.data.model.response

import kotlinx.serialization.Serializable

@Serializable
data class SignInResponseDto(
val result: SignInResponseResultDto? = null,
val code: String? = null
)

@Serializable
data class SignInResponseResultDto(
val token: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.and.data.model.response

import kotlinx.serialization.Serializable

@Serializable
data class SignUpResponseDto(
val result: SignUpResponseResultDto? = null,
val code: String? = null
)

@Serializable
data class SignUpResponseResultDto(
val no: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.sopt.and.data.repositoryimpl

import org.sopt.and.data.datasource.GetMyHobbyDataSource
import org.sopt.and.data.mapper.Mapper
import org.sopt.and.domain.model.MyHobbyEntity
import org.sopt.and.domain.repository.GetMyHobbyRepository

class MyHobbyRepositoryImpl(
private val getMyHobbyDataSource: GetMyHobbyDataSource
) : GetMyHobbyRepository {
override suspend fun getMyHobby(): Result<MyHobbyEntity> =
runCatching {
getMyHobbyDataSource.getMyHobby().result?.let { Mapper.toMyHobbyEntity(it) }!!
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.sopt.and.data.repositoryimpl

import org.sopt.and.data.datasource.SignInDataSource
import org.sopt.and.data.mapper.Mapper
import org.sopt.and.domain.model.SignInInformationEntity
import org.sopt.and.domain.model.SignInResponseEntity
import org.sopt.and.domain.repository.SignInRepository

class SignInRepositoryImpl(
private val signInDataSource: SignInDataSource
) : SignInRepository {
override suspend fun signIn(request: SignInInformationEntity): Result<SignInResponseEntity> =
runCatching {
Mapper.toSignInResponseEntity(
signInDataSource.signIn(
Mapper.toSignInRequestDto(
request
)
)
)!!
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.sopt.and.data.repositoryimpl

import org.sopt.and.data.datasource.SignUpDataSource
import org.sopt.and.data.mapper.Mapper
import org.sopt.and.domain.model.SignUpInformationEntity
import org.sopt.and.domain.model.SignUpResponseEntity
import org.sopt.and.domain.repository.SignUpRepository

class SignUpRepositoryImpl(
private val signUpDataSource: SignUpDataSource
) : SignUpRepository {
override suspend fun signUp(request: SignUpInformationEntity): Result<SignUpResponseEntity> =
runCatching {
Mapper.toSignUpResponseEntity(
signUpDataSource.signUp(
Mapper.toSignUpRequestDto(
request
)
)
)!!
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.sopt.and.api.HobbyService
import org.sopt.and.api.LoginService
import org.sopt.and.api.UserRegistrationService
import org.sopt.and.dto.RequestLoginData
import org.sopt.and.dto.RequestUserRegistrationData
import org.sopt.and.dto.ResponseUserRegistration
import org.sopt.and.data.api.HobbyService
import org.sopt.and.data.api.LoginService
import org.sopt.and.data.api.UserRegistrationService
import org.sopt.and.data.api.dto.RequestLoginData
import org.sopt.and.data.api.dto.RequestUserRegistrationData
import org.sopt.and.data.api.dto.ResponseUserRegistration
import javax.inject.Inject

@HiltViewModel
Expand Down

0 comments on commit b766625

Please sign in to comment.