-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from f-lab-edu/SCRUM-83
SCRUM-83: 독후감 편집에서 태그 추가 및 제거 기능 구현
- Loading branch information
Showing
78 changed files
with
1,923 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/towitty/bookreport/data/database/BookReportDatabase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.towitty.bookreport.data.database | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import com.towitty.bookreport.data.database.model.TagEntity | ||
|
||
|
||
@Database(entities = [TagEntity::class], version = 1, exportSchema = false) | ||
abstract class BookReportDatabase : RoomDatabase() { | ||
|
||
abstract fun tagDao(): TagDao | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/towitty/bookreport/data/database/TagDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.towitty.bookreport.data.database | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Delete | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import androidx.room.Update | ||
import com.towitty.bookreport.data.database.model.TagEntity | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
@Dao | ||
interface TagDao { | ||
@Insert | ||
suspend fun insertTag(tagEntity: TagEntity) | ||
|
||
@Update | ||
suspend fun updateTag(tagEntity: TagEntity) | ||
|
||
@Delete | ||
suspend fun deleteTag(tagEntity: TagEntity) | ||
|
||
@Query("SELECT * FROM tags WHERE id = :id") | ||
fun getTag(id: Int): Flow<TagEntity> | ||
|
||
@Query("SELECT * FROM tags ORDER BY name ASC") | ||
fun getAllTags(): Flow<List<TagEntity>> | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/towitty/bookreport/data/database/di/DaosModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.towitty.bookreport.data.database.di | ||
|
||
import com.towitty.bookreport.data.database.BookReportDatabase | ||
import com.towitty.bookreport.data.database.TagDao | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
object DaosModule { | ||
|
||
@Singleton | ||
@Provides | ||
fun provideTagDao(appDatabase: BookReportDatabase): TagDao = appDatabase.tagDao() | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/towitty/bookreport/data/database/di/DatabaseModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.towitty.bookreport.data.database.di | ||
|
||
import android.content.Context | ||
import androidx.room.Room | ||
import com.towitty.bookreport.data.database.BookReportDatabase | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
object DatabaseModule { | ||
|
||
@Singleton | ||
@Provides | ||
fun provideBookReportDatabase( | ||
@ApplicationContext context: Context | ||
): BookReportDatabase = Room.databaseBuilder( | ||
context, | ||
BookReportDatabase::class.java, | ||
"book_report_db" | ||
).build() | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/towitty/bookreport/data/database/model/TagEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.towitty.bookreport.data.database.model | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "tags") | ||
data class TagEntity( | ||
@PrimaryKey(autoGenerate = true) | ||
val id:Int, | ||
val name:String, | ||
val color: Int | ||
) | ||
|
||
val emptyTagEntity = TagEntity(0, "", 0) |
2 changes: 1 addition & 1 deletion
2
app/src/main/java/com/towitty/bookreport/data/network/ApiService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
app/src/main/java/com/towitty/bookreport/data/network/BookRemoteRepository.kt
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/towitty/bookreport/data/network/IBookDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.towitty.bookreport.data.network | ||
|
||
import com.towitty.bookreport.data.network.model.Book | ||
|
||
interface IBookDataSource { | ||
suspend fun getBook(query: String): Book | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/towitty/bookreport/data/network/di/DataSourceModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.towitty.bookreport.data.network.di | ||
|
||
import com.towitty.bookreport.data.network.BookRemoteDataSource | ||
import com.towitty.bookreport.data.network.IBookDataSource | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
abstract class DataSourceModule { | ||
|
||
@Binds | ||
abstract fun bindsBookDataSource(bookRemoteDataSource: BookRemoteDataSource): IBookDataSource | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/towitty/bookreport/data/repository/BookRemoteRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.towitty.bookreport.data.repository | ||
|
||
import com.towitty.bookreport.data.network.IBookDataSource | ||
import com.towitty.bookreport.data.network.model.BookItem | ||
import com.towitty.bookreport.data.network.model.emptyBookItem | ||
import javax.inject.Inject | ||
|
||
class BookRemoteRepository @Inject constructor( | ||
private val bookRemoteDataSource: IBookDataSource | ||
) : IBookRepository { | ||
private var bookList: List<BookItem> = emptyList() | ||
|
||
override suspend fun searchBooks(query: String): List<BookItem> { | ||
bookList = bookRemoteDataSource.getBook(query).bookList | ||
return bookList | ||
} | ||
|
||
override fun findBookByIsbn(isbn: String): BookItem = bookList.find { it.isbn == isbn } ?: emptyBookItem | ||
} |
Oops, something went wrong.