Skip to content

Commit

Permalink
Merge pull request #230 from School-of-Company/feature/228-apply-moshi
Browse files Browse the repository at this point in the history
🔀 :: (#228) - Moshi 라이브러리 직렬화를 사용하여 Gson의 단점을 보완하였습니다
  • Loading branch information
audgns10 authored Jun 19, 2024
2 parents 67d2248 + ca612cf commit 28fe2de
Show file tree
Hide file tree
Showing 42 changed files with 380 additions and 234 deletions.
3 changes: 3 additions & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ dependencies {
implementation(libs.retrofit.core)
implementation(libs.retrofit.kotlin.serialization)
implementation(libs.retrofit.gson.converter)
implementation(libs.retrofit.moshi.converter)
implementation(libs.moshi)
kapt(libs.retrofit.moshi.codegen)
}

fun getApiKey(propertyKey: String): String {
Expand Down
25 changes: 17 additions & 8 deletions core/network/src/main/java/com/msg/network/di/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.msg.network.api.LectureAPI
import com.msg.network.api.PostAPI
import com.msg.network.api.UserAPI
import com.msg.network.util.AuthInterceptor
import com.squareup.moshi.Moshi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -21,6 +22,7 @@ import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.moshi.MoshiConverterFactory
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

Expand All @@ -47,23 +49,30 @@ object NetworkModule {
.build()
}

@Provides
@Singleton
fun provideMoshiInstance(): Moshi {
return Moshi.Builder().build()
}

@Provides
@Singleton
fun provideConverterFactory(moshi: Moshi): MoshiConverterFactory {
return MoshiConverterFactory.create(moshi)
}

@Provides
fun provideRetrofitInstance(
okHttpClient: OkHttpClient,
gsonConverterFactory: GsonConverterFactory
): Retrofit {
moshiConverterFactory: MoshiConverterFactory
): Retrofit {
return Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.client(okHttpClient)
.addConverterFactory(gsonConverterFactory)
.addConverterFactory(moshiConverterFactory)
.build()
}

@Provides
fun provideGsonConverterFactory(): GsonConverterFactory {
return GsonConverterFactory.create()
}

@Provides
fun provideAuthAPI(retrofit: Retrofit): AuthAPI =
retrofit.create(AuthAPI::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.msg.network.request.admin

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class GetUserListRequest(
val keyword: String,
val page: Int,
val size: Int,
val sort: String,
@Json(name = "keyword") val keyword: String,
@Json(name = "page") val page: Int,
@Json(name = "size") val size: Int,
@Json(name = "sort") val sort: String,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.msg.network.request.auth

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class FindPasswordRequest(
val email: String,
val newPassword: String, // 8 ~ 24 영어(대문자 소문자 상관 X) + 숫자 + 특수 문자(여러 개도 상관 X)
@Json(name = "email") val email: String,
@Json(name = "newPassword") val newPassword: String, // 8 ~ 24 영어(대문자 소문자 상관 X) + 숫자 + 특수 문자(여러 개도 상관 X)
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.msg.network.request.auth

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class LoginRequest(
val email: String,
val password: String
@Json(name = "email") val email: String,
@Json(name = "password") val password: String,
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.msg.network.request.auth

import com.msg.model.enumdata.HighSchool
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class SignUpBbozzakTeacherRequest(
val email: String,
val name: String,
val phoneNumber: String,
val password: String,
val highSchool: HighSchool,
val clubName: String
@Json(name = "email") val email: String,
@Json(name = "name")val name: String,
@Json(name = "phoneNumber") val phoneNumber: String,
@Json(name = "password") val password: String,
@Json(name = "highSchool") val highSchool: HighSchool,
@Json(name = "clubName") val clubName: String,
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.msg.network.request.auth

import com.msg.model.enumdata.HighSchool
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class SignUpCompanyInstructorRequest(
val email: String,
val name: String,
val phoneNumber: String,
val password: String,
val highSchool: HighSchool,
val clubName: String,
val company: String
@Json(name = "email") val email: String,
@Json(name = "name") val name: String,
@Json(name = "phoneNumber") val phoneNumber: String,
@Json(name = "password") val password: String,
@Json(name = "highSchool") val highSchool: HighSchool,
@Json(name = "clubName") val clubName: String,
@Json(name = "company") val company: String,
)
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.msg.network.request.auth

import com.msg.model.enumdata.HighSchool
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class SignUpGovernmentRequest(
val email: String,
val name: String,
val phoneNumber: String,
val password: String,
val highSchool: HighSchool,
val clubName: String,
val governmentName: String,
val position: String,
val sectors: String
@Json(name = "email") val email: String,
@Json(name = "name") val name: String,
@Json(name = "phoneNumber") val phoneNumber: String,
@Json(name = "password") val password: String,
@Json(name = "highSchool") val highSchool: HighSchool,
@Json(name = "clubName") val clubName: String,
@Json(name = "governmentName") val governmentName: String,
@Json(name = "position") val position: String,
@Json(name = "sectors") val sectors: String,
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.msg.network.request.auth

import com.msg.model.enumdata.HighSchool
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class SignUpJobClubTeacherRequest(
val email: String,
val name: String,
val phoneNumber: String,
val password: String,
val highSchool: HighSchool,
val clubName: String
@Json(name = "email") val email: String,
@Json(name = "name") val name: String,
@Json(name = "phoneNumber") val phoneNumber: String,
@Json(name = "password") val password: String,
@Json(name = "highSchool") val highSchool: HighSchool,
@Json(name = "clubName") val clubName: String,
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.msg.network.request.auth

import com.msg.model.enumdata.HighSchool
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class SignUpProfessorRequest(
val email: String,
val name: String,
val phoneNumber: String,
val password: String,
val highSchool: HighSchool,
val clubName: String,
val university: String
@Json(name = "email") val email: String,
@Json(name = "name") val name: String,
@Json(name = "phoneNumber") val phoneNumber: String,
@Json(name = "password") val password: String,
@Json(name = "highSchool") val highSchool: HighSchool,
@Json(name = "clubName") val clubName: String,
@Json(name = "university") val university: String,
)
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.msg.network.request.auth

import com.msg.model.enumdata.HighSchool
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

data class SignUpStudentRequest (
val email: String,
val name: String,
val phoneNumber: String,
val password: String,
val highSchool: HighSchool,
val clubName: String,
val grade: Int,
val classRoom: Int,
val number: Int,
val admissionNumber: Int
@JsonClass(generateAdapter = true)
data class SignUpStudentRequest(
@Json(name = "email") val email: String,
@Json(name = "name") val name: String,
@Json(name = "phoneNumber") val phoneNumber: String,
@Json(name = "password") val password: String,
@Json(name = "highSchool") val highSchool: HighSchool,
@Json(name = "clubName") val clubName: String,
@Json(name = "grade") val grade: Int,
@Json(name = "classRoom") val classRoom: Int,
@Json(name = "number") val number: Int,
@Json(name = "admissionNumber") val admissionNumber: Int,
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.msg.network.request.certification

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.time.LocalDate

@JsonClass(generateAdapter = true)
data class WriteCertificationRequest(
val name: String,
val acquisitionDate: LocalDate
@Json(name = "name") val name: String,
@Json(name = "acquisitionDate") val acquisitionDate: LocalDate,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.msg.network.request.email

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class SendLinkToEmailRequest(
val email: String,
@Json(name = "email") val email: String,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.msg.network.request.faq

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class AddFrequentlyAskedQuestionsRequest(
val question: String,
val answer: String,
@Json(name = "question") val question: String,
@Json(name = "answer") val answer: String,
)
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
package com.msg.network.request.lecture

import com.msg.model.model.lecture.LectureDates
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.time.LocalDateTime
import java.util.UUID


@JsonClass(generateAdapter = true)
data class OpenLectureRequest(
val name: String,
val content: String,
val semester: String,
val division: String,
val department: String,
val line: String,
val userId: UUID,
val startDate: LocalDateTime,
val endDate: LocalDateTime,
val lectureDates: List<LectureDates>,
val lectureType: String,
val credit: Int,
val maxRegisteredUser: Int,
val essentialComplete: Boolean,
@Json(name = "name") val name: String,
@Json(name = "content") val content: String,
@Json(name = "semester") val semester: String,
@Json(name = "division") val division: String,
@Json(name = "department") val department: String,
@Json(name = "line") val line: String,
@Json(name = "userId") val userId: UUID,
@Json(name = "startDate") val startDate: LocalDateTime,
@Json(name = "endDate") val endDate: LocalDateTime,
@Json(name = "lectureDates") val lectureDates: List<LectureDates>,
@Json(name = "lectureType") val lectureType: String,
@Json(name = "credit") val credit: Int,
@Json(name = "maxRegisteredUser") val maxRegisteredUser: Int,
@Json(name = "essentialComplete") val essentialComplete: Boolean,
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.msg.network.request.post

import com.msg.model.enumdata.FeedType
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class WritePostRequest(
val title: String,
val content: String,
val links: List<String>,
val feedType: FeedType
@Json(name = "title") val title: String,
@Json(name = "content") val content: String,
@Json(name = "links") val links: List<String>,
@Json(name = "feedType") val feedType: FeedType,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.msg.network.request.user

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class ChangePasswordRequest(
val currentPassword: String,
val newPassword: String
@Json(name = "currentPassword") val currentPassword: String,
@Json(name = "newPassword") val newPassword: String,
)
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.msg.network.response.activity

import com.msg.model.enumdata.ApproveStatus
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.time.LocalDate
import java.time.LocalDateTime
import java.util.UUID

@JsonClass(generateAdapter = true)
data class GetDetailStudentActivityInfoResponse(
val id: UUID,
val title: String,
val content: String,
val credit: Int,
val activityDate: LocalDate,
val modifiedAt: LocalDateTime,
val approveState: ApproveStatus
@Json(name = "id") val id: UUID,
@Json(name = "title") val title: String,
@Json(name = "content") val content: String,
@Json(name = "credit") val credit: Int,
@Json(name = "activityDate") val activityDate: LocalDate,
@Json(name = "modifiedAt") val modifiedAt: LocalDateTime,
@Json(name = "approveState") val approveState: ApproveStatus,
)
Loading

0 comments on commit 28fe2de

Please sign in to comment.