Fix login bug
This commit is contained in:
@@ -2,10 +2,7 @@ package top.fatweb.api.converter
|
||||
|
||||
import top.fatweb.api.entity.permission.User
|
||||
import top.fatweb.api.param.authentication.LoginParam
|
||||
import top.fatweb.api.vo.authentication.ElementVo
|
||||
import top.fatweb.api.vo.authentication.MenuVo
|
||||
import top.fatweb.api.vo.authentication.OperationVo
|
||||
import top.fatweb.api.vo.authentication.UserInfoVo
|
||||
import top.fatweb.api.vo.authentication.*
|
||||
|
||||
object UserConverter {
|
||||
fun loginParamToUser(loginParam: LoginParam): User {
|
||||
@@ -30,6 +27,13 @@ object UserConverter {
|
||||
lastLoginIp = user.lastLoginIp,
|
||||
createTime = user.createTime,
|
||||
updateTime = user.updateTime,
|
||||
modules = user.modules?.map {
|
||||
ModuleVo(
|
||||
id = it.id,
|
||||
name = it.name,
|
||||
powerId = it.powerId
|
||||
)
|
||||
},
|
||||
menus = user.menus?.map {
|
||||
MenuVo(
|
||||
id = it.id,
|
||||
|
||||
@@ -110,6 +110,9 @@ class User() : Serializable {
|
||||
@TableField(exist = false)
|
||||
var groups: List<Group>? = null
|
||||
|
||||
@TableField(exist = false)
|
||||
var modules: List<Module>? = null
|
||||
|
||||
@TableField(exist = false)
|
||||
var menus: List<Menu>? = null
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class AuthenticationServiceImpl(
|
||||
val redisKey = "${SecurityConstants.jwtIssuer}_login:" + jwt
|
||||
redisUtil.setObject(redisKey, loginUser, SecurityConstants.redisTtl, SecurityConstants.redisTtlUnit)
|
||||
|
||||
return LoginVo(jwt, loginUser.user.lastLoginTime, loginUser.user.lastLoginIp)
|
||||
return LoginVo(jwt, loginUser.user.currentLoginTime, loginUser.user.currentLoginIp)
|
||||
}
|
||||
|
||||
override fun logout(token: String): Boolean = redisUtil.delObject("${SecurityConstants.jwtIssuer}_login:" + token)
|
||||
|
||||
@@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
|
||||
import org.springframework.stereotype.Service
|
||||
import top.fatweb.api.entity.permission.User
|
||||
import top.fatweb.api.mapper.permission.UserMapper
|
||||
import top.fatweb.api.service.permission.IElementService
|
||||
import top.fatweb.api.service.permission.IMenuService
|
||||
import top.fatweb.api.service.permission.IOperationService
|
||||
import top.fatweb.api.service.permission.IUserService
|
||||
import top.fatweb.api.service.permission.*
|
||||
import top.fatweb.api.util.WebUtil
|
||||
|
||||
/**
|
||||
@@ -20,6 +17,7 @@ import top.fatweb.api.util.WebUtil
|
||||
*/
|
||||
@Service
|
||||
class UserServiceImpl(
|
||||
private val moduleService: IModuleService,
|
||||
private val menuService: IMenuService,
|
||||
private val elementService: IElementService,
|
||||
private val operationService: IOperationService
|
||||
@@ -29,6 +27,7 @@ class UserServiceImpl(
|
||||
user ?: let { return null }
|
||||
|
||||
if (user.id == 0L) {
|
||||
user.modules = moduleService.list()
|
||||
user.menus = menuService.list()
|
||||
user.elements = elementService.list()
|
||||
user.operations = operationService.list()
|
||||
|
||||
14
src/main/kotlin/top/fatweb/api/vo/authentication/ModuleVo.kt
Normal file
14
src/main/kotlin/top/fatweb/api/vo/authentication/ModuleVo.kt
Normal file
@@ -0,0 +1,14 @@
|
||||
package top.fatweb.api.vo.authentication
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
@Schema(description = "模块返回参数")
|
||||
data class ModuleVo(
|
||||
val id: Long?,
|
||||
|
||||
@Schema(description = "模块名", example = "系统")
|
||||
val name: String?,
|
||||
|
||||
@Schema(description = "权限 ID")
|
||||
val powerId: Long?
|
||||
)
|
||||
@@ -40,6 +40,9 @@ data class UserInfoVo(
|
||||
@Schema(description = "修改时间", example = "1900-01-01T00:00:00.000Z")
|
||||
val updateTime: LocalDateTime?,
|
||||
|
||||
@Schema(description = "模块列表")
|
||||
val modules: List<ModuleVo>?,
|
||||
|
||||
@Schema(description = "菜单列表")
|
||||
val menus: List<MenuVo>?,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user