Browse Source

更新

master
牧羊人 4 years ago
parent
commit
3c145779a5
3 changed files with 19 additions and 1 deletions
  1. +3
    -1
      src/main/java/com/taauav/admin/entity/SysAdmin.java
  2. +10
    -0
      src/main/java/com/taauav/admin/service/impl/SysAdminServiceImpl.java
  3. +6
    -0
      src/main/java/com/taauav/front/service/impl/LSLoginServiceImpl.java

+ 3
- 1
src/main/java/com/taauav/admin/entity/SysAdmin.java View File

* 上次登录时间 * 上次登录时间
*/ */
@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;




/** /**

+ 10
- 0
src/main/java/com/taauav/admin/service/impl/SysAdminServiceImpl.java View File

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("账号不存在!");

+ 6
- 0
src/main/java/com/taauav/front/service/impl/LSLoginServiceImpl.java View File

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);

Loading…
Cancel
Save