Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dmhub-plugin
Project
Project
Details
Activity
Releases
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
qinxunjia
dmhub-plugin
Commits
044296b4
Commit
044296b4
authored
Jun 23, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志配置修改
parent
3393b66f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
42 deletions
+76
-42
pom.xml
pom.xml
+37
-7
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+10
-10
logback-spring.xml
src/main/resources/logback-spring.xml
+29
-25
No files found.
pom.xml
View file @
044296b4
...
...
@@ -5,7 +5,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.example
</groupId>
<artifactId>
dmhub
-plugin
</artifactId>
<artifactId>
sms
-plugin
</artifactId>
<version>
1.0.0
</version>
<name>
插件服务
</name>
...
...
@@ -27,14 +27,15 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<exclusions>
<exclusion>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
<artifactId>
spring-boot-starter-logging
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
...
...
@@ -57,6 +58,35 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-amqp
</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/net.logstash.logback/logstash-logback-encoder -->
<dependency>
<groupId>
net.logstash.logback
</groupId>
<artifactId>
logstash-logback-encoder
</artifactId>
<version>
3.6
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
1.7.7
</version>
</dependency>
<!-- logback -->
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<version>
1.1.2
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-access
</artifactId>
<version>
1.1.2
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-core
</artifactId>
<version>
1.1.2
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
...
...
@@ -99,7 +129,7 @@
</dependency>
</dependencies>
<build>
<finalName>
dmhub
-plugin-${version}
</finalName>
<finalName>
sms
-plugin-${version}
</finalName>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
...
...
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
044296b4
...
...
@@ -11,8 +11,6 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
@SuppressWarnings
(
"Duplicates"
)
@RestController
@RequestMapping
()
...
...
@@ -23,6 +21,14 @@ public class DmHubApi {
@Autowired
private
MessageService
messageService
;
@GetMapping
(
"/ping"
)
public
String
ping
()
{
log
.
info
(
"====sms ping====="
);
return
"pong"
;
}
/**
* 创建短信模板
*
...
...
@@ -94,9 +100,9 @@ public class DmHubApi {
}
public
boolean
checkSignature
(
String
timestamp
,
String
signature
)
{
String
signStr
=
DmHubConfig
.
appId
+
DmHubConfig
.
appSecret
+
"20200619072847"
;
String
signStr
=
DmHubConfig
.
appId
+
DmHubConfig
.
appSecret
+
timestamp
;
String
encrypt
=
Md5Util
.
encrypt
(
signStr
);
log
.
info
(
"待签名串:"
+
encrypt
);
log
.
info
(
"待签名串:"
+
encrypt
);
if
(!
encrypt
.
equals
(
signature
))
{
log
.
error
(
"签名不一致,插件生成签名:{}"
,
encrypt
);
return
false
;
...
...
@@ -127,10 +133,4 @@ public class DmHubApi {
log
.
info
(
"**********单条发送出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
return
response
;
}
public
static
void
main
(
String
[]
args
)
{
String
a
=
"1smsdemo"
+
"ac031765c3a8c9acc4747808e4fe5918"
+
"20200619070139"
;
String
encrypt
=
Md5Util
.
encrypt
(
a
);
System
.
out
.
println
(
encrypt
);
}
}
src/main/resources/logback-spring.xml
View file @
044296b4
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--定义日志文件的存储地址 -->
<property
name=
"LOG_PATH"
value=
"/opt/log/stash/sms-plug"
/>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<include
resource=
"org/springframework/boot/logging/logback/console-appender.xml"
/>
<springProperty
scope=
"context"
name=
"env"
source=
"spring.profiles"
/>
<property
name=
"service"
value=
"sms-plug"
/>
<property
name=
"logfile"
value=
"${LOG_DIR:-/opt/log/stash}/${service}/${service}"
/>
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}
</pattern>
<charset>
UTF-8
</charset>
</encoder>
</appender>
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<File>
${LOG_PATH}/smsplug.log
</File>
<encoder>
<pattern>
%date [%level] [%thread] %logger{60} [%file : %line] %msg%n
</pattern>
<appender
name=
"logstash"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${logfile}.log
</file>
<encoder
class=
"net.logstash.logback.encoder.LogstashEncoder"
>
<includeMdc>
true
</includeMdc>
<customFields>
{
"service":"${service}",
"env": "${env:-dev}"
}
</customFields>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${
LOG_PATH}daily/sms-plug.%d{yyyy-MM-dd
}.gz
</fileNamePattern>
<maxHistory>
30
</maxHistory>
<!-- 保留180天 --
>
<fileNamePattern>
${
logfile}.log.%d{yyyy-MM-dd-HH
}.gz
</fileNamePattern>
<maxHistory>
7
</maxHistory
>
</rollingPolicy>
</appender>
<root
level=
"
INFO
"
>
<appender-ref
ref=
"
CONSOLE
"
/>
<appender-ref
ref=
"
FILE
"
/>
<root
level=
"
info
"
>
<appender-ref
ref=
"
console
"
/>
<appender-ref
ref=
"
logstash
"
/>
</root>
<!-- 开发、测试环境 -->
<springProfile
name=
"dev,test"
>
<logger
name=
"org.springboot.sample"
level=
"DEBUG"
/>
<logger
name=
"com.bgy"
level=
"DEBUG"
/>
</springProfile>
<!-- 生产环境 -->
<springProfile
name=
"prod"
>
<logger
name=
"org.springframework.web"
level=
"ERROR"
/>
<logger
name=
"org.springboot.sample"
level=
"ERROR"
/>
<logger
name=
"com.bgy"
level=
"ERROR"
/>
</springProfile>
</configuration>
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