mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
@ -37,6 +37,16 @@ public class SysLogininfor implements Serializable {
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
*/
|
||||
private String clientKey;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 登录状态 0成功 1失败
|
||||
*/
|
||||
|
@ -26,6 +26,16 @@ public class SysUserOnline {
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
*/
|
||||
private String clientKey;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
|
@ -33,6 +33,16 @@ public class SysLogininforBo {
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
*/
|
||||
private String clientKey;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
|
@ -45,6 +45,19 @@ public class SysLogininforVo implements Serializable {
|
||||
@ExcelProperty(value = "用户账号")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
*/
|
||||
@ExcelProperty(value = "客户端")
|
||||
private String clientKey;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
@ExcelProperty(value = "设备类型", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_device_type")
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 登录状态(0成功 1失败)
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.dromara.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -12,10 +13,14 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.core.utils.ServletUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.ip.AddressUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.domain.SysClient;
|
||||
import org.dromara.system.domain.SysLogininfor;
|
||||
import org.dromara.system.domain.bo.SysLogininforBo;
|
||||
import org.dromara.system.domain.vo.SysLogininforVo;
|
||||
import org.dromara.system.mapper.SysClientMapper;
|
||||
import org.dromara.system.mapper.SysLogininforMapper;
|
||||
import org.dromara.system.service.ISysClientService;
|
||||
import org.dromara.system.service.ISysLogininforService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -41,6 +46,8 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
||||
|
||||
private final SysLogininforMapper baseMapper;
|
||||
|
||||
private final ISysClientService clientService;
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
@ -52,6 +59,12 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
||||
HttpServletRequest request = logininforEvent.getRequest();
|
||||
final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));
|
||||
final String ip = ServletUtils.getClientIP(request);
|
||||
// 客户端信息
|
||||
String clientid = request.getHeader(LoginHelper.CLIENT_KEY);
|
||||
SysClient client = null;
|
||||
if (StringUtils.isNotBlank(clientid)) {
|
||||
client = clientService.queryByClientId(clientid);
|
||||
}
|
||||
|
||||
String address = AddressUtils.getRealAddressByIP(ip);
|
||||
StringBuilder s = new StringBuilder();
|
||||
@ -70,6 +83,10 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
||||
SysLogininforBo logininfor = new SysLogininforBo();
|
||||
logininfor.setTenantId(logininforEvent.getTenantId());
|
||||
logininfor.setUserName(logininforEvent.getUsername());
|
||||
if (ObjectUtil.isNotNull(client)) {
|
||||
logininfor.setClientKey(client.getClientKey());
|
||||
logininfor.setDeviceType(client.getDeviceType());
|
||||
}
|
||||
logininfor.setIpaddr(ip);
|
||||
logininfor.setLoginLocation(address);
|
||||
logininfor.setBrowser(browser);
|
||||
|
Reference in New Issue
Block a user