记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
1482b2cb
Commit
1482b2cb
authored
Sep 27, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feign:去除TOKEN拦截处理逻辑;
parent
1b20afd3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
54 deletions
+71
-54
liquidnet-service-kylin.yml
...t-bus-config/liquidnet-config/liquidnet-service-kylin.yml
+1
-0
FeignKylinForChimeClient.java
...net/service/feign/kylin/api/FeignKylinForChimeClient.java
+1
-3
SecuringRequestInterceptor.java
...ervice/feign/kylin/config/SecuringRequestInterceptor.java
+37
-37
PlatformTaskHandler.java
...et/service/executor/main/handler/PlatformTaskHandler.java
+32
-14
No files found.
liquidnet-bus-config/liquidnet-config/liquidnet-service-kylin.yml
View file @
1482b2cb
...
...
@@ -147,6 +147,7 @@ global-auth:
-
${liquidnet.info.context}/performance/calendar
-
${liquidnet.info.context}/performance/calendarPerformances
-
${liquidnet.info.context}/performance/*
-
${liquidnet.info.context}/myPerformance/*
# -----------------------------------------------------------
...
...
liquidnet-bus-feign/liquidnet-api-feign-kylin/src/main/java/com/liquidnet/service/feign/kylin/api/FeignKylinForChimeClient.java
View file @
1482b2cb
package
com
.
liquidnet
.
service
.
feign
.
kylin
.
api
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.feign.kylin.config.SecuringRequestInterceptor
;
import
com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo
;
import
feign.hystrix.FallbackFactory
;
import
org.springframework.cloud.openfeign.FeignClient
;
...
...
@@ -25,8 +24,7 @@ import java.util.List;
@FeignClient
(
name
=
"liquidnet-service-kylin"
,
contextId
=
"FeignKylinForChimeClient"
,
path
=
""
,
url
=
"${liquidnet.service.kylin.url}"
,
fallback
=
FallbackFactory
.
Default
.
class
,
configuration
=
SecuringRequestInterceptor
.
class
)
fallback
=
FallbackFactory
.
Default
.
class
)
public
interface
FeignKylinForChimeClient
{
@GetMapping
(
"myPerformance/performancesList"
)
ResponseDto
<
List
<
KylinPerformanceVo
>>
myPerformancesList
();
...
...
liquidnet-bus-feign/liquidnet-api-feign-kylin/src/main/java/com/liquidnet/service/feign/kylin/config/SecuringRequestInterceptor.java
View file @
1482b2cb
package
com
.
liquidnet
.
service
.
feign
.
kylin
.
config
;
import
feign.RequestInterceptor
;
import
feign.RequestTemplate
;
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.util.Enumeration
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 解决feign调用传递header问题
* @class: SecuringRequestInterceptor
* @Package com.liquidnet.service.chime.config
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2021/9/11 19:22
*/
@Component
public
class
SecuringRequestInterceptor
implements
RequestInterceptor
{
@Override
public
void
apply
(
RequestTemplate
requestTemplate
)
{
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
attributes
.
getRequest
();
Enumeration
<
String
>
headerNames
=
request
.
getHeaderNames
();
if
(
headerNames
!=
null
)
{
while
(
headerNames
.
hasMoreElements
())
{
String
name
=
headerNames
.
nextElement
();
String
values
=
request
.
getHeader
(
name
);
requestTemplate
.
header
(
name
,
values
);
}
}
}
}
\ No newline at end of file
//package com.liquidnet.service.feign.kylin.config;
//
//import feign.RequestInterceptor;
//import feign.RequestTemplate;
//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.util.Enumeration;
//
///**
// * @author AnJiabin <anjiabin@zhengzai.tv>
// * @version V1.0
// * @Description: 解决feign调用传递header问题
// * @class: SecuringRequestInterceptor
// * @Package com.liquidnet.service.chime.config
// * @Copyright: LightNet @ Copyright (c) 2021
// * @date 2021/9/11 19:22
// */
//@Component
//public class SecuringRequestInterceptor implements RequestInterceptor {
// @Override
// public void apply(RequestTemplate requestTemplate) {
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
// .getRequestAttributes();
// HttpServletRequest request = attributes.getRequest();
// Enumeration<String> headerNames = request.getHeaderNames();
// if (headerNames != null) {
// while (headerNames.hasMoreElements()) {
// String name = headerNames.nextElement();
// String values = request.getHeader(name);
// requestTemplate.header(name, values);
// }
// }
// }
//}
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-executor-all/liquidnet-service-executor-main/src/main/java/com/liquidnet/service/executor/main/handler/PlatformTaskHandler.java
View file @
1482b2cb
package
com
.
liquidnet
.
service
.
executor
.
main
.
handler
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.feign.kylin.task.FeignPlatformAlipayBackClient
;
import
com.liquidnet.service.feign.platform.task.FeignPlatformCandyTaskClient
;
...
...
@@ -27,9 +28,14 @@ public class PlatformTaskHandler {
try
{
String
result
=
feignPlatformAlipayBackClient
.
alipayActiveCallback
().
getData
();
log
.
info
(
"alipayActiveCallback:结果:"
+
result
);
return
ReturnT
.
SUCCESS
;
ReturnT
<
String
>
success
=
ReturnT
.
SUCCESS
;
success
.
setContent
(
result
);
return
success
;
}
catch
(
Exception
e
)
{
return
ReturnT
.
FAIL
;
log
.
error
(
"exception of handler:{}"
,
e
.
getMessage
(),
e
);
ReturnT
<
String
>
fail
=
ReturnT
.
FAIL
;
fail
.
setMsg
(
e
.
getLocalizedMessage
());
return
fail
;
}
}
...
...
@@ -38,11 +44,14 @@ public class PlatformTaskHandler {
public
ReturnT
<
String
>
candyCouponMgtIssueCoupons
()
{
try
{
ResponseDto
<
String
>
dto
=
feignPlatformCandyTaskClient
.
mgtIssueCoupons
();
log
.
info
(
"result of handler:{}"
,
dto
.
toJson
());
return
new
ReturnT
<>(
dto
.
toJson
());
String
dtoStr
=
JsonUtils
.
toJson
(
dto
);
log
.
info
(
"result of handler:{}"
,
dtoStr
);
return
new
ReturnT
<>(
dtoStr
);
}
catch
(
Exception
e
)
{
log
.
error
(
"exception of handler:{}"
,
e
.
getMessage
(),
e
);
return
ReturnT
.
FAIL
;
ReturnT
<
String
>
fail
=
ReturnT
.
FAIL
;
fail
.
setMsg
(
e
.
getLocalizedMessage
());
return
fail
;
}
}
...
...
@@ -51,11 +60,14 @@ public class PlatformTaskHandler {
public
ReturnT
<
String
>
candyCouponDueProcessForRedeem
()
{
try
{
ResponseDto
<
String
>
dto
=
feignPlatformCandyTaskClient
.
dueProcessForRedeem
();
log
.
info
(
"result of handler:{}"
,
dto
.
toJson
());
return
new
ReturnT
<>(
dto
.
toJson
());
String
dtoStr
=
JsonUtils
.
toJson
(
dto
);
log
.
info
(
"result of handler:{}"
,
dtoStr
);
return
new
ReturnT
<>(
dtoStr
);
}
catch
(
Exception
e
)
{
log
.
error
(
"exception of handler:{}"
,
e
.
getMessage
(),
e
);
return
ReturnT
.
FAIL
;
ReturnT
<
String
>
fail
=
ReturnT
.
FAIL
;
fail
.
setMsg
(
e
.
getLocalizedMessage
());
return
fail
;
}
}
...
...
@@ -64,11 +76,14 @@ public class PlatformTaskHandler {
public
ReturnT
<
String
>
candyCouponDueProcessForCommon
()
{
try
{
ResponseDto
<
String
>
dto
=
feignPlatformCandyTaskClient
.
dueProcessForCommon
();
log
.
info
(
"result of handler:{}"
,
dto
.
toJson
());
return
new
ReturnT
<>(
dto
.
toJson
());
String
dtoStr
=
JsonUtils
.
toJson
(
dto
);
log
.
info
(
"result of handler:{}"
,
dtoStr
);
return
new
ReturnT
<>(
dtoStr
);
}
catch
(
Exception
e
)
{
log
.
error
(
"exception of handler:{}"
,
e
.
getMessage
(),
e
);
return
ReturnT
.
FAIL
;
ReturnT
<
String
>
fail
=
ReturnT
.
FAIL
;
fail
.
setMsg
(
e
.
getLocalizedMessage
());
return
fail
;
}
}
...
...
@@ -77,11 +92,14 @@ public class PlatformTaskHandler {
public
ReturnT
<
String
>
candyCouponDueProcessForUser
()
{
try
{
ResponseDto
<
String
>
dto
=
feignPlatformCandyTaskClient
.
dueProcessForUser
();
log
.
info
(
"result of handler:{}"
,
dto
.
toJson
());
return
new
ReturnT
<>(
dto
.
toJson
());
String
dtoStr
=
JsonUtils
.
toJson
(
dto
);
log
.
info
(
"result of handler:{}"
,
dtoStr
);
return
new
ReturnT
<>(
dtoStr
);
}
catch
(
Exception
e
)
{
log
.
error
(
"exception of handler:{}"
,
e
.
getMessage
(),
e
);
return
ReturnT
.
FAIL
;
ReturnT
<
String
>
fail
=
ReturnT
.
FAIL
;
fail
.
setMsg
(
e
.
getLocalizedMessage
());
return
fail
;
}
}
}
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