提取通用方法到基类控制器
This commit is contained in:
@ -14,6 +14,36 @@ import com.ruoyi.common.exception.CustomException;
|
||||
*/
|
||||
public class SecurityUtils
|
||||
{
|
||||
/**
|
||||
* 用户ID
|
||||
**/
|
||||
public static Long getUserId()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getLoginUser().getUserId();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new CustomException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门ID
|
||||
**/
|
||||
public static Long getDeptId()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getLoginUser().getDeptId();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new CustomException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户账户
|
||||
**/
|
||||
|
Reference in New Issue
Block a user