Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yanxuan-wx-store-sharer
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
wx
yanxuan-wx-store-sharer
Commits
b0ee19e7
Commit
b0ee19e7
authored
May 14, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信验证码配置调整
parent
e231f17b
Pipeline
#75486
passed with stages
in 1 minute 28 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
31 deletions
+63
-31
SmsServiceImpl.java
...xuan/wx/store/sharer/biz/service/impl/SmsServiceImpl.java
+6
-4
UasClientImpl.java
...x/store/sharer/integration/client/impl/UasClientImpl.java
+3
-1
SmsConfig.java
...yanxuan/wx/store/sharer/integration/config/SmsConfig.java
+12
-26
SmsCodeScenesConfigBO.java
...arer/integration/meta/model/bo/SmsCodeScenesConfigBO.java
+42
-0
No files found.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/service/impl/SmsServiceImpl.java
View file @
b0ee19e7
...
...
@@ -11,6 +11,7 @@ import com.netease.yanxuan.wx.store.sharer.common.util.RandomUtils;
import
com.netease.yanxuan.wx.store.sharer.integration.client.IUasClient
;
import
com.netease.yanxuan.wx.store.sharer.integration.config.SmsConfig
;
import
com.netease.yanxuan.wx.store.sharer.integration.constant.SmsConstant
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.bo.SmsCodeScenesConfigBO
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -77,8 +78,9 @@ public class SmsServiceImpl implements ISmsService {
if
(!
success
)
{
return
false
;
}
int
sendIntervalSeconds
=
smsConfig
.
getSendIntervalSeconds
();
int
codeValidMinutes
=
smsConfig
.
getCodeValidMinutes
();
SmsCodeScenesConfigBO
smsCodeScenesConfigBO
=
smsConfig
.
getScenesConfig
(
scenes
);
int
sendIntervalSeconds
=
smsCodeScenesConfigBO
.
getSendIntervalSeconds
();
int
codeValidMinutes
=
smsCodeScenesConfigBO
.
getCodeValidMinutes
();
// 标记验证码已发送
String
sendCodeKey
=
String
.
format
(
SmsConstant
.
SMS_SEND_INTERVAL_KEY
,
scenes
,
mobilePhone
);
redisClient
.
setStr
(
sendCodeKey
,
String
.
valueOf
(
System
.
currentTimeMillis
()),
sendIntervalSeconds
);
...
...
@@ -138,7 +140,7 @@ public class SmsServiceImpl implements ISmsService {
BoundValueOperations
<
String
,
Object
>
operations
=
redisClient
.
boundValueOps
(
key
);
Long
sendCount
=
operations
.
increment
();
operations
.
expire
(
1
,
TimeUnit
.
DAYS
);
return
smsConfig
.
getSendMaxCount
()
>=
(
sendCount
==
null
?
1
:
sendCount
);
return
smsConfig
.
getS
cenesConfig
(
scenes
).
getS
endMaxCount
()
>=
(
sendCount
==
null
?
1
:
sendCount
);
}
/**
...
...
@@ -153,7 +155,7 @@ public class SmsServiceImpl implements ISmsService {
BoundValueOperations
<
String
,
Object
>
operations
=
redisClient
.
boundValueOps
(
key
);
Long
verifyCount
=
operations
.
increment
();
operations
.
expire
(
1
,
TimeUnit
.
DAYS
);
return
smsConfig
.
getVerifyCodeMaxCount
()
>=
(
verifyCount
==
null
?
1
:
verifyCount
);
return
smsConfig
.
get
ScenesConfig
(
scenes
).
get
VerifyCodeMaxCount
()
>=
(
verifyCount
==
null
?
1
:
verifyCount
);
}
private
String
getToday
()
{
...
...
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/client/impl/UasClientImpl.java
View file @
b0ee19e7
...
...
@@ -11,6 +11,7 @@ import com.netease.yanxuan.wx.store.sharer.integration.client.IUasClient;
import
com.netease.yanxuan.wx.store.sharer.integration.config.RpcConfig
;
import
com.netease.yanxuan.wx.store.sharer.integration.config.SmsConfig
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.RestTemplateHandler
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.bo.SmsCodeScenesConfigBO
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpMethod
;
...
...
@@ -59,7 +60,8 @@ public class UasClientImpl implements IUasClient {
private
Map
<
String
,
Object
>
assembleSmsArg
(
String
uid
,
String
phone
,
String
code
,
String
scenes
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"phone"
,
phone
);
params
.
put
(
"message"
,
String
.
format
(
smsConfig
.
getMessageFormat
(),
code
,
smsConfig
.
getCodeValidMinutes
()));
SmsCodeScenesConfigBO
scenesConfig
=
smsConfig
.
getScenesConfig
(
scenes
);
params
.
put
(
"message"
,
String
.
format
(
scenesConfig
.
getMessageFormat
(),
code
,
scenesConfig
.
getCodeValidMinutes
()));
params
.
put
(
"level"
,
1
);
params
.
put
(
"uid"
,
uid
);
params
.
put
(
"topic"
,
String
.
format
(
TOPIC_FORMAT
,
scenes
));
...
...
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/config/SmsConfig.java
View file @
b0ee19e7
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
integration
.
config
;
import
com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ValueMapping
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.bo.SmsCodeScenesConfigBO
;
import
lombok.Data
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.Map
;
/**
* @Description 应用配置
* @Author fanjiaxin
...
...
@@ -15,32 +18,14 @@ import org.springframework.stereotype.Component;
@EnableAutoUpdateApolloConfig
public
class
SmsConfig
{
/**
* 验证码发送最大次数
*/
@Value
(
"${sms.send.max.count:10}"
)
private
Integer
sendMaxCount
;
/**
* 验证码发送间隔时间,秒
* 场景验证码配置
* key: 业务场景标识
*/
@Value
(
"${sms.send.interval.seconds:60
}"
)
private
Integer
sendIntervalSeconds
;
@Value
Mapping
(
"${sms.scenes.config.map:{}
}"
)
private
Map
<
String
,
SmsCodeScenesConfigBO
>
scenesConfigMap
;
/**
* 验证码有效时间,分钟
*/
@Value
(
"${sms.code.valid.minutes:5}"
)
private
Integer
codeValidMinutes
;
/**
* 验证码短信格式
*/
@Value
(
"${sms.message.format:}"
)
private
String
messageFormat
;
/**
* 验证码每日校验次数上限
*/
@Value
(
"${sms.verify.code.max.count:10}"
)
private
Integer
verifyCodeMaxCount
;
public
SmsCodeScenesConfigBO
getScenesConfig
(
String
scenes
)
{
return
scenesConfigMap
.
get
(
scenes
);
}
}
\ No newline at end of file
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/meta/model/bo/SmsCodeScenesConfigBO.java
0 → 100644
View file @
b0ee19e7
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
integration
.
meta
.
model
.
bo
;
import
lombok.Builder
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Description 短信验证码-配置-业务对象
* @Author fanjiaxin
* @Date 2025/3/11 18:43
*/
@Data
@Builder
public
class
SmsCodeScenesConfigBO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 验证码发送间隔时间,秒
*/
private
Integer
sendIntervalSeconds
;
/**
* 验证码有效时间,分钟
*/
private
Integer
codeValidMinutes
;
/**
* 验证码短信格式
*/
private
String
messageFormat
;
/**
* 验证码发送最大次数
*/
private
Integer
sendMaxCount
;
/**
* 验证码每日校验次数上限
*/
private
Integer
verifyCodeMaxCount
;
}
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