当前位置:网站首页>开发知识点
开发知识点
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(), ";");
边栏推荐
- 【STL源码剖析】仿函数(待补充)
- 【Redis笔记】压缩列表(ziplist)
- 返回二叉树中最大的二叉搜索子树的大小
- golang入门:for...range修改切片中元素的值的另类方法
- 【ML】李宏毅三:梯度下降&分类(高斯分布)
- 高数有多难?AI 卷到数学圈,高数考试正确率 81%!
- How difficult is it to be high? AI rolls into the mathematics circle, and the accuracy rate of advanced mathematics examination is 81%!
- Cryptography -- the mode of block cipher
- 采用VNC Viewer方式遠程連接樹莓派
- [array] binary search
猜你喜欢

Intranet penetration | teach you how to conduct intranet penetration hand in hand

JSON数据传递参数

What can I do after buying a domain name?

【STL源码剖析】仿函数(待补充)

Mapper agent development

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

Where is the win11 microphone test? Win11 method of testing microphone

MarkDown基本语法

购买完域名之后能干什么事儿?

(stinger) use pystinger Socks4 to go online and not go out of the network host
随机推荐
万物并作,吾以观复|OceanBase 政企行业实践
Potplayer set minimized shortcut keys
Win11麦克风测试在哪里?Win11测试麦克风的方法
php 获取真实ip
跨境电商如何通过打好数据底座,实现低成本稳步增长
Yolox enhanced feature extraction network panet analysis
Troubleshooting the cause of the crash when STM32 serial port dam receives 253 bytes
判断二叉树是否为满二叉树
第三方支付功能测试点【杭州多测师_王sir】【杭州多测师】
返回二叉树两个节点间的最大距离
Eight bit responder [51 single chip microcomputer]
Print out mode of go
Arduino - character judgment function
返回二叉树中最大的二叉搜索子树的大小
List of major chip Enterprises
Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
Mapper代理开发
Simple square wave generating circuit [51 single chip microcomputer and 8253a]
JDBC教程
Load balancing cluster (LBC)