diff --git a/app/src/main/kotlin/io/sakurasou/model/dao/album/AlbumDao.kt b/app/src/main/kotlin/io/sakurasou/model/dao/album/AlbumDao.kt index bd098ea1..bf133564 100644 --- a/app/src/main/kotlin/io/sakurasou/model/dao/album/AlbumDao.kt +++ b/app/src/main/kotlin/io/sakurasou/model/dao/album/AlbumDao.kt @@ -11,4 +11,5 @@ interface AlbumDao { fun listAlbumByUserId(userId: Long): List fun getAlbumById(albumId: Long): Album? fun saveAlbum(insertDTO: AlbumInsertDTO): Long + fun initAlbumForUser(userId: Long): Long } \ No newline at end of file diff --git a/app/src/main/kotlin/io/sakurasou/model/dao/album/AlbumDaoImpl.kt b/app/src/main/kotlin/io/sakurasou/model/dao/album/AlbumDaoImpl.kt index 01dcff53..660691de 100644 --- a/app/src/main/kotlin/io/sakurasou/model/dao/album/AlbumDaoImpl.kt +++ b/app/src/main/kotlin/io/sakurasou/model/dao/album/AlbumDaoImpl.kt @@ -2,6 +2,9 @@ package io.sakurasou.model.dao.album import io.sakurasou.model.dto.AlbumInsertDTO import io.sakurasou.model.entity.Album +import kotlinx.datetime.Clock +import kotlinx.datetime.TimeZone +import kotlinx.datetime.toLocalDateTime import org.jetbrains.exposed.sql.insertAndGetId import org.jetbrains.exposed.sql.selectAll @@ -54,4 +57,17 @@ class AlbumDaoImpl : AlbumDao { } return entityID.value } + + override fun initAlbumForUser(userId: Long): Long { + val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()) + val uncategorizedAlbum = AlbumInsertDTO( + userId = userId, + name = "uncategorized", + description = "default, cannot delete", + imageCount = 0, + isUncategorized = true, + createTime = now + ) + return saveAlbum(uncategorizedAlbum) + } } \ No newline at end of file diff --git a/app/src/main/kotlin/io/sakurasou/service/album/AlbumService.kt b/app/src/main/kotlin/io/sakurasou/service/album/AlbumService.kt index 828d43a9..3118d5ab 100644 --- a/app/src/main/kotlin/io/sakurasou/service/album/AlbumService.kt +++ b/app/src/main/kotlin/io/sakurasou/service/album/AlbumService.kt @@ -5,6 +5,5 @@ package io.sakurasou.service.album * 2024/9/13 14:48 */ interface AlbumService { - suspend fun initAlbumForUser(userId: Long): Long suspend fun saveAlbum(): Long } \ No newline at end of file diff --git a/app/src/main/kotlin/io/sakurasou/service/album/AlbumServiceImpl.kt b/app/src/main/kotlin/io/sakurasou/service/album/AlbumServiceImpl.kt index 99265eb8..08782078 100644 --- a/app/src/main/kotlin/io/sakurasou/service/album/AlbumServiceImpl.kt +++ b/app/src/main/kotlin/io/sakurasou/service/album/AlbumServiceImpl.kt @@ -1,11 +1,6 @@ package io.sakurasou.service.album -import io.sakurasou.model.DatabaseSingleton.dbQuery import io.sakurasou.model.dao.album.AlbumDao -import io.sakurasou.model.dto.AlbumInsertDTO -import kotlinx.datetime.Clock -import kotlinx.datetime.TimeZone -import kotlinx.datetime.toLocalDateTime /** * @author Shiina Kin @@ -14,21 +9,6 @@ import kotlinx.datetime.toLocalDateTime class AlbumServiceImpl( private val albumDao: AlbumDao ) : AlbumService { - override suspend fun initAlbumForUser(userId: Long): Long { - val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()) - val uncategorizedAlbum = AlbumInsertDTO( - userId = userId, - name = "uncategorized", - description = "default, cannot delete", - imageCount = 0, - isUncategorized = true, - createTime = now - ) - return dbQuery { - albumDao.saveAlbum(uncategorizedAlbum) - } - } - override suspend fun saveAlbum(): Long { TODO("Not yet implemented") }