| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | |
| | | return tokenService.createToken(loginUser); |
| | | } |
| | | |
| | | |
| | | public String loginByUserName(String userName) { |
| | | SysUser sysUser = userService.selectUserByUserName2(userName); |
| | | if (ObjectUtils.isNotEmpty(sysUser)) { |
| | | // 构建登录用户对象 |
| | | LoginUser loginUser = new LoginUser(); |
| | | loginUser.setUser(sysUser); |
| | | loginUser.setUserId(sysUser.getUserId()); |
| | | // 创建 token |
| | | String token = tokenService.createToken(loginUser); |
| | | // 生成token |
| | | return token; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 校验验证码 |
| | | * |