Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gogirl-miniapp-backend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
huluobin
gogirl-miniapp-backend
Commits
f6802cff
Commit
f6802cff
authored
Nov 14, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7fbf7148
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
GogirlTokenServiceImpl.java
...l/application/common/xcx/impl/GogirlTokenServiceImpl.java
+3
-0
SmsService.java
...ava/com/gogirl/infrastructure/service/sms/SmsService.java
+9
-0
QCloudSmsServiceImpl.java
...infrastructure/service/sms/impl/QCloudSmsServiceImpl.java
+11
-1
No files found.
src/main/java/com/gogirl/application/common/xcx/impl/GogirlTokenServiceImpl.java
View file @
f6802cff
...
...
@@ -116,6 +116,9 @@ public class GogirlTokenServiceImpl implements GogirlTokenService {
if
(
responseResult
.
getErrcode
()
!=
null
)
{
throw
new
RRException
(
responseResult
.
getErrmsg
());
}
if
(!
smsService
.
checkSmsCode
(
phone
,
messageCode
))
{
throw
new
RRException
(
"验证码错误"
);
}
String
openid
=
responseResult
.
getOpenid
();
...
...
src/main/java/com/gogirl/infrastructure/service/sms/SmsService.java
View file @
f6802cff
...
...
@@ -12,4 +12,13 @@ public interface SmsService {
* @return
*/
SmsSingleSenderResult
sendBindSmsCode
(
String
phoneNumber
,
String
code
);
/**
* 验证短信
*
* @param phoneNumber
* @param code
* @return
*/
Boolean
checkSmsCode
(
String
phoneNumber
,
String
code
);
}
src/main/java/com/gogirl/infrastructure/service/sms/impl/QCloudSmsServiceImpl.java
View file @
f6802cff
...
...
@@ -5,8 +5,10 @@ import com.github.qcloudsms.SmsSingleSenderResult;
import
com.gogirl.infrastructure.service.sms.SmsService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.json.JSONException
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.xml.ws.http.HTTPException
;
import
java.io.IOException
;
...
...
@@ -16,7 +18,8 @@ import java.io.IOException;
@Service
@Slf4j
public
class
QCloudSmsServiceImpl
implements
SmsService
{
@Resource
StringRedisTemplate
stringRedisTemplate
;
@Override
public
SmsSingleSenderResult
sendBindSmsCode
(
String
phoneNumber
,
String
code
)
{
...
...
@@ -30,6 +33,8 @@ public class QCloudSmsServiceImpl implements SmsService {
try
{
SmsSingleSender
sender
=
new
SmsSingleSender
(
SmsConstant
.
appid
,
SmsConstant
.
appkey
);
result
=
sender
.
sendWithParam
(
"86"
,
phoneNumber
,
templateId
,
params
,
smsSign
,
""
,
""
);
stringRedisTemplate
.
opsForValue
().
set
(
phoneNumber
,
code
);
}
// HTTP响应码错误 json解析错误 网络IO错误
catch
(
HTTPException
|
JSONException
|
IOException
|
com
.
github
.
qcloudsms
.
httpclient
.
HTTPException
e
)
{
...
...
@@ -38,4 +43,9 @@ public class QCloudSmsServiceImpl implements SmsService {
return
result
;
}
@Override
public
Boolean
checkSmsCode
(
String
phoneNumber
,
String
code
)
{
return
code
.
equals
(
stringRedisTemplate
.
opsForValue
().
get
(
phoneNumber
));
}
}
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