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 3b5a191..e021d3b 100644 --- a/src/main/kotlin/top/fatweb/api/controller/permission/UserController.kt +++ b/src/main/kotlin/top/fatweb/api/controller/permission/UserController.kt @@ -3,7 +3,10 @@ package top.fatweb.api.controller.permission import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController +import top.fatweb.api.converter.UserConverter +import top.fatweb.api.entity.common.ResponseResult import top.fatweb.api.service.permission.IUserService +import top.fatweb.api.vo.authentication.UserInfoVo /** *
@@ -19,7 +22,10 @@ class UserController(
private val userService: IUserService
) {
@GetMapping("info")
- fun getInfo() {
+ fun getInfo(): ResponseResult
@@ -35,4 +36,7 @@ class UserServiceImpl(
return user
}
+
+ override fun getInfo() = WebUtil.getLoginUsername()?.let { getUserWithPower(it) } ?: let { null }
+
}
diff --git a/src/main/kotlin/top/fatweb/api/util/WebUtil.kt b/src/main/kotlin/top/fatweb/api/util/WebUtil.kt
index ac280d8..3be731b 100644
--- a/src/main/kotlin/top/fatweb/api/util/WebUtil.kt
+++ b/src/main/kotlin/top/fatweb/api/util/WebUtil.kt
@@ -11,6 +11,8 @@ object WebUtil {
fun getLoginUserId() = getLoginUser()?.user?.id
+ fun getLoginUsername() = getLoginUser()?.user?.username
+
fun getToken(tokenWithPrefix: String) = tokenWithPrefix.removePrefix(SecurityConstants.tokenPrefix)
fun getToken(request: HttpServletRequest) = getToken(request.getHeader(SecurityConstants.headerString))
diff --git a/src/main/kotlin/top/fatweb/api/vo/authentication/ElementVo.kt b/src/main/kotlin/top/fatweb/api/vo/authentication/ElementVo.kt
new file mode 100644
index 0000000..ba2396a
--- /dev/null
+++ b/src/main/kotlin/top/fatweb/api/vo/authentication/ElementVo.kt
@@ -0,0 +1,20 @@
+package top.fatweb.api.vo.authentication
+
+import io.swagger.v3.oas.annotations.media.Schema
+
+@Schema(description = "页面元素返回参数")
+data class ElementVo(
+ val id: Long?,
+
+ @Schema(description = "元素名", example = "AddButton")
+ val name: String?,
+
+ @Schema(description = "权限 ID")
+ val powerId: Long?,
+
+ @Schema(description = "父 ID")
+ val parentId: Long?,
+
+ @Schema(description = "菜单 ID")
+ val menuId: Long?
+)
diff --git a/src/main/kotlin/top/fatweb/api/vo/authentication/MenuVo.kt b/src/main/kotlin/top/fatweb/api/vo/authentication/MenuVo.kt
new file mode 100644
index 0000000..bfb0604
--- /dev/null
+++ b/src/main/kotlin/top/fatweb/api/vo/authentication/MenuVo.kt
@@ -0,0 +1,20 @@
+package top.fatweb.api.vo.authentication
+
+import io.swagger.v3.oas.annotations.media.Schema
+
+@Schema(description = "菜单返回参数")
+data class MenuVo(
+ val id: Long?,
+
+ @Schema(description = "菜单名", example = "System")
+ val name: String?,
+
+ @Schema(description = "URL", example = "/system")
+ val url: String?,
+
+ @Schema(description = "权限 ID")
+ val powerId: Long?,
+
+ @Schema(description = "父 ID")
+ val parentId: Long?
+)
diff --git a/src/main/kotlin/top/fatweb/api/vo/authentication/OperationVo.kt b/src/main/kotlin/top/fatweb/api/vo/authentication/OperationVo.kt
new file mode 100644
index 0000000..1af9f65
--- /dev/null
+++ b/src/main/kotlin/top/fatweb/api/vo/authentication/OperationVo.kt
@@ -0,0 +1,23 @@
+package top.fatweb.api.vo.authentication
+
+import io.swagger.v3.oas.annotations.media.Schema
+
+@Schema(description = "功能返回参数")
+data class OperationVo(
+ val id: Long?,
+
+ @Schema(description = "功能名", example = "Add User")
+ val name: String?,
+
+ @Schema(description = "功能编码", example = "system:user:add")
+ val code: String?,
+
+ @Schema(description = "权限 ID")
+ val powerId: Long?,
+
+ @Schema(description = "父 ID")
+ val parentId: Long?,
+
+ @Schema(description = "页面元素 ID")
+ val elementId: Long?
+)
diff --git a/src/main/kotlin/top/fatweb/api/vo/authentication/UserInfoVo.kt b/src/main/kotlin/top/fatweb/api/vo/authentication/UserInfoVo.kt
new file mode 100644
index 0000000..58bed65
--- /dev/null
+++ b/src/main/kotlin/top/fatweb/api/vo/authentication/UserInfoVo.kt
@@ -0,0 +1,45 @@
+package top.fatweb.api.vo.authentication
+
+import io.swagger.v3.oas.annotations.media.Schema
+import java.time.LocalDateTime
+
+@Schema(description = "获取用户信息返回参数")
+data class UserInfoVo(
+ val id: Long?,
+
+ @Schema(description = "用户名", example = "User")
+ val username: String?,
+
+ @Schema(description = "是否锁定", example = "false")
+ val locking: Boolean?,
+
+ @Schema(description = "过期时间", example = "1900-01-01T00:00:00.000Z")
+ val expiration: LocalDateTime?,
+
+ @Schema(description = "认证过期时间", example = "1900-01-01T00:00:00.000Z")
+ val credentialsExpiration: LocalDateTime?,
+
+ @Schema(description = "是否启用", example = "true")
+ val enable: Boolean?,
+
+ @Schema(description = "最后登录时间", example = "1900-01-01T00:00:00.000Z")
+ val lastLoginTime: LocalDateTime?,
+
+ @Schema(description = "最后登录 IP", example = "1.1.1.1")
+ val lastLoginIp: String?,
+
+ @Schema(description = "创建时间", example = "1900-01-01T00:00:00.000Z")
+ val createTime: LocalDateTime?,
+
+ @Schema(description = "修改时间", example = "1900-01-01T00:00:00.000Z")
+ val updateTime: LocalDateTime?,
+
+ @Schema(description = "菜单列表")
+ val menus: List