mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
add update_5.1.0-5.1.1.sql ;
update 更新 SysLoginService#buildLoginUser 不作 client 传参(后续优化) ; update 更新字段名称 client -> clientKey ; update 优化 SysLogininforServiceImpl 名称以及魔法值 ;
This commit is contained in:
parent
db6e868e30
commit
849803e888
@ -133,7 +133,7 @@ public class SysLoginService {
|
|||||||
/**
|
/**
|
||||||
* 构建登录用户
|
* 构建登录用户
|
||||||
*/
|
*/
|
||||||
public LoginUser buildLoginUser(SysUserVo user, String client, String deviceType) {
|
public LoginUser buildLoginUser(SysUserVo user) {
|
||||||
LoginUser loginUser = new LoginUser();
|
LoginUser loginUser = new LoginUser();
|
||||||
loginUser.setTenantId(user.getTenantId());
|
loginUser.setTenantId(user.getTenantId());
|
||||||
loginUser.setUserId(user.getUserId());
|
loginUser.setUserId(user.getUserId());
|
||||||
@ -141,8 +141,6 @@ public class SysLoginService {
|
|||||||
loginUser.setUsername(user.getUserName());
|
loginUser.setUsername(user.getUserName());
|
||||||
loginUser.setNickname(user.getNickName());
|
loginUser.setNickname(user.getNickName());
|
||||||
loginUser.setUserType(user.getUserType());
|
loginUser.setUserType(user.getUserType());
|
||||||
loginUser.setClient(client);
|
|
||||||
loginUser.setDeviceType(deviceType);
|
|
||||||
loginUser.setMenuPermission(permissionService.getMenuPermission(user.getUserId()));
|
loginUser.setMenuPermission(permissionService.getMenuPermission(user.getUserId()));
|
||||||
loginUser.setRolePermission(permissionService.getRolePermission(user.getUserId()));
|
loginUser.setRolePermission(permissionService.getRolePermission(user.getUserId()));
|
||||||
loginUser.setDeptName(ObjectUtil.isNull(user.getDept()) ? "" : user.getDept().getDeptName());
|
loginUser.setDeptName(ObjectUtil.isNull(user.getDept()) ? "" : user.getDept().getDeptName());
|
||||||
|
|||||||
@ -60,7 +60,9 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
|||||||
|
|
||||||
loginService.checkLogin(LoginType.EMAIL, tenantId, user.getUserName(), userType, () -> !validateEmailCode(tenantId, email, emailCode, userType));
|
loginService.checkLogin(LoginType.EMAIL, tenantId, user.getUserName(), userType, () -> !validateEmailCode(tenantId, email, emailCode, userType));
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user, client.getClientKey(), client.getDeviceType());
|
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||||
|
loginUser.setClientKey(client.getClientKey());
|
||||||
|
loginUser.setDeviceType(client.getDeviceType());
|
||||||
SaLoginModel model = new SaLoginModel();
|
SaLoginModel model = new SaLoginModel();
|
||||||
model.setDevice(client.getDeviceType());
|
model.setDevice(client.getDeviceType());
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||||
|
|||||||
@ -71,7 +71,9 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
|||||||
|
|
||||||
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, userType, () -> !BCrypt.checkpw(password, user.getPassword()));
|
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, userType, () -> !BCrypt.checkpw(password, user.getPassword()));
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user, client.getClientKey(), client.getDeviceType());
|
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||||
|
loginUser.setClientKey(client.getClientKey());
|
||||||
|
loginUser.setDeviceType(client.getDeviceType());
|
||||||
SaLoginModel model = new SaLoginModel();
|
SaLoginModel model = new SaLoginModel();
|
||||||
model.setDevice(client.getDeviceType());
|
model.setDevice(client.getDeviceType());
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||||
|
|||||||
@ -60,7 +60,9 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
|||||||
|
|
||||||
loginService.checkLogin(LoginType.SMS, tenantId, user.getUserName(), userType, () -> !validateSmsCode(tenantId, phonenumber, smsCode, userType));
|
loginService.checkLogin(LoginType.SMS, tenantId, user.getUserName(), userType, () -> !validateSmsCode(tenantId, phonenumber, smsCode, userType));
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user, client.getClientKey(), client.getDeviceType());
|
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||||
|
loginUser.setClientKey(client.getClientKey());
|
||||||
|
loginUser.setDeviceType(client.getDeviceType());
|
||||||
SaLoginModel model = new SaLoginModel();
|
SaLoginModel model = new SaLoginModel();
|
||||||
model.setDevice(client.getDeviceType());
|
model.setDevice(client.getDeviceType());
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||||
|
|||||||
@ -96,7 +96,9 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
|||||||
SysUserVo user = loadUser(tenantId, social.getUserId());
|
SysUserVo user = loadUser(tenantId, social.getUserId());
|
||||||
|
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user, client.getClientKey(), client.getDeviceType());
|
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||||
|
loginUser.setClientKey(client.getClientKey());
|
||||||
|
loginUser.setDeviceType(client.getDeviceType());
|
||||||
SaLoginModel model = new SaLoginModel();
|
SaLoginModel model = new SaLoginModel();
|
||||||
model.setDevice(client.getDeviceType());
|
model.setDevice(client.getDeviceType());
|
||||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||||
|
|||||||
@ -54,6 +54,8 @@ public class XcxAuthStrategy implements IAuthStrategy {
|
|||||||
loginUser.setUsername(user.getUserName());
|
loginUser.setUsername(user.getUserName());
|
||||||
loginUser.setNickname(user.getNickName());
|
loginUser.setNickname(user.getNickName());
|
||||||
loginUser.setUserType(user.getUserType());
|
loginUser.setUserType(user.getUserType());
|
||||||
|
loginUser.setClientKey(client.getClientKey());
|
||||||
|
loginUser.setDeviceType(client.getDeviceType());
|
||||||
loginUser.setOpenid(openid);
|
loginUser.setOpenid(openid);
|
||||||
|
|
||||||
SaLoginModel model = new SaLoginModel();
|
SaLoginModel model = new SaLoginModel();
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class UserOnlineDTO implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 客户端
|
* 客户端
|
||||||
*/
|
*/
|
||||||
private String client;
|
private String clientKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型
|
* 设备类型
|
||||||
|
|||||||
@ -115,7 +115,7 @@ public class LoginUser implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 客户端
|
* 客户端
|
||||||
*/
|
*/
|
||||||
private String client;
|
private String clientKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型
|
* 设备类型
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class UserActionListener implements SaTokenListener {
|
|||||||
dto.setTokenId(tokenValue);
|
dto.setTokenId(tokenValue);
|
||||||
dto.setUserName(user.getUsername());
|
dto.setUserName(user.getUsername());
|
||||||
dto.setUserType(user.getUserType());
|
dto.setUserType(user.getUserType());
|
||||||
dto.setClient(user.getClient());
|
dto.setClientKey(user.getClientKey());
|
||||||
dto.setDeviceType(user.getDeviceType());
|
dto.setDeviceType(user.getDeviceType());
|
||||||
dto.setDeptName(user.getDeptName());
|
dto.setDeptName(user.getDeptName());
|
||||||
if(tokenConfig.getTimeout() == -1) {
|
if(tokenConfig.getTimeout() == -1) {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public class SysLogininfor implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 客户端
|
* 客户端
|
||||||
*/
|
*/
|
||||||
private String client;
|
private String clientKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型
|
* 设备类型
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class SysUserOnline {
|
|||||||
/**
|
/**
|
||||||
* 客户端
|
* 客户端
|
||||||
*/
|
*/
|
||||||
private String client;
|
private String clientKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型
|
* 设备类型
|
||||||
|
|||||||
@ -41,7 +41,7 @@ public class SysLogininforBo {
|
|||||||
/**
|
/**
|
||||||
* 客户端
|
* 客户端
|
||||||
*/
|
*/
|
||||||
private String client;
|
private String clientKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型
|
* 设备类型
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class SysLogininforVo implements Serializable {
|
|||||||
* 客户端
|
* 客户端
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "客户端")
|
@ExcelProperty(value = "客户端")
|
||||||
private String client;
|
private String clientKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型
|
* 设备类型
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|||||||
import org.dromara.common.core.utils.ServletUtils;
|
import org.dromara.common.core.utils.ServletUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.core.utils.ip.AddressUtils;
|
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.SysClient;
|
||||||
import org.dromara.system.domain.SysLogininfor;
|
import org.dromara.system.domain.SysLogininfor;
|
||||||
import org.dromara.system.domain.bo.SysLogininforBo;
|
import org.dromara.system.domain.bo.SysLogininforBo;
|
||||||
@ -45,7 +46,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
|||||||
|
|
||||||
private final SysLogininforMapper baseMapper;
|
private final SysLogininforMapper baseMapper;
|
||||||
|
|
||||||
private final ISysClientService iSysClientService;
|
private final ISysClientService clientService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录登录信息
|
* 记录登录信息
|
||||||
@ -59,10 +60,10 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
|||||||
final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));
|
final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));
|
||||||
final String ip = ServletUtils.getClientIP(request);
|
final String ip = ServletUtils.getClientIP(request);
|
||||||
// 客户端信息
|
// 客户端信息
|
||||||
String clientid = request.getHeader("Clientid");
|
String clientid = request.getHeader(LoginHelper.CLIENT_KEY);
|
||||||
SysClient client = null;
|
SysClient client = null;
|
||||||
if (StringUtils.isNotBlank(clientid)) {
|
if (StringUtils.isNotBlank(clientid)) {
|
||||||
client = iSysClientService.queryByClientId(clientid);
|
client = clientService.queryByClientId(clientid);
|
||||||
}
|
}
|
||||||
|
|
||||||
String address = AddressUtils.getRealAddressByIP(ip);
|
String address = AddressUtils.getRealAddressByIP(ip);
|
||||||
@ -84,7 +85,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
|||||||
logininfor.setUserName(logininforEvent.getUsername());
|
logininfor.setUserName(logininforEvent.getUsername());
|
||||||
logininfor.setUserType(logininforEvent.getUserType());
|
logininfor.setUserType(logininforEvent.getUserType());
|
||||||
if (ObjectUtil.isNotNull(client)) {
|
if (ObjectUtil.isNotNull(client)) {
|
||||||
logininfor.setClient(client.getClientKey());
|
logininfor.setClientKey(client.getClientKey());
|
||||||
logininfor.setDeviceType(client.getDeviceType());
|
logininfor.setDeviceType(client.getDeviceType());
|
||||||
}
|
}
|
||||||
logininfor.setIpaddr(ip);
|
logininfor.setIpaddr(ip);
|
||||||
|
|||||||
@ -99,8 +99,3 @@ insert into sys_role_menu values ('2', '1065');
|
|||||||
|
|
||||||
update sys_dept set leader = null;
|
update sys_dept set leader = null;
|
||||||
alter table sys_dept modify column leader bigint null default null comment '负责人' after order_num;
|
alter table sys_dept modify column leader bigint null default null comment '负责人' after order_num;
|
||||||
|
|
||||||
ALTER TABLE sys_logininfor
|
|
||||||
ADD COLUMN user_type VARCHAR(10) NULL DEFAULT 'sys_user' COMMENT '用户类型(sys_user系统用户)' AFTER `user_name`,
|
|
||||||
ADD COLUMN client VARCHAR(32) NULL DEFAULT NULL COMMENT '客户端' AFTER `user_type`,
|
|
||||||
ADD COLUMN device_type VARCHAR(32) NULL DEFAULT NULL COMMENT '设备类型' AFTER `client`;
|
|
||||||
|
|||||||
4
script/sql/update/update_5.1.0-5.1.1.sql
Normal file
4
script/sql/update/update_5.1.0-5.1.1.sql
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE sys_logininfor
|
||||||
|
ADD COLUMN user_type VARCHAR(10) NULL DEFAULT 'sys_user' COMMENT '用户类型(sys_user系统用户)' AFTER `user_name`,
|
||||||
|
ADD COLUMN client_key VARCHAR(32) NULL DEFAULT NULL COMMENT '客户端' AFTER `user_type`,
|
||||||
|
ADD COLUMN device_type VARCHAR(32) NULL DEFAULT NULL COMMENT '设备类型' AFTER `client_key`;
|
||||||
Loading…
Reference in New Issue
Block a user