Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
8timerv2
8timerapiv200
Commits
edd5a22c
Commit
edd5a22c
authored
Apr 11, 2020
by
dengshichuan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dsc' into 'develop'
短信模板枚举类,阿里云短信常量优化 See merge request 8timerv2/8timerapiv200!23
parents
65cd1bec
a3e64ae2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
59 deletions
+75
-59
src/main/java/cn/timer/api/config/enums/PinType.java
+27
-0
src/main/java/cn/timer/api/utils/AliyunSMS.java
+43
-54
src/main/java/cn/timer/api/utils/RemindUtil.java
+5
-5
No files found.
src/main/java/cn/timer/api/config/enums/PinType.java
0 → 100644
View file @
edd5a22c
package
cn
.
timer
.
api
.
config
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @title 短信模板
* @author dsc
*
*/
@Getter
@AllArgsConstructor
public
enum
PinType
{
AUTHENTICATION
(
"SMS_178485364"
,
"身份验证"
),
LOGIN_CONFIRMATION
(
"SMS_178485363"
,
"登录确认"
),
LOGIN_ABNORMAL
(
"SMS_178485362"
,
"登录异常"
),
REGISTER
(
"SMS_178485361"
,
"用户注册"
),
CHANGE_PASSWORD
(
"SMS_178485360"
,
"修改密码"
),
CHANGE_INFORMATION
(
"SMS_178485359"
,
"信息变更"
),
REMIND
(
"SMS_180347486"
,
"短信提醒"
);
private
final
String
code
;
private
final
String
message
;
}
src/main/java/cn/timer/api/utils/AliyunSMS.java
View file @
edd5a22c
...
...
@@ -12,6 +12,7 @@ import com.aliyuncs.exceptions.ServerException;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
cn.timer.api.config.enums.PinType
;
import
cn.timer.api.dto.qyzx.EntRegisterDto
;
/**
...
...
@@ -22,11 +23,18 @@ import cn.timer.api.dto.qyzx.EntRegisterDto;
*/
public
class
AliyunSMS
{
final
String
name
=
"TemplateCode"
;
// 模板参数
final
String
regionId
=
"cn-shenzhen"
;
// 地区参数
final
String
projectName
=
"8小时人事管家"
;
// 项目名
final
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
final
String
secret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
final
static
String
CODE_NAME
=
"TemplateCode"
;
// 短信模板代码参数名
final
static
String
REGION_ID
=
"cn-shenzhen"
;
// 地区参数
final
static
String
PROJECT_NAME
=
"8小时人事管家"
;
// 项目名
final
static
String
ACCESSKEY_ID
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
final
static
String
SECRET
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
final
static
String
TEMPLATE_PARAM
=
"TemplateParam"
;
// 自定义参数
final
static
String
DOMAIN
=
"dysmsapi.aliyuncs.com"
;
final
static
String
VERSION
=
"2017-05-25"
;
final
static
String
ACTION_SEND
=
"SendSms"
;
// 发短信
final
static
String
ACTION_QUERY
=
"QuerySendDetails"
;
// 短信查询
final
static
String
PAGE_SIZE
=
"1"
;
final
static
String
CURRENT_PAGE
=
"1"
;
/**
*
...
...
@@ -40,48 +48,42 @@ public class AliyunSMS {
String
phone
=
entRegisterDto
.
getPhone
();
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
regionId
,
accessKeyId
,
secret
);
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
REGION_ID
,
ACCESSKEY_ID
,
SECRET
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
CommonRequest
request
=
new
CommonRequest
();
request
.
setMethod
(
MethodType
.
POST
);
request
.
setDomain
(
"dysmsapi.aliyuncs.com"
);
request
.
setVersion
(
"2017-05-25"
);
request
.
setAction
(
"SendSms"
);
request
.
putQueryParameter
(
"RegionId"
,
regionId
);
request
.
setDomain
(
DOMAIN
);
request
.
setVersion
(
VERSION
);
request
.
setAction
(
ACTION_SEND
);
request
.
putQueryParameter
(
"RegionId"
,
REGION_ID
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
phone
);
request
.
putQueryParameter
(
"SignName"
,
projectName
);
request
.
putQueryParameter
(
"SignName"
,
PROJECT_NAME
);
switch
(
templateCode
)
{
// 1."身份验证验证码"
case
1
:
request
.
putQueryParameter
(
name
,
"SMS_178485364"
);
request
.
putQueryParameter
(
CODE_NAME
,
PinType
.
AUTHENTICATION
.
getCode
()
);
break
;
// 2."登录确认验证码"
case
2
:
request
.
putQueryParameter
(
name
,
"SMS_178485363"
);
request
.
putQueryParameter
(
CODE_NAME
,
PinType
.
LOGIN_CONFIRMATION
.
getCode
()
);
break
;
// 3."登录异常验证码"
case
3
:
request
.
putQueryParameter
(
name
,
"SMS_178485362"
);
request
.
putQueryParameter
(
CODE_NAME
,
PinType
.
LOGIN_ABNORMAL
.
getCode
()
);
break
;
// 4."用户注册验证码"
case
4
:
request
.
putQueryParameter
(
name
,
"SMS_178485361"
);
request
.
putQueryParameter
(
CODE_NAME
,
PinType
.
REGISTER
.
getCode
()
);
break
;
// 5."修改密码验证码"
case
5
:
request
.
putQueryParameter
(
name
,
"SMS_178485360"
);
request
.
putQueryParameter
(
CODE_NAME
,
PinType
.
CHANGE_PASSWORD
.
getCode
()
);
break
;
// 6."信息变更验证码"
case
6
:
request
.
putQueryParameter
(
name
,
"SMS_178485359"
);
request
.
putQueryParameter
(
CODE_NAME
,
PinType
.
CHANGE_INFORMATION
.
getCode
()
);
break
;
default
:
request
.
putQueryParameter
(
name
,
"SMS_178485364"
);
request
.
putQueryParameter
(
CODE_NAME
,
PinType
.
AUTHENTICATION
.
getCode
()
);
}
// 【8小时人事管家】验证码934169,您正在尝试修改登录密码,请妥善保管账户信息。
request
.
putQueryParameter
(
"TemplateParam"
,
"{\"code\":\""
+
code
+
"\"}"
);
request
.
putQueryParameter
(
TEMPLATE_PARAM
,
"{\"code\":\""
+
code
+
"\"}"
);
CommonResponse
response
=
null
;
try
{
response
=
client
.
getCommonResponse
(
request
);
...
...
@@ -99,20 +101,19 @@ public class AliyunSMS {
*/
@SuppressWarnings
(
"deprecation"
)
public
String
QuerySendDetails
(
String
phone
,
String
date
,
String
bizId
)
{
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-shenzhen"
,
"LTAI4FuaShJWQ1dggsFWG5CC"
,
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
);
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
REGION_ID
,
ACCESSKEY_ID
,
SECRET
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
CommonRequest
request
=
new
CommonRequest
();
request
.
setMethod
(
MethodType
.
POST
);
request
.
setDomain
(
"dysmsapi.aliyuncs.com"
);
request
.
setVersion
(
"2017-05-25"
);
request
.
setAction
(
"QuerySendDetails"
);
request
.
putQueryParameter
(
"RegionId"
,
"cn-shenzhen"
);
request
.
setDomain
(
DOMAIN
);
request
.
setVersion
(
VERSION
);
request
.
setAction
(
ACTION_QUERY
);
request
.
putQueryParameter
(
"RegionId"
,
REGION_ID
);
request
.
putQueryParameter
(
"PhoneNumber"
,
phone
);
request
.
putQueryParameter
(
"SendDate"
,
date
);
request
.
putQueryParameter
(
"PageSize"
,
"1"
);
request
.
putQueryParameter
(
"CurrentPage"
,
"1"
);
request
.
putQueryParameter
(
"PageSize"
,
PAGE_SIZE
);
request
.
putQueryParameter
(
"CurrentPage"
,
CURRENT_PAGE
);
request
.
putQueryParameter
(
"BizId"
,
bizId
);
String
a
=
null
;
try
{
...
...
@@ -139,21 +140,20 @@ public class AliyunSMS {
* @param phone
*/
@SuppressWarnings
(
"deprecation"
)
public
static
void
tx
(
String
name
,
String
htname
,
String
time
,
String
phone
)
{
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-shenzhen"
,
"LTAI4FuaShJWQ1dggsFWG5CC"
,
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
);
public
static
void
remind
(
String
name
,
String
htname
,
String
time
,
String
phone
)
{
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
REGION_ID
,
ACCESSKEY_ID
,
SECRET
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
CommonRequest
request
=
new
CommonRequest
();
request
.
setMethod
(
MethodType
.
POST
);
request
.
setDomain
(
"dysmsapi.aliyuncs.com"
);
request
.
setVersion
(
"2017-05-25"
);
request
.
setAction
(
"SendSms"
);
request
.
putQueryParameter
(
"RegionId"
,
"cn-shenzhen"
);
request
.
setDomain
(
DOMAIN
);
request
.
setVersion
(
VERSION
);
request
.
setAction
(
ACTION_SEND
);
request
.
putQueryParameter
(
"RegionId"
,
REGION_ID
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
phone
);
request
.
putQueryParameter
(
"SignName"
,
"8小时人事管家"
);
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_180347486"
);
request
.
putQueryParameter
(
"TemplateParam"
,
request
.
putQueryParameter
(
"SignName"
,
PROJECT_NAME
);
request
.
putQueryParameter
(
CODE_NAME
,
PinType
.
REMIND
.
getCode
()
);
request
.
putQueryParameter
(
TEMPLATE_PARAM
,
"{\"name\":\""
+
name
+
"\", \"htname\":\""
+
htname
+
"\",\"time\":\""
+
time
+
"\"}"
);
try
{
CommonResponse
response
=
client
.
getCommonResponse
(
request
);
...
...
@@ -165,15 +165,4 @@ public class AliyunSMS {
}
}
// public static void main(String[] args) {
// AliyunSMS a = new AliyunSMS();
// EntRegisterDto entRegisterDto = new EntRegisterDto();
// entRegisterDto.setPhone("18711519124");
// String a1 = a.yzm(entRegisterDto, 1, 123456);
// JSONObject json = new JSONObject(a1);
// String bizId = (String) json.get("BizId");
// // 流水号
// System.err.println("bizId:"+bizId);
// }
}
src/main/java/cn/timer/api/utils/RemindUtil.java
View file @
edd5a22c
...
...
@@ -30,7 +30,7 @@ public class RemindUtil {
private
static
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
/**
* 间隔时间提醒
1
0min/次
* 间隔时间提醒
3
0min/次
*/
@Scheduled
(
fixedRate
=
30
*
60
*
1000
)
private
void
now
()
{
...
...
@@ -64,13 +64,13 @@ public class RemindUtil {
System
.
err
.
println
(
betweenDay
);
if
(
sjc
>
0
)
{
if
(
betweenDay
<=
1
)
{
AliyunSMS
.
tx
(
name
,
htname
,
time
,
phone
);
// 少于1天短信提醒
AliyunSMS
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于1天短信提醒
}
else
if
(
betweenDay
==
3
)
{
AliyunSMS
.
tx
(
name
,
htname
,
time
,
phone
);
// 少于3天短信提醒
AliyunSMS
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于3天短信提醒
}
else
if
(
betweenDay
==
7
)
{
AliyunSMS
.
tx
(
name
,
htname
,
time
,
phone
);
// 少于7天短信提醒
AliyunSMS
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于7天短信提醒
}
else
if
(
betweenDay
==
30
)
{
AliyunSMS
.
tx
(
name
,
htname
,
time
,
phone
);
// 少于30天短信提醒
AliyunSMS
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于30天短信提醒
}
}
else
{
...
...
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