Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
test-in-sleuth
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
仲光辉
test-in-sleuth
Commits
73c8f640
Commit
73c8f640
authored
Oct 20, 2020
by
仲光辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
切入点表达式修正:@Annotation -->@within 2020/10/20 10:21
parent
f08ada1e
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
16 deletions
+52
-16
DoRequestLog.java
...va/cn/dankal/test/common/service/aspect/DoRequestLog.java
+4
-10
RequestLogAspect.java
...n/dankal/test/common/service/aspect/RequestLogAspect.java
+1
-1
UserController.java
...n/java/cn/dankal/test/user/controller/UserController.java
+11
-1
UserController.java
...n/java/cn/dankal/test/user/controller/UserController.java
+10
-1
OrderController.java
...java/cn/dankal/test/order/controller/OrderController.java
+7
-2
OrderController.java
...java/cn/dankal/test/order/controller/OrderController.java
+6
-1
OrderServiceClient.java
.../java/cn/dankal/test/client/order/OrderServiceClient.java
+8
-0
OrderServiceClientFallback.java
...est/client/order/fallback/OrderServiceClientFallback.java
+5
-0
No files found.
01-test-in-sleuth-common/01-02-service-util/src/main/java/cn/dankal/test/common/service/aspect/DoRequestLog.java
View file @
73c8f640
...
...
@@ -13,17 +13,11 @@ import java.lang.annotation.Target;
* <p>
* 此注解标注使用在标有诸如:
* <br/>
* - {@link org.springframework.web.bind.annotation.Re
questMapping
}
* - {@link org.springframework.web.bind.annotation.Re
stController
}
* <br/>
* - {@link org.springframework.
web.bind.annotation.GetMapping
}
* - {@link org.springframework.
stereotype.Controller
}
* <br/>
* - {@link org.springframework.web.bind.annotation.PostMapping}
* <br/>
* - {@link org.springframework.web.bind.annotation.PutMapping}
* <br/>
* - {@link org.springframework.web.bind.annotation.DeleteMapping}
* </p>
* 等 SpringMVC 处理器方法注解的方法上 用于记录 请求日志 和 处理请求异常日志
* 等 SpringMVC Application Controller注解的类上 用于记录 请求日志 和 处理请求异常日志
* <br/>
* <br/>
* 当前注解{@link DoRequestLog} 是 Request日志切面${@link RequestLogAspect} 的 切入点表达式
...
...
@@ -41,7 +35,7 @@ import java.lang.annotation.Target;
* @create 2020/10/19
* @see RequestLogAspect
*/
@Target
({
ElementType
.
METHOD
})
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
DoRequestLog
{
...
...
01-test-in-sleuth-common/01-02-service-util/src/main/java/cn/dankal/test/common/service/aspect/RequestLogAspect.java
View file @
73c8f640
...
...
@@ -44,7 +44,7 @@ public class RequestLogAspect {
/**
* 切入点表达式
*/
@Pointcut
(
"@
annotatio
n(cn.dankal.test.common.service.aspect.DoRequestLog)"
)
@Pointcut
(
"@
withi
n(cn.dankal.test.common.service.aspect.DoRequestLog)"
)
public
void
pointcut
()
{
}
...
...
03-test-in-sleuth-user/03-01-user-service-01/src/main/java/cn/dankal/test/user/controller/UserController.java
View file @
73c8f640
...
...
@@ -9,6 +9,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
/**
* {@link RestController}
* UserController
...
...
@@ -18,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
* @create 2020/10/18
*/
@Slf4j
@DoRequestLog
@RestController
@RequestMapping
(
"/user"
)
public
class
UserController
{
...
...
@@ -31,7 +35,6 @@ public class UserController {
this
.
orderServiceClient
=
orderServiceClient
;
}
@DoRequestLog
@GetMapping
(
"/{userId}"
)
public
Person
getUserById
(
@PathVariable
(
"userId"
)
Long
userId
)
{
log
.
info
(
"user service 01 get user: {}"
,
userId
);
...
...
@@ -41,4 +44,11 @@ public class UserController {
.
setName
(
"ZGH.MercyModest"
)
.
setOther
(
"user-service-01 --> "
+
orderId
);
}
@RequestMapping
(
"/test/info"
)
public
String
getTestInfo
()
{
String
timeFormatString
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
LocalDateTime
.
now
());
String
orderSimpleInfo
=
orderServiceClient
.
testGetSimpleInfo
();
return
timeFormatString
+
" --> "
+
orderSimpleInfo
;
}
}
03-test-in-sleuth-user/03-02-user-service-02/src/main/java/cn/dankal/test/user/controller/UserController.java
View file @
73c8f640
...
...
@@ -9,6 +9,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
/**
* {@link RestController}
* UserController
...
...
@@ -18,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
* @create 2020/10/18
*/
@Slf4j
@DoRequestLog
@RestController
@RequestMapping
(
"/user"
)
public
class
UserController
{
...
...
@@ -31,7 +35,6 @@ public class UserController {
this
.
orderServiceClient
=
orderServiceClient
;
}
@DoRequestLog
@GetMapping
(
"/{userId}"
)
public
Person
getUserById
(
@PathVariable
(
"userId"
)
Long
userId
)
throws
Throwable
{
if
(
1
==
userId
)
{
...
...
@@ -45,4 +48,10 @@ public class UserController {
.
setName
(
"ZGH.MercyModest"
)
.
setOther
(
"user-service-02 --> "
+
orderId
);
}
@RequestMapping
(
"/test/info"
)
public
String
getTestInfo
()
{
String
timeFormatString
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
LocalDateTime
.
now
());
String
orderSimpleInfo
=
orderServiceClient
.
testGetSimpleInfo
();
return
timeFormatString
+
" --> "
+
orderSimpleInfo
;
}
}
04-test-in-sleuth-order/04-01-order-service-01/src/main/java/cn/dankal/test/order/controller/OrderController.java
View file @
73c8f640
...
...
@@ -19,15 +19,20 @@ import java.util.UUID;
* @create 2020/10/18
*/
@Slf4j
@DoRequestLog
@RestController
@RequestMapping
(
"/order"
)
public
class
OrderController
{
@DoRequestLog
@GetMapping
(
"/{userId}"
)
public
String
getOrderId
(
@PathVariable
(
"userId"
)
Long
userId
)
{
log
.
info
(
"order service 01 getOrderId: {}"
,
userId
);
return
"order service 01 "
+
userId
+
" --> "
+
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
return
"order service 01 "
+
userId
+
" --> "
+
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
}
@GetMapping
(
"/test/info"
)
public
String
testGetSimpleInfo
()
{
return
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
}
}
04-test-in-sleuth-order/04-02-order-service-02/src/main/java/cn/dankal/test/order/controller/OrderController.java
View file @
73c8f640
...
...
@@ -19,11 +19,11 @@ import java.util.UUID;
* @create 2020/10/18
*/
@Slf4j
@DoRequestLog
@RestController
@RequestMapping
(
"/order"
)
public
class
OrderController
{
@DoRequestLog
@GetMapping
(
"/{userId}"
)
public
String
getOrderId
(
@PathVariable
(
"userId"
)
Long
userId
)
{
log
.
info
(
"order service 02 getOrderId: {}"
,
userId
);
...
...
@@ -33,4 +33,9 @@ public class OrderController {
return
"order service 02 "
+
userId
+
" --> "
+
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
}
@GetMapping
(
"/test/info"
)
public
String
testGetSimpleInfo
()
{
return
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
}
}
05-test-in-sleuth-client/05-01-order-service-client/src/main/java/cn/dankal/test/client/order/OrderServiceClient.java
View file @
73c8f640
...
...
@@ -23,4 +23,12 @@ public interface OrderServiceClient {
*/
@GetMapping
(
"/order/{userId}"
)
String
getOrderId
(
@PathVariable
(
"userId"
)
Long
userId
);
/**
* 测试获取 测试信息
*
* @return UUID String
*/
@GetMapping
(
"/order/test/info"
)
String
testGetSimpleInfo
();
}
05-test-in-sleuth-client/05-01-order-service-client/src/main/java/cn/dankal/test/client/order/fallback/OrderServiceClientFallback.java
View file @
73c8f640
...
...
@@ -18,4 +18,9 @@ public class OrderServiceClientFallback implements OrderServiceClient {
public
String
getOrderId
(
Long
userId
)
{
return
"return from OrderServiceClientFallback:getOrderId:"
+
userId
;
}
@Override
public
String
testGetSimpleInfo
()
{
return
"return from OrderServiceClientFallback: null"
;
}
}
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