Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
da51ed9f
提交
da51ed9f
authored
10月 14, 2024
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 图形验证码生成补充过期时间输出
上级
16ea2d1b
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
8 行增加
和
1 行删除
+8
-1
Captcha.java
modules/auth/src/main/java/com/yiring/auth/core/Captcha.java
+4
-1
CaptchaVo.java
...auth/src/main/java/com/yiring/auth/vo/auth/CaptchaVo.java
+4
-0
没有找到文件。
modules/auth/src/main/java/com/yiring/auth/core/Captcha.java
浏览文件 @
da51ed9f
...
@@ -7,6 +7,7 @@ import cn.hutool.core.util.IdUtil;
...
@@ -7,6 +7,7 @@ import cn.hutool.core.util.IdUtil;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.yiring.auth.vo.auth.CaptchaVo
;
import
com.yiring.auth.vo.auth.CaptchaVo
;
import
com.yiring.common.core.Redis
;
import
com.yiring.common.core.Redis
;
import
java.time.LocalDateTime
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -31,12 +32,14 @@ public class Captcha {
...
@@ -31,12 +32,14 @@ public class Captcha {
public
CaptchaVo
create
()
{
public
CaptchaVo
create
()
{
LineCaptcha
lineCaptcha
=
CaptchaUtil
.
createLineCaptcha
(
200
,
80
);
LineCaptcha
lineCaptcha
=
CaptchaUtil
.
createLineCaptcha
(
200
,
80
);
String
key
=
IdUtil
.
fastSimpleUUID
();
String
key
=
IdUtil
.
fastSimpleUUID
();
int
expire
=
300
;
CaptchaVo
vo
=
CaptchaVo
CaptchaVo
vo
=
CaptchaVo
.
builder
()
.
builder
()
.
key
(
key
)
.
key
(
key
)
.
data
(
"data:image/jpg;base64,"
+
lineCaptcha
.
getImageBase64
())
.
data
(
"data:image/jpg;base64,"
+
lineCaptcha
.
getImageBase64
())
.
expire
(
LocalDateTime
.
now
().
plusSeconds
(
expire
))
.
build
();
.
build
();
redis
.
set
(
CAPTCHA_KEY_PREFIX
+
key
,
lineCaptcha
.
getCode
(),
300
);
redis
.
set
(
CAPTCHA_KEY_PREFIX
+
key
,
lineCaptcha
.
getCode
(),
expire
);
return
vo
;
return
vo
;
}
}
...
...
modules/auth/src/main/java/com/yiring/auth/vo/auth/CaptchaVo.java
浏览文件 @
da51ed9f
...
@@ -4,6 +4,7 @@ package com.yiring.auth.vo.auth;
...
@@ -4,6 +4,7 @@ package com.yiring.auth.vo.auth;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
java.io.Serial
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
lombok.*
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
import
lombok.experimental.FieldDefaults
;
...
@@ -31,4 +32,7 @@ public class CaptchaVo implements Serializable {
...
@@ -31,4 +32,7 @@ public class CaptchaVo implements Serializable {
@Schema
(
description
=
"验证码图片 Base64"
,
example
=
"data:image/jpg;base64,iV=="
)
@Schema
(
description
=
"验证码图片 Base64"
,
example
=
"data:image/jpg;base64,iV=="
)
String
data
;
String
data
;
@Schema
(
description
=
"验证码过期时间"
,
example
=
"2024-01-01 00:00:00"
)
LocalDateTime
expire
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论