Optimize param class

This commit is contained in:
2023-11-29 12:04:27 +08:00
parent 557f7ff4ce
commit 6915a39d07
13 changed files with 28 additions and 32 deletions

View File

@@ -46,7 +46,7 @@ object GroupConverter {
fun groupAddParamToGroup(groupAddParam: GroupAddParam) = Group().apply { fun groupAddParamToGroup(groupAddParam: GroupAddParam) = Group().apply {
name = groupAddParam.name name = groupAddParam.name
enable = if (groupAddParam.enable == true) 1 else 0 enable = if (groupAddParam.enable) 1 else 0
roles = groupAddParam.roleIds?.map { Role().apply { id = it } } roles = groupAddParam.roleIds?.map { Role().apply { id = it } }
} }

View File

@@ -15,8 +15,8 @@ data class GroupAddParam(
@field:NotBlank(message = "Name can not be blank") @field:NotBlank(message = "Name can not be blank")
val name: String?, val name: String?,
@Schema(description = "启用", allowableValues = ["true", "false"]) @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
val enable: Boolean? = true, val enable: Boolean = true,
@Schema(description = "角色 ID 列表") @Schema(description = "角色 ID 列表")
val roleIds: List<Long>? = null val roleIds: List<Long>? = null

View File

@@ -1,7 +1,6 @@
package top.fatweb.api.param.permission.group package top.fatweb.api.param.permission.group
import io.swagger.v3.oas.annotations.media.Schema import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.NotNull
/** /**
@@ -13,10 +12,9 @@ import jakarta.validation.constraints.NotNull
@Schema(description = "用户组更改状态请求参数") @Schema(description = "用户组更改状态请求参数")
data class GroupChangeStatusParam( data class GroupChangeStatusParam(
@Schema(description = "用户组 ID") @Schema(description = "用户组 ID")
@field:Min(0) @field:NotNull(message = "ID can not be null")
val id: Long, val id: Long?,
@Schema(description = "启用", allowableValues = ["true", "false"]) @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
@field:NotNull val enable: Boolean = true
val enable: Boolean
) )

View File

@@ -14,6 +14,6 @@ data class GroupGetParam(
@Schema(description = "查询用户组名称") @Schema(description = "查询用户组名称")
val searchName: String? = null, val searchName: String? = null,
@Schema(description = "查询使用正则表达式", allowableValues = ["true", "false"]) @Schema(description = "查询使用正则表达式", allowableValues = ["true", "false"], defaultValue = "false")
val searchRegex: Boolean = false, val searchRegex: Boolean = false,
) : PageSortParam() ) : PageSortParam()

View File

@@ -1,8 +1,8 @@
package top.fatweb.api.param.permission.group package top.fatweb.api.param.permission.group
import io.swagger.v3.oas.annotations.media.Schema import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotNull
/** /**
* Group update param * Group update param
@@ -13,15 +13,15 @@ import jakarta.validation.constraints.NotBlank
@Schema(description = "用户组更新请求参数") @Schema(description = "用户组更新请求参数")
data class GroupUpdateParam( data class GroupUpdateParam(
@Schema(description = "用户组 ID") @Schema(description = "用户组 ID")
@field:Min(0) @field:NotNull(message = "ID can not be null")
val id: Long, val id: Long,
@Schema(description = "用户组名称") @Schema(description = "用户组名称")
@field:NotBlank(message = "Name can not be blank") @field:NotBlank(message = "Name can not be blank")
val name: String?, val name: String?,
@Schema(description = "启用", allowableValues = ["true", "false"]) @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
val enable: Boolean? = true, val enable: Boolean = true,
@Schema(description = "角色 ID 列表") @Schema(description = "角色 ID 列表")
val roleIds: List<Long>? = null val roleIds: List<Long>? = null

View File

@@ -15,8 +15,8 @@ data class RoleAddParam(
@field:NotBlank(message = "Name can not be blank") @field:NotBlank(message = "Name can not be blank")
val name: String?, val name: String?,
@Schema(description = "启用", allowableValues = ["true", "false"]) @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
val enable: Boolean? = true, val enable: Boolean = true,
@Schema(description = "权限 ID 列表") @Schema(description = "权限 ID 列表")
val powerIds: List<Long>? = null val powerIds: List<Long>? = null

View File

@@ -1,7 +1,6 @@
package top.fatweb.api.param.permission.role package top.fatweb.api.param.permission.role
import io.swagger.v3.oas.annotations.media.Schema import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.NotNull
/** /**
@@ -13,10 +12,9 @@ import jakarta.validation.constraints.NotNull
@Schema(description = "角色更改状态请求参数") @Schema(description = "角色更改状态请求参数")
data class RoleChangeStatusParam( data class RoleChangeStatusParam(
@Schema(description = "角色 ID") @Schema(description = "角色 ID")
@field:Min(0) @field:NotNull(message = "Role id can not be null")
val id: Long, val id: Long,
@Schema(description = "启用", allowableValues = ["true", "false"]) @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
@field:NotNull val enable: Boolean = true
val enable: Boolean
) )

View File

@@ -14,6 +14,6 @@ data class RoleGetParam(
@Schema(description = "查询角色名称") @Schema(description = "查询角色名称")
val searchName: String? = null, val searchName: String? = null,
@Schema(description = "查询使用正则表达式", allowableValues = ["true", "false"]) @Schema(description = "查询使用正则表达式", allowableValues = ["true", "false"], defaultValue = "false")
val searchRegex: Boolean = false, val searchRegex: Boolean = false,
) : PageSortParam() ) : PageSortParam()

View File

@@ -1,8 +1,8 @@
package top.fatweb.api.param.permission.role package top.fatweb.api.param.permission.role
import io.swagger.v3.oas.annotations.media.Schema import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.Min
import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.NotNull
/** /**
* Role update param * Role update param
@@ -13,15 +13,15 @@ import jakarta.validation.constraints.NotBlank
@Schema(description = "角色更新请求参数") @Schema(description = "角色更新请求参数")
data class RoleUpdateParam( data class RoleUpdateParam(
@Schema(description = "角色 ID") @Schema(description = "角色 ID")
@field:Min(0) @field:NotNull(message = "Role id can not be null")
val id: Long, val id: Long,
@Schema(description = "角色名称") @Schema(description = "角色名称")
@field:NotBlank(message = "Name can not be blank") @field:NotBlank(message = "Name can not be blank")
val name: String?, val name: String?,
@Schema(description = "启用", allowableValues = ["true", "false"]) @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
val enable: Boolean? = true, val enable: Boolean = true,
@Schema(description = "权限 ID 列表") @Schema(description = "权限 ID 列表")
val powerIds: List<Long>? = null val powerIds: List<Long>? = null

View File

@@ -13,7 +13,7 @@ data class UserAddParam(
@Schema(description = "密码(为空自动生成随机密码)") @Schema(description = "密码(为空自动生成随机密码)")
val password: String?, val password: String?,
@Schema(description = "锁定") @Schema(description = "锁定", allowableValues = ["true", "false"], defaultValue = "false")
val locking: Boolean = false, val locking: Boolean = false,
@Schema(description = "过期时间") @Schema(description = "过期时间")
@@ -22,7 +22,7 @@ data class UserAddParam(
@Schema(description = "认证过期时间") @Schema(description = "认证过期时间")
val credentialsExpiration: LocalDateTime?, val credentialsExpiration: LocalDateTime?,
@Schema(description = "启用") @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
val enable: Boolean = true, val enable: Boolean = true,
@Schema(description = "昵称") @Schema(description = "昵称")

View File

@@ -14,6 +14,6 @@ data class UserGetParam(
@Schema(description = "查询内容") @Schema(description = "查询内容")
val searchValue: String? = null, val searchValue: String? = null,
@Schema(description = "查询使用正则表达式", allowableValues = ["true", "false"]) @Schema(description = "查询使用正则表达式", allowableValues = ["true", "false"], defaultValue = "false")
val searchRegex: Boolean = false, val searchRegex: Boolean = false,
) : PageSortParam() ) : PageSortParam()

View File

@@ -13,7 +13,7 @@ data class UserUpdateParam(
@Schema(description = "用户名") @Schema(description = "用户名")
val username: String?, val username: String?,
@Schema(description = "锁定") @Schema(description = "锁定", allowableValues = ["true", "false"], defaultValue = "false")
val locking: Boolean = false, val locking: Boolean = false,
@Schema(description = "过期时间") @Schema(description = "过期时间")
@@ -22,7 +22,7 @@ data class UserUpdateParam(
@Schema(description = "认证过期时间") @Schema(description = "认证过期时间")
val credentialsExpiration: LocalDateTime?, val credentialsExpiration: LocalDateTime?,
@Schema(description = "启用") @Schema(description = "启用", allowableValues = ["true", "false"], defaultValue = "true")
val enable: Boolean = true, val enable: Boolean = true,
@Schema(description = "昵称") @Schema(description = "昵称")

View File

@@ -26,7 +26,7 @@ data class SysLogGetParam(
@Schema(description = "查询请求 Url") @Schema(description = "查询请求 Url")
val searchRequestUrl: String? = null, val searchRequestUrl: String? = null,
@Schema(description = "查询使用正则表达式") @Schema(description = "查询使用正则表达式", allowableValues = ["true", "false"], defaultValue = "false")
val searchRegex: Boolean = false, val searchRegex: Boolean = false,
@Schema(description = "查询开始时间") @Schema(description = "查询开始时间")