Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
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
吴学德
gdtel-gztel-school-center
Commits
ad05a5b0
Commit
ad05a5b0
authored
Mar 31, 2020
by
黄森林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信接口
parent
edee60b1
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1092 additions
and
9 deletions
+1092
-9
common/src/main/java/com/winsun/smsUtils/ByteFormat.java
+188
-0
common/src/main/java/com/winsun/smsUtils/GetAccessToken.java
+59
-0
common/src/main/java/com/winsun/smsUtils/HMACSHA1.java
+41
-0
common/src/main/java/com/winsun/smsUtils/HttpUtil.java
+191
-0
common/src/main/java/com/winsun/smsUtils/RequestParasUtil.java
+132
-0
common/src/main/java/com/winsun/smsUtils/SendSmsAndMail.java
+155
-0
common/src/main/java/com/winsun/smsUtils/StringUtil.java
+59
-0
common/src/main/java/com/winsun/smsUtils/XXTea.java
+226
-0
core-service/src/main/java/com/winsun/item/modular/system/controller/GetPhoneCodeController.java
+25
-4
core-service/src/main/java/com/winsun/item/modular/system/controller/LoginPwdController.java
+16
-3
service-manager/src/main/java/com/winsun/controller/UniversityInfoController.java
+0
-2
No files found.
common/src/main/java/com/winsun/smsUtils/ByteFormat.java
0 → 100644
View file @
ad05a5b0
package
com
.
winsun
.
smsUtils
;
public
class
ByteFormat
{
//字符集转�?
public
static
final
String
bytesToHexString
(
byte
[]
bArray
)
{
StringBuffer
sb
=
new
StringBuffer
(
bArray
.
length
);
String
sTemp
;
for
(
int
i
=
0
;
i
<
bArray
.
length
;
i
++)
{
sTemp
=
Integer
.
toHexString
(
0xFF
&
bArray
[
i
]);
if
(
sTemp
.
length
()
<
2
)
sb
.
append
(
0
);
sb
.
append
(
sTemp
.
toUpperCase
());
}
return
sb
.
toString
();
}
/**
* 将byte数组转换为十六进制文�?
* @param buf
* @return
*/
public
static
String
toHex
(
byte
[]
buf
)
{
if
(
buf
==
null
||
buf
.
length
==
0
)
{
return
""
;
}
StringBuilder
out
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
buf
.
length
;
i
++
){
out
.
append
(
HEX
[
(
buf
[
i
]>>
4
)
&
0x0f
]
).
append
(
HEX
[
buf
[
i
]
&
0x0f
]
);
}
return
out
.
toString
();
}
/**
* 将十六进制文本转换为byte数组
* @param str
* @return
*/
public
static
byte
[]
hexToBytes
(
String
str
)
{
if
(
str
==
null
)
{
return
null
;
}
char
[]
hex
=
str
.
toCharArray
();
int
length
=
hex
.
length
/
2
;
byte
[]
raw
=
new
byte
[
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
int
high
=
Character
.
digit
(
hex
[
i
*
2
],
16
);
int
low
=
Character
.
digit
(
hex
[
i
*
2
+
1
],
16
);
int
value
=
(
high
<<
4
)
|
low
;
if
(
value
>
127
)
value
-=
256
;
raw
[
i
]
=
(
byte
)
value
;
}
return
raw
;
}
/**
* 将byte数组转换为格式化的十六进制文�?
* @param buf
* @return
*/
public
static
String
dumpHex
(
byte
[]
buf
)
{
if
(
buf
==
null
)
{
return
""
;
}
return
dumpHex
(
buf
,
0
,
buf
.
length
);
}
/**
* 将byte数组转换为格式化的十六进制文�?
* @param buf
* @parm offset
* @param numBytes
* @return
*/
public
static
String
dumpHex
(
byte
[]
buf
,
int
offset
,
int
numBytes
)
{
if
(
buf
==
null
||
buf
.
length
==
0
)
{
return
""
;
}
if
(
offset
>=
buf
.
length
)
{
offset
=
buf
.
length
-
1
;
}
if
(
numBytes
>
buf
.
length
-
offset
)
{
numBytes
=
buf
.
length
-
offset
;
}
StringBuffer
out
=
new
StringBuffer
();
int
rows
,
residue
,
i
,
j
;
byte
[]
save_buf
=
new
byte
[
ROW_BYTES
+
2
];
char
[]
hex_buf
=
new
char
[
4
];
char
[]
idx_buf
=
new
char
[
8
];
rows
=
numBytes
>>
4
;
residue
=
numBytes
&
0x0000000F
;
for
(
i
=
0
;
i
<
rows
;
i
++
)
{
int
hexVal
=
(
i
*
ROW_BYTES
);
idx_buf
[
0
]
=
HEX
[
((
hexVal
>>
12
)
&
15
)
];
idx_buf
[
1
]
=
HEX
[
((
hexVal
>>
8
)
&
15
)
];
idx_buf
[
2
]
=
HEX
[
((
hexVal
>>
4
)
&
15
)
];
idx_buf
[
3
]
=
HEX
[
(
hexVal
&
15
)
];
String
idxStr
=
new
String
(
idx_buf
,
0
,
4
);
out
.
append
(
idxStr
+
": "
);
for
(
j
=
0
;
j
<
ROW_BYTES
;
j
++
)
{
save_buf
[
j
]
=
buf
[
offset
+
(
i
*
ROW_BYTES
)
+
j
];
hex_buf
[
0
]
=
HEX
[
(
save_buf
[
j
]
>>
4
)
&
0x0F
];
hex_buf
[
1
]
=
HEX
[
save_buf
[
j
]
&
0x0F
];
out
.
append
(
hex_buf
[
0
]
);
out
.
append
(
hex_buf
[
1
]
);
out
.
append
(
' '
);
if
(
j
==
ROW_QTR1
||
j
==
ROW_HALF
||
j
==
ROW_QTR2
)
out
.
append
(
' '
);
if
(
save_buf
[
j
]
<
0x20
||
save_buf
[
j
]
>
0x7E
)
save_buf
[
j
]
=
(
byte
)
'.'
;
}
String
saveStr
=
new
String
(
save_buf
,
0
,
j
);
out
.
append
(
" ; "
+
saveStr
+
"\n"
);
}
if
(
residue
>
0
)
{
int
hexVal
=
(
i
*
ROW_BYTES
);
idx_buf
[
0
]
=
HEX
[
((
hexVal
>>
12
)
&
15
)
];
idx_buf
[
1
]
=
HEX
[
((
hexVal
>>
8
)
&
15
)
];
idx_buf
[
2
]
=
HEX
[
((
hexVal
>>
4
)
&
15
)
];
idx_buf
[
3
]
=
HEX
[
(
hexVal
&
15
)
];
String
idxStr
=
new
String
(
idx_buf
,
0
,
4
);
out
.
append
(
idxStr
+
": "
);
for
(
j
=
0
;
j
<
residue
;
j
++
)
{
save_buf
[
j
]
=
buf
[
offset
+
(
i
*
ROW_BYTES
)
+
j
];
hex_buf
[
0
]
=
HEX
[
(
save_buf
[
j
]
>>
4
)
&
0x0F
];
hex_buf
[
1
]
=
HEX
[
save_buf
[
j
]
&
0x0F
];
out
.
append
(
(
char
)
hex_buf
[
0
]
);
out
.
append
(
(
char
)
hex_buf
[
1
]
);
out
.
append
(
' '
);
if
(
j
==
ROW_QTR1
||
j
==
ROW_HALF
||
j
==
ROW_QTR2
)
out
.
append
(
' '
);
if
(
save_buf
[
j
]
<
0x20
||
save_buf
[
j
]
>
0x7E
)
save_buf
[
j
]
=
(
byte
)
'.'
;
}
for
(
/*j INHERITED*/
;
j
<
ROW_BYTES
;
j
++
)
{
save_buf
[
j
]
=
(
byte
)
' '
;
out
.
append
(
" "
);
if
(
j
==
ROW_QTR1
||
j
==
ROW_HALF
||
j
==
ROW_QTR2
)
out
.
append
(
" "
);
}
String
saveStr
=
new
String
(
save_buf
,
0
,
j
);
out
.
append
(
" ; "
+
saveStr
+
"\n"
);
}
return
out
.
toString
();
}
private
final
static
char
[]
HEX
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
private
static
final
int
ROW_BYTES
=
16
;
private
static
final
int
ROW_QTR1
=
3
;
private
static
final
int
ROW_HALF
=
7
;
private
static
final
int
ROW_QTR2
=
11
;
}
common/src/main/java/com/winsun/smsUtils/GetAccessToken.java
0 → 100644
View file @
ad05a5b0
package
com
.
winsun
.
smsUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 令牌获取
*/
public
class
GetAccessToken
{
public
static
void
main
(
String
[]
args
)
{
// String url = "http://183.61.185.118:8082/sendApi/auth/getAccessToken"; //测试
String
url
=
"https://ytx.21cn.com/sendApi/auth/getAccessToken"
;
//生产
String
appKey
=
"6SXyMB2IG"
;
String
appSecret
=
"92a1861c7a94a49fb165a22cb0d7dfad14196c25"
;
String
version
=
"2.0v"
;
String
format
=
"json"
;
String
clientType
=
"10001"
;
Map
<
String
,
String
>
requestData
=
new
HashMap
<>();
requestData
.
put
(
"timeStamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
RequestParasUtil
.
setParas
(
requestData
,
appKey
,
appSecret
,
version
,
format
,
clientType
);
try
{
String
test
=
HttpUtil
.
httpPostMethodNoReTryWithStr
(
url
,
requestData
);
System
.
out
.
println
(
test
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
String
getAccessToken
(){
String
url
=
"https://ytx.21cn.com/sendApi/auth/getAccessToken"
;
//生产
String
appKey
=
"6SXyMB2IG"
;
String
appSecret
=
"92a1861c7a94a49fb165a22cb0d7dfad14196c25"
;
String
version
=
"2.0v"
;
String
format
=
"json"
;
String
clientType
=
"10001"
;
Map
<
String
,
String
>
requestData
=
new
HashMap
<>();
requestData
.
put
(
"timeStamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
System
.
out
.
println
(
requestData
);
RequestParasUtil
.
setParas
(
requestData
,
appKey
,
appSecret
,
version
,
format
,
clientType
);
try
{
System
.
out
.
println
(
requestData
);
String
accesstoken
=
HttpUtil
.
httpPostMethodNoReTryWithStr
(
url
,
requestData
);
System
.
out
.
println
(
accesstoken
);
return
accesstoken
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
common/src/main/java/com/winsun/smsUtils/HMACSHA1.java
0 → 100644
View file @
ad05a5b0
package
com
.
winsun
.
smsUtils
;
import
javax.crypto.Mac
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
public
class
HMACSHA1
{
private
static
final
String
HMAC_SHA1
=
"HmacSHA1"
;
/**
* 生成签名数据
*
* @param data 待加密的数据
* @param key 加密使用的key
* @throws InvalidKeyException
* @throws NoSuchAlgorithmException
*/
public
static
String
getSignature
(
String
data
,
String
key
)
throws
Exception
{
byte
[]
keyBytes
=
key
.
getBytes
();
SecretKeySpec
signingKey
=
new
SecretKeySpec
(
keyBytes
,
HMAC_SHA1
);
Mac
mac
=
Mac
.
getInstance
(
HMAC_SHA1
);
mac
.
init
(
signingKey
);
byte
[]
rawHmac
=
mac
.
doFinal
(
data
.
getBytes
()
);
StringBuilder
sb
=
new
StringBuilder
();
for
(
byte
b
:
rawHmac
)
{
sb
.
append
(
byteToHexString
(
b
)
);
}
return
sb
.
toString
();
}
private
static
String
byteToHexString
(
byte
ib
)
{
char
[]
Digit
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
char
[]
ob
=
new
char
[
2
];
ob
[
0
]
=
Digit
[(
ib
>>>
4
)
&
0X0f
];
ob
[
1
]
=
Digit
[
ib
&
0X0F
];
String
s
=
new
String
(
ob
);
return
s
;
}
}
common/src/main/java/com/winsun/smsUtils/HttpUtil.java
0 → 100644
View file @
ad05a5b0
package
com
.
winsun
.
smsUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpHost
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
HttpUtil
{
public
static
int
httpPostMethodNoReTry
(
String
url
,
Map
<
String
,
String
>
pairs
)
throws
Exception
{
String
ret
=
""
;
int
statusCode
=
0
;
CloseableHttpClient
httpclient
=
null
;
HttpPost
request
=
null
;
try
{
httpclient
=
HttpClients
.
createDefault
();
request
=
new
HttpPost
(
url
);
/** 请求参数 */
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
for
(
Map
.
Entry
<
String
,
String
>
e
:
pairs
.
entrySet
()
)
{
nvps
.
add
(
new
BasicNameValuePair
(
e
.
getKey
(),
e
.
getValue
()
)
);
}
request
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
,
"UTF-8"
)
);
/** 超时时间 5s 重试次数 3 */
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
5000
)
.
setConnectTimeout
(
5000
).
build
();
// 设置请求和传输超时时�?
request
.
setConfig
(
requestConfig
);
// 发�?�请�?
CloseableHttpResponse
response
=
httpclient
.
execute
(
request
);
HttpEntity
entity
=
response
.
getEntity
();
ret
=
EntityUtils
.
toString
(
entity
);
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
if
(
(
statusCode
+
""
).
charAt
(
0
)
!=
'2'
)
{
// 返回�?2XX以外属于请求不成功范�?
throw
new
Exception
(
"请求失败"
);
}
}
catch
(
Exception
e
)
{
throw
new
Exception
(
e
);
}
finally
{
if
(
null
!=
request
)
{
request
.
releaseConnection
();
}
}
return
statusCode
;
}
public
static
String
httpPostMethodNoReTryWithStr
(
String
url
,
Map
<
String
,
String
>
pairs
)
throws
Exception
{
String
ret
=
""
;
int
statusCode
=
0
;
CloseableHttpClient
httpclient
=
null
;
HttpPost
request
=
null
;
try
{
httpclient
=
HttpClients
.
createDefault
();
request
=
new
HttpPost
(
url
);
/** 请求参数 */
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
for
(
Map
.
Entry
<
String
,
String
>
e
:
pairs
.
entrySet
())
{
nvps
.
add
(
new
BasicNameValuePair
(
e
.
getKey
(),
e
.
getValue
()));
}
request
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
,
"UTF-8"
));
/** 超时时间 5s 重试次数 3 */
HttpHost
proxy
=
new
HttpHost
(
"172.18.101.170"
,
3128
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
20000
).
setSocketTimeout
(
20000
)
.
setProxy
(
proxy
).
build
();
request
.
setConfig
(
requestConfig
);
// 发�?�请�?
System
.
out
.
println
(
request
);
CloseableHttpResponse
response
=
httpclient
.
execute
(
request
);
HttpEntity
entity
=
response
.
getEntity
();
ret
=
EntityUtils
.
toString
(
entity
);
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
if
((
statusCode
+
""
).
charAt
(
0
)
!=
'2'
)
{
// 返回�?2XX以外属于请求不成功范�?
throw
new
Exception
(
"request error"
);
}
else
{
return
ret
;
}
}
catch
(
Exception
e
)
{
throw
new
Exception
(
e
);
}
finally
{
if
(
null
!=
request
)
{
request
.
releaseConnection
();
}
}
}
/**
* 功能描述�? 以post的方式发送请�?
*
* @param url
* @param pairs
* 参数键�?�对
* @return
*
*/
public
static
String
httpPostMethod
(
String
url
,
Map
<
String
,
String
>
pairs
)
{
String
ret
=
""
;
int
statusCode
=
0
;
CloseableHttpClient
httpclient
=
null
;
HttpPost
request
=
null
;
try
{
httpclient
=
HttpClients
.
createDefault
();
request
=
new
HttpPost
(
url
);
/** 请求参数 */
if
(
null
!=
pairs
){
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
for
(
Map
.
Entry
<
String
,
String
>
e
:
pairs
.
entrySet
())
{
nvps
.
add
(
new
BasicNameValuePair
(
e
.
getKey
(),
e
.
getValue
()));
}
request
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
,
"UTF-8"
));
}
/** 超时时间 5s 重试次数 3 */
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
5000
).
setConnectTimeout
(
5000
).
build
();
// 设置请求和传输超时时�?
request
.
setConfig
(
requestConfig
);
// 发�?�请�?
CloseableHttpResponse
response
=
httpclient
.
execute
(
request
);
HttpEntity
entity
=
response
.
getEntity
();
ret
=
EntityUtils
.
toString
(
entity
);
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
/** 处理对方服务器redirect的情�? 返回302/303 再次发�?�请求到重定向地�? */
if
(
statusCode
==
HttpStatus
.
SC_MOVED_PERMANENTLY
||
statusCode
==
HttpStatus
.
SC_MOVED_TEMPORARILY
)
{
String
locationUrl
=
response
.
getLastHeader
(
"Location"
).
getValue
();
if
(
StringUtils
.
isNotBlank
(
locationUrl
))
{
ret
=
httpPostMethod
(
locationUrl
,
pairs
);
// 用跳转后的页面重新请求�??
}
}
else
if
((
statusCode
+
""
).
charAt
(
0
)
!=
'2'
)
{
// 返回�?2XX以外属于请求不成功范�?
return
""
;
}
}
catch
(
Exception
e
)
{
try
{
e
.
printStackTrace
();
Thread
.
sleep
(
20L
);
CloseableHttpResponse
response
=
httpclient
.
execute
(
request
);
HttpEntity
entity
=
response
.
getEntity
();
ret
=
EntityUtils
.
toString
(
entity
);
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
}
}
finally
{
if
(
null
!=
request
)
{
request
.
releaseConnection
();
}
}
return
ret
;
}
public
static
String
httpPostMethod
(
String
url
)
throws
Exception
{
String
ret
=
""
;
int
statusCode
=
0
;
CloseableHttpClient
httpclient
=
null
;
HttpGet
request
=
null
;
try
{
httpclient
=
HttpClients
.
createDefault
();
request
=
new
HttpGet
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
5000
)
.
setConnectTimeout
(
5000
).
build
();
// 设置请求和传输超时时�?
request
.
setConfig
(
requestConfig
);
// 发�?�请�?
CloseableHttpResponse
response
=
httpclient
.
execute
(
request
);
HttpEntity
entity
=
response
.
getEntity
();
ret
=
EntityUtils
.
toString
(
entity
);
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
/** 处理对方服务器redirect的情�? 返回302/303 再次发�?�请求到重定向地�? */
if
((
statusCode
+
""
).
charAt
(
0
)
!=
'2'
)
{
// 返回�?2XX以外属于请求不成功范�?
throw
new
Exception
(
"查询失败"
);
}
return
ret
;
}
finally
{
if
(
null
!=
request
)
{
request
.
releaseConnection
();
}
}
}
}
common/src/main/java/com/winsun/smsUtils/RequestParasUtil.java
0 → 100644
View file @
ad05a5b0
package
com
.
winsun
.
smsUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
public
class
RequestParasUtil
{
public
RequestParasUtil
()
{
}
/**
* 加密,获取签名
* @param plainText
* @param appSecret
* @return
*/
public
static
String
generateHmacSignature
(
String
plainText
,
String
appSecret
)
{
String
signature
=
null
;
try
{
long
begin
=
System
.
currentTimeMillis
();
signature
=
HMACSHA1
.
getSignature
(
plainText
,
appSecret
);
}
catch
(
Exception
var5
)
{
var5
.
printStackTrace
();
}
return
signature
;
}
/**
* 平台通用接口封装方式
* @param requestData
* @param appKey
* @param appSecret
* @param version
* @param format
* @param clientType
*/
public
static
void
setParas
(
Map
<
String
,
String
>
requestData
,
String
appKey
,
String
appSecret
,
String
version
,
String
format
,
String
clientType
)
{
if
(
requestData
==
null
)
{
}
else
if
(
appKey
!=
null
&&
version
!=
null
&&
clientType
!=
null
)
{
format
=
format
==
null
?
"json"
:
format
;
String
cipherParas
=
generateXXTeaParasData
(
requestData
,
appSecret
);
requestData
.
clear
();
requestData
.
put
(
"appKey"
,
appKey
);
requestData
.
put
(
"version"
,
version
);
requestData
.
put
(
"clientType"
,
clientType
);
requestData
.
put
(
"format"
,
format
);
requestData
.
put
(
"paras"
,
cipherParas
);
// System.out.println("appSecret:"+appSecret);
String
plainSig
=
appKey
+
clientType
+
format
+
version
+
cipherParas
;
requestData
.
put
(
"sign"
,
generateHmacSignature
(
plainSig
,
appSecret
));
}
else
{
}
}
private
static
String
generateXXTeaParasData
(
Map
<
String
,
String
>
requestData
,
String
appSecret
)
{
try
{
StringBuffer
xxTeaText
=
new
StringBuffer
();
if
(
requestData
!=
null
&&
requestData
.
size
()
>=
1
)
{
String
name
;
String
value
;
for
(
Iterator
var4
=
requestData
.
entrySet
().
iterator
();
var4
.
hasNext
();
xxTeaText
.
append
(
name
+
"="
+
value
+
"&"
))
{
Map
.
Entry
<
String
,
String
>
entry
=
(
Map
.
Entry
)
var4
.
next
();
name
=
(
String
)
entry
.
getKey
();
value
=
""
;
if
(
"returnURL"
.
equals
(
name
))
{
value
=
URLEncoder
.
encode
((
String
)
entry
.
getValue
(),
"utf-8"
);
}
else
{
value
=
(
String
)
entry
.
getValue
();
}
}
if
(!
requestData
.
containsKey
(
"timeStamp"
))
{
xxTeaText
.
append
(
"timeStamp="
+
getTimeStamp
());
}
return
XXTea
.
encrypt
(
xxTeaText
.
toString
(),
"UTF-8"
,
StringUtil
.
toHex
(
appSecret
.
getBytes
()));
}
else
{
return
null
;
}
}
catch
(
Exception
var7
)
{
var7
.
printStackTrace
();
return
null
;
}
}
public
static
Map
<
String
,
String
>
parseXXTeaParasData
(
String
xxTeaText
,
String
appSecret
)
throws
Exception
{
Map
<
String
,
String
>
requestDataMap
=
null
;
try
{
long
begin
=
System
.
currentTimeMillis
();
String
plainParasText
=
XXTea
.
decrypt
(
xxTeaText
,
"UTF-8"
,
StringUtil
.
toHex
(
appSecret
.
getBytes
()));
requestDataMap
=
splitParameters
(
plainParasText
);
return
requestDataMap
;
}
catch
(
Exception
var4
)
{
var4
.
printStackTrace
();
throw
new
Exception
(
"XXTea-decypt-error"
);
}
}
private
static
Map
<
String
,
String
>
splitParameters
(
String
paraStr
)
{
Map
<
String
,
String
>
parameters
=
new
HashMap
<>();
if
(
StringUtils
.
isNotBlank
(
paraStr
))
{
String
[]
array
=
paraStr
.
trim
().
split
(
"&"
);
String
[]
var6
=
array
;
int
var5
=
array
.
length
;
for
(
int
var4
=
0
;
var4
<
var5
;
++
var4
)
{
String
temp
=
var6
[
var4
];
if
(
StringUtils
.
isNotBlank
(
temp
))
{
temp
=
temp
.
trim
();
int
index
=
temp
.
indexOf
(
"="
);
if
(
index
>
0
)
{
String
key
=
temp
.
substring
(
0
,
index
);
String
value
=
temp
.
substring
(
index
+
1
);
if
(
StringUtils
.
isNotBlank
(
key
)
&&
StringUtils
.
isNotBlank
(
value
))
{
parameters
.
put
(
key
.
trim
(),
value
.
trim
());
}
}
}
}
}
return
parameters
;
}
public
static
String
getTimeStamp
()
{
return
String
.
valueOf
(
System
.
currentTimeMillis
());
}
}
common/src/main/java/com/winsun/smsUtils/SendSmsAndMail.java
0 → 100644
View file @
ad05a5b0
package
com
.
winsun
.
smsUtils
;
import
net.sf.json.JSONObject
;
import
java.util.*
;
public
class
SendSmsAndMail
{
public
static
void
main
(
String
[]
args
)
{
ArrayList
<
String
>
obj
=
new
ArrayList
<
String
>();
List
<
String
>
list
=
Arrays
.
asList
(
"13697427771/t1836@sise.cn/660040Abca"
);
obj
.
addAll
(
list
);
System
.
out
.
println
(
obj
.
size
());
for
(
String
s
:
obj
)
{
String
[]
split
=
s
.
split
(
"/"
);
System
.
out
.
println
(
split
[
0
]+
"--"
+
split
[
1
]+
"---"
+
split
[
2
]);
// System.out.println(sendSms(s,"http://yrym.winsun-aly.com/gdtel-xyzx-hhr/customer/plan.do?orderId=d70f3423a6f","2"));
System
.
out
.
println
(
"返回:"
+
sendSms
(
"11111111111"
,
"111111"
,
"7"
));
}
System
.
out
.
println
(
"发送完成"
);
// String res = BaiduDwz.createShortUrl("http://yrym.winsun-aly.com/gdtel-xyzx-hhr/customer/plan.do?orderId=d70f3423a6f");
// 生成url
// System.out.println(res);
}
/**
* @param contactPhone
* 接收短信的手机号
*/
public
static
String
sendSms
(
String
contactPhone
,
String
preurl
,
String
t
)
{
String
url
=
"https://ytx.21cn.com/sendApi//send/smv"
;
// 生产
String
accessTokenJsonString
=
new
GetAccessToken
().
getAccessToken
();
// 获得accessToken
JSONObject
jsonOne
=
JSONObject
.
fromObject
(
accessTokenJsonString
);
String
accessToken
=
jsonOne
.
get
(
"accessToken"
).
toString
();
String
appKey
=
"6SXyMB2IG"
;
// appKey 固定
String
appSecret
=
"92a1861c7a94a49fb165a22cb0d7dfad14196c25"
;
// 固定的appSecret
String
version
=
"2.0v"
;
// 版本
String
format
=
"json"
;
// 数据类型
String
clientType
=
"10001"
;
Map
<
String
,
String
>
requestData
=
new
HashMap
<>();
requestData
.
put
(
"timeStamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
requestData
.
put
(
"accessToken"
,
accessToken
);
requestData
.
put
(
"type"
,
"1"
);
// type=1 只发短信
requestData
.
put
(
"mobile"
,
contactPhone
);
// 接收短信的联系电
//老客户订单通知
if
(
t
.
equals
(
"1"
)){
//【飞young校园】尊敬的用户,您已成功提交申请!每月25号前提交申请,升级套餐次月生效,25号之后提交申请的,升级套餐则次次月生效.升级新套餐成功后原套餐所有优惠失效不能恢复。如需了解订单详情请点击@_url_@
requestData
.
put
(
"smsTemplateId"
,
"00T3ANwPDbeK"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"url\":\""
+
preurl
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"2"
)){
//【飞young校园】尊敬的客户,您已成功下单!如需了解订单详情请点击@_url_@,如有任何问题请点击订单详情页面右上角,添加客服微信咨询。
requestData
.
put
(
"smsTemplateId"
,
"00SyB8gIpbZg"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"url\":\""
+
preurl
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"3"
)){
//【飞young校园】尊敬的用户:您已完成手机卡的活体认证,请在5分钟后插卡拨打电话进行激活。
requestData
.
put
(
"data"
,
"{}"
);
// 数据
requestData
.
put
(
"smsTemplateId"
,
"00N1kCqpMfDs"
);
// 短信模板id 创建成功
}
else
if
(
t
.
equals
(
"4"
)){
//【飞young校园】尊敬的用户,您是本次套餐升级活动的目标用户,诚邀您开学后到广大商中二楼电信营业厅登记升级,升级套餐为19元60G不限速新黑牛卡套餐。温馨提醒:广州大学室内信号优化已完成,其中包括梅苑,竹苑,兰苑和榕轩。回复T退订
requestData
.
put
(
"data"
,
"{}"
);
// 数据
requestData
.
put
(
"smsTemplateId"
,
"00N3YTcilddg"
);
// 短信模板id 创建成功
}
else
if
(
t
.
equals
(
"5"
)){
//【飞young校园】@_url_@ 尊敬的用户,您已成功提交申请!每月25号前提交申请,升级套餐次月生效,25号之后提交申请的,升级套餐则次次月生效.升级新套餐成功后原套餐所有优惠失效不能恢复。如需了解订单详情请点击连接。
requestData
.
put
(
"smsTemplateId"
,
"00NGrNOhwfTs"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"url\":\""
+
preurl
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"6"
)){
//【飞young校园】尊敬的用户,您已提交校园宽带开户预约单。根据国家实名制规定,请在 7天内点击 @_url_@ 按要求上传照片完成实名认证。如已上传完成,请忽略本信息
requestData
.
put
(
"smsTemplateId"
,
"00NP1ndH2gpU"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"url\":\""
+
preurl
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"7"
)){
//【飞young校园】您获取的验证码为:@_code_@ 半小时后过期,请及时使用。
requestData
.
put
(
"smsTemplateId"
,
"00OCutbVIXGS"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"code\":\""
+
preurl
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"9"
)){
//【飞young校园】尊敬的用户,您已提交校园网绑定申请,请您完成手机卡实名激活后,关注微信公众号“ @_name_@ ”绑定校园网进行提速
requestData
.
put
(
"smsTemplateId"
,
"00OKpTZgHm3E"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"name\":\""
+
preurl
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"12"
)){
//【飞young校园】同学您好,经系统核查,您满足升级为每月70G大流量新套餐的条件,请在1月25日24点前点击“广航D人”公众号菜单栏“校园功能”“升级套餐”办理升级。本优惠将于1月25日24点截止,请尽快在公众号登记。
requestData
.
put
(
"smsTemplateId"
,
"00RFwbnkDsZM"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{}"
);
// 数据
}
else
if
(
t
.
equals
(
"13"
)){
//【飞young校园】同学您好,经系统核查,您满足升级为每月70G大流量新套餐的条件,请在1月25日24点前点击“广航D人”公众号菜单栏“校园功能”“升级套餐”办理升级。本优惠将于1月25日24点截止,请尽快在公众号登记。
requestData
.
put
(
"smsTemplateId"
,
"00RqWcH8X1LE"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"name\":\""
+
preurl
+
"\"}"
);
// 数据
}
requestData
.
put
(
"requestId"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
// 16位请求标识码
// 每次不一样就
RequestParasUtil
.
setParas
(
requestData
,
appKey
,
appSecret
,
version
,
format
,
clientType
);
try
{
HttpUtil
.
httpPostMethodNoReTryWithStr
(
url
,
requestData
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
String
sendSms2
(
String
contactPhone
,
String
speed
,
String
name
,
String
t
)
{
String
url
=
"https://ytx.21cn.com/sendApi//send/smv"
;
// 生产
String
accessTokenJsonString
=
new
GetAccessToken
().
getAccessToken
();
// 获得accessToken
JSONObject
jsonOne
=
JSONObject
.
fromObject
(
accessTokenJsonString
);
String
accessToken
=
jsonOne
.
get
(
"accessToken"
).
toString
();
String
appKey
=
"6SXyMB2IG"
;
// appKey 固定
String
appSecret
=
"92a1861c7a94a49fb165a22cb0d7dfad14196c25"
;
// 固定的appSecret
String
version
=
"2.0v"
;
// 版本
String
format
=
"json"
;
// 数据类型
String
clientType
=
"10001"
;
Map
<
String
,
String
>
requestData
=
new
HashMap
<>();
requestData
.
put
(
"timeStamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
requestData
.
put
(
"accessToken"
,
accessToken
);
requestData
.
put
(
"type"
,
"1"
);
// type=1 只发短信
requestData
.
put
(
"mobile"
,
contactPhone
);
// 接收短信的联系电
//老客户订单通知
if
(
t
.
equals
(
"8"
)){
//【飞young校园】尊敬的用户,您的校园网已成功提速到 @_speed_@ ,如有任何疑问可关注微信公众号“ @_name_@ ”咨询。
requestData
.
put
(
"smsTemplateId"
,
"00OKhpE0A3FY"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"speed\":\""
+
speed
+
"\",\"name\":\""
+
name
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"10"
)){
//【飞young校园】尊敬的用户:您好,您已具备校园网提速的条件,您的校园网可提速为 @_speed_@ ,具体操作步骤可关注微信公众号“ @_name_@ ”咨询。
requestData
.
put
(
"smsTemplateId"
,
"00OKpX6Mmvwm"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"speed\":\""
+
speed
+
"\",\"name\":\""
+
name
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"11"
)){
//【飞young校园】尊敬的用户:您好,您已具备校园网提速的条件,您的校园网可提速为 @_speed_@ ,具体操作步骤可关注微信公众号“ @_name_@ ”咨询。
requestData
.
put
(
"smsTemplateId"
,
"00QiOt2Pjygy"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"company\":\""
+
speed
+
"\",\"kuaidi_order\":\""
+
name
+
"\"}"
);
// 数据
}
else
if
(
t
.
equals
(
"12"
)){
//【飞young校园】尊敬的用户:您好!您的校园宽带已开通,宽带账号:@_kd_@,登录密码:@_pass_@ !请保存好账号密码,如有疑问可咨询学校网络中心。祝您生活愉快!
requestData
.
put
(
"smsTemplateId"
,
"00TOMT9K3UPo"
);
// 短信模板id 创建成功
requestData
.
put
(
"data"
,
"{\"kd\":\""
+
speed
+
"\",\"pass\":\""
+
name
+
"\"}"
);
// 数据
}
requestData
.
put
(
"requestId"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
// 16位请求标识码
// 每次不一样就
RequestParasUtil
.
setParas
(
requestData
,
appKey
,
appSecret
,
version
,
format
,
clientType
);
try
{
HttpUtil
.
httpPostMethodNoReTryWithStr
(
url
,
requestData
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
common/src/main/java/com/winsun/smsUtils/StringUtil.java
0 → 100644
View file @
ad05a5b0
package
com
.
winsun
.
smsUtils
;
import
java.io.UnsupportedEncodingException
;
public
class
StringUtil
{
private
static
final
char
digits
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
public
static
boolean
isEmpty
(
String
str
)
{
return
str
==
null
||
str
.
trim
().
length
()
==
0
;
}
public
static
String
toHex
(
byte
byteData
[])
{
return
toHex
(
byteData
,
0
,
byteData
.
length
);
}
public
static
String
toHex
(
String
data
,
String
encode
)
{
try
{
return
toHex
(
data
.
getBytes
(
encode
));
}
catch
(
Exception
e
)
{
}
return
""
;
}
public
static
String
toHex
(
byte
byteData
[],
int
offset
,
int
len
)
{
char
buf
[]
=
new
char
[
len
*
2
];
int
k
=
0
;
for
(
int
i
=
offset
;
i
<
len
;
i
++)
{
buf
[
k
++]
=
digits
[(
byteData
[
i
]
&
255
)
>>
4
];
buf
[
k
++]
=
digits
[
byteData
[
i
]
&
15
];
}
return
new
String
(
buf
);
}
public
static
final
String
DEFAULT_CHARSET
=
"UTF-8"
;
/**
* 判断字符串是否为�?
* @param str
* @return
*/
/**
*
* @param data
* @return
*/
public
static
byte
[]
getBytes
(
String
data
){
byte
[]
bytes
=
new
byte
[]{};
try
{
bytes
=
data
.
getBytes
(
DEFAULT_CHARSET
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
bytes
;
}
}
\ No newline at end of file
common/src/main/java/com/winsun/smsUtils/XXTea.java
0 → 100644
View file @
ad05a5b0
package
com
.
winsun
.
smsUtils
;
/**
* XXTea加解密实�?
*/
public
class
XXTea
{
/**
* 加密
* @param plain 明文
* @param charset 明文字符编码
* @param hexKey 十六进制字符串形式密�?
* @return 十六进制字符串形式密�?
* @throws Exception
*/
public
static
String
encrypt
(
String
plain
,
String
charset
,
String
hexKey
)
throws
Exception
{
if
(
plain
==
null
||
charset
==
null
||
hexKey
==
null
)
{
return
null
;
}
return
ByteFormat
.
toHex
(
encrypt
(
plain
.
getBytes
(
charset
),
ByteFormat
.
hexToBytes
(
hexKey
)));
}
/**
* 解密
* @param cipherHex 十六进制字符串形式密�?
* @param charset 明文字符编码
* @param hexKey 十六进制字符串形式密�?
* @return 明文
* @throws Exception
*/
public
static
String
decrypt
(
String
cipherHex
,
String
charset
,
String
hexKey
)
throws
Exception
{
if
(
cipherHex
==
null
||
charset
==
null
||
hexKey
==
null
)
{
return
null
;
}
return
new
String
(
decrypt
(
ByteFormat
.
hexToBytes
(
cipherHex
),
ByteFormat
.
hexToBytes
(
hexKey
)),
charset
);
}
/**
* 加密
* @param plainData 明文
* @param key 密钥
* @return
*/
public
static
byte
[]
encrypt
(
byte
[]
plainData
,
byte
[]
key
)
{
if
(
plainData
==
null
||
plainData
.
length
==
0
||
key
==
null
)
{
return
null
;
}
return
toByteArray
(
encrypt
(
toIntArray
(
plainData
,
true
),
toIntArray
(
key
,
false
)),
false
);
}
/**
* 解密
* @param cipherData 密文
* @param key 密钥
* @return 明文
*/
public
static
byte
[]
decrypt
(
byte
[]
cipherData
,
byte
[]
key
)
{
if
(
cipherData
==
null
||
cipherData
.
length
==
0
||
key
==
null
)
{
return
null
;
}
return
toByteArray
(
decrypt
(
toIntArray
(
cipherData
,
false
),
toIntArray
(
key
,
false
)),
true
);
}
/**
* Encrypt data with key.
*
* @param v
* @param k
* @return
*/
private
static
int
[]
encrypt
(
int
[]
v
,
int
[]
k
)
{
int
n
=
v
.
length
-
1
;
if
(
n
<
1
)
{
return
v
;
}
if
(
k
.
length
<
4
)
{
int
[]
key
=
new
int
[
4
];
System
.
arraycopy
(
k
,
0
,
key
,
0
,
k
.
length
);
k
=
key
;
}
int
z
=
v
[
n
],
y
=
v
[
0
],
delta
=
0x9E3779B9
,
sum
=
0
,
e
;
int
p
,
q
=
6
+
52
/
(
n
+
1
);
while
(
q
--
>
0
)
{
sum
=
sum
+
delta
;
e
=
sum
>>>
2
&
3
;
for
(
p
=
0
;
p
<
n
;
p
++)
{
y
=
v
[
p
+
1
];
z
=
v
[
p
]
+=
(
z
>>>
5
^
y
<<
2
)
+
(
y
>>>
3
^
z
<<
4
)
^
(
sum
^
y
)
+
(
k
[
p
&
3
^
e
]
^
z
);
}
y
=
v
[
0
];
z
=
v
[
n
]
+=
(
z
>>>
5
^
y
<<
2
)
+
(
y
>>>
3
^
z
<<
4
)
^
(
sum
^
y
)
+
(
k
[
p
&
3
^
e
]
^
z
);
}
return
v
;
}
/**
* Decrypt data with key.
*
* @param v
* @param k
* @return
*/
private
static
int
[]
decrypt
(
int
[]
v
,
int
[]
k
)
{
int
n
=
v
.
length
-
1
;
if
(
n
<
1
)
{
return
v
;
}
if
(
k
.
length
<
4
)
{
int
[]
key
=
new
int
[
4
];
System
.
arraycopy
(
k
,
0
,
key
,
0
,
k
.
length
);
k
=
key
;
}
int
z
=
v
[
n
],
y
=
v
[
0
],
delta
=
0x9E3779B9
,
sum
,
e
;
int
p
,
q
=
6
+
52
/
(
n
+
1
);
sum
=
q
*
delta
;
while
(
sum
!=
0
)
{
e
=
sum
>>>
2
&
3
;
for
(
p
=
n
;
p
>
0
;
p
--)
{
z
=
v
[
p
-
1
];
y
=
v
[
p
]
-=
(
z
>>>
5
^
y
<<
2
)
+
(
y
>>>
3
^
z
<<
4
)
^
(
sum
^
y
)
+
(
k
[
p
&
3
^
e
]
^
z
);
}
z
=
v
[
n
];
y
=
v
[
0
]
-=
(
z
>>>
5
^
y
<<
2
)
+
(
y
>>>
3
^
z
<<
4
)
^
(
sum
^
y
)
+
(
k
[
p
&
3
^
e
]
^
z
);
sum
=
sum
-
delta
;
}
return
v
;
}
/**
* Convert byte array to int array.
*
* @param data
* @param includeLength
* @return
*/
private
static
int
[]
toIntArray
(
byte
[]
data
,
boolean
includeLength
)
{
int
n
=
(((
data
.
length
&
3
)
==
0
)
?
(
data
.
length
>>>
2
)
:
((
data
.
length
>>>
2
)
+
1
));
int
[]
result
;
if
(
includeLength
)
{
result
=
new
int
[
n
+
1
];
result
[
n
]
=
data
.
length
;
}
else
{
result
=
new
int
[
n
];
}
n
=
data
.
length
;
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
result
[
i
>>>
2
]
|=
(
0x000000ff
&
data
[
i
])
<<
((
i
&
3
)
<<
3
);
}
return
result
;
}
/**
* Convert int array to byte array.
*
* @param data
* @param includeLength
* @return
*/
private
static
byte
[]
toByteArray
(
int
[]
data
,
boolean
includeLength
)
{
int
n
=
data
.
length
<<
2
;
if
(
includeLength
)
{
int
m
=
data
[
data
.
length
-
1
];
if
(
m
>
n
||
m
<=
0
)
{
return
null
;
}
else
{
n
=
m
;
}
}
byte
[]
result
=
new
byte
[
n
];
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
result
[
i
]
=
(
byte
)
((
data
[
i
>>>
2
]
>>>
((
i
&
3
)
<<
3
))
&
0xff
);
}
return
result
;
}
public
static
void
main
(
String
args
[]){
String
plainText
=
"dffrrereeeeeeeeeeeeeeeeeeeeeeeerererefffrererefffddfdfdfdfdfdfdf343434343434343ffffrerererere;l;l;ll;;l;l;lffffffffff4343434343434343434343ffffffffffffffffffffffffabcdefgddddddddddddddddddddsdssddssdsdsssddsddddddddddddsdsjj111gfgfgfffffff;llklklklklkkhghghghghgkkkkkkkkkkkkkkkkkkhghjffffffffffffffgao"
;
byte
key
[]
=
"GdWb5dnxhUxFKcE4GqdhL23TndZFYXPy"
.
getBytes
();
try
{
long
t1
=
System
.
currentTimeMillis
();
String
cipherText
=
XXTea
.
encrypt
(
plainText
,
"UTF-8"
,
ByteFormat
.
toHex
(
key
));
System
.
out
.
println
(
cipherText
);
String
pText
=
XXTea
.
decrypt
(
cipherText
,
"UTF-8"
,
ByteFormat
.
toHex
(
key
));
System
.
out
.
println
(
pText
);
long
t2
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
t2
-
t1
);
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
}
}
}
core-service/src/main/java/com/winsun/item/modular/system/controller/GetPhoneCodeController.java
View file @
ad05a5b0
...
@@ -9,7 +9,7 @@ import com.winsun.item.core.shiro.ShiroKit;
...
@@ -9,7 +9,7 @@ import com.winsun.item.core.shiro.ShiroKit;
import
com.winsun.item.core.util.ResponseEntity
;
import
com.winsun.item.core.util.ResponseEntity
;
import
com.winsun.item.modular.system.service.IUserService
;
import
com.winsun.item.modular.system.service.IUserService
;
import
com.winsun.item.util.LoginUtils
;
import
com.winsun.item.util.LoginUtils
;
import
com.winsun.
utils.MessageUt
il
;
import
com.winsun.
smsUtils.SendSmsAndMa
il
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
...
@@ -24,6 +24,8 @@ import java.util.HashMap;
...
@@ -24,6 +24,8 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
/**
* 日志管理的控制器
* 日志管理的控制器
...
@@ -92,7 +94,13 @@ public class GetPhoneCodeController extends BaseController {
...
@@ -92,7 +94,13 @@ public class GetPhoneCodeController extends BaseController {
sent
.
put
(
"message"
,
"发送成功"
);
sent
.
put
(
"message"
,
"发送成功"
);
sent
.
put
(
"code"
,
200
);
sent
.
put
(
"code"
,
200
);
}
else
{
}
else
{
sent
=
MessageUtil
.
sent
(
user
.
getPhone
(),
"2"
,
verificationCode
);
if
(
user
.
getPhone
().
length
()
==
11
){
SendSmsAndMail
.
sendSms
(
user
.
getPhone
(),
verificationCode
,
"7"
);
sent
.
put
(
"message"
,
"发送成功"
);
sent
.
put
(
"code"
,
200
);
}
else
{
sent
.
put
(
"message"
,
"当前用户手机号码不合法!"
);
}
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
log
.
info
(
"错误信息:{}"
,
e
.
getMessage
());
log
.
info
(
"错误信息:{}"
,
e
.
getMessage
());
...
@@ -109,8 +117,21 @@ public class GetPhoneCodeController extends BaseController {
...
@@ -109,8 +117,21 @@ public class GetPhoneCodeController extends BaseController {
String
verificationCode
=
String
.
valueOf
((
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
));
String
verificationCode
=
String
.
valueOf
((
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
));
//5分钟内有效
//5分钟内有效
stringRedisTemplate
.
opsForValue
().
set
(
userId
.
toString
(),
verificationCode
,
1000
*
60
*
5
,
TimeUnit
.
MILLISECONDS
);
stringRedisTemplate
.
opsForValue
().
set
(
userId
.
toString
(),
verificationCode
,
1000
*
60
*
5
,
TimeUnit
.
MILLISECONDS
);
Map
<
String
,
Object
>
sent
=
MessageUtil
.
sent
(
user
.
getPhone
(),
"2"
,
verificationCode
);
Map
<
String
,
Object
>
sent
=
new
HashMap
<>();
return
ResponseEntity
.
newJSON
(
"code"
,
sent
.
get
(
"code"
).
toString
(),
"data"
,
sent
.
get
(
"message"
));
try
{
if
(
user
.
getPhone
().
length
()
==
11
){
SendSmsAndMail
.
sendSms
(
user
.
getPhone
(),
verificationCode
,
"7"
);
}
else
{
sent
.
put
(
"code"
,
400
);
sent
.
put
(
"message"
,
"当前用户手机号码不合法!"
);
}
}
catch
(
Exception
e
){
log
.
info
(
"错误信息:{}"
,
e
.
getMessage
());
sent
.
put
(
"code"
,
400
);
sent
.
put
(
"message"
,
"手机短信发送失败"
);
}
return
ResponseEntity
.
newJSON
(
"code"
,
200
,
"data"
,
"短信发送成功!"
);
}
}
}
}
core-service/src/main/java/com/winsun/item/modular/system/controller/LoginPwdController.java
View file @
ad05a5b0
...
@@ -11,7 +11,7 @@ import com.winsun.item.core.util.ResponseEntity;
...
@@ -11,7 +11,7 @@ import com.winsun.item.core.util.ResponseEntity;
import
com.winsun.item.modular.system.service.IUserService
;
import
com.winsun.item.modular.system.service.IUserService
;
import
com.winsun.item.util.LoginUtils
;
import
com.winsun.item.util.LoginUtils
;
import
com.winsun.mapper.SysUserMapper
;
import
com.winsun.mapper.SysUserMapper
;
import
com.winsun.
utils.MessageUt
il
;
import
com.winsun.
smsUtils.SendSmsAndMa
il
;
import
com.winsun.utils.MyBatisPlusUpdateUtils
;
import
com.winsun.utils.MyBatisPlusUpdateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -109,8 +109,21 @@ public class LoginPwdController {
...
@@ -109,8 +109,21 @@ public class LoginPwdController {
String
verificationCode
=
String
.
valueOf
((
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
));
String
verificationCode
=
String
.
valueOf
((
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
));
//5分钟内有效
//5分钟内有效
stringRedisTemplate
.
opsForValue
().
set
(
account
,
verificationCode
,
1000
*
60
*
5
,
TimeUnit
.
MILLISECONDS
);
stringRedisTemplate
.
opsForValue
().
set
(
account
,
verificationCode
,
1000
*
60
*
5
,
TimeUnit
.
MILLISECONDS
);
Map
<
String
,
Object
>
sent
=
MessageUtil
.
sent
(
phone
,
"2"
,
verificationCode
);
Map
<
String
,
Object
>
sent
=
new
HashMap
<>();
return
ResponseEntity
.
newJSON
(
"code"
,
sent
.
get
(
"code"
).
toString
(),
"data"
,
sent
.
get
(
"message"
));
try
{
if
(
phone
.
length
()
==
11
){
SendSmsAndMail
.
sendSms
(
phone
,
verificationCode
,
"7"
);
}
else
{
sent
.
put
(
"code"
,
400
);
sent
.
put
(
"message"
,
"当前用户手机号码不合法!"
);
}
}
catch
(
Exception
e
){
log
.
info
(
"错误信息:{}"
,
e
.
getMessage
());
sent
.
put
(
"code"
,
400
);
sent
.
put
(
"message"
,
"手机短信发送失败"
);
}
return
ResponseEntity
.
newJSON
(
"code"
,
200
,
"data"
,
"短信发送成功!"
);
}
}
/**
/**
...
...
service-manager/src/main/java/com/winsun/controller/UniversityInfoController.java
View file @
ad05a5b0
...
@@ -9,9 +9,7 @@ import com.winsun.auth.core.annotion.Permission;
...
@@ -9,9 +9,7 @@ import com.winsun.auth.core.annotion.Permission;
import
com.winsun.auth.core.base.controller.BaseController
;
import
com.winsun.auth.core.base.controller.BaseController
;
import
com.winsun.auth.core.common.model.ResponseData
;
import
com.winsun.auth.core.common.model.ResponseData
;
import
com.winsun.auth.core.shiro.ShiroUser
;
import
com.winsun.auth.core.shiro.ShiroUser
;
import
com.winsun.bean.Product
;
import
com.winsun.bean.UniversityInfo
;
import
com.winsun.bean.UniversityInfo
;
import
com.winsun.mapper.ProductMapper
;
import
com.winsun.mapper.UniversityInfoMapper
;
import
com.winsun.mapper.UniversityInfoMapper
;
import
com.winsun.utils.MyBatisPlusUpdateUtils
;
import
com.winsun.utils.MyBatisPlusUpdateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
...
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