增加获取uuid的方法,为压测环境的同一token购物车重复问题处理
This commit is contained in:
parent
62804941c2
commit
65e7f9750a
@ -52,9 +52,6 @@ public class UploadController {
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Autowired
|
||||
private SystemSettingProperties systemSettingProperties;
|
||||
|
||||
@ApiOperation(value = "文件上传")
|
||||
@PostMapping(value = "/file")
|
||||
public ResultMessage<Object> upload(MultipartFile file,
|
||||
|
@ -37,6 +37,20 @@ public class UserContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据request获取用户信息
|
||||
*
|
||||
* @return 授权用户
|
||||
*/
|
||||
public static String getUuid() {
|
||||
if (RequestContextHolder.getRequestAttributes() != null) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String uuid = request.getHeader(SecurityEnum.UUID.getValue());
|
||||
return uuid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据jwt获取token重的用户信息
|
||||
|
@ -10,7 +10,7 @@ public enum SecurityEnum {
|
||||
/**
|
||||
* 存在与header中的token参数头 名
|
||||
*/
|
||||
HEADER_TOKEN("accessToken"), USER_CONTEXT("userContext"), JWT_SECRET("secret");
|
||||
HEADER_TOKEN("accessToken"), USER_CONTEXT("userContext"), JWT_SECRET("secret"), UUID("uuid");
|
||||
|
||||
String value;
|
||||
|
||||
|
@ -229,8 +229,9 @@ public class CartServiceImpl implements CartService {
|
||||
|
||||
//缓存key,默认使用购物车
|
||||
if (cartTypeEnum != null) {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
return cartTypeEnum.getPrefix() + currentUser.getId();
|
||||
// AuthUser currentUser = UserContext.getCurrentUser();
|
||||
// return cartTypeEnum.getPrefix() + currentUser.getId();
|
||||
return cartTypeEnum.getPrefix() + UserContext.getUuid();
|
||||
}
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user