Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanbaoming
jiedao-api-boot-master
Commits
bd2f6a3d
Commit
bd2f6a3d
authored
Nov 20, 2024
by
honghy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
校验是否可以发送验证码,不用筛选场景
parent
29f287d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
SmsCodeServiceImpl.java
...r/yudao/module/system/service/sms/SmsCodeServiceImpl.java
+11
-11
No files found.
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/sms/SmsCodeServiceImpl.java
View file @
bd2f6a3d
...
...
@@ -57,17 +57,17 @@ public class SmsCodeServiceImpl implements SmsCodeService {
private
String
createSmsCode
(
String
mobile
,
String
nodeValue
,
String
ip
)
{
// 校验是否可以发送验证码,不用筛选场景
SmsCodeDO
lastSmsCode
=
smsCodeMapper
.
selectLastByMobile
(
mobile
,
null
,
null
);
//
if (lastSmsCode != null) {
//
if (lastSmsCode.getTodayIndex() >= smsCodeProperties.getSendMaximumQuantityPerDay()) { // 超过当天发送的上限。
//
throw ServiceExceptionUtil.exception(SMS_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY);
//
}
//
if (System.currentTimeMillis() - lastSmsCode.getCreateTime().getTime()
//
< smsCodeProperties.getSendFrequency().toMillis()) { // 发送过于频繁
//
throw ServiceExceptionUtil.exception(SMS_CODE_SEND_TOO_FAST);
//
}
//
// TODO 芋艿:提升,每个 IP 每天可发送数量
//
// TODO 芋艿:提升,每个 IP 每小时可发送数量
//
}
if
(
lastSmsCode
!=
null
)
{
if
(
lastSmsCode
.
getTodayIndex
()
>=
smsCodeProperties
.
getSendMaximumQuantityPerDay
())
{
// 超过当天发送的上限。
throw
ServiceExceptionUtil
.
exception
(
SMS_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY
);
}
if
(
System
.
currentTimeMillis
()
-
lastSmsCode
.
getCreateTime
().
getTime
()
<
smsCodeProperties
.
getSendFrequency
().
toMillis
())
{
// 发送过于频繁
throw
ServiceExceptionUtil
.
exception
(
SMS_CODE_SEND_TOO_FAST
);
}
// TODO 芋艿:提升,每个 IP 每天可发送数量
// TODO 芋艿:提升,每个 IP 每小时可发送数量
}
// 创建验证码记录
String
code
=
String
.
valueOf
(
randomInt
(
smsCodeProperties
.
getBeginCode
(),
smsCodeProperties
.
getEndCode
()
+
1
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment