diff --git a/src/main/java/com/rymcu/vertical/config/BaseExceptionHandler.java b/src/main/java/com/rymcu/vertical/config/BaseExceptionHandler.java index fc47680..9ebe05e 100644 --- a/src/main/java/com/rymcu/vertical/config/BaseExceptionHandler.java +++ b/src/main/java/com/rymcu/vertical/config/BaseExceptionHandler.java @@ -23,6 +23,8 @@ import java.util.Map; /** * 全局异常处理器 + * + * @author ronger * */ @RestControllerAdvice public class BaseExceptionHandler { @@ -46,7 +48,8 @@ public class BaseExceptionHandler { result.setCode(1000002); result.setMessage("用户无权限"); logger.info("用户无权限"); - }else if (ex instanceof ServiceException) {//业务失败的异常,如“账号或密码错误” + }else if (ex instanceof ServiceException) { + //业务失败的异常,如“账号或密码错误” result.setCode(((ServiceException) ex).getCode()); result.setMessage(ex.getMessage()); logger.info(ex.getMessage()); @@ -88,7 +91,8 @@ public class BaseExceptionHandler { } else if (ex instanceof UnauthorizedException) { attributes.put("code", "1000002"); attributes.put("message", "用户无权限"); - } else if (ex instanceof ServiceException) {//业务失败的异常,如“账号或密码错误” + } else if (ex instanceof ServiceException) { + //业务失败的异常,如“账号或密码错误” attributes.put("code",((ServiceException) ex).getCode()); attributes.put("message",ex.getMessage()); logger.info(ex.getMessage()); diff --git a/src/main/java/com/rymcu/vertical/mapper/UserMapper.java b/src/main/java/com/rymcu/vertical/mapper/UserMapper.java index ce95279..de1eae8 100644 --- a/src/main/java/com/rymcu/vertical/mapper/UserMapper.java +++ b/src/main/java/com/rymcu/vertical/mapper/UserMapper.java @@ -113,4 +113,11 @@ public interface UserMapper extends Mapper { * @return */ Author selectAuthor(@Param("id") Integer id); + + /** + * 更新用户最后登录时间 + * @param idUser + * @return + */ + Integer updateLastLoginTime(@Param("idUser") Integer idUser); } \ No newline at end of file diff --git a/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java index dc8ef02..c565045 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/UserServiceImpl.java @@ -100,8 +100,7 @@ public class UserServiceImpl extends AbstractService implements UserServic user = userMapper.selectOne(user); if(user != null){ if(Utils.comparePwd(password, user.getPassword())){ - user.setLastLoginTime(new Date()); - userMapper.updateByPrimaryKeySelective(user); + userMapper.updateLastLoginTime(user.getIdUser()); TokenUser tokenUser = new TokenUser(); BeanCopierUtil.copy(user, tokenUser); tokenUser.setToken(tokenManager.createToken(account)); diff --git a/src/main/java/mapper/UserMapper.xml b/src/main/java/mapper/UserMapper.xml index f134db4..e4af70d 100644 --- a/src/main/java/mapper/UserMapper.xml +++ b/src/main/java/mapper/UserMapper.xml @@ -65,6 +65,9 @@ where id = #{idUser} + + update vertical_user set last_login_time = sysdate where id = #{idUser} +