Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mall
arch
matrix
Commits
c6ed8153
Commit
c6ed8153
authored
Jul 15, 2021
by
房斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志打印规范,
parent
9c94837d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
28 deletions
+48
-28
pom.xml
common-core/pom.xml
+6
-0
Response.java
common-core/src/main/java/com/secoo/mall/common/core/bean/Response.java
+13
-1
pom.xml
common-util/pom.xml
+1
-0
HttpClientUtils.java
common-util/src/main/java/com/secoo/mall/common/util/http/HttpClientUtils.java
+21
-22
pom.xml
matrix-protocol/pom.xml
+1
-0
pom.xml
pom.xml
+6
-5
No files found.
common-core/pom.xml
View file @
c6ed8153
...
@@ -10,6 +10,12 @@
...
@@ -10,6 +10,12 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
common-core
</artifactId>
<artifactId>
common-core
</artifactId>
<dependencies>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependencies>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
...
...
common-core/src/main/java/com/secoo/mall/common/core/bean/Response.java
View file @
c6ed8153
package
com
.
secoo
.
mall
.
common
.
core
.
bean
;
package
com
.
secoo
.
mall
.
common
.
core
.
bean
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.io.Serializable
;
import
java.io.Serializable
;
/**
/**
...
@@ -7,6 +10,8 @@ import java.io.Serializable;
...
@@ -7,6 +10,8 @@ import java.io.Serializable;
*
*
* @param <T>
* @param <T>
*/
*/
@Getter
@Setter
public
class
Response
<
T
>
implements
Serializable
{
public
class
Response
<
T
>
implements
Serializable
{
private
Integer
code
;
private
Integer
code
;
...
@@ -21,6 +26,12 @@ public class Response<T> implements Serializable {
...
@@ -21,6 +26,12 @@ public class Response<T> implements Serializable {
this
.
msg
=
msg
;
this
.
msg
=
msg
;
}
}
public
Response
(
Integer
code
,
String
msg
,
T
data
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
this
.
data
=
data
;
}
public
Integer
getCode
()
{
public
Integer
getCode
()
{
return
code
;
return
code
;
}
}
...
@@ -53,4 +64,4 @@ public class Response<T> implements Serializable {
...
@@ -53,4 +64,4 @@ public class Response<T> implements Serializable {
", data="
+
data
+
", data="
+
data
+
'}'
;
'}'
;
}
}
}
}
\ No newline at end of file
common-util/pom.xml
View file @
c6ed8153
...
@@ -73,6 +73,7 @@
...
@@ -73,6 +73,7 @@
<groupId>
org.apache.httpcomponents
</groupId>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpmime
</artifactId>
<artifactId>
httpmime
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpasyncclient
</artifactId>
<artifactId>
httpasyncclient
</artifactId>
...
...
common-util/src/main/java/com/secoo/mall/common/util/http/HttpClientUtils.java
View file @
c6ed8153
...
@@ -103,7 +103,7 @@ public class HttpClientUtils {
...
@@ -103,7 +103,7 @@ public class HttpClientUtils {
String
result
=
doGet
(
url
,
new
HashMap
<>(
10
));
String
result
=
doGet
(
url
,
new
HashMap
<>(
10
));
return
result
;
return
result
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"发送 GET 请求ERROR
:{}
"
,
e
);
LOG
.
error
(
"发送 GET 请求ERROR
:
"
,
e
);
}
}
return
""
;
return
""
;
}
}
...
@@ -125,7 +125,7 @@ public class HttpClientUtils {
...
@@ -125,7 +125,7 @@ public class HttpClientUtils {
String
result
=
null
;
String
result
=
null
;
if
(
StringUtils
.
isEmpty
(
url
))
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
debug
(
"warn:
doGet url is null or '' "
);
LOG
.
warn
(
"
doGet url is null or '' "
);
return
result
;
return
result
;
}
}
...
@@ -177,7 +177,7 @@ public class HttpClientUtils {
...
@@ -177,7 +177,7 @@ public class HttpClientUtils {
CloseableHttpResponse
response
=
httpclient
.
execute
(
httpGet
);
CloseableHttpResponse
response
=
httpclient
.
execute
(
httpGet
);
LOG
.
info
(
"doGet statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
LOG
.
debug
(
"doGet statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
return
response
.
getEntity
();
return
response
.
getEntity
();
...
@@ -209,7 +209,7 @@ public class HttpClientUtils {
...
@@ -209,7 +209,7 @@ public class HttpClientUtils {
response
=
httpclient
.
execute
(
httpDelete
);
response
=
httpclient
.
execute
(
httpDelete
);
LOG
.
info
(
"httpDelete statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
LOG
.
debug
(
"httpDelete statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
HttpEntity
entity
=
response
.
getEntity
();
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
if
(
entity
!=
null
)
{
...
@@ -251,8 +251,7 @@ public class HttpClientUtils {
...
@@ -251,8 +251,7 @@ public class HttpClientUtils {
});
});
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setDefaultRequestConfig
(
requestConfig
)
CloseableHttpClient
httpclient
=
HttpClients
.
custom
().
setDefaultRequestConfig
(
requestConfig
).
setConnectionManager
(
connMgr
).
build
();
.
setConnectionManager
(
connMgr
).
build
();
CloseableHttpResponse
response
=
null
;
CloseableHttpResponse
response
=
null
;
InputStream
instream
=
null
;
InputStream
instream
=
null
;
try
{
try
{
...
@@ -272,7 +271,7 @@ public class HttpClientUtils {
...
@@ -272,7 +271,7 @@ public class HttpClientUtils {
}
}
response
=
httpclient
.
execute
(
httpPut
);
response
=
httpclient
.
execute
(
httpPut
);
LOG
.
info
(
"doGet statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
LOG
.
debug
(
"doGet statusCode:{}"
,
response
.
getStatusLine
().
getStatusCode
());
HttpEntity
entity
=
response
.
getEntity
();
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
if
(
entity
!=
null
)
{
...
@@ -315,7 +314,7 @@ public class HttpClientUtils {
...
@@ -315,7 +314,7 @@ public class HttpClientUtils {
public
static
String
doPost
(
String
url
,
Map
<
String
,
Object
>
params
)
throws
Exception
{
public
static
String
doPost
(
String
url
,
Map
<
String
,
Object
>
params
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
url
))
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
info
(
"warn:
doPost url is null or '' "
);
LOG
.
warn
(
"
doPost url is null or '' "
);
return
null
;
return
null
;
}
}
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>(
params
.
size
());
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>(
params
.
size
());
...
@@ -339,7 +338,7 @@ public class HttpClientUtils {
...
@@ -339,7 +338,7 @@ public class HttpClientUtils {
public
static
String
doPost
(
String
url
,
String
xml
)
throws
Exception
{
public
static
String
doPost
(
String
url
,
String
xml
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
url
))
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
info
(
"warn:
doPost url is null or '' "
);
LOG
.
warn
(
"
doPost url is null or '' "
);
return
null
;
return
null
;
}
}
...
@@ -359,7 +358,7 @@ public class HttpClientUtils {
...
@@ -359,7 +358,7 @@ public class HttpClientUtils {
public
static
String
doPost
(
String
url
,
Object
json
)
throws
Exception
{
public
static
String
doPost
(
String
url
,
Object
json
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
url
))
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
error
(
"warn:
doPostByJson url is null or '' "
);
LOG
.
warn
(
"
doPostByJson url is null or '' "
);
return
null
;
return
null
;
}
}
HttpPost
httpPost
=
new
HttpPost
(
url
);
HttpPost
httpPost
=
new
HttpPost
(
url
);
...
@@ -373,7 +372,7 @@ public class HttpClientUtils {
...
@@ -373,7 +372,7 @@ public class HttpClientUtils {
public
static
String
doPost
(
String
url
,
HttpEntity
entity
,
Map
<
String
,
String
>
headers
)
throws
Exception
{
public
static
String
doPost
(
String
url
,
HttpEntity
entity
,
Map
<
String
,
String
>
headers
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
url
))
{
if
(
StringUtils
.
isEmpty
(
url
))
{
LOG
.
error
(
"warn:
doPostByJson url is null or '' "
);
LOG
.
warn
(
"
doPostByJson url is null or '' "
);
return
null
;
return
null
;
}
}
HttpPost
httpPost
=
new
HttpPost
(
url
);
HttpPost
httpPost
=
new
HttpPost
(
url
);
...
@@ -396,7 +395,7 @@ public class HttpClientUtils {
...
@@ -396,7 +395,7 @@ public class HttpClientUtils {
public
static
String
doPostSsl
(
String
apiUrl
,
Map
<
String
,
Object
>
params
)
throws
Exception
{
public
static
String
doPostSsl
(
String
apiUrl
,
Map
<
String
,
Object
>
params
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
apiUrl
))
{
if
(
StringUtils
.
isEmpty
(
apiUrl
))
{
LOG
.
info
(
"warn:
doPostSSL url is null or '' "
);
LOG
.
warn
(
"
doPostSSL url is null or '' "
);
return
null
;
return
null
;
}
}
...
@@ -421,7 +420,7 @@ public class HttpClientUtils {
...
@@ -421,7 +420,7 @@ public class HttpClientUtils {
public
static
String
doPostSsl
(
String
apiUrl
,
Object
json
)
throws
Exception
{
public
static
String
doPostSsl
(
String
apiUrl
,
Object
json
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
apiUrl
))
{
if
(
StringUtils
.
isEmpty
(
apiUrl
))
{
LOG
.
info
(
"warn:
doPostSSL By Json url is null or '' "
);
LOG
.
warn
(
"
doPostSSL By Json url is null or '' "
);
return
null
;
return
null
;
}
}
...
@@ -498,32 +497,32 @@ public class HttpClientUtils {
...
@@ -498,32 +497,32 @@ public class HttpClientUtils {
content
[
0
]=
""
;
content
[
0
]=
""
;
// 传入HttpPost request
// 传入HttpPost request
CloseableHttpAsyncClient
httpclient
=
HttpAsyncClients
.
custom
().
setDefaultRequestConfig
(
requestConfig
).
build
();
CloseableHttpAsyncClient
httpclient
=
HttpAsyncClients
.
custom
().
setDefaultRequestConfig
(
requestConfig
).
build
();
LOG
.
info
(
"httpclient test begin time:{}"
,
DateUtil
.
getDateTime
());
LOG
.
debug
(
"httpclient test begin time:{}"
,
DateUtil
.
getDateTime
());
httpclient
.
start
();
httpclient
.
start
();
httpclient
.
execute
(
request
,
new
FutureCallback
<
HttpResponse
>()
{
httpclient
.
execute
(
request
,
new
FutureCallback
<
HttpResponse
>()
{
@Override
@Override
public
void
completed
(
final
HttpResponse
response
)
{
public
void
completed
(
final
HttpResponse
response
)
{
LOG
.
info
(
request
.
getRequestLine
()
+
"->"
+
response
.
getStatusLine
());
LOG
.
debug
(
request
.
getRequestLine
()
+
"->"
+
response
.
getStatusLine
());
LOG
.
info
(
"httpclient test received content time:{}"
,
DateUtil
.
getDateTime
());
LOG
.
debug
(
"httpclient test received content time:{}"
,
DateUtil
.
getDateTime
());
try
{
try
{
content
[
0
]
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
content
[
0
]
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"UTF-8"
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
LOG
.
error
(
"matrix HttpClientUtils asynchronousPost error"
,
e
);
LOG
.
error
(
"matrix HttpClientUtils asynchronousPost error"
,
e
);
}
}
}
}
@Override
@Override
public
void
failed
(
final
Exception
ex
)
{
public
void
failed
(
final
Exception
ex
)
{
LOG
.
info
(
"httpclient test received failed time:{}"
,
DateUtil
.
getDateTime
());
LOG
.
debug
(
"httpclient test received failed time:{}"
,
DateUtil
.
getDateTime
());
LOG
.
error
(
request
.
getRequestLine
()
+
"->"
+
ex
);
LOG
.
error
(
request
.
getRequestLine
()
+
"->"
,
ex
);
}
}
@Override
@Override
public
void
cancelled
()
{
public
void
cancelled
()
{
LOG
.
info
(
"httpclient test received cancelled time:{}"
,
DateUtil
.
getDateTime
());
LOG
.
debug
(
"httpclient test received cancelled time:{}"
,
DateUtil
.
getDateTime
());
LOG
.
error
(
request
.
getRequestLine
()
+
" cancelled"
);
LOG
.
warn
(
request
.
getRequestLine
()
+
" cancelled"
);
}
}
});
});
LOG
.
info
(
"httpclient test end time:{}"
,
DateUtil
.
getDateTime
());
LOG
.
debug
(
"httpclient test end time:{}"
,
DateUtil
.
getDateTime
());
return
content
[
0
];
return
content
[
0
];
}
}
...
...
matrix-protocol/pom.xml
View file @
c6ed8153
...
@@ -156,6 +156,7 @@
...
@@ -156,6 +156,7 @@
<artifactId>
springfox-spring-web
</artifactId>
<artifactId>
springfox-spring-web
</artifactId>
<version>
2.9.2
</version>
<version>
2.9.2
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
pom.xml
View file @
c6ed8153
...
@@ -210,11 +210,7 @@
...
@@ -210,11 +210,7 @@
<artifactId>
joda-time
</artifactId>
<artifactId>
joda-time
</artifactId>
<version>
2.10
</version>
<version>
2.10
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.esotericsoftware
</groupId>
<artifactId>
kryo
</artifactId>
<version>
4.0.2
</version>
</dependency>
<!--protobuf-->
<!--protobuf-->
<dependency>
<dependency>
...
@@ -257,6 +253,11 @@
...
@@ -257,6 +253,11 @@
<artifactId>
httpasyncclient
</artifactId>
<artifactId>
httpasyncclient
</artifactId>
<version>
4.1.2
</version>
<version>
4.1.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.2
</version>
</dependency>
</dependencies>
</dependencies>
...
...
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