* 上次登录时间 | * 上次登录时间 | ||||
*/ | */ | ||||
@TableField("last_time") | @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; | |||||
/** | /** |
QueryWrapper wrapper = new QueryWrapper(); | QueryWrapper wrapper = new QueryWrapper(); | ||||
wrapper.eq("username", username); | wrapper.eq("username", username); | ||||
wrapper.eq("mark", 1); | wrapper.eq("mark", 1); | ||||
try { | |||||
SysAdmin admin = sysAdminMapper.selectOne(wrapper); | |||||
} catch (Exception e) { | |||||
System.out.println(e.getMessage()); | |||||
} | |||||
SysAdmin admin = sysAdminMapper.selectOne(wrapper); | SysAdmin admin = sysAdminMapper.selectOne(wrapper); | ||||
if (admin != null && !"".equals(admin.getAvatar())) { | if (admin != null && !"".equals(admin.getAvatar())) { | ||||
admin.setAvatar(imageUrl + admin.getAvatar()); | admin.setAvatar(imageUrl + admin.getAvatar()); | ||||
.token(currentUser.getSession().getId().toString()) | .token(currentUser.getSession().getId().toString()) | ||||
.build(); | .build(); | ||||
BeanUtils.copyProperties(user, cacheUser); | BeanUtils.copyProperties(user, cacheUser); | ||||
// 更新最近登录时间 | |||||
user.setLastTime(DateUtil.now()); | |||||
sysAdminMapper.updateById(user); | |||||
} catch (UnknownAccountException e) { | } catch (UnknownAccountException e) { | ||||
log.error("账户不存在异常:", e); | log.error("账户不存在异常:", e); | ||||
return response.failure("账号不存在!"); | return response.failure("账号不存在!"); |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
import com.taauav.common.bean.Response; | import com.taauav.common.bean.Response; | ||||
import com.taauav.common.util.DateUtil; | |||||
import com.taauav.common.util.FunctionUtils; | import com.taauav.common.util.FunctionUtils; | ||||
import com.taauav.common.util.JwtUtil; | import com.taauav.common.util.JwtUtil; | ||||
import com.taauav.common.util.StringUtils; | import com.taauav.common.util.StringUtils; | ||||
if (adminInfo.getStatus() != 1) { | if (adminInfo.getStatus() != 1) { | ||||
return response.failure("您已被禁用,请联系管理员"); | return response.failure("您已被禁用,请联系管理员"); | ||||
} | } | ||||
// 更新登录时间 | |||||
adminInfo.setLastTime(DateUtil.now()); | |||||
adminMapper.updateById(adminInfo); | |||||
// 生成token给前端 | // 生成token给前端 | ||||
String token = JwtUtil.createJWT(adminInfo.getId()); | String token = JwtUtil.createJWT(adminInfo.getId()); | ||||
// System.out.print("token:" + token); | // System.out.print("token:" + token); |