-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: 도서관 남은 좌석 API 구현 #387
feat: 도서관 남은 좌석 API 구현 #387
Conversation
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.
Retrofit response 클래스를 proguard-rules.pro의 30라인 밑에 하나도 빠짐없이 선언해 주세요. 난독화 때문에 release에서 제대로 파싱하지 못하는 경우가 많았습니다.
그 외에는 코멘트 가볍게 읽어보시면 되겠습니다.
data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt
Show resolved
Hide resolved
data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/request/LibrarySeatRequest.kt
Show resolved
Hide resolved
data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt
Outdated
Show resolved
Hide resolved
override suspend fun getRemainingSeats(): List<LibraryRoom> { | ||
return try { | ||
libraryClient.fetchRoomSeatStatus().toLibraryAreaList() | ||
} catch (e: HttpException) { | ||
emptyList() | ||
} | ||
} |
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.
예외처리 굿
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.
그런데 여기서 예외처리하는게 맞을까요? UI쪽에서 에러 캐치를 해야 특정 Exception에 대응하는 화면을 만들 수 있는 등의 처리를 할 수 있을 것 같아서요.
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.
음.. 생각해 보니 그렇네요. 여기서는 exception을 그대로 던지거나, exception을 잡고 LibraryException
같은 커스텀 예외를 반환하는 게 나을수도 있겠네요
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.
그게 아니어도 그냥 runCatching 정도로 잡아도 될듯합니다
data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt
Show resolved
Hide resolved
data class LibraryRoomBranchResponse ( | ||
val id: Int, | ||
@SerializedName("name") val roomBranchName: String, | ||
val alias: String, | ||
val libraryCode: String, | ||
val sortOrder: Int | ||
) |
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.
이거 난독화 걸리면 name 빼고 다른 프로퍼티는 난독화 안전하지 않습니다. 혹시 모르니 수정해주시는걸 권장합니다.
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.
cf: 제 리뷰 코멘트와 같은 맥락입니다
data/remote/src/main/java/com/ku_stacks/ku_ring/remote/util/NetworkModule.kt
Show resolved
Hide resolved
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.
이 테스트는 작성한 의도가 있을까요?
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.
이 테스트 코드도 기존 코드를 차용한 것 입니다..
제가 이해한 테스트 코드 진행 순서인데, 이게 맞을까요?
- initService에서 createService 함수를 통해 테스트용 서비스 변수를 초기화
- @test 함수에서 enqueueResponse로 service의 함수를 호출했을 때 반환할 응답으로 json 파일을 지정
- mockWebServer의 takeRequest()를 통해 service가 의도대로 동작했는지 확인
- assert로 반환된 값이랑 예상 값이랑 비교
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.
mockWebServer에서 response를 테스트 하는것은 저희가 직접 정해주는 값을 넣고 그 값이 객체로 잘 역직렬화되는지를 확인하는 것과 같은데, 이런 테스트를 작성해서 얻을 수 있는 효험이 어떤 것이 있을지 생각해보면 좋을 것 같아요. 추가로 리스폰스가 변경이 되면 json 파일도 변경이 되어야 하는 등 유지보수를 해야하는데 그걸 감안하더라도 의미가 있는지까지 같이!
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 class LibrarySeatResponse( | ||
@SerializedName("success") | ||
val success: Boolean, | ||
@SerializedName("code") | ||
val code: String, | ||
@SerializedName("message") | ||
val message: String, | ||
@SerializedName("data") | ||
val data: LibraryRoomListResponse | ||
) |
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.
@SerializedName
을 자동으로 붙여주는 gradle 플러그인을 만들어 보면..? 그냥 아이디어입니다 ㅎㅎ
@Provides | ||
@Singleton | ||
fun provideLibraryService(@Named("Library") retrofit: Retrofit): LibraryService | ||
= retrofit.create(LibraryService::class.java) |
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.
= retrofit.create(LibraryService::class.java) | |
= retrofit.create() |
이렇게 적어도 됩니다ㅋㅋㅋㅋ
@Provides | ||
@Singleton | ||
fun provideLibraryClient(libraryService: LibraryService): LibraryClient | ||
= LibraryClient(libraryService) |
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.
이건 굳이 작성 안해주셔도 될거에요
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.
아 Client가 추상체와 구현체로 나뉘지 않아서 필요가 없겠네요
object LibrarySeatRequest { | ||
const val METHOD_CODE: String = "PC" | ||
const val ROOM_TYPE_ID = 4 | ||
const val BRANCH_TYPE_ID: Int = 1 | ||
} |
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.
이 오브젝트는 따로 작성하신 이유가 있나요?
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.
요청에 필요한 상수들이 한 군데에서 관리되고, 무슨 역할인지 명확히 알 수 있으면 좋을 것 같아서 object로 작성했습니다!
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.
고생하셨습니다.
https://kuring.atlassian.net/browse/KURING-224?atlOrigin=eyJpIjoiNWVhZjQ3N2Y3YWVmNGMyZTg2Mjk0MTY0M2M5NDc3OGEiLCJwIjoiaiJ9
요약
추가 수정 사항
trailing comma
반영@SerializedName
추가runCatching
을 사용한 예외처리