🎨 修改更新用户最后登录时间方式
This commit is contained in:
parent
0a8f00d89e
commit
8d75008023
@ -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());
|
||||
|
@ -113,4 +113,11 @@ public interface UserMapper extends Mapper<User> {
|
||||
* @return
|
||||
*/
|
||||
Author selectAuthor(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 更新用户最后登录时间
|
||||
* @param idUser
|
||||
* @return
|
||||
*/
|
||||
Integer updateLastLoginTime(@Param("idUser") Integer idUser);
|
||||
}
|
@ -100,8 +100,7 @@ public class UserServiceImpl extends AbstractService<User> 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));
|
||||
|
@ -65,6 +65,9 @@
|
||||
</if>
|
||||
where id = #{idUser}
|
||||
</update>
|
||||
<update id="updateLastLoginTime">
|
||||
update vertical_user set last_login_time = sysdate where id = #{idUser}
|
||||
</update>
|
||||
|
||||
<select id="findByAccount" resultMap="BaseResultMap">
|
||||
select id, nickname, account, password, status from vertical_user where account = #{account} and status = 0
|
||||
|
Loading…
Reference in New Issue
Block a user