| | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.entity.TAppUserResp; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUserApplet; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.TAppUserService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | |
| | | throw new UserNotExistsException(); |
| | | } |
| | | // 用户验证 |
| | | TAppUser user = tAppUserService.getOne(Wrappers.<TAppUser>lambdaQuery().eq(TAppUser::getPhone,username)); |
| | | TAppUser user = tAppUserService.getOne(Wrappers.<TAppUser>lambdaQuery().eq(TAppUser::getPhone,username).ne(TAppUser::getStatus,3)); |
| | | if (StringUtils.isNull(user)){ |
| | | log.info("登录用户:{} 不存在.", username); |
| | | throw new ServiceException(MessageUtils.message("user.not.exists")); |
| | | } else if (user.getStatus().equals(3)) { |
| | | log.info("登录用户:{} 已被删除.", username); |
| | | throw new ServiceException(MessageUtils.message("user.password.delete")); |
| | | log.info("登录用户:{} 不存在.创建一个新用户", username); |
| | | user = new TAppUser(); |
| | | user.setPhone(username); |
| | | user.setStatus(1); |
| | | tAppUserService.save(user); |
| | | // throw new ServiceException(MessageUtils.message("user.not.exists")); |
| | | } else { |
| | | if (user.getStatus().equals(2)) { |
| | | log.info("登录用户:{} 已被停用.", username); |
| | | throw new ServiceException(MessageUtils.message("user.blocked")); |
| | | } |
| | | } |
| | | if ("test".equals(env) || "dev".equals(env)) { |
| | | if (!code.equals("111111")) { |
| | |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); |
| | | LoginUserApplet loginUser = new LoginUserApplet(user.getId(), null, null, null); |
| | | recordAppLoginInfo(loginUser.getUserId().toString()); |
| | | TAppUserResp sysUserResp = new TAppUserResp(); |
| | | BeanUtils.copyProperties(user, sysUserResp); |
| | | loginUser.setUser(sysUserResp); |
| | | // 生成token |
| | | return loginUser; |
| | | } |