-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 서재 UI/UX 개편 (3) - Room 모듈 구현 #697
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
Conversation
|
""" Walkthrough이번 변경에서는 Room 기반의 데이터베이스 모듈(core/database)이 신규로 도입되었습니다. Room 엔티티, DAO, 데이터베이스 클래스, DI 모듈, 빌드 및 ProGuard 설정, 그리고 관련 의존성 추가 및 프로젝트 등록이 포함됩니다. 기존 데이터 소스 인터페이스의 메서드 이름도 일관성 있게 수정되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant LibraryLocalDataSource
participant DefaultLibraryDataSource
participant NovelDao
participant WebsosoDatabase
App->>LibraryLocalDataSource: selectAllNovels()
LibraryLocalDataSource->>DefaultLibraryDataSource: selectAllNovels()
DefaultLibraryDataSource->>NovelDao: selectAllNovels()
NovelDao-->>DefaultLibraryDataSource: Flow<List<NovelEntity>>
DefaultLibraryDataSource-->>LibraryLocalDataSource: 결과 반환
LibraryLocalDataSource-->>App: 결과 반환
Assessment against linked issues
Suggested reviewers
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (13)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| @@ -0,0 +1,20 @@ | |||
| import com.into.websoso.buildConfigs | |||
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.
🚫 [ktlint] standard:no-unused-imports reported by reviewdog 🐶
Unused import
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.
Actionable comments posted: 2
🧹 Nitpick comments (4)
data/library/src/main/java/com/into/websoso/data/library/datasource/LibraryLocalDataSource.kt (1)
4-4: 메서드 이름 개선
getFullLibrary()에서selectAllNovels()로 메서드 이름이 변경되었습니다. 이 변경은 SQL 명명 규칙(SELECT)과 일치하도록 표준화되었으며, Room 데이터베이스 도입에 맞추어 더 명확한 의미를 제공합니다.다만, 반환 타입이 명시되어 있지 않습니다. Room 데이터베이스를 사용할 때는 반환 타입을 명확히 지정하는 것이 좋습니다.
- suspend fun selectAllNovels() + suspend fun selectAllNovels(): List<Novel>core/database/src/main/java/com/into/websoso/core/database/WebsosoDatabase.kt (1)
8-12: exportSchema 설정 검토 권장
현재exportSchema = false로 되어 있는데, 데이터베이스 스키마 변경 이력을 버전 관리하려면true로 설정하고schemaLocation을 지정하는 것이 좋습니다.core/database/src/main/java/com/into/websoso/core/database/di/DatabaseModule.kt (1)
16-26: 마이그레이션 전략 추가 검토
버전 1에서 향후 스키마 업데이트 시 마이그레이션 로직이 없으면 앱이 충돌할 수 있습니다.fallbackToDestructiveMigration()또는 명시적addMigrations()설정을 추가하는 방안을 고려해주세요.core/database/src/main/java/com/into/websoso/core/database/datasource/library/NovelDao.kt (1)
16-44: DAO 인터페이스 구현이 잘 되어 있습니다Room DAO 인터페이스가 명확하게 정의되었고 필요한 데이터베이스 작업들(삽입, 조회, 삭제)이 잘 구현되어 있습니다. 특히
selectAllNovels()에서 Flow를 반환하는 것은 데이터베이스 변경사항을 관찰하기 위한 좋은 접근법입니다.다만,
userNovelId를 기준으로 정렬할 때 인덱스 활용을 고려해 볼 수 있습니다.다음과 같이
NovelEntity클래스에 인덱스를 추가하는 것을 고려해보세요:@Entity( tableName = "novels", indices = [Index("userNovelId")] ) data class NovelEntity( // existing fields )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
core/database/.gitignore(1 hunks)core/database/build.gradle.kts(1 hunks)core/database/proguard-rules.pro(1 hunks)core/database/src/main/AndroidManifest.xml(1 hunks)core/database/src/main/java/com/into/websoso/core/database/WebsosoDatabase.kt(1 hunks)core/database/src/main/java/com/into/websoso/core/database/datasource/library/DefaultLibraryDataSource.kt(1 hunks)core/database/src/main/java/com/into/websoso/core/database/datasource/library/NovelDao.kt(1 hunks)core/database/src/main/java/com/into/websoso/core/database/di/DatabaseModule.kt(1 hunks)core/database/src/main/java/com/into/websoso/core/database/entity/NovelEntity.kt(1 hunks)data/library/src/main/java/com/into/websoso/data/library/datasource/LibraryLocalDataSource.kt(1 hunks)gradle/libs.versions.toml(2 hunks)settings.gradle.kts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
core/database/build.gradle.kts (2)
build-logic/src/main/kotlin/com/into/websoso/ProjectExtensions.kt (1)
setNamespace(9-13)build-logic/src/main/kotlin/com/into/websoso/WebsosoDependenciesExtensions.kt (1)
implementation(70-76)
🔇 Additional comments (13)
gradle/libs.versions.toml (2)
34-34: Room 의존성 버전 추가 확인Room 데이터베이스를 위한 버전이 추가되었습니다. 2.7.1 버전은 최신 버전으로 적절해 보입니다. Room은 SQLite 데이터베이스에 대한 추상화 계층을 제공하여 데이터 지속성을 쉽게 구현할 수 있게 해줍니다.
98-100: Room 라이브러리 의존성 추가 확인Room 관련 세 가지 핵심 라이브러리(runtime, ktx, compiler)가 적절하게 추가되었습니다. 이는 Room 데이터베이스 구현에 필요한 모든 기본 구성 요소를 포함하고 있습니다:
- room-runtime: 기본 Room 라이브러리
- room-ktx: Kotlin 확장 기능
- room-compiler: 어노테이션 프로세서
빌드 시스템에 필요한 모든 Room 컴포넌트가 포함되어 있어 적절합니다.
core/database/.gitignore (1)
1-1: 적절한 .gitignore 파일 생성새로운 데이터베이스 모듈에 대한 기본적인 .gitignore 파일이 생성되었습니다. 빌드 디렉토리를 무시하는 것은 표준 관행입니다. 이는 불필요한 빌드 아티팩트가 Git 저장소에 포함되는 것을 방지합니다.
core/database/src/main/AndroidManifest.xml (1)
1-4: 라이브러리 모듈용 기본 매니페스트 파일 확인데이터베이스 모듈을 위한 기본 매니페스트 파일이 적절히 생성되었습니다. 라이브러리 모듈은 일반적으로 액티비티나 권한 등을 선언할 필요가 없으므로 최소한의 매니페스트만 필요합니다. 현재 구성은 라이브러리 모듈에 적합합니다.
settings.gradle.kts (1)
31-31: database 모듈 포함 확인새로운 database 모듈(
:core:database)이 프로젝트 설정에 적절히 추가되었습니다. 이는 PR의 주요 목표인 "Room 모듈 추가 및 도서관 또는 책장 기능과 관련된 데이터베이스 설정"에 부합합니다.core/database/proguard-rules.pro (1)
1-21: 프로가드 파일 템플릿 적절합니다
아직 구체적인 룰이 필요하지 않다면 현재 상태로도 문제 없습니다. 향후 Room 혹은 Hilt 관련 최적화/난독화 규칙이 필요해지면 해당 섹션을 활성화해주세요.core/database/src/main/java/com/into/websoso/core/database/WebsosoDatabase.kt (1)
13-15: 데이터베이스 클래스 정의가 적절합니다
WebsosoDatabase의 추상 메서드와 접근 제한자가 올바르게 적용되어 있으며, DAO 제공 구조도 적절합니다.core/database/src/main/java/com/into/websoso/core/database/entity/NovelEntity.kt (1)
6-15: PrimaryKey 자동 생성 여부 확인 필요
@PrimaryKey에autoGenerate속성이 없으므로,userNovelId를 외부에서 직접 관리해야 합니다. 의도대로 로컬 키를 자동 생성하려면@PrimaryKey(autoGenerate = true)를 검토해주세요.core/database/src/main/java/com/into/websoso/core/database/di/DatabaseModule.kt (1)
13-15: Hilt 모듈 선언 적절합니다
@Module,@InstallIn(SingletonComponent::class)설정으로 애플리케이션 스코프의 싱글턴을 제공하고 있어 적절합니다.core/database/src/main/java/com/into/websoso/core/database/datasource/library/NovelDao.kt (2)
1-15: 적절한 import 선언 확인됨필요한 모든 Room, Dagger Hilt, Kotlin Flow 라이브러리들이 적절하게 임포트되어 있습니다.
46-52: Hilt 모듈 설정이 잘 되어 있습니다NovelDao를 제공하기 위한 Dagger Hilt 모듈이 적절하게 구성되어 있습니다. SingletonComponent를 사용하여 앱 전체에서 단일 인스턴스를 보장하고 있습니다.
core/database/src/main/java/com/into/websoso/core/database/datasource/library/DefaultLibraryDataSource.kt (2)
1-10: 필요한 임포트 모두 포함됨Dagger Hilt 및 의존성 주입에 필요한 모든 임포트가 포함되어 있습니다.
21-27: Hilt 바인딩 모듈 구성이 적절함LibraryDataSourceModule이 DefaultLibraryDataSource를 LibraryLocalDataSource 인터페이스에 적절하게 바인딩하고 있습니다. 싱글톤으로 제공되어 앱 전체에서 일관된 인스턴스를 사용할 수 있습니다.
core/database/build.gradle.kts
Outdated
| implementation(libs.room.ktx) | ||
| implementation(libs.room.runtime) | ||
| implementation(libs.room.compiler) |
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.
Room 컴파일러 의존성은 KAPT로 설정하세요
현재 libs.room.compiler를 implementation으로 추가하셨는데, Room 어노테이션 프로세서가 실행되지 않아 빌드 오류가 발생할 수 있습니다. kapt로 변경하고 kotlin-kapt 플러그인을 적용해주세요.
plugins {
id("websoso.android.library")
+ id("kotlin-kapt")
}
dependencies {
implementation(projects.data.library)
// 데이터베이스 관련 라이브러리
implementation(libs.room.ktx)
implementation(libs.room.runtime)
- implementation(libs.room.compiler)
+ kapt(libs.room.compiler)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| implementation(libs.room.ktx) | |
| implementation(libs.room.runtime) | |
| implementation(libs.room.compiler) | |
| // File: core/database/build.gradle.kts | |
| plugins { | |
| id("websoso.android.library") | |
| id("kotlin-kapt") | |
| } | |
| dependencies { | |
| implementation(projects.data.library) | |
| // 데이터베이스 관련 라이브러리 | |
| implementation(libs.room.ktx) | |
| implementation(libs.room.runtime) | |
| kapt(libs.room.compiler) | |
| } |
🤖 Prompt for AI Agents
In core/database/build.gradle.kts around lines 17 to 19, the Room compiler
dependency is incorrectly added using implementation, which prevents the
annotation processor from running and causes build errors. Change the dependency
from implementation(libs.room.compiler) to kapt(libs.room.compiler) and ensure
the kotlin-kapt plugin is applied at the top of the build script to enable
annotation processing.
| internal class DefaultLibraryDataSource | ||
| @Inject | ||
| constructor( | ||
| private val novelDao: NovelDao, | ||
| ) : LibraryLocalDataSource { | ||
| override suspend fun selectAllNovels() { | ||
| TODO("Not yet implemented") | ||
| } | ||
| } |
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.
미구현된 메서드 구현 필요
selectAllNovels() 메서드가 TODO로 남아있어 기능이 구현되지 않았습니다. novelDao를 활용하여 이 메서드를 완전히 구현해야 합니다.
다음과 같이 메서드를 구현하는 것을 권장합니다:
- override suspend fun selectAllNovels() {
- TODO("Not yet implemented")
- }
+ override suspend fun selectAllNovels() = novelDao.selectAllNovels()또한, LibraryLocalDataSource의 반환 타입에 따라 적절한 모델 변환이 필요할 수 있습니다. 만약 LibraryLocalDataSource 인터페이스의 메서드가 특정 반환 타입을 가지고 있다면 그에 맞게 수정해주세요.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| internal class DefaultLibraryDataSource | |
| @Inject | |
| constructor( | |
| private val novelDao: NovelDao, | |
| ) : LibraryLocalDataSource { | |
| override suspend fun selectAllNovels() { | |
| TODO("Not yet implemented") | |
| } | |
| } | |
| internal class DefaultLibraryDataSource | |
| @Inject | |
| constructor( | |
| private val novelDao: NovelDao, | |
| ) : LibraryLocalDataSource { | |
| override suspend fun selectAllNovels() = novelDao.selectAllNovels() | |
| } |
🤖 Prompt for AI Agents
In
core/database/src/main/java/com/into/websoso/core/database/datasource/library/DefaultLibraryDataSource.kt
around lines 11 to 19, the selectAllNovels() method is currently unimplemented
with a TODO. Implement this method by using novelDao to fetch all novels from
the database. Ensure the return type matches the LibraryLocalDataSource
interface's definition, and if necessary, convert the data from novelDao into
the appropriate model before returning it.
yeonjeen
left a comment
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.
수고하셨숨당~
📌𝘐𝘴𝘴𝘶𝘦𝘴
📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯
Summary by CodeRabbit
신규 기능
환경 설정
리팩터링