From ad198ec9ccdfc4e96f88431aba0d3c11d3f0f2d6 Mon Sep 17 00:00:00 2001 From: Shiina Kin Date: Tue, 17 Sep 2024 17:45:37 +0800 Subject: [PATCH] feat: modify user and image entity image: is_private, user: is_default_image_private --- .../main/kotlin/io/sakurasou/model/dao/image/ImageDaoImpl.kt | 2 ++ app/src/main/kotlin/io/sakurasou/model/dao/image/Images.kt | 1 + app/src/main/kotlin/io/sakurasou/model/dao/user/UserDaoImpl.kt | 3 +++ app/src/main/kotlin/io/sakurasou/model/dao/user/Users.kt | 1 + app/src/main/kotlin/io/sakurasou/model/dto/ImageDTO.kt | 1 + app/src/main/kotlin/io/sakurasou/model/dto/UserDTO.kt | 1 + app/src/main/kotlin/io/sakurasou/model/entity/Image.kt | 1 + app/src/main/kotlin/io/sakurasou/model/entity/User.kt | 1 + .../kotlin/io/sakurasou/service/common/CommonServiceImpl.kt | 1 + .../main/kotlin/io/sakurasou/service/user/UserServiceImpl.kt | 1 + .../test/kotlin/io/sakurasou/service/auth/AuthServiceTest.kt | 2 ++ .../kotlin/io/sakurasou/service/common/CommonServiceTest.kt | 1 + .../test/kotlin/io/sakurasou/service/user/UserServiceTest.kt | 1 + 13 files changed, 17 insertions(+) diff --git a/app/src/main/kotlin/io/sakurasou/model/dao/image/ImageDaoImpl.kt b/app/src/main/kotlin/io/sakurasou/model/dao/image/ImageDaoImpl.kt index a62cb820..d8b394df 100644 --- a/app/src/main/kotlin/io/sakurasou/model/dao/image/ImageDaoImpl.kt +++ b/app/src/main/kotlin/io/sakurasou/model/dao/image/ImageDaoImpl.kt @@ -41,6 +41,7 @@ class ImageDaoImpl : ImageDao { it[height] = insertDTO.height it[md5] = insertDTO.md5 it[sha1] = insertDTO.sha1 + it[isPrivate] = insertDTO.isPrivate it[createTime] = insertDTO.createTime } return entityID.value @@ -63,6 +64,7 @@ class ImageDaoImpl : ImageDao { it[Images.height], it[Images.md5], it[Images.sha1], + it[Images.isPrivate], it[Images.createTime] ) } \ No newline at end of file diff --git a/app/src/main/kotlin/io/sakurasou/model/dao/image/Images.kt b/app/src/main/kotlin/io/sakurasou/model/dao/image/Images.kt index d43e8592..d96d09df 100644 --- a/app/src/main/kotlin/io/sakurasou/model/dao/image/Images.kt +++ b/app/src/main/kotlin/io/sakurasou/model/dao/image/Images.kt @@ -27,6 +27,7 @@ object Images : LongIdTable() { val height = integer("height").check { it greater 0 } val md5 = char("md5", 32) val sha1 = char("sha1", 40) + val isPrivate = bool("is_private") val createTime = datetime("create_time") init { diff --git a/app/src/main/kotlin/io/sakurasou/model/dao/user/UserDaoImpl.kt b/app/src/main/kotlin/io/sakurasou/model/dao/user/UserDaoImpl.kt index da654e8d..d779ffeb 100644 --- a/app/src/main/kotlin/io/sakurasou/model/dao/user/UserDaoImpl.kt +++ b/app/src/main/kotlin/io/sakurasou/model/dao/user/UserDaoImpl.kt @@ -20,6 +20,7 @@ class UserDaoImpl : UserDao { row[Users.name], row[Users.password], row[Users.email], + row[Users.isDefaultImagePrivate], row[Users.createTime], row[Users.updateTime] ) @@ -36,6 +37,7 @@ class UserDaoImpl : UserDao { row[Users.name], row[Users.password], row[Users.email], + row[Users.isDefaultImagePrivate], row[Users.createTime], row[Users.updateTime] ) @@ -48,6 +50,7 @@ class UserDaoImpl : UserDao { it[name] = user.username it[password] = user.password it[email] = user.email + it[isDefaultImagePrivate] = user.isDefaultImagePrivate it[createTime] = user.createTime it[updateTime] = user.updateTime } diff --git a/app/src/main/kotlin/io/sakurasou/model/dao/user/Users.kt b/app/src/main/kotlin/io/sakurasou/model/dao/user/Users.kt index bea8f650..f870f391 100644 --- a/app/src/main/kotlin/io/sakurasou/model/dao/user/Users.kt +++ b/app/src/main/kotlin/io/sakurasou/model/dao/user/Users.kt @@ -13,6 +13,7 @@ object Users : LongIdTable("users") { val name = varchar("name", 50).uniqueIndex() val password = char("password", 60) val email = varchar("email", 255).nullable() + val isDefaultImagePrivate = bool("is_default_image_private") val createTime = datetime("create_time") val updateTime = datetime("update_time") diff --git a/app/src/main/kotlin/io/sakurasou/model/dto/ImageDTO.kt b/app/src/main/kotlin/io/sakurasou/model/dto/ImageDTO.kt index f0e79bc7..b54ffb64 100644 --- a/app/src/main/kotlin/io/sakurasou/model/dto/ImageDTO.kt +++ b/app/src/main/kotlin/io/sakurasou/model/dto/ImageDTO.kt @@ -22,5 +22,6 @@ data class ImageInsertDTO( val height: Int, val md5: String, val sha1: String, + val isPrivate: Boolean, val createTime: LocalDateTime ) \ No newline at end of file diff --git a/app/src/main/kotlin/io/sakurasou/model/dto/UserDTO.kt b/app/src/main/kotlin/io/sakurasou/model/dto/UserDTO.kt index 22de2fd4..116b6359 100644 --- a/app/src/main/kotlin/io/sakurasou/model/dto/UserDTO.kt +++ b/app/src/main/kotlin/io/sakurasou/model/dto/UserDTO.kt @@ -11,6 +11,7 @@ data class UserInsertDTO( val username: String, val password: String, val email: String?, + val isDefaultImagePrivate: Boolean, val createTime: LocalDateTime, val updateTime: LocalDateTime ) \ No newline at end of file diff --git a/app/src/main/kotlin/io/sakurasou/model/entity/Image.kt b/app/src/main/kotlin/io/sakurasou/model/entity/Image.kt index 963419f9..f3352625 100644 --- a/app/src/main/kotlin/io/sakurasou/model/entity/Image.kt +++ b/app/src/main/kotlin/io/sakurasou/model/entity/Image.kt @@ -25,5 +25,6 @@ data class Image( val height: Int, val md5: String, val sha1: String, + val isPrivate: Boolean, val createTime: LocalDateTime ) \ No newline at end of file diff --git a/app/src/main/kotlin/io/sakurasou/model/entity/User.kt b/app/src/main/kotlin/io/sakurasou/model/entity/User.kt index 63b5ce63..d6b56a6b 100644 --- a/app/src/main/kotlin/io/sakurasou/model/entity/User.kt +++ b/app/src/main/kotlin/io/sakurasou/model/entity/User.kt @@ -14,6 +14,7 @@ data class User( val name: String, val password: String, val email: String?, + val isDefaultImagePrivate: Boolean, val createTime: LocalDateTime, val updateTime: LocalDateTime ) \ No newline at end of file diff --git a/app/src/main/kotlin/io/sakurasou/service/common/CommonServiceImpl.kt b/app/src/main/kotlin/io/sakurasou/service/common/CommonServiceImpl.kt index c316a6ec..7ab84d42 100644 --- a/app/src/main/kotlin/io/sakurasou/service/common/CommonServiceImpl.kt +++ b/app/src/main/kotlin/io/sakurasou/service/common/CommonServiceImpl.kt @@ -38,6 +38,7 @@ class CommonServiceImpl( username = siteInitRequest.username, password = encodePassword, email = siteInitRequest.email, + isDefaultImagePrivate = true, createTime = now, updateTime = now ) diff --git a/app/src/main/kotlin/io/sakurasou/service/user/UserServiceImpl.kt b/app/src/main/kotlin/io/sakurasou/service/user/UserServiceImpl.kt index a8d4b4de..b0f30bd5 100644 --- a/app/src/main/kotlin/io/sakurasou/service/user/UserServiceImpl.kt +++ b/app/src/main/kotlin/io/sakurasou/service/user/UserServiceImpl.kt @@ -36,6 +36,7 @@ class UserServiceImpl( username = userInsertRequest.username, password = encodePassword, email = userInsertRequest.email, + isDefaultImagePrivate = true, createTime = now, updateTime = now ) diff --git a/app/src/test/kotlin/io/sakurasou/service/auth/AuthServiceTest.kt b/app/src/test/kotlin/io/sakurasou/service/auth/AuthServiceTest.kt index 36063199..d39e6267 100644 --- a/app/src/test/kotlin/io/sakurasou/service/auth/AuthServiceTest.kt +++ b/app/src/test/kotlin/io/sakurasou/service/auth/AuthServiceTest.kt @@ -70,6 +70,7 @@ class AuthServiceTest { name = username, password = hashedPassword, email = email, + isDefaultImagePrivate = true, createTime = now, updateTime = now ) @@ -98,6 +99,7 @@ class AuthServiceTest { name = username, password = hashedPassword, email = email, + isDefaultImagePrivate = true, createTime = now, updateTime = now ) diff --git a/app/src/test/kotlin/io/sakurasou/service/common/CommonServiceTest.kt b/app/src/test/kotlin/io/sakurasou/service/common/CommonServiceTest.kt index 8c33229a..c1351b62 100644 --- a/app/src/test/kotlin/io/sakurasou/service/common/CommonServiceTest.kt +++ b/app/src/test/kotlin/io/sakurasou/service/common/CommonServiceTest.kt @@ -84,6 +84,7 @@ class CommonServiceTest { username = "testUser", password = encodedPassword, email = "test@example.com", + isDefaultImagePrivate = true, createTime = now, updateTime = now ) diff --git a/app/src/test/kotlin/io/sakurasou/service/user/UserServiceTest.kt b/app/src/test/kotlin/io/sakurasou/service/user/UserServiceTest.kt index 1f2036b9..883a14d4 100644 --- a/app/src/test/kotlin/io/sakurasou/service/user/UserServiceTest.kt +++ b/app/src/test/kotlin/io/sakurasou/service/user/UserServiceTest.kt @@ -87,6 +87,7 @@ class UserServiceTest { username = "testUser", password = encodedPassword, email = "test@example.com", + isDefaultImagePrivate = true, createTime = now, updateTime = now )