diff --git a/src/main/kotlin/top/fatweb/api/config/DataFormatConfig.kt b/src/main/kotlin/top/fatweb/api/config/DataFormatConfig.kt index de59ddf..c974b86 100644 --- a/src/main/kotlin/top/fatweb/api/config/DataFormatConfig.kt +++ b/src/main/kotlin/top/fatweb/api/config/DataFormatConfig.kt @@ -35,6 +35,7 @@ class DataFormatConfig { * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 + * @see TimeZone */ @set:Value("\${spring.jackson.time-zone}}") lateinit var timeZone: TimeZone diff --git a/src/main/kotlin/top/fatweb/api/config/SwaggerConfig.kt b/src/main/kotlin/top/fatweb/api/config/SwaggerConfig.kt index ac5bddd..78a59bf 100644 --- a/src/main/kotlin/top/fatweb/api/config/SwaggerConfig.kt +++ b/src/main/kotlin/top/fatweb/api/config/SwaggerConfig.kt @@ -15,7 +15,6 @@ import top.fatweb.api.properties.ServerProperties */ @Configuration class SwaggerConfig { - @Bean fun customOpenAPI(): OpenAPI? { val contact = Contact().name("FatttSnake").url("https://fatweb.top").email("fatttsnake@fatweb.top") diff --git a/src/main/kotlin/top/fatweb/api/config/SysLogConfig.kt b/src/main/kotlin/top/fatweb/api/config/SysLogConfig.kt index 4391656..2d8ac34 100644 --- a/src/main/kotlin/top/fatweb/api/config/SysLogConfig.kt +++ b/src/main/kotlin/top/fatweb/api/config/SysLogConfig.kt @@ -10,6 +10,7 @@ import top.fatweb.api.interceptor.SysLogInterceptor * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 + * @see WebMvcConfigurer */ @Configuration class SysLogConfig( diff --git a/src/main/kotlin/top/fatweb/api/config/WebMvcRegistrationsConfig.kt b/src/main/kotlin/top/fatweb/api/config/WebMvcRegistrationsConfig.kt index df606c0..6fcf518 100644 --- a/src/main/kotlin/top/fatweb/api/config/WebMvcRegistrationsConfig.kt +++ b/src/main/kotlin/top/fatweb/api/config/WebMvcRegistrationsConfig.kt @@ -10,6 +10,7 @@ import top.fatweb.api.util.ApiResponseMappingHandlerMapping * * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 + * @see WebMvcRegistrations */ @Configuration class WebMvcRegistrationsConfig : WebMvcRegistrations { diff --git a/src/main/kotlin/top/fatweb/api/controller/api/v1/AvatarController.kt b/src/main/kotlin/top/fatweb/api/controller/api/v1/AvatarController.kt index bfd2808..6fb1c2b 100644 --- a/src/main/kotlin/top/fatweb/api/controller/api/v1/AvatarController.kt +++ b/src/main/kotlin/top/fatweb/api/controller/api/v1/AvatarController.kt @@ -27,10 +27,21 @@ import top.fatweb.api.vo.api.v1.avatar.AvatarBase64Vo class AvatarController( private val avatarService: IAvatarService ) { + /** + * Get random avatar + * + * @param apiVersion Api version + * @param avatarBaseParam Avatar base parameters + * @return Avatar byte array + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarBaseParam + * @see ByteArray + */ @Operation(summary = "获取随机头像") @GetMapping(produces = [MediaType.IMAGE_PNG_VALUE]) - fun getDefault(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ByteArray { - return when ((1..4).random()) { + fun getRandom(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ByteArray = + when ((1..4).random()) { 1 -> avatarService.triangle(avatarBaseParam) 2 -> avatarService.square(avatarBaseParam) 3 -> avatarService.identicon(avatarBaseParam) @@ -43,15 +54,26 @@ class AvatarController( background = avatarBaseParam?.background }) } - } + /** + * Get random avatar as base64 + * + * @param apiVersion Api version + * @param avatarBaseParam Avatar base parameters + * @return Response object includes avatar base64 string + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarBaseParam + * @see ResponseResult + * @see AvatarBase64Vo + */ @Operation(summary = "获取随机头像 Base64") @GetMapping("base64") - fun getDefaultBase64( + fun getRandomBase64( @PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam? - ): ResponseResult { - return ResponseResult.success( + ): ResponseResult = + ResponseResult.success( ResponseCode.API_AVATAR_SUCCESS, data = when ((1..4).random()) { 1 -> avatarService.triangleBase64(avatarBaseParam) 2 -> avatarService.squareBase64(avatarBaseParam) @@ -66,65 +88,160 @@ class AvatarController( }) } ) - } + /** + * Get triangle avatar + * + * @param apiVersion Api version + * @param avatarBaseParam Avatar base parameters + * @return Avatar byte array + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarBaseParam + * @see ByteArray + */ @Operation(summary = "三角形头像") @GetMapping("/triangle", produces = [MediaType.IMAGE_PNG_VALUE]) - fun triangle(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ByteArray { - return avatarService.triangle(avatarBaseParam) - } + fun triangle(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ByteArray = + avatarService.triangle(avatarBaseParam) + /** + * Get triangle avatar as base64 + * + * @param apiVersion Api version + * @param avatarBaseParam Avatar base parameters + * @return Response object includes avatar base64 string + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarBaseParam + * @see ResponseResult + * @see AvatarBase64Vo + */ @Operation(summary = "三角形头像 Base64") @GetMapping("/triangle/base64") - fun triangleBase64(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ResponseResult { - return ResponseResult.success( + fun triangleBase64( + @PathVariable apiVersion: String, + @Valid avatarBaseParam: AvatarBaseParam? + ): ResponseResult = + ResponseResult.success( ResponseCode.API_AVATAR_SUCCESS, data = avatarService.triangleBase64(avatarBaseParam) ) - } + /** + * Get square avatar + * + * @param apiVersion Api version + * @param avatarBaseParam Avatar base parameters + * @return Avatar byte array + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarBaseParam + * @see ByteArray + */ @Operation(summary = "正方形头像") @GetMapping("/square", produces = [MediaType.IMAGE_PNG_VALUE]) - fun square(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ByteArray { - return avatarService.square(avatarBaseParam) - } + fun square(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ByteArray = + avatarService.square(avatarBaseParam) + /** + * Get square avatar as base64 + * + * @param apiVersion Api version + * @param avatarBaseParam Avatar base parameters + * @return Response object includes avatar base64 string + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarBaseParam + * @see ResponseResult + * @see AvatarBase64Vo + */ @Operation(summary = "正方形头像 Base64") @GetMapping("/square/base64") - fun squareBase64(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ResponseResult { - return ResponseResult.success( + fun squareBase64( + @PathVariable apiVersion: String, + @Valid avatarBaseParam: AvatarBaseParam? + ): ResponseResult = + ResponseResult.success( ResponseCode.API_AVATAR_SUCCESS, data = avatarService.squareBase64(avatarBaseParam) ) - } + /** + * Get identicon avatar + * + * @param apiVersion Api version + * @param avatarBaseParam Avatar base parameters + * @return Avatar byte array + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarBaseParam + * @see ByteArray + */ @Operation(summary = "Identicon 头像") @GetMapping("/identicon", produces = [MediaType.IMAGE_PNG_VALUE]) - fun identicon(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ByteArray { - return avatarService.identicon(avatarBaseParam) - } + fun identicon(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ByteArray = + avatarService.identicon(avatarBaseParam) + /** + * Get identicon avatar as base64 + * + * @param apiVersion Api version + * @param avatarBaseParam Avatar base parameters + * @return Response object includes avatar base64 string + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarBaseParam + * @see ResponseResult + * @see AvatarBase64Vo + */ @Operation(summary = "Identicon 头像 Base64") @GetMapping("/identicon/base64") - fun identiconBase64(@PathVariable apiVersion: String, @Valid avatarBaseParam: AvatarBaseParam?): ResponseResult { - return ResponseResult.success( + fun identiconBase64( + @PathVariable apiVersion: String, + @Valid avatarBaseParam: AvatarBaseParam? + ): ResponseResult = + ResponseResult.success( ResponseCode.API_AVATAR_SUCCESS, data = avatarService.identiconBase64(avatarBaseParam) ) - } + /** + * Get GitHub avatar + * + * @param apiVersion Api version + * @param avatarGitHubParam Avatar base parameters + * @return Avatar byte array + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarGitHubParam + * @see ByteArray + */ @Operation(summary = "GitHub 头像") @GetMapping("/github", produces = [MediaType.IMAGE_PNG_VALUE]) - fun github(@PathVariable apiVersion: String, @Valid avatarGitHubParam: AvatarGitHubParam?): ByteArray { - return avatarService.github(avatarGitHubParam) - } + fun github(@PathVariable apiVersion: String, @Valid avatarGitHubParam: AvatarGitHubParam?): ByteArray = + avatarService.github(avatarGitHubParam) + /** + * Get GitHub avatar as base64 + * + * @param apiVersion Api version + * @param avatarGitHubParam Avatar base parameters + * @return Response object includes avatar base64 string + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see AvatarGitHubParam + * @see ResponseResult + * @see AvatarBase64Vo + */ @Operation(summary = "GitHub 头像 Base64") @GetMapping("/github/base64") - fun githubBase64(@PathVariable apiVersion: String, @Valid avatarGitHubParam: AvatarGitHubParam?): ResponseResult { - return ResponseResult.success( + fun githubBase64( + @PathVariable apiVersion: String, + @Valid avatarGitHubParam: AvatarGitHubParam? + ): ResponseResult = + ResponseResult.success( ResponseCode.API_AVATAR_SUCCESS, data = avatarService.githubBase64(avatarGitHubParam) ) - } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/api/controller/permission/AuthenticationController.kt b/src/main/kotlin/top/fatweb/api/controller/permission/AuthenticationController.kt index 9698d40..e2cbd63 100644 --- a/src/main/kotlin/top/fatweb/api/controller/permission/AuthenticationController.kt +++ b/src/main/kotlin/top/fatweb/api/controller/permission/AuthenticationController.kt @@ -14,6 +14,8 @@ import top.fatweb.api.entity.common.ResponseResult import top.fatweb.api.param.permission.LoginParam import top.fatweb.api.service.permission.IAuthenticationService import top.fatweb.api.util.WebUtil +import top.fatweb.api.vo.permission.LoginVo +import top.fatweb.api.vo.permission.TokenVo /** * Authentication controller @@ -26,24 +28,59 @@ import top.fatweb.api.util.WebUtil class AuthenticationController( private val authenticationService: IAuthenticationService ) { + /** + * Login + * + * @param request + * @param loginParam Login parameters + * @return Response object includes login result + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see HttpServletRequest + * @see LoginParam + * @see ResponseResult + * @see LoginVo + */ @Operation(summary = "登录") @PostMapping("/login") - fun login(request: HttpServletRequest, @Valid @RequestBody loginParam: LoginParam) = ResponseResult.success( - ResponseCode.PERMISSION_LOGIN_SUCCESS, - "Login success", - authenticationService.login(request, UserConverter.loginParamToUser(loginParam)) - ) + fun login(request: HttpServletRequest, @Valid @RequestBody loginParam: LoginParam): ResponseResult = + ResponseResult.success( + ResponseCode.PERMISSION_LOGIN_SUCCESS, + "Login success", + authenticationService.login(request, UserConverter.loginParamToUser(loginParam)) + ) + /** + * Logout + * + * @param request + * @return Response object includes logout result + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see HttpServletRequest + * @see ResponseResult + */ @Operation(summary = "登出") @PostMapping("/logout") - fun logout(request: HttpServletRequest) = when (authenticationService.logout(WebUtil.getToken(request))) { + fun logout(request: HttpServletRequest): ResponseResult = when (authenticationService.logout(WebUtil.getToken(request))) { true -> ResponseResult.success(ResponseCode.PERMISSION_LOGOUT_SUCCESS, "Logout success", null) false -> ResponseResult.fail(ResponseCode.PERMISSION_LOGOUT_FAILED, "Logout failed", null) } + /** + * Renew token + * + * @param request + * @return Response object includes new token + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see HttpServletRequest + * @see ResponseResult + * @see TokenVo + */ @Operation(summary = "更新 Token") @GetMapping("/token") - fun renewToken(request: HttpServletRequest) = ResponseResult.success( + fun renewToken(request: HttpServletRequest): ResponseResult = ResponseResult.success( ResponseCode.PERMISSION_TOKEN_RENEW_SUCCESS, "Token renew success", authenticationService.renewToken(WebUtil.getToken(request)) diff --git a/src/main/kotlin/top/fatweb/api/controller/permission/GroupController.kt b/src/main/kotlin/top/fatweb/api/controller/permission/GroupController.kt index 1b6b212..ce7328e 100644 --- a/src/main/kotlin/top/fatweb/api/controller/permission/GroupController.kt +++ b/src/main/kotlin/top/fatweb/api/controller/permission/GroupController.kt @@ -10,8 +10,8 @@ import top.fatweb.api.entity.common.ResponseResult import top.fatweb.api.param.permission.group.* import top.fatweb.api.service.permission.IGroupService import top.fatweb.api.vo.PageVo -import top.fatweb.api.vo.permission.base.GroupVo import top.fatweb.api.vo.permission.GroupWithRoleVo +import top.fatweb.api.vo.permission.base.GroupVo /** * Group controller @@ -25,67 +25,133 @@ import top.fatweb.api.vo.permission.GroupWithRoleVo class GroupController( val groupService: IGroupService ) { + /** + * Get group by ID + * + * @param id Group ID + * @return Response object includes group info + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see GroupWithRoleVo + */ @Operation(summary = "获取单个用户组") @GetMapping("/{id}") @PreAuthorize("hasAnyAuthority('system:group:query:one')") - fun getOne(@PathVariable id: Long): ResponseResult { - return ResponseResult.databaseSuccess( + fun getOne(@PathVariable id: Long): ResponseResult = + ResponseResult.databaseSuccess( data = groupService.getOne(id) ) - } + /** + * Get group paging information + * + * @param groupGetParam Get group parameters + * @return Response object includes group paging information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see GroupGetParam + * @see ResponseResult + * @see PageVo + * @see GroupWithRoleVo + */ @Operation(summary = "获取用户组") @GetMapping @PreAuthorize("hasAnyAuthority('system:group:query:all')") - fun get(@Valid groupGetParam: GroupGetParam?): ResponseResult> { - return ResponseResult.databaseSuccess( + fun get(@Valid groupGetParam: GroupGetParam?): ResponseResult> = + ResponseResult.databaseSuccess( data = groupService.getPage(groupGetParam) ) - } + /** + * Get group list + * + * @return Response object includes group list + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see GroupVo + */ @Operation(summary = "获取用户组列表") @GetMapping("/list") @PreAuthorize("hasAnyAuthority('system:group:query:list', 'system:user:add:one', 'system:user:modify:one')") - fun list(): ResponseResult> { - return ResponseResult.databaseSuccess( + fun list(): ResponseResult> = + ResponseResult.databaseSuccess( data = groupService.listAll() ) - } + /** + * Add group + * + * @param groupAddParam Add group parameters + * @return Response object includes group information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see GroupAddParam + * @see ResponseResult + * @see GroupVo + */ @Operation(summary = "添加用户组") @PostMapping @PreAuthorize("hasAnyAuthority('system:group:add:one')") - fun add(@Valid @RequestBody groupAddParam: GroupAddParam): ResponseResult { - return groupService.add(groupAddParam)?.let { + fun add(@Valid @RequestBody groupAddParam: GroupAddParam): ResponseResult = + groupService.add(groupAddParam)?.let { ResponseResult.databaseSuccess( ResponseCode.DATABASE_INSERT_SUCCESS, data = it ) } ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_INSERT_FAILED) } - } + /** + * Update group + * + * @param groupUpdateParam Update group parameters + * @return Response object includes group information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see GroupUpdateParam + * @see ResponseResult + * @see GroupVo + */ @Operation(summary = "修改用户组") @PutMapping @PreAuthorize("hasAnyAuthority('system:group:modify:one')") - fun update(@Valid @RequestBody groupUpdateParam: GroupUpdateParam): ResponseResult { - return groupService.update(groupUpdateParam)?.let { + fun update(@Valid @RequestBody groupUpdateParam: GroupUpdateParam): ResponseResult = + groupService.update(groupUpdateParam)?.let { ResponseResult.databaseSuccess( ResponseCode.DATABASE_UPDATE_SUCCESS, data = it ) } ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_UPDATE_FILED) } - } + /** + * Update status of group + * + * @param groupUpdateStatusParam Update status of group parameters + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see GroupUpdateStatusParam + * @see ResponseResult + */ @Operation(summary = "修改用户组状态") @PatchMapping @PreAuthorize("hasAnyAuthority('system:group:modify:status')") - fun changStatus(@Valid @RequestBody groupChangeStatusParam: GroupChangeStatusParam): ResponseResult { - return if (groupService.changeStatus(groupChangeStatusParam)) { + fun updateStatus(@Valid @RequestBody groupUpdateStatusParam: GroupUpdateStatusParam): ResponseResult = + if (groupService.status(groupUpdateStatusParam)) { ResponseResult.databaseSuccess(ResponseCode.DATABASE_UPDATE_SUCCESS) } else { ResponseResult.databaseFail(ResponseCode.DATABASE_UPDATE_FILED) } - } - @Operation(summary = "删除角色") + /** + * Delete group by ID + * + * @param id Group ID + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + */ + @Operation(summary = "删除用户组") @DeleteMapping("/{id}") @PreAuthorize("hasAnyAuthority('system:group:delete:one')") fun delete(@PathVariable id: Long): ResponseResult { @@ -93,7 +159,17 @@ class GroupController( return ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) } - @Operation(summary = "批量删除角色") + /** + * Delete group by list + * + * @param groupDeleteParam Delete group parameters + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see GroupDeleteParam + * @see ResponseResult + */ + @Operation(summary = "批量删除用户组") @DeleteMapping @PreAuthorize("hasAnyAuthority('system:group:delete:multiple')") fun deleteList(@Valid @RequestBody groupDeleteParam: GroupDeleteParam): ResponseResult { diff --git a/src/main/kotlin/top/fatweb/api/controller/permission/PowerController.kt b/src/main/kotlin/top/fatweb/api/controller/permission/PowerController.kt index da57913..45c63ef 100644 --- a/src/main/kotlin/top/fatweb/api/controller/permission/PowerController.kt +++ b/src/main/kotlin/top/fatweb/api/controller/permission/PowerController.kt @@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController import top.fatweb.api.entity.common.ResponseResult import top.fatweb.api.service.permission.IPowerService +import top.fatweb.api.vo.permission.PowerSetVo /** * Power controller @@ -21,8 +22,16 @@ import top.fatweb.api.service.permission.IPowerService class PowerController( private val powerService: IPowerService ) { + /** + * Get power list + * + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see PowerSetVo + */ @Operation(summary = "获取权限列表") @GetMapping("/list") @PreAuthorize("hasAnyAuthority('system:power:query:list', 'system:role:add:one', 'system:role:modify:one')") - fun getList() = ResponseResult.databaseSuccess(data = powerService.getList()) + fun getList(): ResponseResult = ResponseResult.databaseSuccess(data = powerService.getList()) } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/api/controller/permission/RoleController.kt b/src/main/kotlin/top/fatweb/api/controller/permission/RoleController.kt index d25c5b9..73bf3c7 100644 --- a/src/main/kotlin/top/fatweb/api/controller/permission/RoleController.kt +++ b/src/main/kotlin/top/fatweb/api/controller/permission/RoleController.kt @@ -25,6 +25,16 @@ import top.fatweb.api.vo.permission.base.RoleVo class RoleController( private val roleService: IRoleService ) { + /** + * Get role by ID + * + * @param id Role ID + * @return Response object includes role information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see RoleWithPowerVo + */ @Operation(summary = "获取单个角色") @GetMapping("/{id}") @PreAuthorize("hasAnyAuthority('system:role:query:one')") @@ -34,6 +44,17 @@ class RoleController( ) } + /** + * Get role paging information + * + * @param roleGetParam Get role parameters + * @return Response object includes role paging information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see RoleGetParam + * @see ResponseResult + * @see RoleWithPowerVo + */ @Operation(summary = "获取角色") @GetMapping @PreAuthorize("hasAnyAuthority('system:role:query:all')") @@ -43,6 +64,15 @@ class RoleController( ) } + /** + * Get role list + * + * @return Response object includes role list + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see RoleVo + */ @Operation(summary = "获取角色列表") @GetMapping("/list") @PreAuthorize("hasAnyAuthority('system:role:query:list', 'system:group:add:one', 'system:group:modify:one', 'system:user:add:one', 'system:user:modify:one')") @@ -52,6 +82,17 @@ class RoleController( ) } + /** + * Add role + * + * @param roleAddParam Add role parameters + * @return Response object includes role information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see RoleAddParam + * @see ResponseResult + * @see RoleVo + */ @Operation(summary = "添加角色") @PostMapping @PreAuthorize("hasAnyAuthority('system:role:add:one')") @@ -63,6 +104,17 @@ class RoleController( } ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_INSERT_FAILED) } } + /** + * Update role + * + * @param roleUpdateParam Update role parameters + * @return Response object includes role information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see RoleUpdateParam + * @see ResponseResult + * @see RoleVo + */ @Operation(summary = "修改角色") @PutMapping @PreAuthorize("hasAnyAuthority('system:role:modify:one')") @@ -74,17 +126,36 @@ class RoleController( } ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_UPDATE_FILED) } } + /** + * Update status of role + * + * @param roleUpdateStatusParam Update status of role parameters + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see RoleUpdateStatusParam + * @see ResponseResult + */ @Operation(summary = "修改角色状态") @PatchMapping @PreAuthorize("hasAnyAuthority('system:role:modify:status')") - fun changStatus(@Valid @RequestBody roleChangeStatusParam: RoleChangeStatusParam): ResponseResult { - return if (roleService.changeStatus(roleChangeStatusParam)) { + fun status(@Valid @RequestBody roleUpdateStatusParam: RoleUpdateStatusParam): ResponseResult { + return if (roleService.status(roleUpdateStatusParam)) { ResponseResult.databaseSuccess(ResponseCode.DATABASE_UPDATE_SUCCESS) } else { ResponseResult.databaseFail(ResponseCode.DATABASE_UPDATE_FILED) } } + /** + * Delete role by ID + * + * @param id + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + */ @Operation(summary = "删除角色") @DeleteMapping("/{id}") @PreAuthorize("hasAnyAuthority('system:role:delete:one')") @@ -93,6 +164,16 @@ class RoleController( return ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) } + /** + * Delete role by list + * + * @param roleDeleteParam Delete role parameters + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see RoleDeleteParam + * @see ResponseResult + */ @Operation(summary = "批量删除角色") @DeleteMapping @PreAuthorize("hasAnyAuthority('system:role:delete:multiple')") diff --git a/src/main/kotlin/top/fatweb/api/controller/permission/UserController.kt b/src/main/kotlin/top/fatweb/api/controller/permission/UserController.kt index c412d7c..81b15da 100644 --- a/src/main/kotlin/top/fatweb/api/controller/permission/UserController.kt +++ b/src/main/kotlin/top/fatweb/api/controller/permission/UserController.kt @@ -27,64 +27,130 @@ import top.fatweb.api.vo.permission.UserWithRoleInfoVo class UserController( private val userService: IUserService ) { + /** + * Get current user information + * + * @return Response object includes user information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see UserWithPowerInfoVo + */ @Operation(summary = "获取当前用户信息") @GetMapping("info") - fun getInfo(): ResponseResult { + fun getInfo(): ResponseResult = userService.getInfo()?.let { - return ResponseResult.databaseSuccess(data = it) - } ?: let { return ResponseResult.databaseFail() } - } + ResponseResult.databaseSuccess(data = it) + } ?: let { ResponseResult.databaseFail() } + /** + * Get user by ID + * + * @param id User ID + * @return Response object includes user information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + * @see UserWithRoleInfoVo + */ @Operation(summary = "获取单个用户") @GetMapping("/{id}") @PreAuthorize("hasAnyAuthority('system:user:query:one')") - fun getOne(@PathVariable id: Long): ResponseResult { - return userService.getOne(id)?.let { + fun getOne(@PathVariable id: Long): ResponseResult = + userService.getOne(id)?.let { ResponseResult.databaseSuccess(data = it) } ?: let { throw NoRecordFoundException() } - } + /** + * Get user paging information + * + * @param userGetParam Get user parameters + * @return Response object includes user paging information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see UserGetParam + * @see ResponseResult + * @see UserWithRoleInfoVo + */ @Operation(summary = "获取用户") @GetMapping @PreAuthorize("hasAnyAuthority('system:user:query:all')") - fun get(@Valid userGetParam: UserGetParam?): ResponseResult> { - return ResponseResult.databaseSuccess( + fun get(@Valid userGetParam: UserGetParam?): ResponseResult> = + ResponseResult.databaseSuccess( data = userService.getPage(userGetParam) ) - } + /** + * Add user + * + * @param userAddParam Add user parameters + * @return Response object includes user information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see UserAddParam + * @see ResponseResult + * @see UserWithPasswordRoleInfoVo + */ @Operation(summary = "添加用户") @PostMapping @PreAuthorize("hasAnyAuthority('system:user:add:one')") - fun add(@Valid @RequestBody userAddParam: UserAddParam): ResponseResult { - return userService.add(userAddParam)?.let { + fun add(@Valid @RequestBody userAddParam: UserAddParam): ResponseResult = + userService.add(userAddParam)?.let { ResponseResult.databaseSuccess( ResponseCode.DATABASE_INSERT_SUCCESS, data = it ) } ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_INSERT_FAILED) } - } + /** + * Update user + * + * @param userUpdateParam Update user parameters + * @return Response object includes user information + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see UserUpdateParam + * @see ResponseResult + * @see UserWithRoleInfoVo + */ @Operation(summary = "修改用户") @PutMapping @PreAuthorize("hasAnyAuthority('system:user:modify:one')") - fun update(@Valid @RequestBody userUpdateParam: UserUpdateParam): ResponseResult { - return userService.update(userUpdateParam)?.let { + fun update(@Valid @RequestBody userUpdateParam: UserUpdateParam): ResponseResult = + userService.update(userUpdateParam)?.let { ResponseResult.databaseSuccess( ResponseCode.DATABASE_UPDATE_SUCCESS, data = it ) } ?: let { ResponseResult.databaseFail(ResponseCode.DATABASE_UPDATE_FILED) } - } + /** + * Update user password + * + * @param userUpdatePasswordParam Update user password parameters + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see UserUpdatePasswordParam + * @see ResponseResult + */ @Operation(summary = "修改密码") @PatchMapping @PreAuthorize("hasAnyAuthority('system:user:modify:password')") - fun changePassword(@Valid @RequestBody userChangePasswordParam: UserChangePasswordParam): ResponseResult { - userService.changePassword(userChangePasswordParam) + fun password(@Valid @RequestBody userUpdatePasswordParam: UserUpdatePasswordParam): ResponseResult { + userService.password(userUpdatePasswordParam) return ResponseResult.databaseSuccess(ResponseCode.DATABASE_UPDATE_SUCCESS) } + /** + * Delete user by ID + * + * @param id User ID + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see ResponseResult + */ @Operation(summary = "删除用户") @DeleteMapping("/{id}") @PreAuthorize("hasAnyAuthority('system:user:delete:one')") @@ -93,6 +159,16 @@ class UserController( return ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) } + /** + * Delete user by list + * + * @param userDeleteParam Delete user parameters + * @return Response object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see UserDeleteParam + * @see ResponseResult + */ @Operation(summary = "批量删除用户") @DeleteMapping @PreAuthorize("hasAnyAuthority('system:user:delete:multiple')") @@ -100,5 +176,4 @@ class UserController( userService.delete(userDeleteParam) return ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS) } -} - +} \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/api/controller/system/SysLogController.kt b/src/main/kotlin/top/fatweb/api/controller/system/SysLogController.kt index 5fa661f..e1954fa 100644 --- a/src/main/kotlin/top/fatweb/api/controller/system/SysLogController.kt +++ b/src/main/kotlin/top/fatweb/api/controller/system/SysLogController.kt @@ -27,6 +27,17 @@ import top.fatweb.api.vo.system.SysLogVo class SysLogController( private val sysLogService: ISysLogService ) { + /** + * Get system log + * + * @param sysLogGetParam Get system log parameters + * @return Response object includes system log + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see SysLogGetParam + * @see ResponseResult + * @see SysLogVo + */ @Operation(summary = "获取") @GetMapping @PreAuthorize("hasAnyAuthority('system:log:query:all')") diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/FuncConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/FuncConverter.kt index 70e7410..9079ee2 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/FuncConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/FuncConverter.kt @@ -10,6 +10,16 @@ import top.fatweb.api.vo.permission.base.FuncVo * @since 1.0.0 */ object FuncConverter { + /** + * Convert Func object into FuncVo object + * + * @param func Func object + * @return FuncVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Func + * @see FuncVo + */ fun funcToFuncVo(func: Func) = FuncVo( id = func.id, name = func.name, diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/GroupConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/GroupConverter.kt index 2b4afd9..b218e48 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/GroupConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/GroupConverter.kt @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage import top.fatweb.api.entity.permission.Group import top.fatweb.api.entity.permission.Role import top.fatweb.api.param.permission.group.GroupAddParam -import top.fatweb.api.param.permission.group.GroupChangeStatusParam +import top.fatweb.api.param.permission.group.GroupUpdateStatusParam import top.fatweb.api.param.permission.group.GroupUpdateParam import top.fatweb.api.vo.PageVo import top.fatweb.api.vo.permission.base.GroupVo @@ -17,6 +17,16 @@ import top.fatweb.api.vo.permission.GroupWithRoleVo * @since 1.0.0 */ object GroupConverter { + /** + * Convert Group object into GroupVo object + * + * @param group Group object + * @return GroupVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Group + * @see GroupVo + */ fun groupToGroupVo(group: Group) = GroupVo( id = group.id, name = group.name, @@ -25,6 +35,16 @@ object GroupConverter { updateTime = group.updateTime ) + /** + * Convert Group object into GroupWithRoleVo object + * + * @param group Group object + * @return GroupWithRoleVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Group + * @see GroupWithRoleVo + */ fun groupToGroupWithRoleVo(group: Group) = GroupWithRoleVo( id = group.id, name = group.name, @@ -34,7 +54,19 @@ object GroupConverter { roles = group.roles?.map { RoleConverter.roleToRoleVo(it) } ) - fun groupPageToGroupWithRolePageVo(groupPage: IPage): PageVo = PageVo( + /** + * Convert IPage object into PageVo object + * + * @param groupPage IPage object + * @return PageVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see IPage + * @see Group + * @see PageVo + * @see GroupWithRoleVo + */ + fun groupPageToGroupWithRolePageVo(groupPage: IPage) = PageVo( total = groupPage.total, pages = groupPage.pages, size = groupPage.size, @@ -44,21 +76,51 @@ object GroupConverter { } ) + /** + * Convert GroupAddParam object into Group object + * + * @param groupAddParam GroupAddParam object + * @return Group object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see GroupAddParam + * @see Group + */ fun groupAddParamToGroup(groupAddParam: GroupAddParam) = Group().apply { name = groupAddParam.name enable = if (groupAddParam.enable) 1 else 0 roles = groupAddParam.roleIds?.map { Role().apply { id = it } } } + /** + * Convert GroupUpdateParam object into Group object + * + * @param groupUpdateParam GroupUpdateParam object + * @return Group object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see GroupUpdateParam + * @see Group + */ fun groupUpdateParamToGroup(groupUpdateParam: GroupUpdateParam) = Group().apply { id = groupUpdateParam.id name = groupUpdateParam.name - enable = if (groupUpdateParam.enable == true) 1 else 0 + enable = if (groupUpdateParam.enable) 1 else 0 roles = groupUpdateParam.roleIds?.map { Role().apply { id = it } } } - fun groupChangeStatusParamToGroup(groupChangeStatusParam: GroupChangeStatusParam) = Group().apply { - id = groupChangeStatusParam.id - enable = if (groupChangeStatusParam.enable) 1 else 0 + /** + * Convert GroupUpdateStatusParam object into Group object + * + * @param groupUpdateStatusParam GroupUpdateStatusParam object + * @return Group object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see GroupUpdateStatusParam + * @see Group + */ + fun groupUpdateStatusParamToGroup(groupUpdateStatusParam: GroupUpdateStatusParam) = Group().apply { + id = groupUpdateStatusParam.id + enable = if (groupUpdateStatusParam.enable) 1 else 0 } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/MenuConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/MenuConverter.kt index 489381e..8b9f205 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/MenuConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/MenuConverter.kt @@ -10,6 +10,16 @@ import top.fatweb.api.vo.permission.base.MenuVo * @since 1.0.0 */ object MenuConverter { + /** + * Convert Menu object into MenuVo object + * + * @param menu Menu object + * @return MenuVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Menu + * @see MenuVo + */ fun menuToMenuVo(menu: Menu) = MenuVo( id = menu.id, name = menu.name, diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/ModuleConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/ModuleConverter.kt index 5b6c381..4c32635 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/ModuleConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/ModuleConverter.kt @@ -10,6 +10,16 @@ import top.fatweb.api.vo.permission.base.ModuleVo * @since 1.0.0 */ object ModuleConverter { + /** + * Convert Module object into ModuleVo object + * + * @param module Module object + * @return ModuleVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Module + * @see ModuleVo + */ fun moduleToModuleVo(module: Module) = ModuleVo( id = module.id, name = module.name diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/OperationConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/OperationConverter.kt index b6a4b36..6328ad4 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/OperationConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/OperationConverter.kt @@ -10,6 +10,16 @@ import top.fatweb.api.vo.permission.base.OperationVo * @since 1.0.0 */ object OperationConverter { + /** + * Convert Operation object into OperationVo object + * + * @param operation Operation object + * @return OperationVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Operation + * @see OperationVo + */ fun operationToOperationVo(operation: Operation) = OperationVo( id = operation.id, name = operation.name, diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/PowerConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/PowerConverter.kt index 65db452..4c4dc05 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/PowerConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/PowerConverter.kt @@ -10,6 +10,16 @@ import top.fatweb.api.vo.permission.PowerSetVo * @since 1.0.0 */ object PowerConverter { + /** + * Convert PowerSet object into PowerSetVo object + * + * @param powerSet PowerSet object + * @return PowerSetVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see PowerSet + * @see PowerSetVo + */ fun powerSetToPowerSetVo(powerSet: PowerSet) = PowerSetVo( moduleList = powerSet.moduleList?.map { ModuleConverter.moduleToModuleVo(it) }, menuList = powerSet.menuList?.map { MenuConverter.menuToMenuVo(it) }, diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/RoleConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/RoleConverter.kt index a55d749..044227f 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/RoleConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/RoleConverter.kt @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage import top.fatweb.api.entity.permission.Power import top.fatweb.api.entity.permission.Role import top.fatweb.api.param.permission.role.RoleAddParam -import top.fatweb.api.param.permission.role.RoleChangeStatusParam +import top.fatweb.api.param.permission.role.RoleUpdateStatusParam import top.fatweb.api.param.permission.role.RoleUpdateParam import top.fatweb.api.vo.PageVo import top.fatweb.api.vo.permission.base.RoleVo @@ -17,6 +17,16 @@ import top.fatweb.api.vo.permission.RoleWithPowerVo * @since 1.0.0 */ object RoleConverter { + /** + * Convert Role object into RoleVo object + * + * @param role Role object + * @return RoleVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Role + * @see RoleVo + */ fun roleToRoleVo(role: Role) = RoleVo( id = role.id, name = role.name, @@ -25,6 +35,16 @@ object RoleConverter { updateTime = role.updateTime ) + /** + * Convert Role object into RoleWithPowerVo object + * + * @param role Role object + * @return RoleWithPowerVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see Role + * @see RoleWithPowerVo + */ fun roleToRoleWithPowerVo(role: Role) = RoleWithPowerVo( id = role.id, name = role.name, @@ -37,6 +57,18 @@ object RoleConverter { operations = role.operations?.map { OperationConverter.operationToOperationVo(it) } ) + /** + * Convert IPage object into PageVo object + * + * @param rolePage IPage object + * @return PageVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see IPage + * @see Role + * @see PageVo + * @see RoleWithPowerVo + */ fun rolePageToRoleWithPowerPageVo(rolePage: IPage) = PageVo( total = rolePage.total, pages = rolePage.pages, @@ -47,21 +79,51 @@ object RoleConverter { } ) + /** + * Convert RoleAddParam object into Role object + * + * @param roleAddParam RoleAddParam object + * @return Role object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see RoleAddParam + * @see Role + */ fun roleAddParamToRole(roleAddParam: RoleAddParam) = Role().apply { name = roleAddParam.name - enable = if (roleAddParam.enable == true) 1 else 0 + enable = if (roleAddParam.enable) 1 else 0 powers = roleAddParam.powerIds?.map { Power().apply { id = it } } } + /** + * Convert RoleUpdateParam into Role object + * + * @param roleUpdateParam RoleUpdateParam object + * @return Role object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see RoleUpdateParam + * @see Role + */ fun roleUpdateParamToRole(roleUpdateParam: RoleUpdateParam) = Role().apply { id = roleUpdateParam.id name = roleUpdateParam.name - enable = if (roleUpdateParam.enable == true) 1 else 0 + enable = if (roleUpdateParam.enable) 1 else 0 powers = roleUpdateParam.powerIds?.map { Power().apply { id = it } } } - fun roleChangeStatusParamToRole(roleChangeStatusParam: RoleChangeStatusParam) = Role().apply { - id = roleChangeStatusParam.id - enable = if (roleChangeStatusParam.enable) 1 else 0 + /** + * Convert RoleUpdateStatusParam object into Role object + * + * @param roleUpdateStatusParam RoleUpdateStatusParam object + * @return Role object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see RoleUpdateStatusParam + * @see Role + */ + fun roleUpdateStatusParamToRole(roleUpdateStatusParam: RoleUpdateStatusParam) = Role().apply { + id = roleUpdateStatusParam.id + enable = if (roleUpdateStatusParam.enable) 1 else 0 } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/UserConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/UserConverter.kt index 55dc200..1d3cb5b 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/UserConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/UserConverter.kt @@ -22,12 +22,31 @@ import top.fatweb.avatargenerator.GitHubAvatar * @since 1.0.0 */ object UserConverter { - + /** + * Convert LoginParam object into User object + * + * @param loginParam LoginParam object + * @return User object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see LoginParam + * @see User + */ fun loginParamToUser(loginParam: LoginParam) = User().apply { username = loginParam.username password = loginParam.password } + /** + * Convert User object into UserWithPowerInfoVo object + * + * @param user User object + * @return UserWithPowerInfoVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see User + * @see UserWithPowerInfoVo + */ fun userToUserWithPowerInfoVo(user: User) = UserWithPowerInfoVo( id = user.id, username = user.username, @@ -58,6 +77,16 @@ object UserConverter { } ) + /** + * Convert User object into UserWithRoleInfoVo object + * + * @param user User object + * @return UserWithRoleInfoVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see User + * @see UserWithRoleInfoVo + */ fun userToUserWithRoleInfoVo(user: User) = UserWithRoleInfoVo( id = user.id, username = user.username, @@ -82,6 +111,16 @@ object UserConverter { } ) + /** + * Convert User object into UserWithInfoVo object + * + * @param user User object + * @return UserWithInfoVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see User + * @see UserWithInfoVo + */ fun userToUserWithInfoVo(user: User) = UserWithInfoVo( id = user.id, username = user.username, @@ -100,6 +139,16 @@ object UserConverter { } ) + /** + * Convert User object into UserWithPasswordRoleInfoVo object + * + * @param user User object + * @return UserWithPasswordRoleInfoVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see User + * @see UserWithPasswordRoleInfoVo + */ fun userToUserWithPasswordRoleInfoVo(user: User) = UserWithPasswordRoleInfoVo( id = user.id, username = user.username, @@ -125,6 +174,16 @@ object UserConverter { } ) + /** + * Convert UserAddParam object into User object + * + * @param userAddParam UserAddParam object + * @return User object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see UserAddParam + * @see User + */ fun userAddParamToUser(userAddParam: UserAddParam) = User().apply { username = userAddParam.username password = userAddParam.password @@ -142,6 +201,16 @@ object UserConverter { groups = userAddParam.groupIds?.map { Group().apply { id = it } } } + /** + * Convert UserUpdateParam object into User object + * + * @param userUpdateParam UserUpdateParam object + * @return User object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see UserUpdateParam + * @see User + */ fun userUpdateParamToUser(userUpdateParam: UserUpdateParam) = User().apply { id = userUpdateParam.id username = userUpdateParam.username @@ -158,6 +227,18 @@ object UserConverter { groups = if (userUpdateParam.id != 0L) userUpdateParam.groupIds?.map { Group().apply { id = it } } else null } + /** + * Convert IPage object into PageVo object + * + * @param userPage IPage object + * @return PageVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see IPage + * @see User + * @see PageVo + * @see UserWithRoleInfoVo + */ fun userPageToUserWithRoleInfoPageVo(userPage: IPage) = PageVo( total = userPage.total, pages = userPage.pages, diff --git a/src/main/kotlin/top/fatweb/api/converter/permission/UserInfoConverter.kt b/src/main/kotlin/top/fatweb/api/converter/permission/UserInfoConverter.kt index dd5c3db..dd2c253 100644 --- a/src/main/kotlin/top/fatweb/api/converter/permission/UserInfoConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/permission/UserInfoConverter.kt @@ -10,6 +10,16 @@ import top.fatweb.api.vo.permission.base.UserInfoVo * @since 1.0.0 */ object UserInfoConverter { + /** + * Convert UserInfo object into UserInfoVo object + * + * @param userInfo UserInfo object + * @return UserInfoVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see UserInfo + * @see UserInfoVo + */ fun userInfoToUserInfoVo(userInfo: UserInfo) = UserInfoVo( id = userInfo.id, userId = userInfo.userId, diff --git a/src/main/kotlin/top/fatweb/api/converter/system/SysLogConverter.kt b/src/main/kotlin/top/fatweb/api/converter/system/SysLogConverter.kt index f27dbbf..80812df 100644 --- a/src/main/kotlin/top/fatweb/api/converter/system/SysLogConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/system/SysLogConverter.kt @@ -12,7 +12,19 @@ import top.fatweb.api.vo.system.SysLogVo * @since 1.0.0 */ object SysLogConverter { - fun sysLogPageToSysLogPageVo(syslogPage: IPage): PageVo = PageVo( + /** + * Convert IPage object into PageVo object + * + * @param syslogPage IPage object + * @return PageVo object + * @author FatttSnake, fatttsnake@gmail.com + * @since 1.0.0 + * @see IPage + * @see SysLog + * @see PageVo + * @see SysLogVo + */ + fun sysLogPageToSysLogPageVo(syslogPage: IPage) = PageVo( syslogPage.total, syslogPage.pages, syslogPage.size, diff --git a/src/main/kotlin/top/fatweb/api/param/permission/group/GroupChangeStatusParam.kt b/src/main/kotlin/top/fatweb/api/param/permission/group/GroupUpdateStatusParam.kt similarity index 93% rename from src/main/kotlin/top/fatweb/api/param/permission/group/GroupChangeStatusParam.kt rename to src/main/kotlin/top/fatweb/api/param/permission/group/GroupUpdateStatusParam.kt index 9ff6129..b7c80d9 100644 --- a/src/main/kotlin/top/fatweb/api/param/permission/group/GroupChangeStatusParam.kt +++ b/src/main/kotlin/top/fatweb/api/param/permission/group/GroupUpdateStatusParam.kt @@ -10,7 +10,7 @@ import jakarta.validation.constraints.NotNull * @since 1.0.0 */ @Schema(description = "用户组更改状态请求参数") -data class GroupChangeStatusParam( +data class GroupUpdateStatusParam( @Schema(description = "用户组 ID") @field:NotNull(message = "ID can not be null") val id: Long?, diff --git a/src/main/kotlin/top/fatweb/api/param/permission/role/RoleChangeStatusParam.kt b/src/main/kotlin/top/fatweb/api/param/permission/role/RoleUpdateStatusParam.kt similarity index 94% rename from src/main/kotlin/top/fatweb/api/param/permission/role/RoleChangeStatusParam.kt rename to src/main/kotlin/top/fatweb/api/param/permission/role/RoleUpdateStatusParam.kt index a6ce7cb..48a3c4b 100644 --- a/src/main/kotlin/top/fatweb/api/param/permission/role/RoleChangeStatusParam.kt +++ b/src/main/kotlin/top/fatweb/api/param/permission/role/RoleUpdateStatusParam.kt @@ -10,7 +10,7 @@ import jakarta.validation.constraints.NotNull * @since 1.0.0 */ @Schema(description = "角色更改状态请求参数") -data class RoleChangeStatusParam( +data class RoleUpdateStatusParam( @Schema(description = "角色 ID") @field:NotNull(message = "Role id can not be null") val id: Long?, diff --git a/src/main/kotlin/top/fatweb/api/param/permission/user/UserChangePasswordParam.kt b/src/main/kotlin/top/fatweb/api/param/permission/user/UserUpdatePasswordParam.kt similarity index 94% rename from src/main/kotlin/top/fatweb/api/param/permission/user/UserChangePasswordParam.kt rename to src/main/kotlin/top/fatweb/api/param/permission/user/UserUpdatePasswordParam.kt index 55a1d79..26f19bf 100644 --- a/src/main/kotlin/top/fatweb/api/param/permission/user/UserChangePasswordParam.kt +++ b/src/main/kotlin/top/fatweb/api/param/permission/user/UserUpdatePasswordParam.kt @@ -6,7 +6,7 @@ import jakarta.validation.constraints.NotNull import java.time.LocalDateTime @Schema(description = "用户更改密码请求参数") -data class UserChangePasswordParam( +data class UserUpdatePasswordParam( @Schema(description = "用户 ID") @field:NotNull(message = "ID can not be null") val id: Long?, diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IGroupService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IGroupService.kt index 746c724..c79c7d0 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/IGroupService.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/IGroupService.kt @@ -24,7 +24,7 @@ interface IGroupService : IService { fun update(groupUpdateParam: GroupUpdateParam): GroupVo? - fun changeStatus(groupChangeStatusParam: GroupChangeStatusParam): Boolean + fun status(groupUpdateStatusParam: GroupUpdateStatusParam): Boolean fun deleteOne(id: Long) diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IRoleService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IRoleService.kt index ae9c9d7..bbac86e 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/IRoleService.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/IRoleService.kt @@ -24,7 +24,7 @@ interface IRoleService : IService { fun update(roleUpdateParam: RoleUpdateParam): RoleVo? - fun changeStatus(roleChangeStatusParam: RoleChangeStatusParam): Boolean + fun status(roleUpdateStatusParam: RoleUpdateStatusParam): Boolean fun deleteOne(id: Long) diff --git a/src/main/kotlin/top/fatweb/api/service/permission/IUserService.kt b/src/main/kotlin/top/fatweb/api/service/permission/IUserService.kt index 5268641..a65c178 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/IUserService.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/IUserService.kt @@ -30,7 +30,7 @@ interface IUserService : IService { fun update(userUpdateParam: UserUpdateParam): UserWithRoleInfoVo? - fun changePassword(userChangePasswordParam: UserChangePasswordParam) + fun password(userUpdatePasswordParam: UserUpdatePasswordParam) fun deleteOne(id: Long) diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/GroupServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/GroupServiceImpl.kt index e6e7fcf..0f0d046 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/impl/GroupServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/GroupServiceImpl.kt @@ -117,10 +117,10 @@ class GroupServiceImpl( return GroupConverter.groupToGroupVo(group) } - override fun changeStatus(groupChangeStatusParam: GroupChangeStatusParam): Boolean { - updateById(GroupConverter.groupChangeStatusParamToGroup(groupChangeStatusParam)).let { - if (it && !groupChangeStatusParam.enable) { - groupChangeStatusParam.id?.let { id -> offlineUser(id) } + override fun status(groupUpdateStatusParam: GroupUpdateStatusParam): Boolean { + updateById(GroupConverter.groupUpdateStatusParamToGroup(groupUpdateStatusParam)).let { + if (it && !groupUpdateStatusParam.enable) { + groupUpdateStatusParam.id?.let { id -> offlineUser(id) } } return it diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleServiceImpl.kt index 148c24e..512ecda 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/RoleServiceImpl.kt @@ -124,10 +124,10 @@ class RoleServiceImpl( return RoleConverter.roleToRoleVo(role) } - override fun changeStatus(roleChangeStatusParam: RoleChangeStatusParam): Boolean { - updateById(RoleConverter.roleChangeStatusParamToRole(roleChangeStatusParam)).let { - if (it && !roleChangeStatusParam.enable) { - roleChangeStatusParam.id?.let { id -> offlineUser(id) } + override fun status(roleUpdateStatusParam: RoleUpdateStatusParam): Boolean { + updateById(RoleConverter.roleUpdateStatusParamToRole(roleUpdateStatusParam)).let { + if (it && !roleUpdateStatusParam.enable) { + roleUpdateStatusParam.id?.let { id -> offlineUser(id) } } return it diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/UserServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserServiceImpl.kt index fa90b5d..4ca0de6 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/impl/UserServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/UserServiceImpl.kt @@ -201,25 +201,25 @@ class UserServiceImpl( return UserConverter.userToUserWithRoleInfoVo(user) } - override fun changePassword(userChangePasswordParam: UserChangePasswordParam) { - if (WebUtil.getLoginUserId() != 0L && userChangePasswordParam.id == 0L) { + override fun password(userUpdatePasswordParam: UserUpdatePasswordParam) { + if (WebUtil.getLoginUserId() != 0L && userUpdatePasswordParam.id == 0L) { throw AccessDeniedException("Access denied") } - val user = baseMapper.selectById(userChangePasswordParam.id) + val user = baseMapper.selectById(userUpdatePasswordParam.id) user?.let { val wrapper = KtUpdateWrapper(User()) wrapper.eq(User::id, user.id) - .set(User::password, passwordEncoder.encode(userChangePasswordParam.password)) + .set(User::password, passwordEncoder.encode(userUpdatePasswordParam.password)) .set( User::credentialsExpiration, - if (user.id != 0L) userChangePasswordParam.credentialsExpiration else null + if (user.id != 0L) userUpdatePasswordParam.credentialsExpiration else null ) .set(User::updateTime, LocalDateTime.now(ZoneOffset.UTC)) this.update(wrapper) - userChangePasswordParam.id?.let { WebUtil.offlineUser(redisUtil, it) } + userUpdatePasswordParam.id?.let { WebUtil.offlineUser(redisUtil, it) } } ?: let { throw NoRecordFoundException() }