| | |
| | | import com.ruoyi.framework.manager.AsyncManager; |
| | | import com.ruoyi.framework.manager.factory.AsyncFactory; |
| | | import com.ruoyi.framework.security.context.AuthenticationContextHolder; |
| | | import com.ruoyi.system.model.TSysAppUser; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.TSysAppUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private ISysConfigService configService; |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | @Autowired |
| | | private TSysAppUserService sysAppUserService; |
| | | |
| | | /** |
| | | * 登录验证 |
| | |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null"))); |
| | | throw new UserNotExistsException(); |
| | | } |
| | | // 用户验证 |
| | | // TTenant user = tenantService.getOne(Wrappers.<TTenant>lambdaQuery().eq(TTenant::getAccount,username)); |
| | | // if (StringUtils.isNull(user)){ |
| | | // log.info("登录用户:{} 不存在.", username); |
| | | // throw new ServiceException(MessageUtils.message("user.not.exists")); |
| | | // } else if (user.getDisabled()) { |
| | | // log.info("登录用户:{} 已被删除.", username); |
| | | // throw new ServiceException(MessageUtils.message("user.password.delete")); |
| | | // } |
| | | // 校验验证码 |
| | | // Object cacheObject = redisCache.getCacheObject(user.getAccount()); |
| | | // if(!code.equals(String.valueOf(cacheObject))){ |
| | | // log.info("登录用户:{} 短信验证码错误{}", username,code); |
| | | // throw new ServiceException("短信验证码错误"); |
| | | // } |
| | | // AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); |
| | | // TTenantResp tTenantResp = new TTenantResp(); |
| | | // BeanUtils.copyProperties(user,tTenantResp); |
| | | // LoginUserApplet loginUser = new LoginUserApplet(user.getId(), null, tTenantResp, null); |
| | | Object cacheObject = redisCache.getCacheObject(username); |
| | | if(!code.equals(String.valueOf(cacheObject))){ |
| | | log.info("登录用户:{} 短信验证码错误{}", username,code); |
| | | throw new ServiceException("短信验证码错误"); |
| | | } |
| | | // 用户验证 |
| | | TSysAppUser sysAppUser = sysAppUserService.getOne(Wrappers.<TSysAppUser>lambdaQuery().eq(TSysAppUser::getPhone,username)); |
| | | if (StringUtils.isNull(sysAppUser)){ |
| | | sysAppUser = new TSysAppUser(); |
| | | sysAppUser.setPhone(username); |
| | | sysAppUser.setNickName(username.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2")); |
| | | sysAppUserService.save(sysAppUser); |
| | | } |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); |
| | | TSysUserResp user = new TSysUserResp(); |
| | | BeanUtils.copyProperties(sysAppUser,user); |
| | | LoginUserApplet loginUser = new LoginUserApplet(user.getId(), null, user, null); |
| | | // 生成token |
| | | return new LoginUserApplet(); |
| | | return loginUser; |
| | | } |
| | | |
| | | |