generated from AND-SOPT-ANDROID/and-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
357 additions
and
73 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.sopt.and | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class WavveApp : Application() |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/sopt/and/data/dataremote/datasource/UserRemoteDataSource.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 org.sopt.and.data.dataremote.datasource | ||
|
||
import org.sopt.and.data.dataremote.model.request.RequestLoginDto | ||
import org.sopt.and.data.dataremote.model.request.RequestSignUpDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseLoginDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseMyHobbyDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseSignUpDto | ||
|
||
|
||
interface UserRemoteDataSource { | ||
suspend fun postSignup(requestSignUpDto: RequestSignUpDto): ResponseSignUpDto | ||
|
||
suspend fun postLogin(requestLoginDto: RequestLoginDto): ResponseLoginDto | ||
|
||
suspend fun getUserHobby(token: String): ResponseMyHobbyDto | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/org/sopt/and/data/dataremote/datasourceimpl/UserRemoteDataSourceImpl.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,25 @@ | ||
package org.sopt.and.data.dataremote.datasourceimpl | ||
|
||
import org.sopt.and.data.dataremote.datasource.UserRemoteDataSource | ||
import org.sopt.and.data.dataremote.model.request.RequestLoginDto | ||
import org.sopt.and.data.dataremote.model.request.RequestSignUpDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseLoginDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseMyHobbyDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseSignUpDto | ||
import org.sopt.and.data.dataremote.service.UserService | ||
import javax.inject.Inject | ||
|
||
class UserRemoteDataSourceImpl @Inject constructor( | ||
private val service: UserService | ||
) : UserRemoteDataSource { | ||
override suspend fun postSignup(requestSignUpDto: RequestSignUpDto): ResponseSignUpDto = | ||
service.postSignup(requestSignUpDto = requestSignUpDto) | ||
|
||
|
||
override suspend fun postLogin(requestLoginDto: RequestLoginDto): ResponseLoginDto = | ||
service.postLogin(requestLoginDto = requestLoginDto) | ||
|
||
override suspend fun getUserHobby(token: String): ResponseMyHobbyDto = | ||
service.getUserHobby(token = token) | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...and/data/model/request/RequsetLoginDto.kt → ...taremote/model/request/RequsetLoginDto.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
2 changes: 1 addition & 1 deletion
2
...nd/data/model/request/RequsetSignUpDto.kt → ...aremote/model/request/RequsetSignUpDto.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
2 changes: 1 addition & 1 deletion
2
...d/data/model/response/ResponseLoginDto.kt → ...remote/model/response/ResponseLoginDto.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
6 changes: 3 additions & 3 deletions
6
...data/model/response/ResponseMyHobbyDto.kt → ...mote/model/response/ResponseMyHobbyDto.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
2 changes: 1 addition & 1 deletion
2
.../data/model/response/ResponseSignUpDto.kt → ...emote/model/response/ResponseSignUpDto.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
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/sopt/and/data/dataremote/service/UserService.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,27 @@ | ||
package org.sopt.and.data.dataremote.service | ||
|
||
import org.sopt.and.data.dataremote.model.request.RequestLoginDto | ||
import org.sopt.and.data.dataremote.model.request.RequestSignUpDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseLoginDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseMyHobbyDto | ||
import org.sopt.and.data.dataremote.model.response.ResponseSignUpDto | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.POST | ||
|
||
|
||
interface UserService { | ||
@POST("/user") | ||
suspend fun postSignup(@Body requestSignUpDto: RequestSignUpDto): ResponseSignUpDto | ||
|
||
@POST("/login") | ||
suspend fun postLogin(@Body requestLoginDto: RequestLoginDto): ResponseLoginDto | ||
|
||
|
||
@GET("/user/my-hobby") | ||
suspend fun getUserHobby( | ||
@Header("token") token: String | ||
): ResponseMyHobbyDto | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/and/data/mapper/todomain/ResponseLoginDtoMapper.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 org.sopt.and.data.mapper.todomain | ||
|
||
import org.sopt.and.data.dataremote.model.response.ResponseLoginDto | ||
import org.sopt.and.domain.model.Token | ||
|
||
fun ResponseLoginDto.toDomain(): Token = Token( | ||
token = this.result.token | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/and/data/mapper/todomain/ResponseMyHobbyDtoMapper.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 org.sopt.and.data.mapper.todomain | ||
|
||
import org.sopt.and.data.dataremote.model.response.ResponseMyHobbyDto | ||
import org.sopt.and.domain.model.Hobby | ||
|
||
fun ResponseMyHobbyDto.toDomain(): Hobby = Hobby( | ||
hobby = this.result.hobby | ||
) |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/sopt/and/data/repositoryimpl/UserRepositoryImpl.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,27 @@ | ||
package org.sopt.and.data.repositoryimpl | ||
|
||
import org.sopt.and.data.dataremote.datasource.UserRemoteDataSource | ||
import org.sopt.and.data.dataremote.model.request.RequestLoginDto | ||
import org.sopt.and.data.dataremote.model.request.RequestSignUpDto | ||
import org.sopt.and.data.mapper.todomain.toDomain | ||
import org.sopt.and.domain.model.Hobby | ||
import org.sopt.and.domain.model.Token | ||
import org.sopt.and.domain.repository.UserRepository | ||
|
||
class UserRepositoryImpl @Inject constructor( | ||
private val userRemoteDataSource: UserRemoteDataSource | ||
) : UserRepository { | ||
|
||
override suspend fun postSignup(requestSignUpDto: RequestSignUpDto): Result<Unit> = | ||
runCatching { | ||
userRemoteDataSource.postSignup(requestSignUpDto = requestSignUpDto) | ||
} | ||
|
||
override suspend fun postLogin(requestLoginDto: RequestLoginDto): Result<Token> = runCatching { | ||
userRemoteDataSource.postLogin(requestLoginDto = requestLoginDto).toDomain() | ||
} | ||
|
||
override suspend fun getUserHobby(token: String): Result<Hobby> = runCatching { | ||
userRemoteDataSource.getUserHobby(token = token).toDomain() | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
app/src/main/java/org/sopt/and/data/service/RetrofitInstance.kt
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
app/src/main/java/org/sopt/and/data/service/UserService.kt
This file was deleted.
Oops, something went wrong.
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 org.sopt.and.di | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.sopt.and.data.dataremote.datasource.UserRemoteDataSource | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class DataSourceModule { | ||
@Binds | ||
@Singleton | ||
abstract fun bindsUserRemoteDataSource(userRemoteDataSourceImpl: UserRemoteDataSource): UserRemoteDataSource | ||
} |
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,71 @@ | ||
package org.sopt.and.di | ||
|
||
import com.example.kakaowebtoon.BuildConfig | ||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaTypeOrNull | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import retrofit2.Retrofit | ||
import java.util.concurrent.TimeUnit | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object NetworkModule { | ||
@OptIn(ExperimentalSerializationApi::class) | ||
@Provides | ||
@Singleton | ||
fun providesJson(): Json = | ||
Json { | ||
isLenient = true | ||
prettyPrint = true | ||
explicitNulls = false | ||
ignoreUnknownKeys = true | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun providesOkHttpClient( | ||
loggingInterceptor: HttpLoggingInterceptor | ||
): OkHttpClient = | ||
OkHttpClient.Builder().apply { | ||
connectTimeout(10, TimeUnit.SECONDS) | ||
writeTimeout(10, TimeUnit.SECONDS) | ||
readTimeout(10, TimeUnit.SECONDS) | ||
addInterceptor(loggingInterceptor) | ||
addInterceptor { chain -> | ||
val request = chain.request().newBuilder() | ||
.addHeader("Accept", "*/*") | ||
.build() | ||
chain.proceed(request) | ||
} | ||
}.build() | ||
|
||
@Provides | ||
@Singleton | ||
fun providesLoggingInterceptor(): HttpLoggingInterceptor = | ||
HttpLoggingInterceptor().apply { | ||
level = HttpLoggingInterceptor.Level.BODY | ||
} | ||
|
||
@ExperimentalSerializationApi | ||
@Provides | ||
@Singleton | ||
fun providesRetrofit( | ||
okHttpClient: OkHttpClient, | ||
json: Json | ||
): Retrofit = | ||
Retrofit.Builder() | ||
.baseUrl(BuildConfig.BASE_URL) | ||
.client(okHttpClient) | ||
.addConverterFactory( | ||
json.asConverterFactory(requireNotNull("application/json".toMediaTypeOrNull())) | ||
) | ||
.build() | ||
} |
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,17 @@ | ||
package org.sopt.and.di | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.sopt.and.data.repositoryimpl.UserRepositoryImpl | ||
import org.sopt.and.domain.repository.UserRepository | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class RepositoryModule { | ||
@Binds | ||
@Singleton | ||
abstract fun bindUserRepository(userRepositoryImpl: UserRepositoryImpl): UserRepository | ||
} |
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,20 @@ | ||
package org.sopt.and.di | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.sopt.and.data.dataremote.service.UserService | ||
import retrofit2.Retrofit | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object ServiceModule { | ||
@Provides | ||
@Singleton | ||
fun providesService(retrofit: Retrofit): UserService = | ||
retrofit.create(UserService::class.java) | ||
|
||
|
||
} |
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,5 @@ | ||
package org.sopt.and.domain.model | ||
|
||
data class Hobby( | ||
var hobby: String = "", | ||
) |
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,5 @@ | ||
package org.sopt.and.domain.model | ||
|
||
data class Token( | ||
var token: String = "", | ||
) |
2 changes: 1 addition & 1 deletion
2
...src/main/java/org/sopt/and/domain/User.kt → ...in/java/org/sopt/and/domain/model/User.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,4 +1,4 @@ | ||
package org.sopt.and.domain | ||
package org.sopt.and.domain.model | ||
|
||
data class User( | ||
val email: String = "", | ||
|
Oops, something went wrong.