Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
620adf45
Commit
620adf45
authored
Feb 15, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加短信发送太频繁提示
parent
5af56dc2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
src/main/java/cn/meteor/beyondclouds/core/flow/ParamType.java
+1
-0
src/main/java/cn/meteor/beyondclouds/modules/sms/api/SmsApi.java
+14
-1
src/main/java/cn/meteor/beyondclouds/modules/sms/enums/SmsErrorCode.java
+2
-1
No files found.
src/main/java/cn/meteor/beyondclouds/core/flow/ParamType.java
View file @
620adf45
...
...
@@ -9,5 +9,6 @@ public enum ParamType {
BLOG
,
PROJECT
,
QUESTION
,
SMS_CODE
,
SEARCH_KEYWORDS_TOPIC
}
src/main/java/cn/meteor/beyondclouds/modules/sms/api/SmsApi.java
View file @
620adf45
...
...
@@ -3,9 +3,13 @@ package cn.meteor.beyondclouds.modules.sms.api;
import
cn.meteor.beyondclouds.core.annotation.Anonymous
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.core.constant.RegexPatterns
;
import
cn.meteor.beyondclouds.core.flow.AccessInfo
;
import
cn.meteor.beyondclouds.core.flow.CollectAccessInfo
;
import
cn.meteor.beyondclouds.core.flow.ParamType
;
import
cn.meteor.beyondclouds.modules.sms.enums.SmsErrorCode
;
import
cn.meteor.beyondclouds.modules.sms.exception.SmsServiceException
;
import
cn.meteor.beyondclouds.modules.sms.service.ISmsService
;
import
cn.meteor.beyondclouds.util.AccessInfoUtils
;
import
cn.meteor.beyondclouds.util.VerifyCodeUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -35,10 +39,19 @@ public class SmsApi {
@Anonymous
@ApiOperation
(
"发送验证码"
)
@GetMapping
(
"/verifyCode"
)
public
Response
sendVerify
(
@RequestParam
(
"mobile"
)
String
mobile
)
{
public
Response
sendVerify
(
@RequestParam
(
"mobile"
)
String
mobile
,
@CollectAccessInfo
(
paramName
=
"mobile"
,
type
=
ParamType
.
SMS_CODE
)
AccessInfo
accessInfo
)
{
if
(!
mobile
.
matches
(
RegexPatterns
.
MOBILE
))
{
return
Response
.
error
(
SmsErrorCode
.
INVALID_MOBILE
);
}
if
(
AccessInfoUtils
.
hasFieldInfo
(
accessInfo
))
{
Integer
count
=
accessInfo
.
getFieldVisitCount
();
if
(
count
>
2
)
{
return
Response
.
error
(
SmsErrorCode
.
TOO_FREQUENT
);
}
}
try
{
smsService
.
sendVerifyCode
(
mobile
,
VerifyCodeUtils
.
randomVerifyCode
());
return
Response
.
success
();
...
...
src/main/java/cn/meteor/beyondclouds/modules/sms/enums/SmsErrorCode.java
View file @
620adf45
...
...
@@ -10,7 +10,8 @@ public enum SmsErrorCode implements IErrorCode {
SERVER_ERROR
(
2001
,
"发送短信时阿里的服务器出现了异常"
),
CLIENT_ERROR
(
2002
,
"发送短信时自己的服务器出现了异常"
),
SEND_FAILURE
(
2004
,
"短信发送失败"
),
INVALID_MOBILE
(
2005
,
"手机号格式错误"
);
INVALID_MOBILE
(
2005
,
"手机号格式错误"
),
TOO_FREQUENT
(
2006
,
"短信发生太频繁"
);
private
long
code
;
private
String
msg
;
...
...
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