Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
94e17977
Commit
94e17977
authored
Jun 25, 2019
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加阿里云短信的常量配置
parent
7e184856
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
31 deletions
+39
-31
_sqls/guns_mysql.sql
+7
-2
guns-base-sms/src/main/java/cn/stylefeng/guns/sms/config/SmsAutoConfiguration.java
+0
-14
guns-base-sms/src/main/java/cn/stylefeng/guns/sms/core/sms/service/AliyunSmsManager.java
+9
-5
guns-base-sms/src/main/java/cn/stylefeng/guns/sms/modular/service/SmsInfoService.java
+1
-1
guns-base/src/main/java/cn/stylefeng/guns/base/consts/ConstantsContext.java
+21
-1
guns-base/src/main/java/cn/stylefeng/guns/base/sms/AliyunSmsProperties.java
+1
-1
guns-vip-main/src/main/resources/application-local.yml
+0
-7
No files found.
_sqls/guns_mysql.sql
View file @
94e17977
...
...
@@ -16,7 +16,7 @@ USE guns;
Target Server Version : 50724
File Encoding : 65001
Date: 25/06/2019
09:21:13
Date: 25/06/2019
13:20:39
*/
SET
NAMES
utf8mb4
;
...
...
@@ -43,7 +43,7 @@ CREATE TABLE `database_info` (
-- Records of database_info
-- ----------------------------
BEGIN
;
INSERT
INTO
`database_info`
VALUES
(
11433
20353162928129
,
'master'
,
'com.mysql.cj.jdbc.Driver'
,
'root'
,
'root'
,
'jdbc:mysql://127.0.0.1:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT'
,
'主数据源,项目启动数据源!'
,
'2019-06-25 08:49:48
'
);
INSERT
INTO
`database_info`
VALUES
(
11433
87804278038529
,
'master'
,
'com.mysql.cj.jdbc.Driver'
,
'root'
,
'root'
,
'jdbc:mysql://127.0.0.1:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT'
,
'主数据源,项目启动数据源!'
,
'2019-06-25 13:17:50
'
);
COMMIT
;
-- ----------------------------
...
...
@@ -95,6 +95,11 @@ CREATE TABLE `sys_config` (
-- ----------------------------
BEGIN
;
INSERT
INTO
`sys_config`
VALUES
(
1143324237579165697
,
'验证码开关'
,
'GUNS_KAPTCHA_OPEN'
,
'Y'
,
1106120265689055233
,
'DISABLE'
,
'是否开启验证码'
,
'2019-06-24 12:46:43'
,
1
,
'2019-06-25 09:04:42'
,
1
);
INSERT
INTO
`sys_config`
VALUES
(
1143386834613694465
,
'阿里云短信的keyId'
,
'GUNS_SMS_ACCESSKEY_ID'
,
'N'
,
NULL
,
'xxxkey'
,
'阿里云短信的密钥key'
,
'2019-06-25 13:13:59'
,
1
,
'2019-06-25 13:19:21'
,
1
);
INSERT
INTO
`sys_config`
VALUES
(
1143386953933254657
,
'阿里云短信的secret'
,
'GUNS_SMS_ACCESSKEY_SECRET'
,
'N'
,
NULL
,
'xxxsecret'
,
'阿里云短信的secret'
,
'2019-06-25 13:14:28'
,
1
,
NULL
,
NULL
);
INSERT
INTO
`sys_config`
VALUES
(
1143387023449649154
,
'阿里云短信的签名'
,
'GUNS_SMS_SIGN_NAME'
,
'N'
,
NULL
,
'xxxsign'
,
'阿里云短信的签名'
,
'2019-06-25 13:14:44'
,
1
,
NULL
,
NULL
);
INSERT
INTO
`sys_config`
VALUES
(
1143387131109044225
,
'阿里云短信登录的模板号'
,
'GUNS_SMS_LOGIN_TEMPLATE_CODE'
,
'N'
,
NULL
,
'SMS_XXXXXX'
,
'阿里云短信登录的模板号'
,
'2019-06-25 13:15:10'
,
1
,
NULL
,
NULL
);
INSERT
INTO
`sys_config`
VALUES
(
1143387225019510785
,
'验证码短信失效时间'
,
'GUNS_SMS_INVALIDATE_MINUTES'
,
'N'
,
NULL
,
'2'
,
'验证码短信失效时间'
,
'2019-06-25 13:15:32'
,
1
,
NULL
,
NULL
);
COMMIT
;
-- ----------------------------
...
...
guns-base-sms/src/main/java/cn/stylefeng/guns/sms/config/SmsAutoConfiguration.java
View file @
94e17977
package
cn
.
stylefeng
.
guns
.
sms
.
config
;
import
cn.stylefeng.guns.sms.config.properties.AliyunSmsProperties
;
import
cn.stylefeng.guns.sms.core.cache.impl.MapSignManager
;
import
cn.stylefeng.guns.sms.core.sms.service.AliyunSmsManager
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -17,18 +15,6 @@ import org.springframework.context.annotation.Configuration;
public
class
SmsAutoConfiguration
{
/**
* 阿里云短信发送的配置
*
* @author fengshuonan
* @Date 2018/7/6 下午3:24
*/
@Bean
@ConfigurationProperties
(
prefix
=
"aliyun.sms"
)
public
AliyunSmsProperties
aliyunSmsProperties
()
{
return
new
AliyunSmsProperties
();
}
/**
* 短信发送管理器
*
* @author fengshuonan
...
...
guns-base-sms/src/main/java/cn/stylefeng/guns/sms/core/sms/service/AliyunSmsManager.java
View file @
94e17977
package
cn
.
stylefeng
.
guns
.
sms
.
core
.
sms
.
service
;
import
cn.hutool.core.date.DateUtil
;
import
cn.stylefeng.guns.sms.config.properties.AliyunSmsProperties
;
import
cn.stylefeng.guns.base.consts.ConstantsContext
;
import
cn.stylefeng.guns.base.sms.AliyunSmsProperties
;
import
cn.stylefeng.guns.sms.core.cache.MultiSignManager
;
import
cn.stylefeng.guns.sms.core.enums.SmsResultEnum
;
import
cn.stylefeng.guns.sms.core.exception.SmsException
;
...
...
@@ -40,9 +41,6 @@ import static cn.hutool.core.date.DatePattern.PURE_DATE_PATTERN;
public
class
AliyunSmsManager
implements
SmsManager
{
@Autowired
private
AliyunSmsProperties
aliyunSmsProperties
;
@Autowired
private
MultiSignManager
multiSignManager
;
@Override
...
...
@@ -50,6 +48,9 @@ public class AliyunSmsManager implements SmsManager {
log
.
info
(
"开始发送阿里云短信,手机号是:"
+
phoneNumber
+
",模板号是:"
+
templateCode
+
",参数是:"
+
JSON
.
toJSONString
(
params
));
//获取发送短信的配置
AliyunSmsProperties
aliyunSmsProperties
=
ConstantsContext
.
getAliyunSmsProperties
();
//检验参数是否合法
assertSendSmsParams
(
phoneNumber
,
templateCode
,
params
,
aliyunSmsProperties
);
...
...
@@ -143,6 +144,8 @@ public class AliyunSmsManager implements SmsManager {
//初始化ascClient需要的几个参数
final
String
product
=
"Dysmsapi"
;
//短信API产品名称(短信产品名固定,无需修改)
final
String
domain
=
"dysmsapi.aliyuncs.com"
;
//短信API产品域名(接口地址固定,无需修改)
AliyunSmsProperties
aliyunSmsProperties
=
ConstantsContext
.
getAliyunSmsProperties
();
final
String
accessKeyId
=
aliyunSmsProperties
.
getAccessKeyId
();
final
String
accessKeySecret
=
aliyunSmsProperties
.
getAccessKeySecret
();
...
...
@@ -231,7 +234,8 @@ public class AliyunSmsManager implements SmsManager {
* @Date 2018/8/13 21:23
*/
private
String
getSmsSign
(
String
phone
)
{
String
signName
=
this
.
aliyunSmsProperties
.
getSignName
();
AliyunSmsProperties
aliyunSmsProperties
=
ConstantsContext
.
getAliyunSmsProperties
();
String
signName
=
aliyunSmsProperties
.
getSignName
();
//如果是单个签名就用一个签名发
if
(!
signName
.
contains
(
","
))
{
...
...
guns-base-sms/src/main/java/cn/stylefeng/guns/sms/modular/service/SmsInfoService.java
View file @
94e17977
package
cn
.
stylefeng
.
guns
.
sms
.
modular
.
service
;
import
cn.stylefeng.guns.
sms.config.propertie
s.AliyunSmsProperties
;
import
cn.stylefeng.guns.
base.sm
s.AliyunSmsProperties
;
import
cn.stylefeng.guns.sms.core.enums.SmsResultEnum
;
import
cn.stylefeng.guns.sms.core.enums.SmsSendStatus
;
import
cn.stylefeng.guns.sms.core.enums.SmsVerifyResult
;
...
...
guns-base/src/main/java/cn/stylefeng/guns/base/consts/ConstantsContext.java
View file @
94e17977
package
cn
.
stylefeng
.
guns
.
base
.
consts
;
import
cn.stylefeng.guns.base.enums.CommonStatus
;
import
cn.stylefeng.guns.base.sms.AliyunSmsProperties
;
import
cn.stylefeng.roses.core.util.ToolUtil
;
import
java.util.Map
;
...
...
@@ -53,7 +54,7 @@ public class ConstantsContext {
}
/**
* 获取开关
* 获取
验证码
开关
*/
public
static
Boolean
getKaptchaOpen
()
{
String
gunsKaptchaOpen
=
(
String
)
CONSTNTS_HOLDER
.
get
(
"GUNS_KAPTCHA_OPEN"
);
...
...
@@ -63,4 +64,23 @@ public class ConstantsContext {
return
false
;
}
}
/**
* 获取短信的配置
*/
public
static
AliyunSmsProperties
getAliyunSmsProperties
()
{
String
gunsSmsAccesskeyId
=
(
String
)
CONSTNTS_HOLDER
.
get
(
"GUNS_SMS_ACCESSKEY_ID"
);
String
gunsSmsAccesskeySecret
=
(
String
)
CONSTNTS_HOLDER
.
get
(
"GUNS_SMS_ACCESSKEY_SECRET"
);
String
gunsSmsSignName
=
(
String
)
CONSTNTS_HOLDER
.
get
(
"GUNS_SMS_SIGN_NAME"
);
String
gunsSmsLoginTemplateCode
=
(
String
)
CONSTNTS_HOLDER
.
get
(
"GUNS_SMS_LOGIN_TEMPLATE_CODE"
);
String
gunsSmsInvalidateMinutes
=
(
String
)
CONSTNTS_HOLDER
.
get
(
"GUNS_SMS_INVALIDATE_MINUTES"
);
AliyunSmsProperties
aliyunSmsProperties
=
new
AliyunSmsProperties
();
aliyunSmsProperties
.
setAccessKeyId
(
gunsSmsAccesskeyId
);
aliyunSmsProperties
.
setAccessKeySecret
(
gunsSmsAccesskeySecret
);
aliyunSmsProperties
.
setSignName
(
gunsSmsSignName
);
aliyunSmsProperties
.
setLoginTemplateCode
(
gunsSmsLoginTemplateCode
);
aliyunSmsProperties
.
setInvalidateMinutes
(
Integer
.
valueOf
(
gunsSmsInvalidateMinutes
));
return
aliyunSmsProperties
;
}
}
guns-base
-sms/src/main/java/cn/stylefeng/guns/sms/config/propertie
s/AliyunSmsProperties.java
→
guns-base
/src/main/java/cn/stylefeng/guns/base/sm
s/AliyunSmsProperties.java
View file @
94e17977
package
cn
.
stylefeng
.
guns
.
sms
.
config
.
propertie
s
;
package
cn
.
stylefeng
.
guns
.
base
.
sm
s
;
import
lombok.Data
;
...
...
guns-vip-main/src/main/resources/application-local.yml
View file @
94e17977
...
...
@@ -41,13 +41,6 @@ spring:
username
:
sn93@qq.com
password
:
xxxpassword
# 阿里云短信发送配置
aliyun
:
sms
:
accessKeyId
:
xxxkey
accessKeySecret
:
xxxSecret
signName
:
mySignName
# 邮件发送(改为自己的账号)
mail
:
from
:
sn93@qq.com
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