Skip to content

Commit

Permalink
[feat]: 개발자 리스트 조회 API 성공
Browse files Browse the repository at this point in the history
  • Loading branch information
kangyuri1114 committed May 9, 2024
1 parent 8f2cad1 commit 8fb5b4e
Show file tree
Hide file tree
Showing 35 changed files with 664 additions and 42 deletions.
33 changes: 3 additions & 30 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.zucchini.buildsrc.Constants


plugins {
id("com.android.application")
kotlin("android")
Expand All @@ -21,36 +22,6 @@ android {
versionName = Constants.versionName

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

// buildConfigField(
// "String",
// "NATIVE_APP_KEY",
// gradleLocalProperties(rootDir).getProperty("native.app.key"),
// )
// manifestPlaceholders["NATIVE_APP_KEY"] =
// gradleLocalProperties(rootDir).getProperty("nativeAppKey")
}

buildTypes {
debug {
// buildConfigField(
// "String",
// "BASE_URL",
// gradleLocalProperties(rootDir).getProperty("test.base.url")
// )
}
release {
// buildConfigField(
// "String",
// "BASE_URL",
// gradleLocalProperties(rootDir).getProperty("base.url")
// )
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}
}

compileOptions {
Expand All @@ -75,6 +46,7 @@ dependencies {
implementation(project(":domain"))
implementation(project(":core:designsystem"))
implementation(project(":core:common"))
implementation(project(":core:network"))
implementation(project(":feature:projects"))

KotlinDependencies.run {
Expand All @@ -95,6 +67,7 @@ dependencies {
KaptDependencies.run {
kapt(hiltCompiler)
kapt(hiltWorkManagerCompiler)
kapt(hiltAndroidCompiler)
}

TestDependencies.run {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
android:roundIcon="@drawable/logo_olive_rotational"
android:supportsRtl="true"
android:theme="@style/Theme.SSUPlectorAndroid"
tools:targetApi="31">
tools:targetApi="31"
android:usesCleartextTraffic="true">
<activity
android:name=".InitActivity"
android:exported="true"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/zucchini/ssuplector/InitActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.zucchini.projects.IntroduceActivity
import com.zucchini.projects.MainActivity
import com.zucchini.ssuplector.databinding.ActivityInitBinding
import dagger.hilt.android.AndroidEntryPoint

Expand Down
10 changes: 10 additions & 0 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,19 @@ dependencies {
implementation(timber)
}

AndroidXDependencies.run {
implementation(hilt)
}

TestDependencies.run {
testImplementation(jUnit)
androidTestImplementation(androidTest)
androidTestImplementation(espresso)
}

KaptDependencies.run {
kapt(hiltCompiler)
kapt(hiltWorkManagerCompiler)
kapt(hiltAndroidCompiler)
}
}
11 changes: 11 additions & 0 deletions core/common/src/main/java/com/zucchini/qualifier/Auth.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.hmh.hamyeonham.common.qualifier

import javax.inject.Qualifier

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class Secured

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class Unsecured
11 changes: 11 additions & 0 deletions core/common/src/main/java/com/zucchini/qualifier/Interceptor.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.hmh.hamyeonham.common.qualifier

import javax.inject.Qualifier

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class Log

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class Auth
7 changes: 7 additions & 0 deletions core/common/src/main/java/com/zucchini/qualifier/OAuth.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.hmh.hamyeonham.common.qualifier

import javax.inject.Qualifier

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class Kakao
1 change: 1 addition & 0 deletions core/network/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
86 changes: 86 additions & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import com.zucchini.buildsrc.Constants

plugins {
id("com.android.library")
kotlin("android")
kotlin("kapt")
id("kotlin-parcelize")
id("dagger.hilt.android.plugin")
kotlin("plugin.serialization") version Versions.kotlinVersion

}

android {
namespace = "com.zucchini.core.network"
compileSdk = Constants.compileSdk

defaultConfig {
minSdk = Constants.minSdk
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

}

compileOptions {
sourceCompatibility = Versions.javaVersion
targetCompatibility = Versions.javaVersion
}

buildFeatures {
buildConfig = true
}
buildTypes {
debug {
buildConfigField(
"String",
"BASE_URL",
gradleLocalProperties(rootDir).getProperty("base.url"),
)
}
release {
buildConfigField(
"String",
"BASE_URL",
gradleLocalProperties(rootDir).getProperty("base.url"),
)
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}
}
}

dependencies {
implementation(project(":core:common"))

KotlinDependencies.run {
implementation(kotlin)
implementation(coroutines)
implementation(jsonSerialization)
}

ThirdPartyDependencies.run {
implementation(platform(okHttpBom))
implementation(okHttp)
implementation(okHttpLoggingInterceptor)
implementation(retrofit)
implementation(retrofitJsonConverter)
implementation(timber)
implementation(ossLicense)
}

AndroidXDependencies.run {
implementation(hilt)
implementation(workManager)
implementation(hiltWorkManager)
}

KaptDependencies.run {
kapt(hiltCompiler)
kapt(hiltWorkManagerCompiler)
kapt(hiltAndroidCompiler)

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.sample.network.di

import com.hmh.hamyeonham.common.qualifier.Unsecured
import com.sample.network.service.DevelopersService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.create
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DevelopersModule {
@Provides
@Singleton
fun provideDevelopersApi(@Unsecured retrofit: Retrofit): DevelopersService = retrofit.create()
}
118 changes: 118 additions & 0 deletions core/network/src/main/java/com/sample/network/di/NetModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package com.sample.network.di

import com.hmh.hamyeonham.common.qualifier.Auth
import com.hmh.hamyeonham.common.qualifier.Log
import com.hmh.hamyeonham.common.qualifier.Secured
import com.hmh.hamyeonham.common.qualifier.Unsecured
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.zucchini.core.network.BuildConfig
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.serialization.json.Json
import okhttp3.Authenticator
import okhttp3.Interceptor
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Converter
import retrofit2.Retrofit
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

private const val baseUrl = BuildConfig.BASE_URL

@Module
@InstallIn(SingletonComponent::class)
object NetModule {
@Provides
@Singleton
fun provideJson(): Json = Json {
ignoreUnknownKeys = true
coerceInputValues = true
}

@Singleton
@Provides
fun provideJsonConverterFactory(json: Json): Converter.Factory {
return json.asConverterFactory("application/json".toMediaType())
}

@Singleton
@Provides
@Log
fun provideLoggingInterceptor(): Interceptor =
HttpLoggingInterceptor().setLevel(
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.NONE
},
)

// @Singleton
// @Provides
// @Auth
// fun provideAuthInterceptor(interceptor: AuthInterceptor): Interceptor = interceptor

@Singleton
@Provides
@Secured
fun provideOkHttpClient(
@Log logInterceptor: Interceptor,
@Auth authInterceptor: Interceptor,
authenticator: Authenticator,
): OkHttpClient = OkHttpClient.Builder()
.addInterceptor(logInterceptor)
.addInterceptor(authInterceptor)
.authenticator(authenticator)
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS)
.build()

@Singleton
@Provides
@Unsecured
fun provideOkHttpClientNotNeededAuth(
@Log logInterceptor: Interceptor,
): OkHttpClient = OkHttpClient.Builder()
.addInterceptor(logInterceptor)
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(15, TimeUnit.SECONDS)
.build()

@Singleton
@Provides
@Secured
fun provideRetrofit(
@Secured client: OkHttpClient,
converterFactory: Converter.Factory,
): Retrofit = Retrofit.Builder()
.baseUrl(baseUrl)
.client(client)
.addConverterFactory(converterFactory)
.build()

@Singleton
@Provides
@Unsecured
fun provideRetrofitNotNeededAuth(
@Unsecured client: OkHttpClient,
converterFactory: Converter.Factory,
): Retrofit = Retrofit.Builder()
.baseUrl(baseUrl)
.client(client)
.addConverterFactory(converterFactory)
.build()

// @Module
// @InstallIn(SingletonComponent::class)
// interface Binder {
// @Binds
// @Singleton
// fun provideAuthenticator(authenticator: Authenticator): Authenticator
// }
}
19 changes: 19 additions & 0 deletions core/network/src/main/java/com/sample/network/di/ProjectsModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.sample.network.di

import com.hmh.hamyeonham.common.qualifier.Unsecured
import com.sample.network.service.ProjectsService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.create
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ProjectsModule {
@Provides
@Singleton
fun provideProjectsApi(@Unsecured retrofit: Retrofit): ProjectsService = retrofit.create()
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class DevelopersDetailResponse(
@SerialName("imageLink")
val imageLink: String,
@SerialName("developerList")
val developerList: List<Developer>,
val developerList: List<DeveloperInfoInDevelopersDetail>,
@SerialName("shortIntro")
val shortIntro: String,
@SerialName("longIntro")
Expand All @@ -37,7 +37,7 @@ data class DevelopersDetailResponse(
val techStackList: List<String>,
) {
@Serializable
data class Developer(
data class DeveloperInfoInDevelopersDetail(
@SerialName("id")
val id: Int,
@SerialName("name")
Expand Down
Loading

0 comments on commit 8fb5b4e

Please sign in to comment.