Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
communication
Project
Project
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
耿迪迪
communication
Commits
716a211e
Commit
716a211e
authored
Jun 29, 2021
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
信息发送服务
parents
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
2769 additions
and
0 deletions
+2769
-0
.gitignore
.gitignore
+33
-0
MavenWrapperDownloader.java
.mvn/wrapper/MavenWrapperDownloader.java
+117
-0
maven-wrapper.jar
.mvn/wrapper/maven-wrapper.jar
+0
-0
maven-wrapper.properties
.mvn/wrapper/maven-wrapper.properties
+2
-0
mvnw
mvnw
+310
-0
mvnw.cmd
mvnw.cmd
+182
-0
pom.xml
pom.xml
+107
-0
CommunicationApplication.java
...va/com/zehong/communication/CommunicationApplication.java
+15
-0
AopInterceptor.java
...hong/communication/common/interceptor/AopInterceptor.java
+77
-0
LogInterceptor.java
...hong/communication/common/interceptor/LogInterceptor.java
+94
-0
Result.java
...n/java/com/zehong/communication/common/result/Result.java
+45
-0
ResultEnum.java
...va/com/zehong/communication/common/result/ResultEnum.java
+33
-0
SmsController.java
...va/com/zehong/communication/controller/SmsController.java
+61
-0
VoiceNotifyController.java
...ehong/communication/controller/VoiceNotifyController.java
+59
-0
RequestLogMapper.java
...n/java/com/zehong/communication/dao/RequestLogMapper.java
+32
-0
RequestLog.java
...main/java/com/zehong/communication/entity/RequestLog.java
+68
-0
RequestLogExample.java
...va/com/zehong/communication/entity/RequestLogExample.java
+621
-0
BaseRequestModel.java
...java/com/zehong/communication/model/BaseRequestModel.java
+9
-0
SendBatchSms.java
...ain/java/com/zehong/communication/model/SendBatchSms.java
+10
-0
SendBatchVoiceNotify.java
.../com/zehong/communication/model/SendBatchVoiceNotify.java
+9
-0
SendSms.java
src/main/java/com/zehong/communication/model/SendSms.java
+9
-0
SendVoiceNotify.java
.../java/com/zehong/communication/model/SendVoiceNotify.java
+9
-0
RequestLogService.java
...a/com/zehong/communication/service/RequestLogService.java
+31
-0
SmsService.java
...ain/java/com/zehong/communication/service/SmsService.java
+11
-0
VoiceNotifyService.java
.../com/zehong/communication/service/VoiceNotifyService.java
+23
-0
RequestLogServiceImpl.java
...ong/communication/service/impl/RequestLogServiceImpl.java
+72
-0
SmsServiceImpl.java
...com/zehong/communication/service/impl/SmsServiceImpl.java
+137
-0
VoiceNotifyServiceImpl.java
...ng/communication/service/impl/VoiceNotifyServiceImpl.java
+54
-0
HttpUtil.java
src/main/java/com/zehong/communication/util/HttpUtil.java
+133
-0
IPUtils.java
src/main/java/com/zehong/communication/util/IPUtils.java
+49
-0
MD5Utils.java
src/main/java/com/zehong/communication/util/MD5Utils.java
+66
-0
application.yml
src/main/resources/application.yml
+51
-0
RequestLogMapper.xml
src/main/resources/mapper/RequestLogMapper.xml
+227
-0
CommunicationApplicationTests.java
...m/zehong/communication/CommunicationApplicationTests.java
+13
-0
No files found.
.gitignore
0 → 100644
View file @
716a211e
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
.mvn/wrapper/MavenWrapperDownloader.java
0 → 100644
View file @
716a211e
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
java.net.*
;
import
java.io.*
;
import
java.nio.channels.*
;
import
java.util.Properties
;
public
class
MavenWrapperDownloader
{
private
static
final
String
WRAPPER_VERSION
=
"0.5.6"
;
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private
static
final
String
DEFAULT_DOWNLOAD_URL
=
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+
WRAPPER_VERSION
+
"/maven-wrapper-"
+
WRAPPER_VERSION
+
".jar"
;
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private
static
final
String
MAVEN_WRAPPER_PROPERTIES_PATH
=
".mvn/wrapper/maven-wrapper.properties"
;
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private
static
final
String
MAVEN_WRAPPER_JAR_PATH
=
".mvn/wrapper/maven-wrapper.jar"
;
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private
static
final
String
PROPERTY_NAME_WRAPPER_URL
=
"wrapperUrl"
;
public
static
void
main
(
String
args
[])
{
System
.
out
.
println
(
"- Downloader started"
);
File
baseDirectory
=
new
File
(
args
[
0
]);
System
.
out
.
println
(
"- Using base directory: "
+
baseDirectory
.
getAbsolutePath
());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File
mavenWrapperPropertyFile
=
new
File
(
baseDirectory
,
MAVEN_WRAPPER_PROPERTIES_PATH
);
String
url
=
DEFAULT_DOWNLOAD_URL
;
if
(
mavenWrapperPropertyFile
.
exists
())
{
FileInputStream
mavenWrapperPropertyFileInputStream
=
null
;
try
{
mavenWrapperPropertyFileInputStream
=
new
FileInputStream
(
mavenWrapperPropertyFile
);
Properties
mavenWrapperProperties
=
new
Properties
();
mavenWrapperProperties
.
load
(
mavenWrapperPropertyFileInputStream
);
url
=
mavenWrapperProperties
.
getProperty
(
PROPERTY_NAME_WRAPPER_URL
,
url
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"- ERROR loading '"
+
MAVEN_WRAPPER_PROPERTIES_PATH
+
"'"
);
}
finally
{
try
{
if
(
mavenWrapperPropertyFileInputStream
!=
null
)
{
mavenWrapperPropertyFileInputStream
.
close
();
}
}
catch
(
IOException
e
)
{
// Ignore ...
}
}
}
System
.
out
.
println
(
"- Downloading from: "
+
url
);
File
outputFile
=
new
File
(
baseDirectory
.
getAbsolutePath
(),
MAVEN_WRAPPER_JAR_PATH
);
if
(!
outputFile
.
getParentFile
().
exists
())
{
if
(!
outputFile
.
getParentFile
().
mkdirs
())
{
System
.
out
.
println
(
"- ERROR creating output directory '"
+
outputFile
.
getParentFile
().
getAbsolutePath
()
+
"'"
);
}
}
System
.
out
.
println
(
"- Downloading to: "
+
outputFile
.
getAbsolutePath
());
try
{
downloadFileFromURL
(
url
,
outputFile
);
System
.
out
.
println
(
"Done"
);
System
.
exit
(
0
);
}
catch
(
Throwable
e
)
{
System
.
out
.
println
(
"- Error downloading"
);
e
.
printStackTrace
();
System
.
exit
(
1
);
}
}
private
static
void
downloadFileFromURL
(
String
urlString
,
File
destination
)
throws
Exception
{
if
(
System
.
getenv
(
"MVNW_USERNAME"
)
!=
null
&&
System
.
getenv
(
"MVNW_PASSWORD"
)
!=
null
)
{
String
username
=
System
.
getenv
(
"MVNW_USERNAME"
);
char
[]
password
=
System
.
getenv
(
"MVNW_PASSWORD"
).
toCharArray
();
Authenticator
.
setDefault
(
new
Authenticator
()
{
@Override
protected
PasswordAuthentication
getPasswordAuthentication
()
{
return
new
PasswordAuthentication
(
username
,
password
);
}
});
}
URL
website
=
new
URL
(
urlString
);
ReadableByteChannel
rbc
;
rbc
=
Channels
.
newChannel
(
website
.
openStream
());
FileOutputStream
fos
=
new
FileOutputStream
(
destination
);
fos
.
getChannel
().
transferFrom
(
rbc
,
0
,
Long
.
MAX_VALUE
);
fos
.
close
();
rbc
.
close
();
}
}
.mvn/wrapper/maven-wrapper.jar
0 → 100644
View file @
716a211e
File added
.mvn/wrapper/maven-wrapper.properties
0 → 100644
View file @
716a211e
distributionUrl
=
https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
wrapperUrl
=
https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
mvnw
0 → 100644
View file @
716a211e
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if
[
-z
"
$MAVEN_SKIP_RC
"
]
;
then
if
[
-f
/etc/mavenrc
]
;
then
.
/etc/mavenrc
fi
if
[
-f
"
$HOME
/.mavenrc"
]
;
then
.
"
$HOME
/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin
=
false
;
darwin
=
false
;
mingw
=
false
case
"
`
uname
`
"
in
CYGWIN
*
)
cygwin
=
true
;;
MINGW
*
)
mingw
=
true
;;
Darwin
*
)
darwin
=
true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if
[
-z
"
$JAVA_HOME
"
]
;
then
if
[
-x
"/usr/libexec/java_home"
]
;
then
export
JAVA_HOME
=
"
`
/usr/libexec/java_home
`
"
else
export
JAVA_HOME
=
"/Library/Java/Home"
fi
fi
;;
esac
if
[
-z
"
$JAVA_HOME
"
]
;
then
if
[
-r
/etc/gentoo-release
]
;
then
JAVA_HOME
=
`
java-config
--jre-home
`
fi
fi
if
[
-z
"
$M2_HOME
"
]
;
then
## resolve links - $0 may be a link to maven's home
PRG
=
"
$0
"
# need this for relative symlinks
while
[
-h
"
$PRG
"
]
;
do
ls
=
`
ls
-ld
"
$PRG
"
`
link
=
`
expr
"
$ls
"
:
'.*-> \(.*\)$'
`
if
expr
"
$link
"
:
'/.*'
>
/dev/null
;
then
PRG
=
"
$link
"
else
PRG
=
"
`
dirname
"
$PRG
"
`
/
$link
"
fi
done
saveddir
=
`
pwd
`
M2_HOME
=
`
dirname
"
$PRG
"
`
/..
# make it fully qualified
M2_HOME
=
`
cd
"
$M2_HOME
"
&&
pwd
`
cd
"
$saveddir
"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if
$cygwin
;
then
[
-n
"
$M2_HOME
"
]
&&
M2_HOME
=
`
cygpath
--unix
"
$M2_HOME
"
`
[
-n
"
$JAVA_HOME
"
]
&&
JAVA_HOME
=
`
cygpath
--unix
"
$JAVA_HOME
"
`
[
-n
"
$CLASSPATH
"
]
&&
CLASSPATH
=
`
cygpath
--path
--unix
"
$CLASSPATH
"
`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if
$mingw
;
then
[
-n
"
$M2_HOME
"
]
&&
M2_HOME
=
"
`
(
cd
"
$M2_HOME
"
;
pwd
)
`
"
[
-n
"
$JAVA_HOME
"
]
&&
JAVA_HOME
=
"
`
(
cd
"
$JAVA_HOME
"
;
pwd
)
`
"
fi
if
[
-z
"
$JAVA_HOME
"
]
;
then
javaExecutable
=
"
`
which javac
`
"
if
[
-n
"
$javaExecutable
"
]
&&
!
[
"
`
expr
\"
$javaExecutable
\"
:
'\([^ ]*\)'
`
"
=
"no"
]
;
then
# readlink(1) is not available as standard on Solaris 10.
readLink
=
`
which
readlink
`
if
[
!
`
expr
"
$readLink
"
:
'\([^ ]*\)'
`
=
"no"
]
;
then
if
$darwin
;
then
javaHome
=
"
`
dirname
\"
$javaExecutable
\"
`
"
javaExecutable
=
"
`
cd
\"
$javaHome
\"
&&
pwd
-P
`
/javac"
else
javaExecutable
=
"
`
readlink
-f
\"
$javaExecutable
\"
`
"
fi
javaHome
=
"
`
dirname
\"
$javaExecutable
\"
`
"
javaHome
=
`
expr
"
$javaHome
"
:
'\(.*\)/bin'
`
JAVA_HOME
=
"
$javaHome
"
export
JAVA_HOME
fi
fi
fi
if
[
-z
"
$JAVACMD
"
]
;
then
if
[
-n
"
$JAVA_HOME
"
]
;
then
if
[
-x
"
$JAVA_HOME
/jre/sh/java"
]
;
then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD
=
"
$JAVA_HOME
/jre/sh/java"
else
JAVACMD
=
"
$JAVA_HOME
/bin/java"
fi
else
JAVACMD
=
"
`
which java
`
"
fi
fi
if
[
!
-x
"
$JAVACMD
"
]
;
then
echo
"Error: JAVA_HOME is not defined correctly."
>
&2
echo
" We cannot execute
$JAVACMD
"
>
&2
exit
1
fi
if
[
-z
"
$JAVA_HOME
"
]
;
then
echo
"Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER
=
org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir
()
{
if
[
-z
"
$1
"
]
then
echo
"Path not specified to find_maven_basedir"
return
1
fi
basedir
=
"
$1
"
wdir
=
"
$1
"
while
[
"
$wdir
"
!=
'/'
]
;
do
if
[
-d
"
$wdir
"
/.mvn
]
;
then
basedir
=
$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if
[
-d
"
${
wdir
}
"
]
;
then
wdir
=
`
cd
"
$wdir
/.."
;
pwd
`
fi
# end of workaround
done
echo
"
${
basedir
}
"
}
# concatenates all lines of a file
concat_lines
()
{
if
[
-f
"
$1
"
]
;
then
echo
"
$(
tr
-s
'\n'
' '
<
"
$1
"
)
"
fi
}
BASE_DIR
=
`
find_maven_basedir
"
$(
pwd
)
"
`
if
[
-z
"
$BASE_DIR
"
]
;
then
exit
1
;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if
[
-r
"
$BASE_DIR
/.mvn/wrapper/maven-wrapper.jar"
]
;
then
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
"Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
"Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if
[
-n
"
$MVNW_REPOURL
"
]
;
then
jarUrl
=
"
$MVNW_REPOURL
/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl
=
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while
IFS
=
"="
read
key value
;
do
case
"
$key
"
in
(
wrapperUrl
)
jarUrl
=
"
$value
"
;
break
;;
esac
done
<
"
$BASE_DIR
/.mvn/wrapper/maven-wrapper.properties"
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
"Downloading from:
$jarUrl
"
fi
wrapperJarPath
=
"
$BASE_DIR
/.mvn/wrapper/maven-wrapper.jar"
if
$cygwin
;
then
wrapperJarPath
=
`
cygpath
--path
--windows
"
$wrapperJarPath
"
`
fi
if
command
-v
wget
>
/dev/null
;
then
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
"Found wget ... using wget"
fi
if
[
-z
"
$MVNW_USERNAME
"
]
||
[
-z
"
$MVNW_PASSWORD
"
]
;
then
wget
"
$jarUrl
"
-O
"
$wrapperJarPath
"
else
wget
--http-user
=
$MVNW_USERNAME
--http-password
=
$MVNW_PASSWORD
"
$jarUrl
"
-O
"
$wrapperJarPath
"
fi
elif
command
-v
curl
>
/dev/null
;
then
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
"Found curl ... using curl"
fi
if
[
-z
"
$MVNW_USERNAME
"
]
||
[
-z
"
$MVNW_PASSWORD
"
]
;
then
curl
-o
"
$wrapperJarPath
"
"
$jarUrl
"
-f
else
curl
--user
$MVNW_USERNAME
:
$MVNW_PASSWORD
-o
"
$wrapperJarPath
"
"
$jarUrl
"
-f
fi
else
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
"Falling back to using Java to download"
fi
javaClass
=
"
$BASE_DIR
/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if
$cygwin
;
then
javaClass
=
`
cygpath
--path
--windows
"
$javaClass
"
`
fi
if
[
-e
"
$javaClass
"
]
;
then
if
[
!
-e
"
$BASE_DIR
/.mvn/wrapper/MavenWrapperDownloader.class"
]
;
then
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
" - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
(
"
$JAVA_HOME
/bin/javac"
"
$javaClass
"
)
fi
if
[
-e
"
$BASE_DIR
/.mvn/wrapper/MavenWrapperDownloader.class"
]
;
then
# Running the downloader
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
" - Running MavenWrapperDownloader.java ..."
fi
(
"
$JAVA_HOME
/bin/java"
-cp
.mvn/wrapper MavenWrapperDownloader
"
$MAVEN_PROJECTBASEDIR
"
)
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export
MAVEN_PROJECTBASEDIR
=
${
MAVEN_BASEDIR
:-
"
$BASE_DIR
"
}
if
[
"
$MVNW_VERBOSE
"
=
true
]
;
then
echo
$MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS
=
"
$(
concat_lines
"
$MAVEN_PROJECTBASEDIR
/.mvn/jvm.config"
)
$MAVEN_OPTS
"
# For Cygwin, switch paths to Windows format before running java
if
$cygwin
;
then
[
-n
"
$M2_HOME
"
]
&&
M2_HOME
=
`
cygpath
--path
--windows
"
$M2_HOME
"
`
[
-n
"
$JAVA_HOME
"
]
&&
JAVA_HOME
=
`
cygpath
--path
--windows
"
$JAVA_HOME
"
`
[
-n
"
$CLASSPATH
"
]
&&
CLASSPATH
=
`
cygpath
--path
--windows
"
$CLASSPATH
"
`
[
-n
"
$MAVEN_PROJECTBASEDIR
"
]
&&
MAVEN_PROJECTBASEDIR
=
`
cygpath
--path
--windows
"
$MAVEN_PROJECTBASEDIR
"
`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS
=
"
$MAVEN_CONFIG
$@
"
export
MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER
=
org.apache.maven.wrapper.MavenWrapperMain
exec
"
$JAVACMD
"
\
$MAVEN_OPTS
\
-classpath
"
$MAVEN_PROJECTBASEDIR
/.mvn/wrapper/maven-wrapper.jar"
\
"-Dmaven.home=
${
M2_HOME
}
"
"-Dmaven.multiModuleProjectDirectory=
${
MAVEN_PROJECTBASEDIR
}
"
\
${
WRAPPER_LAUNCHER
}
$MAVEN_CONFIG
"
$@
"
mvnw.cmd
0 → 100644
View file @
716a211e
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
pom.xml
0 → 100644
View file @
716a211e
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.5.2
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.zehong
</groupId>
<artifactId>
communication
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
communication
</name>
<description>
Demo project for Spring Boot
</description>
<properties>
<java.version>
1.8
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.2
</version>
</dependency>
<!--阿里云短信sdk-->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
4.0.6
</version>
<!-- 注:如提示报错,先升级基础包版,无法解决可联系技术支持 -->
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-dysmsapi
</artifactId>
<version>
1.1.0
</version>
</dependency>
<!--json转换-->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.47
</version>
</dependency>
<!--log日志-->
<dependency>
<groupId>
commons-logging
</groupId>
<artifactId>
commons-logging
</artifactId>
<version>
1.2
</version>
</dependency>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<version>
1.2.17
</version>
</dependency>
<!--commons-lang-->
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.6
</version>
</dependency>
<!--aop-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-aop
</artifactId>
</dependency>
<!--mybatis-->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<version>
1.3.0
</version>
</dependency>
<!--lombok-->
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.4
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
src/main/java/com/zehong/communication/CommunicationApplication.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
@MapperScan
(
"com.zehong.communication.dao"
)
public
class
CommunicationApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
CommunicationApplication
.
class
,
args
);
}
}
src/main/java/com/zehong/communication/common/interceptor/AopInterceptor.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
common
.
interceptor
;
import
com.zehong.communication.common.result.Result
;
import
com.zehong.communication.common.result.ResultEnum
;
import
com.zehong.communication.util.IPUtils
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
@Order
(
0
)
@Aspect
@Component
public
class
AopInterceptor
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AopInterceptor
.
class
);
@Value
(
"${iPWhite}"
)
private
String
iPWhite
;
/**
* 定义拦截器规则
*/
@Pointcut
(
"execution(* com.zehong.communication.controller.*.*(..))"
)
public
void
pointCut
()
{
}
/**
* 拦截器具体实现
*
* @throws Throwable
*/
@Around
(
value
=
"pointCut()"
)
public
Object
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
try
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
//判断是否为黑名单用户
String
ip
=
IPUtils
.
getIpAddress
(
request
);
if
(
checkIpWhite
(
ip
))
{
logger
.
info
(
"当前请求ip:"
+
ip
+
",在白名单名单中"
);
return
point
.
proceed
();
}
else
{
//ip不在黑名单中返回true
logger
.
info
(
"当前请求ip:"
+
ip
+
",不存在白名单中,拒绝访问"
);
return
new
Result
(
ResultEnum
.
NOT_IN_IPWHITE
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"白名单拦截出错:"
+
e
);
return
new
Result
(
ResultEnum
.
SYSTEM_EXCEPTION
);
}
}
/**
* 对比白名单IP
* @param ip 请求ip
* @return
* @throws Exception
*/
public
boolean
checkIpWhite
(
String
ip
)
throws
Exception
{
String
[]
ipWhites
=
iPWhite
.
split
(
","
);
for
(
String
whiteIp
:
ipWhites
){
return
whiteIp
.
equals
(
ip
);
}
return
false
;
}
}
src/main/java/com/zehong/communication/common/interceptor/LogInterceptor.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
common
.
interceptor
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zehong.communication.common.result.Result
;
import
com.zehong.communication.common.result.ResultEnum
;
import
com.zehong.communication.entity.RequestLog
;
import
com.zehong.communication.model.BaseRequestModel
;
import
com.zehong.communication.service.RequestLogService
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.SimpleDateFormat
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.UUID
;
@Order
(
0
)
@Aspect
@Component
public
class
LogInterceptor
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LogInterceptor
.
class
);
@Autowired
private
RequestLogService
requestLogService
;
@Value
(
"${secretKey}"
)
private
String
secretKey
;
/**
* 定义拦截器规则
*/
@Pointcut
(
"execution(* com.zehong.communication.controller.*.*(..))"
)
public
void
pointCut
()
{
}
/**
* 拦截器具体实现
*
*/
@Around
(
value
=
"pointCut()"
)
public
Object
around
(
ProceedingJoinPoint
point
){
// 获取方法参数
Object
[]
pointParams
=
point
.
getArgs
();
String
params
=
Arrays
.
toString
(
pointParams
);
try
{
for
(
Object
pointParam
:
pointParams
){
if
(
pointParam
instanceof
BaseRequestModel
){
String
secretKey
=
((
BaseRequestModel
)
pointParam
).
getSecretKey
();
if
(!
this
.
secretKey
.
equals
(
secretKey
)){
return
new
Result
(
ResultEnum
.
SECRETKRY_ERROR
);
}
}
}
Object
result
=
point
.
proceed
();
insertRequestLogRecord
(
params
,
JSONObject
.
toJSONString
(
result
));
return
result
;
}
catch
(
Throwable
e
){
logger
.
error
(
"日志拦截出错:"
+
e
);
insertRequestLogRecord
(
params
,
e
.
getMessage
());
return
new
Result
(
ResultEnum
.
SYSTEM_EXCEPTION
);
}
}
/**
* 记录请求日志
* @param params 请求参数
* @param result 请求结果
*/
private
void
insertRequestLogRecord
(
String
params
,
String
result
){
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
request
.
getParameter
(
"secretKey"
);
RequestLog
requestLog
=
new
RequestLog
();
requestLog
.
setId
(
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
));
requestLog
.
setRequestMapping
(
request
.
getRequestURL
().
toString
());
requestLog
.
setParams
(
params
);
requestLog
.
setSecretKey
(
secretKey
);
requestLog
.
setPostTime
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
()));
requestLog
.
setResult
(
JSONObject
.
toJSONString
(
result
));
requestLogService
.
insert
(
requestLog
);
}
}
src/main/java/com/zehong/communication/common/result/Result.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
common
.
result
;
import
java.io.Serializable
;
public
class
Result
implements
Serializable
{
private
String
code
;
private
String
msg
;
private
Object
data
;
public
Result
(
String
code
,
String
msg
,
Object
data
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
this
.
data
=
data
;
}
public
Result
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
Result
(
ResultEnum
resultEnum
){
this
.
code
=
resultEnum
.
getCode
();
this
.
msg
=
resultEnum
.
getMsg
();
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
src/main/java/com/zehong/communication/common/result/ResultEnum.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
common
.
result
;
public
enum
ResultEnum
{
/**
* 请求成功
*/
SUCCESS
(
"0"
,
"接口请求成功!"
),
BUSSINESS_FAIL
(
"1"
,
"业务异常!"
),
FAIL
(
"2"
,
"接口请求失败!"
),
SYSTEM_EXCEPTION
(
"3"
,
"系统异常!"
)
,
NOT_IN_IPWHITE
(
"4"
,
"当前IP不在白名单中,请联系管理员"
),
SECRETKRY_ERROR
(
"5"
,
"secretKey不存在或秘钥不正确!"
);
private
String
code
;
private
String
msg
;
ResultEnum
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
src/main/java/com/zehong/communication/controller/SmsController.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
controller
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.zehong.communication.common.result.Result
;
import
com.zehong.communication.common.result.ResultEnum
;
import
com.zehong.communication.model.SendBatchSms
;
import
com.zehong.communication.model.SendSms
;
import
com.zehong.communication.service.SmsService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 发送短信
* @author gengdidi
*/
@RestController
@RequestMapping
(
"/sms"
)
@PropertySource
(
value
=
"classpath:application.yml"
,
encoding
=
"UTF-8"
)
public
class
SmsController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SmsController
.
class
);
@Autowired
private
SmsService
smsService
;
/**
* 短信发送
* @param sendSms 短信实体
* @return Result
*/
@RequestMapping
(
value
=
"/sendSms"
,
method
=
RequestMethod
.
GET
)
public
Result
sendSms
(
@RequestBody
SendSms
sendSms
){
try
{
return
smsService
.
sendSms
(
sendSms
.
getPhoneNumber
());
}
catch
(
ClientException
e
)
{
logger
.
info
(
"短信发送失败,phoneNumber:%"
,
sendSms
.
getPhoneNumber
(),
e
);
return
new
Result
(
ResultEnum
.
SYSTEM_EXCEPTION
);
}
}
/**
* 群发短信
* @param sendBatchSms 群发短信实体
* @return Result
*/
@RequestMapping
(
value
=
"/sendBatchSms"
,
method
=
RequestMethod
.
POST
)
public
Result
sendBatchSms
(
@RequestBody
SendBatchSms
sendBatchSms
){
try
{
return
smsService
.
sendBatchSms
(
sendBatchSms
.
getPhoneNumbers
());
}
catch
(
ClientException
e
)
{
logger
.
info
(
"批量发送短信失败,phoneNumbers:%"
,
sendBatchSms
.
getPhoneNumbers
(),
e
);
return
new
Result
(
ResultEnum
.
SYSTEM_EXCEPTION
);
}
}
}
src/main/java/com/zehong/communication/controller/VoiceNotifyController.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
controller
;
import
com.zehong.communication.common.result.Result
;
import
com.zehong.communication.common.result.ResultEnum
;
import
com.zehong.communication.model.SendBatchVoiceNotify
;
import
com.zehong.communication.model.SendVoiceNotify
;
import
com.zehong.communication.service.VoiceNotifyService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
/**
*发送语音
* @author gengdidi
*/
@RestController
@RequestMapping
(
"/voiceNotify"
)
public
class
VoiceNotifyController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
VoiceNotifyController
.
class
);
@Autowired
private
VoiceNotifyService
voiceNotifyService
;
/**
* 发送语音 被叫号码,限单个,仅支持11位国内号码
* @param sendVoiceNotify 发送语音实体
* @return String
*/
@RequestMapping
(
value
=
"/sendVoiceNotify"
,
method
=
RequestMethod
.
GET
)
public
Result
sendVoiceNotify
(
@RequestBody
SendVoiceNotify
sendVoiceNotify
){
try
{
return
voiceNotifyService
.
sendVoiceNotify
(
sendVoiceNotify
.
getPhoneNumber
());
}
catch
(
IOException
|
URISyntaxException
e
)
{
logger
.
info
(
"语音发送失败!phoneNumber:%"
,
sendVoiceNotify
.
getPhoneNumber
(),
e
);
return
new
Result
(
ResultEnum
.
SYSTEM_EXCEPTION
);
}
}
/**
*批量发送语音 被叫号码,模版无变量多个则以英文半角分号“;”分割;模板带变量,多个号码以英文分号“;”分割,号码和变量以英文逗号“,”隔开, 多个变量以竖线“|”隔开,如 130XXXXXXXX,123|456;186XXXXXXXX,321|654(注意:文件语音模板类型 号码之间分隔用“,”隔开)
* @param sendBatchVoiceNotify 批量发送语音实体
* @return String
*/
@RequestMapping
(
value
=
"/sendBatchVoiceNotify"
,
method
=
RequestMethod
.
GET
)
public
Result
sendBatchVoiceNotify
(
@RequestBody
SendBatchVoiceNotify
sendBatchVoiceNotify
){
try
{
return
voiceNotifyService
.
sendBatchVoiceNotify
(
sendBatchVoiceNotify
.
getPhoneNumbers
());
}
catch
(
IOException
|
URISyntaxException
e
)
{
logger
.
info
(
"群发语音失败!phoneNumbers:%"
,
sendBatchVoiceNotify
.
getPhoneNumbers
(),
e
);
return
new
Result
(
ResultEnum
.
SYSTEM_EXCEPTION
);
}
}
}
src/main/java/com/zehong/communication/dao/RequestLogMapper.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
dao
;
import
com.zehong.communication.entity.RequestLog
;
import
com.zehong.communication.entity.RequestLogExample
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
RequestLogMapper
{
int
countByExample
(
RequestLogExample
example
);
int
deleteByExample
(
RequestLogExample
example
);
int
deleteByPrimaryKey
(
String
id
);
int
insert
(
RequestLog
record
);
int
insertSelective
(
RequestLog
record
);
List
<
RequestLog
>
selectByExample
(
RequestLogExample
example
);
RequestLog
selectByPrimaryKey
(
String
id
);
int
updateByExampleSelective
(
@Param
(
"record"
)
RequestLog
record
,
@Param
(
"example"
)
RequestLogExample
example
);
int
updateByExample
(
@Param
(
"record"
)
RequestLog
record
,
@Param
(
"example"
)
RequestLogExample
example
);
int
updateByPrimaryKeySelective
(
RequestLog
record
);
int
updateByPrimaryKey
(
RequestLog
record
);
}
\ No newline at end of file
src/main/java/com/zehong/communication/entity/RequestLog.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
entity
;
import
java.io.Serializable
;
public
class
RequestLog
implements
Serializable
{
private
String
id
;
private
String
secretKey
;
private
String
requestMapping
;
private
String
params
;
private
String
postTime
;
private
String
result
;
private
static
final
long
serialVersionUID
=
1L
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
==
null
?
null
:
id
.
trim
();
}
public
String
getSecretKey
()
{
return
secretKey
;
}
public
void
setSecretKey
(
String
secretKey
)
{
this
.
secretKey
=
secretKey
==
null
?
null
:
secretKey
.
trim
();
}
public
String
getRequestMapping
()
{
return
requestMapping
;
}
public
void
setRequestMapping
(
String
requestMapping
)
{
this
.
requestMapping
=
requestMapping
==
null
?
null
:
requestMapping
.
trim
();
}
public
String
getParams
()
{
return
params
;
}
public
void
setParams
(
String
params
)
{
this
.
params
=
params
==
null
?
null
:
params
.
trim
();
}
public
String
getPostTime
()
{
return
postTime
;
}
public
void
setPostTime
(
String
postTime
)
{
this
.
postTime
=
postTime
==
null
?
null
:
postTime
.
trim
();
}
public
String
getResult
()
{
return
result
;
}
public
void
setResult
(
String
result
)
{
this
.
result
=
result
==
null
?
null
:
result
.
trim
();
}
}
\ No newline at end of file
src/main/java/com/zehong/communication/entity/RequestLogExample.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
entity
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
RequestLogExample
{
protected
String
orderByClause
;
protected
boolean
distinct
;
protected
List
<
Criteria
>
oredCriteria
;
public
RequestLogExample
()
{
oredCriteria
=
new
ArrayList
<
Criteria
>();
}
public
void
setOrderByClause
(
String
orderByClause
)
{
this
.
orderByClause
=
orderByClause
;
}
public
String
getOrderByClause
()
{
return
orderByClause
;
}
public
void
setDistinct
(
boolean
distinct
)
{
this
.
distinct
=
distinct
;
}
public
boolean
isDistinct
()
{
return
distinct
;
}
public
List
<
Criteria
>
getOredCriteria
()
{
return
oredCriteria
;
}
public
void
or
(
Criteria
criteria
)
{
oredCriteria
.
add
(
criteria
);
}
public
Criteria
or
()
{
Criteria
criteria
=
createCriteriaInternal
();
oredCriteria
.
add
(
criteria
);
return
criteria
;
}
public
Criteria
createCriteria
()
{
Criteria
criteria
=
createCriteriaInternal
();
if
(
oredCriteria
.
size
()
==
0
)
{
oredCriteria
.
add
(
criteria
);
}
return
criteria
;
}
protected
Criteria
createCriteriaInternal
()
{
Criteria
criteria
=
new
Criteria
();
return
criteria
;
}
public
void
clear
()
{
oredCriteria
.
clear
();
orderByClause
=
null
;
distinct
=
false
;
}
protected
abstract
static
class
GeneratedCriteria
{
protected
List
<
Criterion
>
criteria
;
protected
GeneratedCriteria
()
{
super
();
criteria
=
new
ArrayList
<
Criterion
>();
}
public
boolean
isValid
()
{
return
criteria
.
size
()
>
0
;
}
public
List
<
Criterion
>
getAllCriteria
()
{
return
criteria
;
}
public
List
<
Criterion
>
getCriteria
()
{
return
criteria
;
}
protected
void
addCriterion
(
String
condition
)
{
if
(
condition
==
null
)
{
throw
new
RuntimeException
(
"Value for condition cannot be null"
);
}
criteria
.
add
(
new
Criterion
(
condition
));
}
protected
void
addCriterion
(
String
condition
,
Object
value
,
String
property
)
{
if
(
value
==
null
)
{
throw
new
RuntimeException
(
"Value for "
+
property
+
" cannot be null"
);
}
criteria
.
add
(
new
Criterion
(
condition
,
value
));
}
protected
void
addCriterion
(
String
condition
,
Object
value1
,
Object
value2
,
String
property
)
{
if
(
value1
==
null
||
value2
==
null
)
{
throw
new
RuntimeException
(
"Between values for "
+
property
+
" cannot be null"
);
}
criteria
.
add
(
new
Criterion
(
condition
,
value1
,
value2
));
}
public
Criteria
andIdIsNull
()
{
addCriterion
(
"id is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdIsNotNull
()
{
addCriterion
(
"id is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdEqualTo
(
String
value
)
{
addCriterion
(
"id ="
,
value
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdNotEqualTo
(
String
value
)
{
addCriterion
(
"id <>"
,
value
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdGreaterThan
(
String
value
)
{
addCriterion
(
"id >"
,
value
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"id >="
,
value
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdLessThan
(
String
value
)
{
addCriterion
(
"id <"
,
value
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"id <="
,
value
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdLike
(
String
value
)
{
addCriterion
(
"id like"
,
value
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdNotLike
(
String
value
)
{
addCriterion
(
"id not like"
,
value
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdIn
(
List
<
String
>
values
)
{
addCriterion
(
"id in"
,
values
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"id not in"
,
values
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"id between"
,
value1
,
value2
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andIdNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"id not between"
,
value1
,
value2
,
"id"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyIsNull
()
{
addCriterion
(
"secret_key is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyIsNotNull
()
{
addCriterion
(
"secret_key is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyEqualTo
(
String
value
)
{
addCriterion
(
"secret_key ="
,
value
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyNotEqualTo
(
String
value
)
{
addCriterion
(
"secret_key <>"
,
value
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyGreaterThan
(
String
value
)
{
addCriterion
(
"secret_key >"
,
value
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"secret_key >="
,
value
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyLessThan
(
String
value
)
{
addCriterion
(
"secret_key <"
,
value
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"secret_key <="
,
value
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyLike
(
String
value
)
{
addCriterion
(
"secret_key like"
,
value
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyNotLike
(
String
value
)
{
addCriterion
(
"secret_key not like"
,
value
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyIn
(
List
<
String
>
values
)
{
addCriterion
(
"secret_key in"
,
values
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"secret_key not in"
,
values
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"secret_key between"
,
value1
,
value2
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andSecretKeyNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"secret_key not between"
,
value1
,
value2
,
"secretKey"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingIsNull
()
{
addCriterion
(
"request_mapping is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingIsNotNull
()
{
addCriterion
(
"request_mapping is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingEqualTo
(
String
value
)
{
addCriterion
(
"request_mapping ="
,
value
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingNotEqualTo
(
String
value
)
{
addCriterion
(
"request_mapping <>"
,
value
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingGreaterThan
(
String
value
)
{
addCriterion
(
"request_mapping >"
,
value
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"request_mapping >="
,
value
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingLessThan
(
String
value
)
{
addCriterion
(
"request_mapping <"
,
value
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"request_mapping <="
,
value
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingLike
(
String
value
)
{
addCriterion
(
"request_mapping like"
,
value
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingNotLike
(
String
value
)
{
addCriterion
(
"request_mapping not like"
,
value
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingIn
(
List
<
String
>
values
)
{
addCriterion
(
"request_mapping in"
,
values
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"request_mapping not in"
,
values
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"request_mapping between"
,
value1
,
value2
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andRequestMappingNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"request_mapping not between"
,
value1
,
value2
,
"requestMapping"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsIsNull
()
{
addCriterion
(
"params is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsIsNotNull
()
{
addCriterion
(
"params is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsEqualTo
(
String
value
)
{
addCriterion
(
"params ="
,
value
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsNotEqualTo
(
String
value
)
{
addCriterion
(
"params <>"
,
value
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsGreaterThan
(
String
value
)
{
addCriterion
(
"params >"
,
value
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"params >="
,
value
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsLessThan
(
String
value
)
{
addCriterion
(
"params <"
,
value
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"params <="
,
value
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsLike
(
String
value
)
{
addCriterion
(
"params like"
,
value
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsNotLike
(
String
value
)
{
addCriterion
(
"params not like"
,
value
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsIn
(
List
<
String
>
values
)
{
addCriterion
(
"params in"
,
values
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"params not in"
,
values
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"params between"
,
value1
,
value2
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andParamsNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"params not between"
,
value1
,
value2
,
"params"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeIsNull
()
{
addCriterion
(
"post_time is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeIsNotNull
()
{
addCriterion
(
"post_time is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeEqualTo
(
String
value
)
{
addCriterion
(
"post_time ="
,
value
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeNotEqualTo
(
String
value
)
{
addCriterion
(
"post_time <>"
,
value
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeGreaterThan
(
String
value
)
{
addCriterion
(
"post_time >"
,
value
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"post_time >="
,
value
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeLessThan
(
String
value
)
{
addCriterion
(
"post_time <"
,
value
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"post_time <="
,
value
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeLike
(
String
value
)
{
addCriterion
(
"post_time like"
,
value
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeNotLike
(
String
value
)
{
addCriterion
(
"post_time not like"
,
value
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeIn
(
List
<
String
>
values
)
{
addCriterion
(
"post_time in"
,
values
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"post_time not in"
,
values
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"post_time between"
,
value1
,
value2
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andPostTimeNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"post_time not between"
,
value1
,
value2
,
"postTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultIsNull
()
{
addCriterion
(
"result is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultIsNotNull
()
{
addCriterion
(
"result is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultEqualTo
(
String
value
)
{
addCriterion
(
"result ="
,
value
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultNotEqualTo
(
String
value
)
{
addCriterion
(
"result <>"
,
value
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultGreaterThan
(
String
value
)
{
addCriterion
(
"result >"
,
value
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultGreaterThanOrEqualTo
(
String
value
)
{
addCriterion
(
"result >="
,
value
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultLessThan
(
String
value
)
{
addCriterion
(
"result <"
,
value
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultLessThanOrEqualTo
(
String
value
)
{
addCriterion
(
"result <="
,
value
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultLike
(
String
value
)
{
addCriterion
(
"result like"
,
value
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultNotLike
(
String
value
)
{
addCriterion
(
"result not like"
,
value
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultIn
(
List
<
String
>
values
)
{
addCriterion
(
"result in"
,
values
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultNotIn
(
List
<
String
>
values
)
{
addCriterion
(
"result not in"
,
values
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"result between"
,
value1
,
value2
,
"result"
);
return
(
Criteria
)
this
;
}
public
Criteria
andResultNotBetween
(
String
value1
,
String
value2
)
{
addCriterion
(
"result not between"
,
value1
,
value2
,
"result"
);
return
(
Criteria
)
this
;
}
}
public
static
class
Criteria
extends
GeneratedCriteria
{
protected
Criteria
()
{
super
();
}
}
public
static
class
Criterion
{
private
String
condition
;
private
Object
value
;
private
Object
secondValue
;
private
boolean
noValue
;
private
boolean
singleValue
;
private
boolean
betweenValue
;
private
boolean
listValue
;
private
String
typeHandler
;
public
String
getCondition
()
{
return
condition
;
}
public
Object
getValue
()
{
return
value
;
}
public
Object
getSecondValue
()
{
return
secondValue
;
}
public
boolean
isNoValue
()
{
return
noValue
;
}
public
boolean
isSingleValue
()
{
return
singleValue
;
}
public
boolean
isBetweenValue
()
{
return
betweenValue
;
}
public
boolean
isListValue
()
{
return
listValue
;
}
public
String
getTypeHandler
()
{
return
typeHandler
;
}
protected
Criterion
(
String
condition
)
{
super
();
this
.
condition
=
condition
;
this
.
typeHandler
=
null
;
this
.
noValue
=
true
;
}
protected
Criterion
(
String
condition
,
Object
value
,
String
typeHandler
)
{
super
();
this
.
condition
=
condition
;
this
.
value
=
value
;
this
.
typeHandler
=
typeHandler
;
if
(
value
instanceof
List
<?>)
{
this
.
listValue
=
true
;
}
else
{
this
.
singleValue
=
true
;
}
}
protected
Criterion
(
String
condition
,
Object
value
)
{
this
(
condition
,
value
,
null
);
}
protected
Criterion
(
String
condition
,
Object
value
,
Object
secondValue
,
String
typeHandler
)
{
super
();
this
.
condition
=
condition
;
this
.
value
=
value
;
this
.
secondValue
=
secondValue
;
this
.
typeHandler
=
typeHandler
;
this
.
betweenValue
=
true
;
}
protected
Criterion
(
String
condition
,
Object
value
,
Object
secondValue
)
{
this
(
condition
,
value
,
secondValue
,
null
);
}
}
}
\ No newline at end of file
src/main/java/com/zehong/communication/model/BaseRequestModel.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
model
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
BaseRequestModel
implements
Serializable
{
private
String
secretKey
;
}
src/main/java/com/zehong/communication/model/SendBatchSms.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
model
;
import
lombok.Data
;
@Data
public
class
SendBatchSms
extends
BaseRequestModel
{
private
String
[]
phoneNumbers
;
}
src/main/java/com/zehong/communication/model/SendBatchVoiceNotify.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
model
;
import
lombok.Data
;
@Data
public
class
SendBatchVoiceNotify
extends
BaseRequestModel
{
private
String
phoneNumbers
;
}
src/main/java/com/zehong/communication/model/SendSms.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
model
;
import
lombok.Data
;
@Data
public
class
SendSms
extends
BaseRequestModel
{
private
String
phoneNumber
;
}
src/main/java/com/zehong/communication/model/SendVoiceNotify.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
model
;
import
lombok.Data
;
@Data
public
class
SendVoiceNotify
extends
BaseRequestModel
{
private
String
phoneNumber
;
}
src/main/java/com/zehong/communication/service/RequestLogService.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
service
;
import
com.zehong.communication.entity.RequestLog
;
import
com.zehong.communication.entity.RequestLogExample
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
RequestLogService
{
int
countByExample
(
RequestLogExample
example
);
int
deleteByExample
(
RequestLogExample
example
);
int
deleteByPrimaryKey
(
String
id
);
int
insert
(
RequestLog
record
);
int
insertSelective
(
RequestLog
record
);
List
<
RequestLog
>
selectByExample
(
RequestLogExample
example
);
RequestLog
selectByPrimaryKey
(
String
id
);
int
updateByExampleSelective
(
@Param
(
"record"
)
RequestLog
record
,
@Param
(
"example"
)
RequestLogExample
example
);
int
updateByExample
(
@Param
(
"record"
)
RequestLog
record
,
@Param
(
"example"
)
RequestLogExample
example
);
int
updateByPrimaryKeySelective
(
RequestLog
record
);
int
updateByPrimaryKey
(
RequestLog
record
);
}
src/main/java/com/zehong/communication/service/SmsService.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
service
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.zehong.communication.common.result.Result
;
public
interface
SmsService
{
Result
sendSms
(
String
phoneNumber
)
throws
ClientException
;
Result
sendBatchSms
(
String
[]
phoneNumbers
)
throws
ClientException
;
}
src/main/java/com/zehong/communication/service/VoiceNotifyService.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
service
;
import
com.zehong.communication.common.result.Result
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
public
interface
VoiceNotifyService
{
/**
* 发送语音 被叫号码,限单个,仅支持11位国内号码
* @param phoneNumber 手机号
* @return String
*/
Result
sendVoiceNotify
(
String
phoneNumber
)
throws
IOException
,
URISyntaxException
;
/**
*批量发送语音 被叫号码,模版无变量多个则以英文半角分号“;”分割;模板带变量,多个号码以英文分号“;”分割,号码和变量以英文逗号“,”隔开, 多个变量以竖线“|”隔开,如 130XXXXXXXX,123|456;186XXXXXXXX,321|654(注意:文件语音模板类型 号码之间分隔用“,”隔开)
* @param phoneNumbers 手机号
* @return String
*/
Result
sendBatchVoiceNotify
(
String
phoneNumbers
)
throws
IOException
,
URISyntaxException
;
}
src/main/java/com/zehong/communication/service/impl/RequestLogServiceImpl.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
service
.
impl
;
import
com.zehong.communication.dao.RequestLogMapper
;
import
com.zehong.communication.entity.RequestLog
;
import
com.zehong.communication.entity.RequestLogExample
;
import
com.zehong.communication.service.RequestLogService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
public
class
RequestLogServiceImpl
implements
RequestLogService
{
@Resource
private
RequestLogMapper
requestLogMapper
;
@Override
public
int
countByExample
(
RequestLogExample
example
)
{
return
requestLogMapper
.
countByExample
(
example
);
}
@Override
public
int
deleteByExample
(
RequestLogExample
example
)
{
return
requestLogMapper
.
deleteByExample
(
example
);
}
@Override
public
int
deleteByPrimaryKey
(
String
id
)
{
return
requestLogMapper
.
deleteByPrimaryKey
(
id
);
}
@Override
public
int
insert
(
RequestLog
record
)
{
return
requestLogMapper
.
insert
(
record
);
}
@Override
public
int
insertSelective
(
RequestLog
record
)
{
return
requestLogMapper
.
insertSelective
(
record
);
}
@Override
public
List
<
RequestLog
>
selectByExample
(
RequestLogExample
example
)
{
return
requestLogMapper
.
selectByExample
(
example
);
}
@Override
public
RequestLog
selectByPrimaryKey
(
String
id
)
{
return
requestLogMapper
.
selectByPrimaryKey
(
id
);
}
@Override
public
int
updateByExampleSelective
(
RequestLog
record
,
RequestLogExample
example
)
{
return
requestLogMapper
.
updateByExampleSelective
(
record
,
example
);
}
@Override
public
int
updateByExample
(
RequestLog
record
,
RequestLogExample
example
)
{
return
requestLogMapper
.
updateByExample
(
record
,
example
);
}
@Override
public
int
updateByPrimaryKeySelective
(
RequestLog
record
)
{
return
requestLogMapper
.
updateByPrimaryKeySelective
(
record
);
}
@Override
public
int
updateByPrimaryKey
(
RequestLog
record
)
{
return
requestLogMapper
.
updateByPrimaryKey
(
record
);
}
}
src/main/java/com/zehong/communication/service/impl/SmsServiceImpl.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
service
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendBatchSmsRequest
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendBatchSmsResponse
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest
;
import
com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.IClientProfile
;
import
com.zehong.communication.common.result.Result
;
import
com.zehong.communication.common.result.ResultEnum
;
import
com.zehong.communication.service.SmsService
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
@Service
public
class
SmsServiceImpl
implements
SmsService
{
@Value
(
"${accessKeyId}"
)
private
String
accessKeyId
;
@Value
(
"${accessKeySecret}"
)
private
String
accessKeySecret
;
@Value
(
"${signName}"
)
private
String
signName
;
@Value
(
"${templateCode}"
)
private
String
templateCode
;
@Value
(
"${signNameJson}"
)
private
String
SignNameJson
;
/**
* 短信API产品名称(短信产品名固定,无需修改)
*/
private
final
String
PRODUCT
=
"Dysmsapi"
;
/**
* 短信API产品域名(接口地址固定,无需修改)
*/
private
final
String
DOMAIN
=
"dysmsapi.aliyuncs.com"
;
@Override
public
Result
sendSms
(
String
phoneNumber
)
throws
ClientException
{
//设置超时时间-可自行调整
System
.
setProperty
(
"sun.net.client.defaultConnectTimeout"
,
"10000"
);
System
.
setProperty
(
"sun.net.client.defaultReadTimeout"
,
"10000"
);
//初始化ascClient需要的几个参数
//初始化ascClient,暂时不支持多region(请勿修改)
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
accessKeyId
,
accessKeySecret
);
DefaultProfile
.
addEndpoint
(
"cn-hangzhou"
,
"cn-hangzhou"
,
PRODUCT
,
DOMAIN
);
IAcsClient
acsClient
=
new
DefaultAcsClient
(
profile
);
SendSmsRequest
request
=
getSmsRequest
();
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000”
request
.
setPhoneNumbers
(
phoneNumber
);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
//友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
//参考:request.setTemplateParam("{\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"}")
request
.
setTemplateParam
(
"{\"cphone\":\""
+
phoneNumber
+
"\"}"
);
//请求失败这里会抛ClientException异常
SendSmsResponse
sendSmsResponse
=
acsClient
.
getAcsResponse
(
request
);
if
(
sendSmsResponse
.
getCode
()
!=
null
&&
sendSmsResponse
.
getCode
().
equals
(
"OK"
))
{
//请求成功
return
new
Result
(
ResultEnum
.
SUCCESS
.
getCode
(),
sendSmsResponse
.
getMessage
());
}
return
new
Result
(
ResultEnum
.
FAIL
.
getCode
(),
sendSmsResponse
.
getMessage
());
}
@Override
public
Result
sendBatchSms
(
String
[]
phoneNumbers
)
throws
ClientException
{
//设置超时时间-可自行调整
System
.
setProperty
(
"sun.net.client.defaultConnectTimeout"
,
"10000"
);
System
.
setProperty
(
"sun.net.client.defaultReadTimeout"
,
"10000"
);
//初始化ascClient,暂时不支持多region(请勿修改)
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
accessKeyId
,
accessKeySecret
);
DefaultProfile
.
addEndpoint
(
"cn-hangzhou"
,
"cn-hangzhou"
,
PRODUCT
,
DOMAIN
);
IAcsClient
acsClient
=
new
DefaultAcsClient
(
profile
);
//组装请求对象
SendBatchSmsRequest
request
=
new
SendBatchSmsRequest
();
//使用post提交
request
.
setMethod
(
MethodType
.
POST
);
//必填:待发送手机号。支持JSON格式的批量调用,批量上限为100个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
//"[\"1500000000\",\"1500000001\"]"
request
.
setPhoneNumberJson
(
new
JSONArray
(
Arrays
.
asList
(
phoneNumbers
)).
toJSONString
());
//必填:短信签名-支持不同的号码发送不同的短信签名
request
.
setSignNameJson
(
SignNameJson
);
//必填:短信模板-可在短信控制台中找到
request
.
setTemplateCode
(
templateCode
);
//必填:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
//友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
request
.
setTemplateParamJson
(
getTemplateParamJson
(
phoneNumbers
));
//可选-上行短信扩展码(扩展码字段控制在7位或以下,无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCodeJson("[\"90997\",\"90998\"]");
//请求失败这里会抛ClientException异常
SendBatchSmsResponse
sendSmsResponse
=
acsClient
.
getAcsResponse
(
request
);
if
(
sendSmsResponse
.
getCode
()
!=
null
&&
sendSmsResponse
.
getCode
().
equals
(
"OK"
))
{
//请求成功
return
new
Result
(
ResultEnum
.
SUCCESS
.
getCode
(),
sendSmsResponse
.
getMessage
());
}
return
new
Result
(
ResultEnum
.
FAIL
.
getCode
(),
sendSmsResponse
.
getMessage
());
}
private
SendSmsRequest
getSmsRequest
(){
//组装请求对象
SendSmsRequest
request
=
new
SendSmsRequest
();
//使用post提交
request
.
setMethod
(
MethodType
.
POST
);
//必填:短信签名-可在短信控制台中找到
request
.
setSignName
(
signName
);
//必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版
request
.
setTemplateCode
(
templateCode
);
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request
.
setOutId
(
"yourOutId"
);
return
request
;
}
private
String
getTemplateParamJson
(
String
[]
phoneNumbers
){
StringBuilder
templateParamJson
=
new
StringBuilder
(
"["
);
for
(
String
phoneNumber
:
phoneNumbers
){
templateParamJson
.
append
(
"{\"cphone\":\""
);
templateParamJson
.
append
(
phoneNumber
);
templateParamJson
.
append
(
"\"}"
);
}
templateParamJson
.
append
(
"]"
);
return
templateParamJson
.
toString
();
}
}
src/main/java/com/zehong/communication/service/impl/VoiceNotifyServiceImpl.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
service
.
impl
;
import
com.zehong.communication.common.result.Result
;
import
com.zehong.communication.service.VoiceNotifyService
;
import
com.zehong.communication.util.HttpUtil
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.util.HashMap
;
import
java.util.Map
;
@Service
public
class
VoiceNotifyServiceImpl
implements
VoiceNotifyService
{
@Value
(
"${voiceNotifyURL}"
)
private
String
voiceNotifyURL
;
@Value
(
"${appId}"
)
private
String
appId
;
@Value
(
"${appKey}"
)
private
String
appKey
;
@Value
(
"${templateId}"
)
private
String
templateId
;
@Value
(
"${batchVoiceNotifyURL}"
)
private
String
batchVoiceNotifyURL
;
@Override
public
Result
sendVoiceNotify
(
String
phoneNumber
)
throws
IOException
,
URISyntaxException
{
Map
<
String
,
Object
>
params
=
getParams
();
params
.
put
(
"mobile"
,
phoneNumber
);
return
HttpUtil
.
doPost
(
voiceNotifyURL
,
params
);
}
@Override
public
Result
sendBatchVoiceNotify
(
String
phoneNumbers
)
throws
IOException
,
URISyntaxException
{
Map
<
String
,
Object
>
params
=
getParams
();
params
.
put
(
"mobile"
,
phoneNumbers
);
return
HttpUtil
.
doPost
(
batchVoiceNotifyURL
,
params
);
}
private
Map
<
String
,
Object
>
getParams
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"appId"
,
appId
);
params
.
put
(
"appKey"
,
appKey
);
params
.
put
(
"templateId"
,
templateId
);
params
.
put
(
"param"
,
"2222,某某街道,报警器报警(手机号后四位,地址,原因"
);
return
params
;
}
}
src/main/java/com/zehong/communication/util/HttpUtil.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
util
;
import
com.zehong.communication.common.result.Result
;
import
com.zehong.communication.common.result.ResultEnum
;
import
org.apache.http.*
;
import
org.apache.http.client.HttpClient
;
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.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.protocol.HTTP
;
import
org.apache.http.util.EntityUtils
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
public
class
HttpUtil
{
/**
* get请求
* @return
*/
public
static
Result
doGet
(
String
url
)
throws
IOException
{
HttpClient
client
=
new
DefaultHttpClient
();
//发送get请求
HttpGet
request
=
new
HttpGet
(
url
);
HttpResponse
response
=
client
.
execute
(
request
);
/**请求发送成功,并得到响应**/
if
(
response
.
getStatusLine
().
getStatusCode
()
==
HttpStatus
.
SC_OK
)
{
/**读取服务器返回过来的json字符串数据**/
String
strResult
=
EntityUtils
.
toString
(
response
.
getEntity
());
return
new
Result
(
ResultEnum
.
SUCCESS
.
getCode
(),
strResult
);
}
return
new
Result
(
ResultEnum
.
FAIL
.
getCode
(),
EntityUtils
.
toString
(
response
.
getEntity
()));
}
/**
* post请求(用于key-value格式的参数)
* @param url
* @param params
* @return
*/
public
static
Result
doPost
(
String
url
,
Map
params
)
throws
IOException
,
URISyntaxException
{
// 定义HttpClient
HttpClient
client
=
new
DefaultHttpClient
();
// 实例化HTTP方法
HttpPost
request
=
new
HttpPost
();
request
.
setURI
(
new
URI
(
url
));
//设置参数
List
<
NameValuePair
>
nvps
=
new
ArrayList
<>();
for
(
Iterator
iter
=
params
.
keySet
().
iterator
();
iter
.
hasNext
();)
{
String
name
=
(
String
)
iter
.
next
();
String
value
=
String
.
valueOf
(
params
.
get
(
name
));
nvps
.
add
(
new
BasicNameValuePair
(
name
,
value
));
}
request
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
,
HTTP
.
UTF_8
));
HttpResponse
response
=
client
.
execute
(
request
);
int
code
=
response
.
getStatusLine
().
getStatusCode
();
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
response
.
getEntity
()
.
getContent
(),
"utf-8"
));
StringBuffer
sb
=
new
StringBuffer
(
""
);
String
line
=
""
;
String
NL
=
System
.
getProperty
(
"line.separator"
);
while
((
line
=
in
.
readLine
())
!=
null
)
{
sb
.
append
(
line
+
NL
);
}
in
.
close
();
//请求成功
if
(
code
==
200
){
return
new
Result
(
ResultEnum
.
SUCCESS
.
getCode
(),
sb
.
toString
());
}
return
new
Result
(
ResultEnum
.
FAIL
.
getCode
(),
sb
.
toString
());
}
/**
* post请求(用于请求json格式的参数)
* @param url
* @param params
* @return
*/
public
static
Result
doPost
(
String
url
,
String
params
)
throws
Exception
{
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
// 创建httpPost
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
setHeader
(
"Accept"
,
"application/json"
);
httpPost
.
setHeader
(
"Content-Type"
,
"application/json"
);
String
charSet
=
"UTF-8"
;
StringEntity
entity
=
new
StringEntity
(
params
,
charSet
);
httpPost
.
setEntity
(
entity
);
CloseableHttpResponse
response
=
null
;
try
{
response
=
httpclient
.
execute
(
httpPost
);
StatusLine
status
=
response
.
getStatusLine
();
int
state
=
status
.
getStatusCode
();
HttpEntity
responseEntity
=
response
.
getEntity
();
String
jsonString
=
EntityUtils
.
toString
(
responseEntity
);
if
(
state
==
HttpStatus
.
SC_OK
)
{
return
new
Result
(
ResultEnum
.
SUCCESS
.
getCode
(),
jsonString
);
}
return
new
Result
(
ResultEnum
.
FAIL
.
getCode
(),
jsonString
);
}
finally
{
if
(
response
!=
null
)
{
try
{
response
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
try
{
httpclient
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/main/java/com/zehong/communication/util/IPUtils.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
util
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
public
class
IPUtils
{
public
final
static
String
getIpAddress
(
HttpServletRequest
request
)
throws
IOException
{
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"HTTP_CLIENT_IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"HTTP_X_FORWARDED_FOR"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
}
}
else
if
(
ip
.
length
()
>
15
)
{
String
[]
ips
=
ip
.
split
(
","
);
for
(
int
index
=
0
;
index
<
ips
.
length
;
index
++)
{
String
strIp
=
(
String
)
ips
[
index
];
if
(!(
"unknown"
.
equalsIgnoreCase
(
strIp
)))
{
ip
=
strIp
;
break
;
}
}
}
return
ip
;
}
}
src/main/java/com/zehong/communication/util/MD5Utils.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
.
util
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.digest.DigestUtils
;
public
class
MD5Utils
{
/**
* f225e66813e6d6a663daf919c1935dcb md5
*/
static
final
String
TARGET
=
"zehongcommunicationservice"
;
/**
* 不可逆算法 MD5
* @param target 目标字符串
* @return
*/
public
static
String
Md5
(
String
target
){
return
DigestUtils
.
md5Hex
(
target
);
}
/**
* 不可逆算法 SHA1
* @param target 目标字符串
* @param type 加密算法
* @return String
*/
public
static
String
sha1
(
String
target
,
String
type
){
switch
(
type
){
case
"shaHex"
:
return
DigestUtils
.
shaHex
(
target
);
case
"sha256Hex"
:
return
DigestUtils
.
sha256Hex
(
target
);
case
"sha384Hex"
:
return
DigestUtils
.
sha384Hex
(
target
);
case
"sha512Hex"
:
return
DigestUtils
.
sha512Hex
(
target
);
default
:
return
null
;
}
}
/**
* 可逆算法 BASE64加密算法
* @param target 目标字符串
* @return String
*/
public
static
String
encodeBase64
(
String
target
){
//加密
byte
[]
b
=
Base64
.
encodeBase64
(
target
.
getBytes
(),
true
);
return
new
String
(
b
);
}
/**
* 可逆算法 BASE64解密算法
* @param target 目标字符串
* @return String
*/
public
static
String
decodeBase64
(
String
target
){
//解密
byte
[]
b1
=
Base64
.
decodeBase64
(
target
);
return
new
String
(
b1
);
}
}
src/main/resources/application.yml
0 → 100644
View file @
716a211e
# 开发环境配置
server
:
# 服务器的HTTP端口,默认为8080
port
:
8080
servlet
:
# 应用的访问路径
context-path
:
/
tomcat
:
# tomcat的URI编码
uri-encoding
:
UTF-8
# tomcat最大线程数,默认为200
max-threads
:
800
# Tomcat启动初始化的线程数,默认值25
min-spare-threads
:
30
# 数据源配置
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://36.148.23.59:3306/communication?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username
:
root
password
:
root@123
mybatis
:
type-aliases-package
:
com.zehong.communication.entity
mapper-locations
:
classpath*:mapper/**/*Mapper.xml
#语音通知接口
voiceNotifyURL
:
https://api.253.com/open/notify/voice-notify
appId
:
N69N0WkT
appKey
:
IE5F7Jih
templateId
:
4371
#批量发送语音
batchVoiceNotifyURL
:
https://api.253.com/open/notify/batch-voice-notify
#阿里云发送短信
accessKeyId
:
LTAI2xiZNF3iV2aV
accessKeySecret
:
bprEWwn1M0xgglRQCQEMYSPiYctDk4
signName
:
泽宏云
templateCode
:
SMS_162524468
#阿里批量发送短信
signNameJson
:
[
\"泽宏云\"
]
#ip白名单
iPWhite
:
192.168.2.23
#秘钥
secretKey
:
f225e66813e6d6a663daf919c1935dcb
\ No newline at end of file
src/main/resources/mapper/RequestLogMapper.xml
0 → 100644
View file @
716a211e
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.zehong.communication.dao.RequestLogMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.zehong.communication.entity.RequestLog"
>
<id
column=
"id"
property=
"id"
jdbcType=
"CHAR"
/>
<result
column=
"secret_key"
property=
"secretKey"
jdbcType=
"CHAR"
/>
<result
column=
"request_mapping"
property=
"requestMapping"
jdbcType=
"VARCHAR"
/>
<result
column=
"params"
property=
"params"
jdbcType=
"CHAR"
/>
<result
column=
"post_time"
property=
"postTime"
jdbcType=
"CHAR"
/>
<result
column=
"result"
property=
"result"
jdbcType=
"CHAR"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where
>
<foreach
collection=
"oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
suffix=
")"
prefixOverrides=
"and"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose
>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
collection=
"criterion.value"
item=
"listItem"
open=
"("
close=
")"
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Update_By_Example_Where_Clause"
>
<where
>
<foreach
collection=
"example.oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
suffix=
")"
prefixOverrides=
"and"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose
>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
collection=
"criterion.value"
item=
"listItem"
open=
"("
close=
")"
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Base_Column_List"
>
id, secret_key, request_mapping, params, post_time, result
</sql>
<select
id=
"selectByExample"
resultMap=
"BaseResultMap"
parameterType=
"com.zehong.communication.entity.RequestLogExample"
>
select
<if
test=
"distinct"
>
distinct
</if>
<include
refid=
"Base_Column_List"
/>
from request_log
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
</if>
</select>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.String"
>
select
<include
refid=
"Base_Column_List"
/>
from request_log
where id = #{id,jdbcType=CHAR}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.String"
>
delete from request_log
where id = #{id,jdbcType=CHAR}
</delete>
<delete
id=
"deleteByExample"
parameterType=
"com.zehong.communication.entity.RequestLogExample"
>
delete from request_log
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</delete>
<insert
id=
"insert"
parameterType=
"com.zehong.communication.entity.RequestLog"
>
insert into request_log (id, secret_key, request_mapping,
params, post_time, result)
values (#{id,jdbcType=CHAR}, #{secretKey,jdbcType=CHAR}, #{requestMapping,jdbcType=VARCHAR},
#{params,jdbcType=CHAR}, #{postTime,jdbcType=CHAR}, #{result,jdbcType=CHAR})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.zehong.communication.entity.RequestLog"
>
insert into request_log
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"secretKey != null"
>
secret_key,
</if>
<if
test=
"requestMapping != null"
>
request_mapping,
</if>
<if
test=
"params != null"
>
params,
</if>
<if
test=
"postTime != null"
>
post_time,
</if>
<if
test=
"result != null"
>
result,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id,jdbcType=CHAR},
</if>
<if
test=
"secretKey != null"
>
#{secretKey,jdbcType=CHAR},
</if>
<if
test=
"requestMapping != null"
>
#{requestMapping,jdbcType=VARCHAR},
</if>
<if
test=
"params != null"
>
#{params,jdbcType=CHAR},
</if>
<if
test=
"postTime != null"
>
#{postTime,jdbcType=CHAR},
</if>
<if
test=
"result != null"
>
#{result,jdbcType=CHAR},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"com.zehong.communication.entity.RequestLogExample"
resultType=
"java.lang.Integer"
>
select count(*) from request_log
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</select>
<update
id=
"updateByExampleSelective"
parameterType=
"map"
>
update request_log
<set
>
<if
test=
"record.id != null"
>
id = #{record.id,jdbcType=CHAR},
</if>
<if
test=
"record.secretKey != null"
>
secret_key = #{record.secretKey,jdbcType=CHAR},
</if>
<if
test=
"record.requestMapping != null"
>
request_mapping = #{record.requestMapping,jdbcType=VARCHAR},
</if>
<if
test=
"record.params != null"
>
params = #{record.params,jdbcType=CHAR},
</if>
<if
test=
"record.postTime != null"
>
post_time = #{record.postTime,jdbcType=CHAR},
</if>
<if
test=
"record.result != null"
>
result = #{record.result,jdbcType=CHAR},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByExample"
parameterType=
"map"
>
update request_log
set id = #{record.id,jdbcType=CHAR},
secret_key = #{record.secretKey,jdbcType=CHAR},
request_mapping = #{record.requestMapping,jdbcType=VARCHAR},
params = #{record.params,jdbcType=CHAR},
post_time = #{record.postTime,jdbcType=CHAR},
result = #{record.result,jdbcType=CHAR}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.zehong.communication.entity.RequestLog"
>
update request_log
<set
>
<if
test=
"secretKey != null"
>
secret_key = #{secretKey,jdbcType=CHAR},
</if>
<if
test=
"requestMapping != null"
>
request_mapping = #{requestMapping,jdbcType=VARCHAR},
</if>
<if
test=
"params != null"
>
params = #{params,jdbcType=CHAR},
</if>
<if
test=
"postTime != null"
>
post_time = #{postTime,jdbcType=CHAR},
</if>
<if
test=
"result != null"
>
result = #{result,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=CHAR}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.zehong.communication.entity.RequestLog"
>
update request_log
set secret_key = #{secretKey,jdbcType=CHAR},
request_mapping = #{requestMapping,jdbcType=VARCHAR},
params = #{params,jdbcType=CHAR},
post_time = #{postTime,jdbcType=CHAR},
result = #{result,jdbcType=CHAR}
where id = #{id,jdbcType=CHAR}
</update>
</mapper>
\ No newline at end of file
src/test/java/com/zehong/communication/CommunicationApplicationTests.java
0 → 100644
View file @
716a211e
package
com
.
zehong
.
communication
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
CommunicationApplicationTests
{
@Test
void
contextLoads
()
{
}
}
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