| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import com.ruoyi.common.core.domain.model.LoginUserApplet; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | |
| | | throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | /** |
| | | * 获取用户账户小程序 |
| | | **/ |
| | | public static String getUsernameApplet() |
| | | { |
| | | try |
| | | { |
| | | return getLoginUserApplet().getUsername(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取用户 |
| | |
| | | throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | public static LoginUserApplet getLoginUserApplet() |
| | | { |
| | | try |
| | | { |
| | | return (LoginUserApplet) getAuthentication().getPrincipal(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取Authentication |