当前位置:网站首页>开发知识点
开发知识点
2022-07-02 22:20:00 【捕風捉影】
//TODO 5、防重令牌(防止表单重复提交)
//为用户设置一个token,三十分钟过期时间(存在redis)
String token = UUID.randomUUID().toString().replace("-", "");
redisTemplate.opsForValue().set(USER_ORDER_TOKEN_PREFIX+memberResponseVo.getId(),token,30, TimeUnit.MINUTES);
confirmVo.setOrderToken(token);
生成uuid 作为redis 的key
redis脚本程序判断判断前端传递过来的数据是否和后端一致
//1、验证令牌是否合法【令牌的对比和删除必须保证原子性】
String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
String orderToken = vo.getOrderToken();
//通过lure脚本原子验证令牌和删除令牌
Long result = redisTemplate.execute(new DefaultRedisScript<Long>(script, Long.class),
Arrays.asList(USER_ORDER_TOKEN_PREFIX + memberResponseVo.getId()),
orderToken);
集合转为string
//使用StringUtils.collectionToDelimitedString将list集合转换为String
String skuAttrValues = StringUtils.collectionToDelimitedString(items.getSkuAttrValues(), ";");
边栏推荐
- SharedPreferences 保存List<Bean> 到本地并解决com.google.gson.internal.LinkedTreeMap cannot be cast to异常
- (stinger) use pystinger Socks4 to go online and not go out of the network host
- JDBC练习案例
- Redis expiration policy +conf record
- Compose 中的 'ViewPager' 详解 | 开发者说·DTalk
- @BindsInstance在Dagger2中怎么使用
- Win11麦克风测试在哪里?Win11测试麦克风的方法
- 【ML】李宏毅三:梯度下降&分类(高斯分布)
- MySQL Foundation
- Dishes launcher small green program and directory management (efficiency tool)
猜你喜欢

Win11麦克风测试在哪里?Win11测试麦克风的方法

Where is the win11 automatic shutdown setting? Two methods of setting automatic shutdown in win11

基于Pyqt5工具栏按钮可实现界面切换-2

RuntimeError: no valid convolution algorithms available in CuDNN

一文掌握基于深度学习的人脸表情识别开发(基于PaddlePaddle)

Master the development of facial expression recognition based on deep learning (based on paddlepaddle)

Eight honors and eight disgraces of the programmer version~

Win11如何开启目视控制?Win11开启目视控制的方法

JDBC练习案例

golang入门:for...range修改切片中元素的值的另类方法
随机推荐
Use redis to realize self increment serial number
MySQL基础
2022年最新最全软件测试面试题大全
【OJ】两个数组的交集(set、哈希映射 ...)
面试过了,起薪16k
Compose 中的 'ViewPager' 详解 | 开发者说·DTalk
The difference between new and make in golang
Quantitative analysis of PSNR, SSIM and RMSE
流媒体技术优化
Win11如何开启目视控制?Win11开启目视控制的方法
【Redis笔记】压缩列表(ziplist)
A single element in an ordered array -- Valentine's Day mental problems
C MVC creates a view to get rid of the influence of layout
All things work together, and I will review oceanbase's practice in government and enterprise industry
Eight bit responder [51 single chip microcomputer]
LINQ usage collection in C #
采用VNC Viewer方式遠程連接樹莓派
[analysis of STL source code] imitation function (to be supplemented)
Highly available cluster (HAC)
Third party payment function test point [Hangzhou multi tester _ Wang Sir] [Hangzhou multi tester]