|
|
@ -10,6 +10,7 @@ import com.ruoyi.common.core.domain.R;
|
|
|
|
import com.ruoyi.common.core.enums.UserStatus;
|
|
|
|
import com.ruoyi.common.core.enums.UserStatus;
|
|
|
|
import com.ruoyi.common.core.exception.ServiceException;
|
|
|
|
import com.ruoyi.common.core.exception.ServiceException;
|
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.utils.DateUtils;
|
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.core.utils.ip.IpUtils;
|
|
|
|
import com.ruoyi.common.core.utils.ip.IpUtils;
|
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
@ -98,9 +99,26 @@ public class SysLoginService
|
|
|
|
}
|
|
|
|
}
|
|
|
|
passwordService.validate(user, password);
|
|
|
|
passwordService.validate(user, password);
|
|
|
|
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
|
|
|
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
|
|
|
|
|
|
|
recordLoginInfo(user.getUserId());
|
|
|
|
return userInfo;
|
|
|
|
return userInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 记录登录信息
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param userId 用户ID
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void recordLoginInfo(Long userId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
SysUser sysUser = new SysUser();
|
|
|
|
|
|
|
|
sysUser.setUserId(userId);
|
|
|
|
|
|
|
|
// 更新用户登录IP
|
|
|
|
|
|
|
|
sysUser.setLoginIp(IpUtils.getIpAddr());
|
|
|
|
|
|
|
|
// 更新用户登录时间
|
|
|
|
|
|
|
|
sysUser.setLoginDate(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
remoteUserService.recordUserLogin(sysUser, SecurityConstants.INNER);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void logout(String loginName)
|
|
|
|
public void logout(String loginName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
|
|
|
recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
|
|
|