-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/코드리뷰 #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
The head ref may contain hidden characters: "fix/\uCF54\uB4DC\uB9AC\uBDF0"
Fix/코드리뷰 #37
Changes from all commits
ad658c1
8a36f33
1e306fb
be7cf59
e7300ce
151369a
ba6027c
020edaa
0a07046
4f97ec2
3af5828
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,6 @@ | ||
| package com.simply407.patpat.data.model | ||
|
|
||
| data class CounselorMbtiInfo(val name: String, val mbtiList: List<String>) | ||
|
|
||
| object MBTIRepository { | ||
| val CounselorMbtiDataList = listOf( | ||
| CounselorMbtiInfo("복남이", listOf("INFJ", "INFP", "ENFJ", "ENFP")), | ||
| CounselorMbtiInfo("닥터 냉철한", listOf("INTJ", "INTP", "ENTJ", "ENTP")), | ||
| CounselorMbtiInfo("곽두팔", listOf("ISTJ", "ISTP", "ESTJ", "ESTP")), | ||
| CounselorMbtiInfo("코코", listOf("ISFJ", "ISFP", "ESFJ", "ESFP")) | ||
| ) | ||
| } | ||
| data class CounselorMbtiInfo( | ||
| val name: String, | ||
| val mbtiList: List<String> | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,26 @@ | ||
| package com.simply407.patpat.data.model | ||
|
|
||
| // TODO data 가 null이 되면 어떤일이 벌어질까? totalElements 이 null이 되면 어떤일이 벌어질까? | ||
| // TODO 원시타입 vs 참조타입 | ||
|
|
||
| // JsonDataException 또는 JsonParseException) 가 발생합니다. | ||
| // - non nullable -> nullable 변경해주기 | ||
| // ex) val data: List<CreateLetterResponse> -> val data: List<CreateLetterResponse>? | ||
|
|
||
| // 원시타입 | ||
| // - 기본 데이터 타입으로, 메모리에 직접 값을 저장 | ||
| // - ex) Int, Long, Float, Double, Boolean, Char, Byte, Short 등 | ||
| // - null 값을 가질 수 없음 | ||
|
|
||
| // 참조타입 | ||
| // - 객체의 메모리 주소를 저장 | ||
| // - ex) String, List, Map, Array, Class 등 | ||
| // - null 값을 가질 수 있음 | ||
| // - Int?, Boolean? → Kotlin에서 nullable한 원시 타입도 결국 참조 타입으로 처리됨 | ||
|
|
||
| data class GetAllLettersResponse( | ||
| val data: List<CreateLetterResponse>, | ||
| val totalElements: Int, | ||
| val data: List<CreateLetterResponse>?, | ||
| val totalElements: Int?, | ||
| val currentPage: Int, | ||
| val totalPages: Int | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,49 @@ | ||
| package com.simply407.patpat.data.repository | ||
|
|
||
| import com.simply407.patpat.data.api.PatPatService | ||
| import com.simply407.patpat.data.api.RetrofitInstance | ||
| import com.simply407.patpat.data.model.ChattingRoomInfo | ||
| import com.simply407.patpat.data.model.MessageInfo | ||
| import com.simply407.patpat.data.model.PostMessageRequest | ||
| import retrofit2.Response | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
|
|
||
| class ChattingRepository { | ||
| // TODO 의존성주입을 하면 더 좋을 것 같다. hilt를 사용해 | ||
| // TODO create 의 내부 구현을 확인해보면 좋을듯 | ||
| // TODO API return형은 Response data class 를 반환 할 수 있게 repository에서 구현로직 들어가야함 | ||
| private val patPatService: PatPatService = RetrofitInstance.client.create(PatPatService::class.java) | ||
|
|
||
| val patApi = RetrofitInstance.getInstance().create(com.simply407.patpat.data.api.patApi::class.java) | ||
| suspend fun getAllChattingRoomInfo(accessToken: String, counselorId: String, page: Int, size: Int) = patPatService.getAllChattingRoomInfo(accessToken, counselorId, page, size) | ||
|
|
||
| suspend fun getAllChattingRoomInfo(accessToken: String, counselorId: String, page: Int, size: Int) = patApi.getAllChattingRoomInfo(accessToken, counselorId, page, size) | ||
| suspend fun postMessage( | ||
| accessToken: String, | ||
| counselorId: String, | ||
| postMessageRequest: PostMessageRequest | ||
| ) = patPatService.postMessage(accessToken, counselorId, postMessageRequest) | ||
| } | ||
|
|
||
| // Hilt에 결합 정보를 제공하는 한 가지 방법은 생성자 삽입입니다 | ||
| // 클래스의 생성자에서 @Inject 주석을 사용하여 클래스의 인스턴스를 제공하는 방법을 Hilt에 알려줍니다 | ||
| @Singleton | ||
| class ChattingRepository @Inject constructor( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repository에 Singleton annotation을 붙여야 할까요? |
||
| private val patPatService: PatPatService | ||
| ) { | ||
| suspend fun getAllChattingRoomInfo( | ||
| accessToken: String, | ||
| counselorId: String, | ||
| page: Int, | ||
| size: Int | ||
| ): Response<ChattingRoomInfo> { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Response 반환이 아닌 ChattingRoomInfo 로 반환 시켜보세요. Response로 반환하게 되면 해당 repository 에 대한 사용이 너무 어려울 것 같습니다. |
||
| return patPatService.getAllChattingRoomInfo(accessToken, counselorId, page, size) | ||
| } | ||
|
|
||
| suspend fun postMessage( | ||
| accessToken: String, | ||
| counselorId: String, | ||
| postMessageRequest: PostMessageRequest | ||
| ) = patApi.postMessage(accessToken, counselorId, postMessageRequest) | ||
| } | ||
| ): Response<MessageInfo> { | ||
| return patPatService.postMessage(accessToken, counselorId, postMessageRequest) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| package com.simply407.patpat.data.repository | ||
|
|
||
| import com.simply407.patpat.data.api.PatPatService | ||
| import com.simply407.patpat.data.api.RetrofitInstance | ||
|
|
||
| class CounselorRepository { | ||
|
|
||
| val patApi = RetrofitInstance.getInstance().create(com.simply407.patpat.data.api.patApi::class.java) | ||
| private val patPatService: PatPatService = RetrofitInstance.client.create(PatPatService::class.java) | ||
|
|
||
| suspend fun getCounselors(accessToken: String) = patApi.getCounselors(accessToken) | ||
| } | ||
| suspend fun getCounselors(accessToken: String) = patPatService.getCounselors(accessToken) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,23 @@ | ||
| package com.simply407.patpat.data.repository | ||
|
|
||
| import com.simply407.patpat.data.api.PatPatService | ||
| import com.simply407.patpat.data.api.RetrofitInstance | ||
| import com.simply407.patpat.data.model.CreateLetterRequest | ||
| import com.simply407.patpat.data.model.LikeLetterRequest | ||
|
|
||
| class LetterRepository { | ||
|
|
||
| val patApi = RetrofitInstance.getInstance().create(com.simply407.patpat.data.api.patApi::class.java) | ||
| private val patPatService: PatPatService = RetrofitInstance.client.create(PatPatService::class.java) | ||
|
|
||
| suspend fun createLetter(accessToken: String, createLetterRequest: CreateLetterRequest) = | ||
| patApi.createLetter(accessToken, createLetterRequest) | ||
| patPatService.createLetter(accessToken, createLetterRequest) | ||
|
|
||
| suspend fun getAllLetters(accessToken: String, page: Int, size: Int, isLiked: Boolean) = | ||
| patApi.getAllLetters(accessToken, page, size, isLiked) | ||
| patPatService.getAllLetters(accessToken, page, size, isLiked) | ||
|
|
||
| suspend fun likeLetter( | ||
| accessToken: String, | ||
| letterId: String, | ||
| likeLetterRequest: LikeLetterRequest | ||
| ) = patApi.likeLetter(accessToken, letterId, likeLetterRequest) | ||
| } | ||
| ) = patPatService.likeLetter(accessToken, letterId, likeLetterRequest) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| package com.simply407.patpat.data.repository | ||
|
|
||
|
|
||
| import com.simply407.patpat.data.api.PatPatService | ||
| import com.simply407.patpat.data.api.RetrofitInstance | ||
| import com.simply407.patpat.data.model.LoginRequest | ||
|
|
||
| class LoginRepository { | ||
|
|
||
| val patApi = RetrofitInstance.getInstance().create(com.simply407.patpat.data.api.patApi::class.java) | ||
| private val patPatService: PatPatService = RetrofitInstance.client.create(PatPatService::class.java) | ||
|
|
||
| suspend fun postLogin(loginRequest: LoginRequest) = patApi.postLogin(loginRequest) | ||
| suspend fun postLogin(loginRequest: LoginRequest) = patPatService.postLogin(loginRequest) | ||
|
|
||
| suspend fun userLogout(accessToken: String) = patApi.userLogout(accessToken) | ||
| suspend fun userLogout(accessToken: String) = patPatService.userLogout(accessToken) | ||
|
|
||
| suspend fun userWithdrawal(accessToken: String) = patApi.userWithdrawal(accessToken) | ||
| } | ||
| suspend fun userWithdrawal(accessToken: String) = patPatService.userWithdrawal(accessToken) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.simply407.patpat.data.repository | ||
|
|
||
| import android.content.Context | ||
| import com.simply407.patpat.R | ||
| import com.simply407.patpat.data.model.CounselorMbtiInfo | ||
|
|
||
| // TODO 샘플코드이긴 하지만... 만약 String을 객체로 담고 싶다면?? | ||
| class MBTIRepository(context: Context) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사실 이렇게 context를 넣어서 관리하는 것 보단 Resource만 보내고 이걸 사용하는 UI component쪽의 context를 사용해서 해당 Resource를 사용하는게 더 좋을 것 같습니다. |
||
| val counselorMbtiDataList = listOf( | ||
| CounselorMbtiInfo( | ||
| context.getString(R.string.counselor_boknam), | ||
| listOf( | ||
| context.getString(R.string.mbti_infj), | ||
| context.getString(R.string.mbti_infp), | ||
| context.getString(R.string.mbti_enfj), | ||
| context.getString(R.string.mbti_enfp) | ||
| ) | ||
| ), CounselorMbtiInfo( | ||
| context.getString(R.string.counselor_doctor), | ||
| listOf( | ||
| context.getString(R.string.mbti_intj), | ||
| context.getString(R.string.mbti_intp), | ||
| context.getString(R.string.mbti_entj), | ||
| context.getString(R.string.mbti_entp) | ||
| ) | ||
| ), CounselorMbtiInfo( | ||
| context.getString(R.string.counselor_kwak), | ||
| listOf( | ||
| context.getString(R.string.mbti_istj), | ||
| context.getString(R.string.mbti_istp), | ||
| context.getString(R.string.mbti_estj), | ||
| context.getString(R.string.mbti_estp) | ||
| ) | ||
| ), CounselorMbtiInfo( | ||
| context.getString(R.string.counselor_coco), | ||
| listOf( | ||
| context.getString(R.string.mbti_isfj), | ||
| context.getString(R.string.mbti_isfp), | ||
| context.getString(R.string.mbti_esfj), | ||
| context.getString(R.string.mbti_esfp) | ||
| ) | ||
| ) | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| package com.simply407.patpat.data.repository | ||
|
|
||
| import com.simply407.patpat.data.api.PatPatService | ||
| import com.simply407.patpat.data.api.RetrofitInstance | ||
| import com.simply407.patpat.data.model.NewUserInfo | ||
|
|
||
| class UserInfoRepository { | ||
|
|
||
| val patApi = RetrofitInstance.getInstance().create(com.simply407.patpat.data.api.patApi::class.java) | ||
| private val patPatService: PatPatService = RetrofitInstance.client.create(PatPatService::class.java) | ||
|
|
||
| suspend fun getUserInfo(accessToken: String) = patApi.getUserInfo(accessToken) | ||
| suspend fun getUserInfo(accessToken: String) = patPatService.getUserInfo(accessToken) | ||
|
|
||
| suspend fun putUserInfo(accessToken: String, newUserInfo: NewUserInfo) = | ||
| patApi.putUserInfo(accessToken, newUserInfo) | ||
| } | ||
| patPatService.putUserInfo(accessToken, newUserInfo) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data layer 의 폴더 안에 UI model이 있는 게 조금 이상한 것 같아요.
나중에는 멀티 모듈로 개선하면 좋을 것 같습니다.