Skip to content

Commit

Permalink
refactor: change email field in UserVO to non-nullable and add albumC…
Browse files Browse the repository at this point in the history
…ount to UserPageVO
  • Loading branch information
ShiinaKin committed Nov 25, 2024
1 parent ea33e1f commit b050d19
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
10 changes: 7 additions & 3 deletions app/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3778,7 +3778,7 @@
"type" : "string"
},
"email" : {
"type" : [ "null", "string" ]
"type" : "string"
},
"groupName" : {
"type" : "string"
Expand All @@ -3805,7 +3805,7 @@
"type" : "string"
}
},
"required" : [ "albumCount", "allSize", "createTime", "groupName", "id", "imageCount", "isBanned", "isDefaultImagePrivate", "totalImageSize", "username" ]
"required" : [ "albumCount", "allSize", "createTime", "email", "groupName", "id", "imageCount", "isBanned", "isDefaultImagePrivate", "totalImageSize", "username" ]
},
"CommonResponse_UserVO" : {
"type" : "object",
Expand Down Expand Up @@ -3905,6 +3905,10 @@
"UserPageVO" : {
"type" : "object",
"properties" : {
"albumCount" : {
"type" : "integer",
"format" : "int64"
},
"createTime" : {
"type" : "string"
},
Expand All @@ -3930,7 +3934,7 @@
"type" : "string"
}
},
"required" : [ "createTime", "groupName", "id", "imageCount", "isBanned", "totalImageSize", "username" ]
"required" : [ "albumCount", "createTime", "groupName", "id", "imageCount", "isBanned", "totalImageSize", "username" ]
},
"CommonResponse_PageResult_UserPageVO" : {
"type" : "object",
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/kotlin/io/sakurasou/controller/vo/UserVO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class UserVO(
val id: Long,
val username: String,
val groupName: String,
val email: String?,
val email: String,
val isDefaultImagePrivate: Boolean,
val isBanned: Boolean,
val createTime: LocalDateTime,
Expand All @@ -33,5 +33,6 @@ data class UserPageVO(
val isBanned: Boolean,
val createTime: LocalDateTime,
val imageCount: Long,
val albumCount: Long,
val totalImageSize: Double
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.sakurasou.model.dao.user
import io.sakurasou.controller.request.PageRequest
import io.sakurasou.controller.vo.PageResult
import io.sakurasou.controller.vo.UserPageVO
import io.sakurasou.model.dao.album.Albums
import io.sakurasou.model.dao.group.Groups
import io.sakurasou.model.dao.image.Images
import io.sakurasou.model.dto.UserInsertDTO
Expand Down Expand Up @@ -92,10 +93,11 @@ class UserDaoImpl : UserDao {
query
.adjustColumnSet {
innerJoin(Groups) { Users.groupId eq Groups.id }
.leftJoin(Albums) { Users.id eq Albums.userId }
.leftJoin(Images) { Users.id eq Images.userId }
}
.adjustSelect { select(Users.fields + Groups.name + Images.id.count() + Images.size.sum()) }
.groupBy(Users.id, Users.name, Users.isBanned, Groups.name)
.adjustSelect { select(Users.fields + Groups.name + Albums.id.count() + Images.id.count() + Images.size.sum()) }
.groupBy(Users.id, Users.name, Users.isBanned, Groups.name, Users.createTime)
.also {
pageRequest.additionalCondition?.let { map ->
map["isBanned"]?.let { isBanned ->
Expand All @@ -115,6 +117,7 @@ class UserDaoImpl : UserDao {
isBanned = it[Users.isBanned],
createTime = it[Users.createTime],
imageCount = it[Images.id.count()],
albumCount = it[Albums.id.count()],
totalImageSize = it[Images.size.sum()]?.let { size ->
if (size != 0L) size / 1024 / 1024.0 else 0.0
} ?: 0.0
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/kotlin/io/sakurasou/model/dao/user/Users.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ object Users : LongIdTable("users") {
}

val columnMap = mapOf(
"id" to Users.id,
"name" to Users.name,
"isBanned" to Users.isBanned,
"groupName" to Groups.name,
"createTime" to Users.createTime,
"imageCount" to Images.id.count(),
"albumCount" to Albums.id.count(),
"totalImageSize" to Images.size.sum()
)
}
6 changes: 6 additions & 0 deletions ui/packages/api-client/src/models/user-page-vo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
* @interface UserPageVO
*/
export interface UserPageVO {
/**
*
* @type {number}
* @memberof UserPageVO
*/
'albumCount': number;
/**
*
* @type {string}
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/api-client/src/models/user-vo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface UserVO {
* @type {string}
* @memberof UserVO
*/
'email'?: string | null;
'email': string;
/**
*
* @type {string}
Expand Down

0 comments on commit b050d19

Please sign in to comment.