当前位置:网站首页>开发知识点
开发知识点
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(), ";");
边栏推荐
- cocospods 的使用
- How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
- 采用VNC Viewer方式遠程連接樹莓派
- Talk about memory model and memory order
- vim区间删行注释
- Mapper agent development
- Warning: implicitly declaring library function 'printf' with type 'int (const char *,...)‘
- 高数有多难?AI 卷到数学圈,高数考试正确率 81%!
- Eight honors and eight disgraces of the programmer version~
- Win11麦克风测试在哪里?Win11测试麦克风的方法
猜你喜欢

2022年最新最全软件测试面试题大全

What if win11 can't turn off the sticky key? The sticky key is cancelled but it doesn't work. How to solve it

Go basic anonymous variable

Use of recyclerview with viewbinding

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

Bean load control

Catalogue of digital image processing experiments

(毒刺)利用Pystinger Socks4上线不出网主机

Eight honors and eight disgraces of the programmer version~

Data set - fault diagnosis: various data and data description of bearings of Western Reserve University
随机推荐
C MVC creates a view to get rid of the influence of layout
Win11麦克风测试在哪里?Win11测试麦克风的方法
How difficult is it to be high? AI rolls into the mathematics circle, and the accuracy rate of advanced mathematics examination is 81%!
Master the development of facial expression recognition based on deep learning (based on paddlepaddle)
Dishes launcher small green program and directory management (efficiency tool)
2022年最新最全软件测试面试题大全
Win11自动关机设置在哪?Win11设置自动关机的两种方法
@How to use bindsinstance in dagger2
cocospods 的使用
Mapper agent development
解决:exceptiole ‘xxxxx.QRTZ_LOCKS‘ doesn‘t exist以及mysql的my.cnf文件追加lower_case_table_names后启动报错
PHP get real IP
What can I do after buying a domain name?
Win11如何开启目视控制?Win11开启目视控制的方法
Explain promise usage in detail
VIM interval deletion note
Realize the linkage between bottomnavigationview and navigation
【Proteus仿真】51单片机+LCD12864推箱子游戏
潘多拉 IOT 开发板学习(HAL 库)—— 实验3 按键输入实验(学习笔记)
The concepts of terminal voltage, phase voltage and line voltage in FOC vector control and BLDC control are still unclear