Skip to content

Commit

Permalink
feat/#8: User Service, DataSource, Repository에 getMyHobby 내 취미 조회 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kangyein9892 committed Nov 15, 2024
1 parent 639101e commit ff83054
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.sopt.and.data.di.UserSharedPreference
import org.sopt.and.data.dto.request.SignUpRequestDto
import org.sopt.and.data.service.UserService
import org.sopt.and.domain.exception.Result
import org.sopt.and.domain.model.MyHobbyResponse
import org.sopt.and.domain.model.SignUpResponse

internal class UserDataSource @Inject constructor(
Expand Down Expand Up @@ -37,6 +38,10 @@ internal class UserDataSource @Inject constructor(
userService.signUp(request).result.toDomainModel()
}

suspend fun getMyHobby(token: String): Result<MyHobbyResponse> = execute {
userService.getMyHobby(token).result.toDomainModel()
}

companion object {
private const val ID = "id"
private const val PASSWORD = "password"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.sopt.and.domain.model.SignUpResponse
import org.sopt.and.domain.model.User
import org.sopt.and.domain.repository.UserRepository
import org.sopt.and.domain.exception.Result
import org.sopt.and.domain.model.MyHobbyResponse

internal class UserRepositoryImpl @Inject constructor(
private val userDataSource: UserDataSource
Expand All @@ -32,4 +33,8 @@ internal class UserRepositoryImpl @Inject constructor(
return userDataSource.signUp(user.toRequestBody())
}

override suspend fun getMyHobby(token: String): Result<MyHobbyResponse> {
return userDataSource.getMyHobby(token)
}

}
7 changes: 7 additions & 0 deletions data/src/main/java/org/sopt/and/data/service/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package org.sopt.and.data.service

import org.sopt.and.data.dto.BaseResponse
import org.sopt.and.data.dto.request.SignUpRequestDto
import org.sopt.and.data.dto.response.MyHobbyResponseDto
import org.sopt.and.data.dto.response.SignUpResponseDto
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST

internal interface UserService {
Expand All @@ -12,4 +15,8 @@ internal interface UserService {
@Body request: SignUpRequestDto
): BaseResponse<SignUpResponseDto>

@GET("user/my-hobby")
suspend fun getMyHobby(
@Header("token") token: String
): BaseResponse<MyHobbyResponseDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package org.sopt.and.domain.repository
import org.sopt.and.domain.model.SignUpResponse
import org.sopt.and.domain.model.User
import org.sopt.and.domain.exception.Result
import org.sopt.and.domain.model.MyHobbyResponse

interface UserRepository {
fun saveUser(id: String, password: String)
fun saveToken(token: String)
fun clearUserPreference()
fun getToken(): String
suspend fun signUp(user: User): Result<SignUpResponse>
suspend fun getMyHobby(token: String): Result<MyHobbyResponse>
}

0 comments on commit ff83054

Please sign in to comment.