update 去除登录警告

feature/model
疯狂的狮子li 3 years ago
parent 2006e5e51e
commit aaf9f57459

@ -27,8 +27,10 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
this.setFieldValByName("createTime", new Date(), metaObject);
}
if (metaObject.hasGetter("createBy")) {
if (metaObject.getValue("createBy") == null) {
this.setFieldValByName("createBy", getLoginUsername(), metaObject);
}
}
} catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
}
@ -39,8 +41,10 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
public void updateFill(MetaObject metaObject) {
try {
if (metaObject.hasGetter("updateBy")) {
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…
Cancel
Save