mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-28 05:25:15 +00:00
更新
This commit is contained in:
@@ -26,6 +26,20 @@ public class CommonUtil {
|
||||
return (UserDto) tokenInfoDtoObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得token
|
||||
*
|
||||
* @param request request
|
||||
* @return String
|
||||
*/
|
||||
public static String getToken(HttpServletRequest request) {
|
||||
Object tokenObj = request.getAttribute(CommonConstant.PARAMETER_NAME_TOKEN);
|
||||
if (tokenObj != null) {
|
||||
return (String) tokenObj;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有化构造函数
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.google.common.cache.Cache;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.itkk.udf.api.common.CommonConstant;
|
||||
import org.itkk.udf.api.common.dto.UserDto;
|
||||
import org.itkk.udf.api.common.service.IUserService;
|
||||
@@ -125,6 +126,19 @@ public class UserService implements IUserService {
|
||||
return this.login(new LoginDto().setUserId(registeredDto.getUserId()).setPswd(registeredDto.getPswd()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*
|
||||
* @param token token
|
||||
*/
|
||||
public void logout(String token) {
|
||||
//判空
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
//删除缓存
|
||||
dbCacheService.delete(token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户密码
|
||||
*
|
||||
|
||||
@@ -29,6 +29,17 @@ public class UserController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*
|
||||
* @return RestResponse<String>
|
||||
*/
|
||||
@DeleteMapping("logout")
|
||||
public RestResponse<String> logout() {
|
||||
userService.logout(CommonUtil.getToken(httpServletRequest));
|
||||
return RestResponse.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改密码
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user