update 去除登录警告
This commit is contained in:
parent
2006e5e51e
commit
aaf9f57459
@ -27,7 +27,9 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
||||
this.setFieldValByName("createTime", new Date(), metaObject);
|
||||
}
|
||||
if (metaObject.hasGetter("createBy")) {
|
||||
this.setFieldValByName("createBy", getLoginUsername(), metaObject);
|
||||
if (metaObject.getValue("createBy") == null) {
|
||||
this.setFieldValByName("createBy", getLoginUsername(), metaObject);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
||||
@ -39,7 +41,9 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
try {
|
||||
if (metaObject.hasGetter("updateBy")) {
|
||||
this.setFieldValByName("updateBy", getLoginUsername(), metaObject);
|
||||
if (metaObject.getValue("updateBy") == null) {
|
||||
this.setFieldValByName("updateBy", getLoginUsername(), metaObject);
|
||||
}
|
||||
}
|
||||
if (metaObject.hasGetter("updateTime")) {
|
||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||
|
@ -78,7 +78,7 @@ public class SysLoginService {
|
||||
}
|
||||
asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request);
|
||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||
recordLoginInfo(loginUser.getUserId());
|
||||
recordLoginInfo(loginUser.getUserId(), username);
|
||||
// 生成token
|
||||
return tokenService.createToken(loginUser);
|
||||
}
|
||||
@ -110,11 +110,12 @@ public class SysLoginService {
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
public void recordLoginInfo(Long userId) {
|
||||
public void recordLoginInfo(Long userId, String username) {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserId(userId);
|
||||
sysUser.setLoginIp(ServletUtils.getClientIP());
|
||||
sysUser.setLoginDate(DateUtils.getNowDate());
|
||||
sysUser.setUpdateBy(username);
|
||||
userService.updateUserProfile(sysUser);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user