@@ -150,7 +150,9 @@ public class SysAdmin extends Entity { | |||
* 上次登录时间 | |||
*/ | |||
@TableField("last_time") | |||
private Integer lastTime; | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
private Date lastTime; | |||
/** |
@@ -84,6 +84,11 @@ public class SysAdminServiceImpl extends BaseServiceImpl<SysAdminMapper, SysAdmi | |||
QueryWrapper wrapper = new QueryWrapper(); | |||
wrapper.eq("username", username); | |||
wrapper.eq("mark", 1); | |||
try { | |||
SysAdmin admin = sysAdminMapper.selectOne(wrapper); | |||
} catch (Exception e) { | |||
System.out.println(e.getMessage()); | |||
} | |||
SysAdmin admin = sysAdminMapper.selectOne(wrapper); | |||
if (admin != null && !"".equals(admin.getAvatar())) { | |||
admin.setAvatar(imageUrl + admin.getAvatar()); | |||
@@ -134,6 +139,11 @@ public class SysAdminServiceImpl extends BaseServiceImpl<SysAdminMapper, SysAdmi | |||
.token(currentUser.getSession().getId().toString()) | |||
.build(); | |||
BeanUtils.copyProperties(user, cacheUser); | |||
// 更新最近登录时间 | |||
user.setLastTime(DateUtil.now()); | |||
sysAdminMapper.updateById(user); | |||
} catch (UnknownAccountException e) { | |||
log.error("账户不存在异常:", e); | |||
return response.failure("账号不存在!"); |
@@ -3,6 +3,7 @@ package com.taauav.front.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.common.util.DateUtil; | |||
import com.taauav.common.util.FunctionUtils; | |||
import com.taauav.common.util.JwtUtil; | |||
import com.taauav.common.util.StringUtils; | |||
@@ -65,6 +66,11 @@ public class LSLoginServiceImpl extends ServiceImpl<LsAdminMapper, LsAdmin> impl | |||
if (adminInfo.getStatus() != 1) { | |||
return response.failure("您已被禁用,请联系管理员"); | |||
} | |||
// 更新登录时间 | |||
adminInfo.setLastTime(DateUtil.now()); | |||
adminMapper.updateById(adminInfo); | |||
// 生成token给前端 | |||
String token = JwtUtil.createJWT(adminInfo.getId()); | |||
// System.out.print("token:" + token); |