diff --git a/src/main/kotlin/top/fatweb/api/converter/UserConverter.kt b/src/main/kotlin/top/fatweb/api/converter/UserConverter.kt index 0703449..d481e0f 100644 --- a/src/main/kotlin/top/fatweb/api/converter/UserConverter.kt +++ b/src/main/kotlin/top/fatweb/api/converter/UserConverter.kt @@ -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, diff --git a/src/main/kotlin/top/fatweb/api/entity/permission/User.kt b/src/main/kotlin/top/fatweb/api/entity/permission/User.kt index 62fa0be..a3d1fdc 100644 --- a/src/main/kotlin/top/fatweb/api/entity/permission/User.kt +++ b/src/main/kotlin/top/fatweb/api/entity/permission/User.kt @@ -110,6 +110,9 @@ class User() : Serializable { @TableField(exist = false) var groups: List? = null + @TableField(exist = false) + var modules: List? = null + @TableField(exist = false) var menus: List? = null diff --git a/src/main/kotlin/top/fatweb/api/service/permission/impl/AuthenticationServiceImpl.kt b/src/main/kotlin/top/fatweb/api/service/permission/impl/AuthenticationServiceImpl.kt index 7147327..1207262 100644 --- a/src/main/kotlin/top/fatweb/api/service/permission/impl/AuthenticationServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/api/service/permission/impl/AuthenticationServiceImpl.kt @@ -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) 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 914e421..c78179a 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 @@ -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() diff --git a/src/main/kotlin/top/fatweb/api/vo/authentication/ModuleVo.kt b/src/main/kotlin/top/fatweb/api/vo/authentication/ModuleVo.kt new file mode 100644 index 0000000..2496629 --- /dev/null +++ b/src/main/kotlin/top/fatweb/api/vo/authentication/ModuleVo.kt @@ -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? +) diff --git a/src/main/kotlin/top/fatweb/api/vo/authentication/UserInfoVo.kt b/src/main/kotlin/top/fatweb/api/vo/authentication/UserInfoVo.kt index 29f047b..e6c059d 100644 --- a/src/main/kotlin/top/fatweb/api/vo/authentication/UserInfoVo.kt +++ b/src/main/kotlin/top/fatweb/api/vo/authentication/UserInfoVo.kt @@ -40,6 +40,9 @@ data class UserInfoVo( @Schema(description = "修改时间", example = "1900-01-01T00:00:00.000Z") val updateTime: LocalDateTime?, + @Schema(description = "模块列表") + val modules: List?, + @Schema(description = "菜单列表") val menus: List?, diff --git a/src/main/resources/mapper/permission/UserMapper.xml b/src/main/resources/mapper/permission/UserMapper.xml index 4fb3f41..e058d98 100644 --- a/src/main/resources/mapper/permission/UserMapper.xml +++ b/src/main/resources/mapper/permission/UserMapper.xml @@ -17,6 +17,9 @@ t_user.update_time as user_update_time, t_user.deleted as user_deleted, t_user.version as user_version, + tmo.id as module_id, + tmo.name as module_name, + tmo.power_id as module_power_id, tm.id as menu_id, tm.name as menu_name, tm.url as menu_url, @@ -31,8 +34,7 @@ t.name as operation_name, t.code as operation_code, t.power_id as operation_power_id, - t.element_id as operation_element_id, - t.parent_id as operation_parent_id + t.element_id as operation_element_id from t_user left join (select * from t_user_group where deleted = 0) as tug on t_user.id = tug.user_id left join (select * from t_group where deleted = 0 and enable = 1) as tg on tg.id = tug.group_id @@ -42,6 +44,7 @@ on tr.id = trg.role_id or tr.id = tur.role_id left join (select * from t_power_role where deleted = 0) as tpr on tr.id = tpr.role_id left join t_power as tp on tp.id = tpr.power_id + left join t_module as tmo on tp.id = tmo.power_id left join t_menu as tm on tp.id = tm.power_id left join t_element as te on tp.id = te.power_id left join t_operation as t on tp.id = t.power_id @@ -68,12 +71,18 @@ + + + + + + @@ -88,7 +97,6 @@ -