mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-19 21:45:06 +08:00
增加 get-info 接口的相关方法
This commit is contained in:
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.dashboard.framework.redis.core;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* Redis Key 定义类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class RedisKeyDefine {
|
||||
|
||||
public enum KeyTypeEnum {
|
||||
|
||||
STRING,
|
||||
LIST,
|
||||
HASH,
|
||||
SET,
|
||||
ZSET,
|
||||
STREAM,
|
||||
PUBSUB;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 过期时间 - 永不过期
|
||||
*/
|
||||
public static final Duration TIMEOUT_FOREVER = null;
|
||||
|
||||
/**
|
||||
* 过期时间 - 动态,通过参数传入
|
||||
*/
|
||||
public static final Duration TIMEOUT_DYNAMIC = null;
|
||||
|
||||
/**
|
||||
* Key 模板
|
||||
*/
|
||||
private final String keyTemplate;
|
||||
/**
|
||||
* Key 类型的枚举
|
||||
*/
|
||||
private final KeyTypeEnum keyType;
|
||||
/**
|
||||
* Value 类型
|
||||
*
|
||||
* 如果是使用分布式锁,设置为 {@link java.util.concurrent.locks.Lock} 类型
|
||||
*/
|
||||
private final Class<?> valueType;
|
||||
/**
|
||||
* 过期时间
|
||||
*
|
||||
* 为空时,表示永不过期 {@link #TIMEOUT_FOREVER}
|
||||
*/
|
||||
private final Duration timeout;
|
||||
|
||||
public RedisKeyDefine(String keyTemplate, KeyTypeEnum keyType, Class<?> valueType, Duration timeout) {
|
||||
this.keyTemplate = keyTemplate;
|
||||
this.keyType = keyType;
|
||||
this.valueType = valueType;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,6 @@ package cn.iocoder.dashboard.framework.security.core;
|
||||
import cn.iocoder.dashboard.modules.system.enums.user.UserStatus;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
@ -23,10 +22,14 @@ public class LoginUser implements UserDetails {
|
||||
* 用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 科室编号
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 角色编号数组
|
||||
*/
|
||||
private Set<Integer> roleIds;
|
||||
private Set<Long> roleIds;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@ import org.springframework.security.web.authentication.WebAuthenticationDetailsS
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 安全服务工具类
|
||||
@ -15,6 +16,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
*/
|
||||
public class SecurityUtils {
|
||||
|
||||
private SecurityUtils() {}
|
||||
|
||||
/**
|
||||
* 从请求中,获得认证 Token
|
||||
*
|
||||
@ -41,6 +44,19 @@ public class SecurityUtils {
|
||||
return (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得当前用户的编号
|
||||
*
|
||||
* @return 用户编号
|
||||
*/
|
||||
public static Long getLoginUserId() {
|
||||
return getLoginUser().getUserId();
|
||||
}
|
||||
|
||||
public static Set<Long> getLoginUserRoleIds() {
|
||||
return getLoginUser().getRoleIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前用户
|
||||
*
|
||||
|
Reference in New Issue
Block a user