From 3e612af044313813921114b197e62b27ee445730 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 26 Feb 2024 15:33:37 +0800 Subject: [PATCH] Automatically remove spaces on both sides of parameters --- .../top/fatweb/oxygen/api/annotation/Trim.kt | 8 +++ .../fatweb/oxygen/api/aop/TrimInterceptor.kt | 65 +++++++++++++++++++ .../permission/AuthenticationController.kt | 5 ++ .../controller/permission/GroupController.kt | 4 ++ .../controller/permission/RoleController.kt | 4 ++ .../controller/permission/UserController.kt | 8 ++- .../controller/system/SettingsController.kt | 5 ++ .../api/controller/system/SysLogController.kt | 2 + .../api/controller/tool/BaseController.kt | 3 + .../api/controller/tool/CategoryController.kt | 3 + .../api/controller/tool/EditController.kt | 6 +- .../controller/tool/ManagementController.kt | 2 + .../api/controller/tool/StoreController.kt | 8 ++- .../api/controller/tool/TemplateController.kt | 3 + .../oxygen/api/param/CaptchaCodeParam.kt | 3 + .../api/param/permission/ForgetParam.kt | 5 +- .../oxygen/api/param/permission/LoginParam.kt | 5 +- .../api/param/permission/RegisterParam.kt | 8 ++- .../api/param/permission/VerifyParam.kt | 5 +- .../param/permission/group/GroupAddParam.kt | 5 +- .../param/permission/group/GroupGetParam.kt | 5 +- .../permission/group/GroupUpdateParam.kt | 5 +- .../api/param/permission/role/RoleAddParam.kt | 5 +- .../api/param/permission/role/RoleGetParam.kt | 5 +- .../param/permission/role/RoleUpdateParam.kt | 5 +- .../api/param/permission/user/UserAddParam.kt | 11 +++- .../api/param/permission/user/UserGetParam.kt | 5 +- .../permission/user/UserInfoUpdateParam.kt | 5 +- .../param/permission/user/UserUpdateParam.kt | 11 +++- .../api/param/system/BaseSettingsParam.kt | 14 ++-- .../oxygen/api/param/system/MailSendParam.kt | 5 +- .../api/param/system/MailSettingsParam.kt | 17 +++-- .../api/param/system/SensitiveWordAddParam.kt | 5 +- .../oxygen/api/param/system/SysLogGetParam.kt | 5 +- .../oxygen/api/param/tool/ToolBaseAddParam.kt | 5 +- .../api/param/tool/ToolBaseUpdateParam.kt | 5 +- .../api/param/tool/ToolCategoryAddParam.kt | 5 +- .../api/param/tool/ToolCategoryUpdateParam.kt | 5 +- .../oxygen/api/param/tool/ToolCreateParam.kt | 8 ++- .../api/param/tool/ToolManagementGetParam.kt | 5 +- .../api/param/tool/ToolStoreGetParam.kt | 11 +++- .../api/param/tool/ToolTemplateAddParam.kt | 8 ++- .../api/param/tool/ToolTemplateUpdateParam.kt | 8 ++- .../oxygen/api/param/tool/ToolUpdateParam.kt | 5 +- .../oxygen/api/param/tool/ToolUpgradeParam.kt | 5 +- .../impl/AuthenticationServiceImpl.kt | 6 +- 46 files changed, 285 insertions(+), 51 deletions(-) create mode 100644 src/main/kotlin/top/fatweb/oxygen/api/annotation/Trim.kt create mode 100644 src/main/kotlin/top/fatweb/oxygen/api/aop/TrimInterceptor.kt diff --git a/src/main/kotlin/top/fatweb/oxygen/api/annotation/Trim.kt b/src/main/kotlin/top/fatweb/oxygen/api/annotation/Trim.kt new file mode 100644 index 0000000..de8c054 --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/annotation/Trim.kt @@ -0,0 +1,8 @@ +package top.fatweb.oxygen.api.annotation + +import java.lang.annotation.Inherited + +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS, AnnotationTarget.PROPERTY) +@Retention(AnnotationRetention.RUNTIME) +@Inherited +annotation class Trim \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/aop/TrimInterceptor.kt b/src/main/kotlin/top/fatweb/oxygen/api/aop/TrimInterceptor.kt new file mode 100644 index 0000000..fbfe2eb --- /dev/null +++ b/src/main/kotlin/top/fatweb/oxygen/api/aop/TrimInterceptor.kt @@ -0,0 +1,65 @@ +package top.fatweb.oxygen.api.aop + +import org.aspectj.lang.JoinPoint +import org.aspectj.lang.annotation.Aspect +import org.aspectj.lang.annotation.Before +import org.aspectj.lang.annotation.Pointcut +import org.springframework.stereotype.Component +import org.springframework.web.servlet.HandlerInterceptor +import top.fatweb.oxygen.api.annotation.Trim +import kotlin.reflect.KMutableProperty +import kotlin.reflect.full.* +import kotlin.reflect.jvm.isAccessible + +@Component +@Aspect +class TrimInterceptor : HandlerInterceptor { + @Pointcut("@annotation(top.fatweb.oxygen.api.annotation.Trim)") + fun trimPointcut() { + } + + @Before("trimPointcut()") + fun doBefore(joinPoint: JoinPoint): Any { + val args = joinPoint.args + + args?.forEachIndexed { index, any -> + if (args[index]::class.hasAnnotation()) args[index] = trim(any) + } + + return args + } + + private fun trim(any: Any?): Any? { + any ?: return null + + when (any) { + is Boolean, Short, Int, Long, Float, Double -> { + return any + } + + is String -> { + return any.trim() + } + + else -> { + val members = any::class.declaredMemberProperties + if (members.isEmpty()) { + return any + } + members.forEach { + if (!it.returnType.isSupertypeOf(String::class.starProjectedType) + || it !is KMutableProperty<*> + || !it.hasAnnotation() + ) { + return@forEach + } + it.isAccessible = true + if (it.call(any) != null) { + it.setter.call(any, (it.call(any) as String).trim()) + } + } + return any + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/AuthenticationController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/AuthenticationController.kt index 1d21a2c..6958926 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/AuthenticationController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/AuthenticationController.kt @@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.permission.* @@ -38,6 +39,7 @@ class AuthenticationController( * @see ResponseResult * @see RegisterVo */ + @Trim @Operation(summary = "注册") @PostMapping("/register") fun register( @@ -75,6 +77,7 @@ class AuthenticationController( * @see VerifyParam * @see ResponseResult */ + @Trim @Operation(summary = "验证邮箱") @PostMapping("/verify") fun verify(@Valid @RequestBody verifyParam: VerifyParam): ResponseResult { @@ -95,6 +98,7 @@ class AuthenticationController( * @see ForgetParam * @see ResponseResult */ + @Trim @Operation(summary = "忘记密码") @PostMapping("/forget") fun forget(request: HttpServletRequest, @Valid @RequestBody forgetParam: ForgetParam): ResponseResult { @@ -139,6 +143,7 @@ class AuthenticationController( * @see ResponseResult * @see LoginVo */ + @Trim @Operation(summary = "登录") @PostMapping("/login") fun login(request: HttpServletRequest, @Valid @RequestBody loginParam: LoginParam): ResponseResult = diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/GroupController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/GroupController.kt index 664a928..549b4c8 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/GroupController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/GroupController.kt @@ -5,6 +5,7 @@ import jakarta.validation.Valid import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.permission.group.* @@ -52,6 +53,7 @@ class GroupController( * @see PageVo * @see GroupWithRoleVo */ + @Trim @Operation(summary = "获取用户组") @GetMapping @PreAuthorize("hasAnyAuthority('system:group:query:all')") @@ -88,6 +90,7 @@ class GroupController( * @see ResponseResult * @see GroupVo */ + @Trim @Operation(summary = "添加用户组") @PostMapping @PreAuthorize("hasAnyAuthority('system:group:add:one')") @@ -107,6 +110,7 @@ class GroupController( * @see ResponseResult * @see GroupVo */ + @Trim @Operation(summary = "修改用户组") @PutMapping @PreAuthorize("hasAnyAuthority('system:group:modify:one')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/RoleController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/RoleController.kt index 77144e2..71c16a1 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/RoleController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/RoleController.kt @@ -5,6 +5,7 @@ import jakarta.validation.Valid import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.permission.role.* @@ -51,6 +52,7 @@ class RoleController( * @see ResponseResult * @see RoleWithPowerVo */ + @Trim @Operation(summary = "获取角色") @GetMapping @PreAuthorize("hasAnyAuthority('system:role:query:all')") @@ -88,6 +90,7 @@ class RoleController( * @see ResponseResult * @see RoleVo */ + @Trim @Operation(summary = "添加角色") @PostMapping @PreAuthorize("hasAnyAuthority('system:role:add:one')") @@ -107,6 +110,7 @@ class RoleController( * @see ResponseResult * @see RoleVo */ + @Trim @Operation(summary = "修改角色") @PutMapping @PreAuthorize("hasAnyAuthority('system:role:modify:one')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/UserController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/UserController.kt index e7c4490..ca9b504 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/UserController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/permission/UserController.kt @@ -5,6 +5,7 @@ import jakarta.validation.Valid import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.permission.user.* @@ -50,10 +51,11 @@ class UserController( * @see ResponseResult * @see UserWithPowerInfoVo */ + @Trim @Operation(summary = "获取指定用户基本信息") @GetMapping("/info/{username}") fun getBasicInfo(@PathVariable username: String): ResponseResult = - ResponseResult.databaseSuccess(data = userService.getBasicInfo(username)) + ResponseResult.databaseSuccess(data = userService.getBasicInfo(username.trim())) /** * Update current user information @@ -65,6 +67,7 @@ class UserController( * @see UserInfoUpdateParam * @see ResponseResult */ + @Trim @Operation(summary = "更新当前用户信息") @PatchMapping("info") fun updateInfo(@RequestBody @Valid userInfoUpdateParam: UserInfoUpdateParam): ResponseResult = @@ -116,6 +119,7 @@ class UserController( * @see ResponseResult * @see UserWithRoleInfoVo */ + @Trim @Operation(summary = "获取用户") @GetMapping @PreAuthorize("hasAnyAuthority('system:user:query:all')") @@ -135,6 +139,7 @@ class UserController( * @see ResponseResult * @see UserWithPasswordRoleInfoVo */ + @Trim @Operation(summary = "添加用户") @PostMapping @PreAuthorize("hasAnyAuthority('system:user:add:one')") @@ -154,6 +159,7 @@ class UserController( * @see ResponseResult * @see UserWithRoleInfoVo */ + @Trim @Operation(summary = "修改用户") @PutMapping @PreAuthorize("hasAnyAuthority('system:user:modify:one')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SettingsController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SettingsController.kt index 5d5c28b..9ca025b 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SettingsController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SettingsController.kt @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.PutMapping import org.springframework.web.bind.annotation.RequestBody import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.system.* @@ -56,6 +57,7 @@ class SettingsController( * @see BaseSettingsParam * @see ResponseResult */ + @Trim @Operation(summary = "更新基础设置") @PutMapping("/base") @PreAuthorize("hasAnyAuthority('system:settings:modify:base')") @@ -88,6 +90,7 @@ class SettingsController( * @see MailSettingsParam * @see ResponseResult */ + @Trim @Operation(summary = "更新邮件设置") @PutMapping("/mail") @PreAuthorize("hasAnyAuthority('system:settings:modify:mail')") @@ -106,6 +109,7 @@ class SettingsController( * @see MailSendParam * @see ResponseResult */ + @Trim @Operation(summary = "邮件发送测试") @PostMapping("/mail") @PreAuthorize("hasAnyAuthority('system:settings:modify:mail')") @@ -139,6 +143,7 @@ class SettingsController( * @see SensitiveWordAddParam * @see ResponseResult */ + @Trim @Operation(summary = "添加敏感词") @PostMapping("/sensitive") @PreAuthorize("hasAnyAuthority('system:settings:modify:sensitive')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SysLogController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SysLogController.kt index 09c76e7..8cc0713 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SysLogController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/system/SysLogController.kt @@ -5,6 +5,7 @@ import jakarta.validation.Valid import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.GetMapping import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.system.SysLogGetParam @@ -34,6 +35,7 @@ class SysLogController( * @see ResponseResult * @see SysLogVo */ + @Trim @Operation(summary = "获取") @GetMapping @PreAuthorize("hasAnyAuthority('system:log:query:all')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt index f682fd3..60cf7a4 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt @@ -5,6 +5,7 @@ import jakarta.validation.Valid import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam @@ -65,6 +66,7 @@ class BaseController( * @see ResponseResult * @see ToolBaseVo */ + @Trim @Operation(summary = "新增基板") @PostMapping @PreAuthorize("hasAnyAuthority('system:tool:add:base')") @@ -85,6 +87,7 @@ class BaseController( * @see ResponseResult * @see ToolBaseVo */ + @Trim @Operation(summary = "更新基板") @PutMapping @PreAuthorize("hasAnyAuthority('system:tool:modify:base')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt index 1872a39..460c3d4 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/CategoryController.kt @@ -5,6 +5,7 @@ import jakarta.validation.Valid import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.tool.ToolCategoryAddParam @@ -65,6 +66,7 @@ class CategoryController( * @see ResponseResult * @see ToolCategoryVo */ + @Trim @Operation(summary = "新增类别") @PostMapping @PreAuthorize("hasAnyAuthority('system:tool:add:category')") @@ -85,6 +87,7 @@ class CategoryController( * @see ResponseResult * @see ToolCategoryVo */ + @Trim @Operation(summary = "更新类别") @PutMapping @PreAuthorize("hasAnyAuthority('system:tool:modify:category')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt index 2e4863e..6a40175 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.Operation import jakarta.validation.Valid import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.tool.ToolCreateParam @@ -79,6 +80,7 @@ class EditController( * @see ResponseResult * @see ToolVo */ + @Trim @Operation(summary = "创建工具") @PostMapping fun create(@RequestBody @Valid toolCreateParam: ToolCreateParam): ResponseResult = @@ -95,6 +97,7 @@ class EditController( * @see ResponseResult * @see ToolVo */ + @Trim @Operation(summary = "升级工具") @PatchMapping fun upgrade(@RequestBody @Valid toolUpgradeParam: ToolUpgradeParam): ResponseResult = @@ -138,7 +141,7 @@ class EditController( ): ResponseResult = ResponseResult.databaseSuccess( ResponseCode.DATABASE_SELECT_SUCCESS, - data = editService.detail(username, toolId, ver) + data = editService.detail(username.trim(), toolId.trim(), ver.trim()) ) /** @@ -152,6 +155,7 @@ class EditController( * @see ResponseResult * @see ToolVo */ + @Trim @Operation(summary = "更新工具") @PutMapping fun update(@RequestBody @Valid toolUpdateParam: ToolUpdateParam): ResponseResult = diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/ManagementController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/ManagementController.kt index 9bdff74..bda530d 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/ManagementController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/ManagementController.kt @@ -5,6 +5,7 @@ import jakarta.validation.Valid import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.tool.ToolManagementGetParam @@ -52,6 +53,7 @@ class ManagementController( * @see PageVo * @see ToolVo */ + @Trim @Operation(summary = "获取工具") @GetMapping @PreAuthorize("hasAnyAuthority('system:tool:query:tool')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/StoreController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/StoreController.kt index 3c18850..c29e193 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/StoreController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/StoreController.kt @@ -1,9 +1,11 @@ package top.fatweb.oxygen.api.controller.tool +import io.swagger.v3.oas.annotations.Operation import jakarta.validation.Valid import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.PageSortParam import top.fatweb.oxygen.api.param.tool.ToolStoreGetParam @@ -34,6 +36,8 @@ class StoreController( * @see PageVo * @see ToolVo */ + @Trim + @Operation(description = "获取商店工具") @GetMapping fun get(@Valid toolStoreGetParam: ToolStoreGetParam): ResponseResult> = ResponseResult.databaseSuccess(data = storeService.getPage(toolStoreGetParam)) @@ -51,7 +55,9 @@ class StoreController( * @see PageVo * @see ToolVo */ + @Trim + @Operation(description = "获取商店指定用户工具") @GetMapping("/{username}") fun get(@PathVariable username: String, @Valid pageSortParam: PageSortParam): ResponseResult> = - ResponseResult.databaseSuccess(data = storeService.getPage(pageSortParam, username)) + ResponseResult.databaseSuccess(data = storeService.getPage(pageSortParam, username.trim())) } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt index ab7fe7e..b65815c 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/TemplateController.kt @@ -5,6 +5,7 @@ import jakarta.validation.Valid import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult import top.fatweb.oxygen.api.param.tool.ToolTemplateAddParam @@ -65,6 +66,7 @@ class TemplateController( * @see ResponseResult * @see ToolTemplateVo */ + @Trim @Operation(summary = "添加模板") @PostMapping @PreAuthorize("hasAnyAuthority('system:tool:add:template')") @@ -85,6 +87,7 @@ class TemplateController( * @see ResponseResult * @see ToolTemplateVo */ + @Trim @Operation(summary = "更新模板") @PutMapping @PreAuthorize("hasAnyAuthority('system:tool:modify:template')") diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/CaptchaCodeParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/CaptchaCodeParam.kt index fa686ce..876e665 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/CaptchaCodeParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/CaptchaCodeParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +import top.fatweb.oxygen.api.annotation.Trim /** * Captcha code parameter @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotBlank * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim open class CaptchaCodeParam { /** * Captcha code @@ -16,6 +18,7 @@ open class CaptchaCodeParam { * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "验证码", required = true) @field:NotBlank(message = "Captcha code can not be blank") var captchaCode: String? = null diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/ForgetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/ForgetParam.kt index de70365..2d02d13 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/ForgetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/ForgetParam.kt @@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.param.permission import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.Pattern +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.CaptchaCodeParam /** @@ -12,6 +13,7 @@ import top.fatweb.oxygen.api.param.CaptchaCodeParam * @since 1.0.0 * @see CaptchaCodeParam */ +@Trim @Schema(description = "忘记密码请求参数") data class ForgetParam( /** @@ -20,8 +22,9 @@ data class ForgetParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "邮箱", required = true, example = "user@email.com") @field:NotBlank(message = "Email can not be blank") @field:Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address") - val email: String? + var email: String? ) : CaptchaCodeParam() diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/LoginParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/LoginParam.kt index df53af9..66bc3e9 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/LoginParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/LoginParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.permission import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.CaptchaCodeParam /** @@ -11,6 +12,7 @@ import top.fatweb.oxygen.api.param.CaptchaCodeParam * @since 1.0.0 * @see CaptchaCodeParam */ +@Trim @Schema(description = "登录请求参数") data class LoginParam( /** @@ -19,9 +21,10 @@ data class LoginParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "账户", required = true, example = "test") @field:NotBlank(message = "Account can not be blank") - val account: String?, + var account: String?, /** * Password diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RegisterParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RegisterParam.kt index 7b26d33..3280d1f 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RegisterParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RegisterParam.kt @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.Pattern import jakarta.validation.constraints.Size +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.CaptchaCodeParam /** @@ -13,6 +14,7 @@ import top.fatweb.oxygen.api.param.CaptchaCodeParam * @since 1.0.0 * @see CaptchaCodeParam */ +@Trim @Schema(description = "注册请求参数") data class RegisterParam( /** @@ -21,10 +23,11 @@ data class RegisterParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "用户名", required = true, example = "abc") @field:NotBlank(message = "Username can not be blank") @field:Pattern(regexp = "[a-zA-Z-_][0-9a-zA-Z-_]{2,38}", message = "Illegal username") - val username: String?, + var username: String?, /** * Email @@ -32,10 +35,11 @@ data class RegisterParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "邮箱", required = true, example = "user@email.com") @field:NotBlank(message = "Email can not be blank") @field:Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address") - val email: String?, + var email: String?, /** * Password diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/VerifyParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/VerifyParam.kt index 90e832f..a9be0c0 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/VerifyParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/VerifyParam.kt @@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.param.permission import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.Pattern +import top.fatweb.oxygen.api.annotation.Trim /** * Verify email parameters @@ -10,6 +11,7 @@ import jakarta.validation.constraints.Pattern * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "验证邮箱请求参数") data class VerifyParam( /** @@ -28,9 +30,10 @@ data class VerifyParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "昵称", example = "QwQ") @field:Pattern(regexp = "^.{3,20}$", message = "Nickname must be 3-20 characters") - val nickname: String?, + var nickname: String?, /** * Avatar diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupAddParam.kt index 6f24d3d..b5e4af8 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupAddParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.permission.group import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +import top.fatweb.oxygen.api.annotation.Trim /** * Add group parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotBlank * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "用户组添加请求参数") data class GroupAddParam( /** @@ -17,9 +19,10 @@ data class GroupAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "用户组名称", required = true, example = "Group_1") @field:NotBlank(message = "Name can not be blank") - val name: String?, + var name: String?, /** * Enable diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupGetParam.kt index f494191..73ecff0 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupGetParam.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.param.permission.group import io.swagger.v3.oas.annotations.media.Schema +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.PageSortParam /** @@ -10,6 +11,7 @@ import top.fatweb.oxygen.api.param.PageSortParam * @since 1.0.0 * @see PageSortParam */ +@Trim @Schema(description = "用户组查询请求参数") data class GroupGetParam( /** @@ -18,8 +20,9 @@ data class GroupGetParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "查询用户组名称", example = "Group_1") - val searchName: String?, + var searchName: String?, /** * Use regex diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupUpdateParam.kt index 937679c..509de1f 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/group/GroupUpdateParam.kt @@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.param.permission.group import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull +import top.fatweb.oxygen.api.annotation.Trim /** * Update group parameters @@ -10,6 +11,7 @@ import jakarta.validation.constraints.NotNull * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "用户组更新请求参数") data class GroupUpdateParam( /** @@ -28,9 +30,10 @@ data class GroupUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "用户组名称", required = true, example = "Group_1") @field:NotBlank(message = "Name can not be blank") - val name: String?, + var name: String?, /** * Enable diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleAddParam.kt index ab093c5..ad7aaf6 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleAddParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.permission.role import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +import top.fatweb.oxygen.api.annotation.Trim /** * Add role parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotBlank * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "角色添加请求参数") data class RoleAddParam( /** @@ -17,9 +19,10 @@ data class RoleAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "角色名称", required = true, example = "Role_1") @field:NotBlank(message = "Name can not be blank") - val name: String?, + var name: String?, /** * Enable diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleGetParam.kt index 929ba19..f6d8280 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleGetParam.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.param.permission.role import io.swagger.v3.oas.annotations.media.Schema +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.PageSortParam /** @@ -10,6 +11,7 @@ import top.fatweb.oxygen.api.param.PageSortParam * @since 1.0.0 * @see PageSortParam */ +@Trim @Schema(description = "角色查询请求参数") data class RoleGetParam( /** @@ -18,8 +20,9 @@ data class RoleGetParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "查询角色名称", example = "Role_1") - val searchName: String?, + var searchName: String?, /** * Use regex diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleUpdateParam.kt index c24704f..40cbd57 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/role/RoleUpdateParam.kt @@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.param.permission.role import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull +import top.fatweb.oxygen.api.annotation.Trim /** * Update role parameters @@ -10,6 +11,7 @@ import jakarta.validation.constraints.NotNull * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "角色更新请求参数") data class RoleUpdateParam( /** @@ -28,9 +30,10 @@ data class RoleUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "角色名称", required = true, example = "Role_1") @field:NotBlank(message = "Name can not be blank") - val name: String?, + var name: String?, /** * Enable diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserAddParam.kt index ae817a8..7ccf586 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserAddParam.kt @@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.param.permission.user import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.Pattern +import top.fatweb.oxygen.api.annotation.Trim import java.time.LocalDateTime /** @@ -11,6 +12,7 @@ import java.time.LocalDateTime * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "添加用户请求参数") data class UserAddParam( /** @@ -19,9 +21,10 @@ data class UserAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "用户名", required = true, example = "User_1") @field:NotBlank(message = "Username can not be blank") - val username: String?, + var username: String?, /** * Password @@ -85,9 +88,10 @@ data class UserAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "昵称", required = true, example = "Nickname_1") @field:NotBlank(message = "Nickname can not be blank") - val nickname: String?, + var nickname: String?, /** * Avatar base63 @@ -104,10 +108,11 @@ data class UserAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "邮箱", required = true, example = "user@email.com") @NotBlank(message = "Email can not be blank") @Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address") - val email: String?, + var email: String?, /** * List of role IDs diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserGetParam.kt index c8a68ec..358fe52 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserGetParam.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.param.permission.user import io.swagger.v3.oas.annotations.media.Schema +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.PageSortParam /** @@ -10,6 +11,7 @@ import top.fatweb.oxygen.api.param.PageSortParam * @since 1.0.0 * @see PageSortParam */ +@Trim @Schema(description = "查询用户请求参数") data class UserGetParam( /** @@ -32,8 +34,9 @@ data class UserGetParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "查询内容", example = "User_1") - val searchValue: String?, + var searchValue: String?, /** * Use regex diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserInfoUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserInfoUpdateParam.kt index 92529ed..4aae0a9 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserInfoUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserInfoUpdateParam.kt @@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.param.permission.user import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.Size +import top.fatweb.oxygen.api.annotation.Trim /** * Update user information parameters @@ -10,6 +11,7 @@ import jakarta.validation.constraints.Size * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "更新用户信息请求参数") data class UserInfoUpdateParam( /** @@ -27,8 +29,9 @@ data class UserInfoUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "昵称", example = "QwQ") @field:NotBlank(message = "Nickname can not be blank") @field:Size(min = 3, max = 30, message = "Nickname must be 3-20 characters") - val nickname: String? + var nickname: String? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserUpdateParam.kt index b8830a6..d26a479 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserUpdateParam.kt @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.Pattern +import top.fatweb.oxygen.api.annotation.Trim import java.time.LocalDateTime /** @@ -12,6 +13,7 @@ import java.time.LocalDateTime * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "更新用户请求参数") data class UserUpdateParam( /** @@ -30,9 +32,10 @@ data class UserUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "用户名", required = true, example = "User_1") @field:NotBlank(message = "Username can not be blank") - val username: String?, + var username: String?, /** * Verified @@ -87,9 +90,10 @@ data class UserUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "昵称", required = true, example = "Nickname_1") @field:NotBlank(message = "Nickname can not be blank") - val nickname: String?, + var nickname: String?, /** * Avatar base64 @@ -106,10 +110,11 @@ data class UserUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "邮箱", required = true, example = "user@email.com") @NotBlank(message = "Email can not be blank") @Pattern(regexp = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$", message = "Illegal email address") - val email: String?, + var email: String?, /** * List of role IDs diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/system/BaseSettingsParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/system/BaseSettingsParam.kt index eaf5226..16effd0 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/system/BaseSettingsParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/system/BaseSettingsParam.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.param.system import io.swagger.v3.oas.annotations.media.Schema +import top.fatweb.oxygen.api.annotation.Trim /** * Base settings parameters @@ -8,6 +9,7 @@ import io.swagger.v3.oas.annotations.media.Schema * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "基础设置请求参数") data class BaseSettingsParam( /** @@ -16,8 +18,9 @@ data class BaseSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "应用名称") - val appName: String?, + var appName: String?, /** * Application URL @@ -25,8 +28,9 @@ data class BaseSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "应用 URL") - val appUrl: String?, + var appUrl: String?, /** * Verify URL @@ -34,8 +38,9 @@ data class BaseSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "验证邮箱 URL") - val verifyUrl: String?, + var verifyUrl: String?, /** * Retrieve URL @@ -43,6 +48,7 @@ data class BaseSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "找回密码 URL") - val retrieveUrl: String? + var retrieveUrl: String? ) \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSendParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSendParam.kt index 08ffd20..842c49a 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSendParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSendParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.system import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +import top.fatweb.oxygen.api.annotation.Trim /** * Mail send parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotBlank * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "邮件发送请求参数") data class MailSendParam( /** @@ -17,7 +19,8 @@ data class MailSendParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "接收者", required = true, example = "user@email.com") @field:NotBlank - val to: String? + var to: String? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSettingsParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSettingsParam.kt index d56ca69..8e5cec5 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSettingsParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSettingsParam.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.param.system import io.swagger.v3.oas.annotations.media.Schema +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.settings.MailSecurityType /** @@ -9,6 +10,7 @@ import top.fatweb.oxygen.api.settings.MailSecurityType * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "邮件设置请求参数") data class MailSettingsParam( /** @@ -17,8 +19,9 @@ data class MailSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "SMTP 服务器") - val host: String?, + var host: String?, /** * Port @@ -26,8 +29,9 @@ data class MailSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "端口号") - val port: Int?, + var port: Int?, /** * Security type @@ -44,8 +48,9 @@ data class MailSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "用户名") - val username: String?, + var username: String?, /** * Password @@ -62,8 +67,9 @@ data class MailSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "发送者") - val from: String?, + var from: String?, /** * Sender name @@ -71,6 +77,7 @@ data class MailSettingsParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "发送者名称") - val fromName: String? + var fromName: String? ) \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/system/SensitiveWordAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/system/SensitiveWordAddParam.kt index 6071bf2..2324293 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/system/SensitiveWordAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/system/SensitiveWordAddParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.system import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.system.SensitiveWord /** @@ -10,6 +11,7 @@ import top.fatweb.oxygen.api.entity.system.SensitiveWord * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(defaultValue = "敏感词添加请求参数") data class SensitiveWordAddParam( /** @@ -18,9 +20,10 @@ data class SensitiveWordAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "词", required = true) @field:NotBlank(message = "Word can not be blank") - val word: String?, + var word: String?, /** * Use for diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/system/SysLogGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/system/SysLogGetParam.kt index ef5263b..8b3bfe0 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/system/SysLogGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/system/SysLogGetParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.system import io.swagger.v3.oas.annotations.media.Schema import org.springframework.format.annotation.DateTimeFormat +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.PageSortParam import java.time.LocalDateTime @@ -12,6 +13,7 @@ import java.time.LocalDateTime * @since 1.0.0 * @see PageSortParam */ +@Trim @Schema(description = "获取系统日志请求参数") data class SysLogGetParam( /** @@ -46,8 +48,9 @@ data class SysLogGetParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "查询请求 Url") - val searchRequestUrl: String?, + var searchRequestUrl: String?, /** * Use regex diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt index 582925b..d62e4df 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseAddParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +import top.fatweb.oxygen.api.annotation.Trim /** * Add tool base parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotBlank * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim data class ToolBaseAddParam( /** * Name @@ -16,7 +18,8 @@ data class ToolBaseAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "名称", required = true) @field: NotBlank(message = "Name can not be blank") - val name: String? + var name: String? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt index d4da30e..fd5ef0b 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolBaseUpdateParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotNull +import top.fatweb.oxygen.api.annotation.Trim /** * Update tool base parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotNull * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim data class ToolBaseUpdateParam( /** * ID @@ -26,8 +28,9 @@ data class ToolBaseUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "名称") - val name: String?, + var name: String?, /** * Source diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt index 657bb98..2f615d0 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryAddParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank +import top.fatweb.oxygen.api.annotation.Trim /** * Add tool category parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotBlank * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim data class ToolCategoryAddParam( /** * Name @@ -16,9 +18,10 @@ data class ToolCategoryAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "名称", required = true) @field: NotBlank(message = "Name can not be blank") - val name: String?, + var name: String?, /** * Enable diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt index 84496b3..00fc869 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCategoryUpdateParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotNull +import top.fatweb.oxygen.api.annotation.Trim /** * Update tool category parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotNull * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim data class ToolCategoryUpdateParam( /** * ID @@ -26,8 +28,9 @@ data class ToolCategoryUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "名称") - val name: String?, + var name: String?, /** * Enable diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCreateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCreateParam.kt index 3cb0361..0f8b666 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCreateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolCreateParam.kt @@ -5,6 +5,7 @@ import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotEmpty import jakarta.validation.constraints.NotNull import jakarta.validation.constraints.Pattern +import top.fatweb.oxygen.api.annotation.Trim /** * Create tool parameters @@ -12,6 +13,7 @@ import jakarta.validation.constraints.Pattern * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "创建工具请求参数") data class ToolCreateParam( /** @@ -20,9 +22,10 @@ data class ToolCreateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "名称", required = true) @field: NotBlank(message = "Name can not be blank") - val name: String?, + var name: String?, /** * Tool ID @@ -30,13 +33,14 @@ data class ToolCreateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "工具唯一 ID", required = true, example = "tool_a") @field: NotBlank(message = "ToolId can not be blank") @field: Pattern( regexp = "^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$", message = "Ver can only match '^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$'" ) - val toolId: String?, + var toolId: String?, /** * Icon diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolManagementGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolManagementGetParam.kt index dd58600..52973ce 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolManagementGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolManagementGetParam.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.PageSortParam /** @@ -10,6 +11,7 @@ import top.fatweb.oxygen.api.param.PageSortParam * @since 1.0.0 * @see PageSortParam */ +@Trim data class ToolManagementGetParam( /** * Type of search @@ -31,8 +33,9 @@ data class ToolManagementGetParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "查询内容", example = "ToolName") - val searchValue: String?, + var searchValue: String?, /** * Use regex diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolStoreGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolStoreGetParam.kt index a83ae41..f127bcb 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolStoreGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolStoreGetParam.kt @@ -1,6 +1,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema +import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.param.PageSortParam /** @@ -10,7 +11,15 @@ import top.fatweb.oxygen.api.param.PageSortParam * @since 1.0.0 * @see PageSortParam */ +@Trim data class ToolStoreGetParam( + /** + * Value to search for + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + */ + @Trim @Schema(description = "查询内容", example = "ToolName") - val searchValue: String? + var searchValue: String? ) : PageSortParam() diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt index 137c554..c8560d1 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateAddParam.kt @@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotNull +import top.fatweb.oxygen.api.annotation.Trim /** * Add tool template parameters @@ -10,6 +11,7 @@ import jakarta.validation.constraints.NotNull * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim data class ToolTemplateAddParam( /** * Name @@ -17,9 +19,10 @@ data class ToolTemplateAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "名称", required = true) @field: NotBlank(message = "Name can not be blank") - val name: String?, + var name: String?, /** * Base ID @@ -37,9 +40,10 @@ data class ToolTemplateAddParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "入口文件", required = true) @field:NotBlank(message = "EntryPoint can not be null") - val entryPoint: String? = null, + var entryPoint: String? = null, /** * Enable diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt index 523f74d..4d2c157 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolTemplateUpdateParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotNull +import top.fatweb.oxygen.api.annotation.Trim /** * Update tool template parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotNull * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim data class ToolTemplateUpdateParam( /** * ID @@ -26,8 +28,9 @@ data class ToolTemplateUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "名称") - val name: String?, + var name: String?, /** * Base ID @@ -53,8 +56,9 @@ data class ToolTemplateUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "入口文件") - val entryPoint: String?, + var entryPoint: String?, /** * Enable diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpdateParam.kt index 935ceef..90b4610 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpdateParam.kt @@ -2,6 +2,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotNull +import top.fatweb.oxygen.api.annotation.Trim /** * Update tool parameters @@ -9,6 +10,7 @@ import jakarta.validation.constraints.NotNull * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "更新工具请求参数") data class ToolUpdateParam( /** @@ -27,8 +29,9 @@ data class ToolUpdateParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "名称") - val name: String?, + var name: String?, /** * Icon diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpgradeParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpgradeParam.kt index e3cca51..d4e20d4 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpgradeParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/tool/ToolUpgradeParam.kt @@ -3,6 +3,7 @@ package top.fatweb.oxygen.api.param.tool import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.Pattern +import top.fatweb.oxygen.api.annotation.Trim /** * Upgrade tool parameters @@ -10,6 +11,7 @@ import jakarta.validation.constraints.Pattern * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ +@Trim @Schema(description = "升级工具请求参数") data class ToolUpgradeParam( /** @@ -18,13 +20,14 @@ data class ToolUpgradeParam( * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ + @Trim @Schema(description = "工具唯一 ID", required = true, example = "tool_a") @field: NotBlank(message = "ToolId can not be blank") @field: Pattern( regexp = "^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$", message = "Ver can only match '^[a-zA-Z-_][0-9a-zA-Z-_]{2,19}\$'" ) - val toolId: String?, + var toolId: String?, /** * Version diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/AuthenticationServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/AuthenticationServiceImpl.kt index 5b360aa..bd0e265 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/AuthenticationServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/AuthenticationServiceImpl.kt @@ -92,7 +92,7 @@ class AuthenticationServiceImpl( sendVerifyMail(user.username!!, user.verify!!, registerParam.email!!) - val loginVo = this.login(request, registerParam.username, registerParam.password!!) + val loginVo = this.login(request, registerParam.username!!, registerParam.password!!) return RegisterVo(token = loginVo.token, userId = loginVo.userId) } @@ -135,7 +135,7 @@ class AuthenticationServiceImpl( if (verifyParam.nickname.isNullOrBlank() || verifyParam.avatar.isNullOrBlank()) { throw AccountNeedInitException() } - sensitiveWordService.checkSensitiveWord(verifyParam.nickname) + sensitiveWordService.checkSensitiveWord(verifyParam.nickname!!) userService.update( KtUpdateWrapper(User()).eq(User::id, user.id).set(User::verify, null) @@ -166,7 +166,7 @@ class AuthenticationServiceImpl( LocalDateTime.now(ZoneOffset.UTC).toInstant(ZoneOffset.UTC).toEpochMilli() }-${UUID.randomUUID()}-${UUID.randomUUID()}-${UUID.randomUUID()}" userService.update(KtUpdateWrapper(User()).eq(User::id, user.id).set(User::forget, code)) - sendRetrieveMail(user.username!!, request.remoteAddr, code, forgetParam.email) + sendRetrieveMail(user.username!!, request.remoteAddr, code, forgetParam.email!!) } @Transactional