Skip to content

Commit

Permalink
[maro/#33] feat :: SongDao, SongDatabase 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
leesumin0526 committed May 27, 2024
1 parent b7fa9e7 commit bb3935b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 27 deletions.
60 changes: 35 additions & 25 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions UMC_6th/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
}

android {
Expand Down Expand Up @@ -46,6 +47,9 @@ android {

dependencies {

implementation("androidx.room:room-migration:2.6.0")
implementation("androidx.room:room-runtime:2.6.0")
kapt("androidx.room:room-compiler:2.6.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.fragment:fragment-ktx:1.3.0")
Expand Down
23 changes: 23 additions & 0 deletions UMC_6th/app/src/main/java/com/example/umc_6th/SongDao.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.umc_6th

import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update

interface SongDao {
@Insert
fun insert(song: Song)

@Update
fun update(song: Song)

@Delete
fun delete(song : Song)

@Query("SELECT * FROM SongTable")
fun getSongs() : List<Song>

@Query("SELECT * FROM SongTable WHERE id = :id")
fun getSong(id : Int): Song
}
12 changes: 10 additions & 2 deletions UMC_6th/app/src/main/java/com/example/umc_6th/song.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package com.example.umc_6th

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "SongTable")
data class Song(
val title : String = "",
val singer : String = "",
var second : Int = 0,
var playTime : Int = 60,
var isPlaying : Boolean = false,
var music : String = ""
)
var music : String = "",
var coverImg : Int? = null,
var isLike : Boolean = false
){
@PrimaryKey(autoGenerate = true) var id : Int = 0
}

0 comments on commit bb3935b

Please # to comment.