Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
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
liyuan
byit-myth-job
Commits
54cbd841
Commit
54cbd841
authored
Mar 23, 2020
by
guominglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改解析返回实体问题
parent
53e1ccce
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
24 deletions
+18
-24
pom.xml
byit-myth-admin/pom.xml
+0
-4
pom.xml
byit-myth-core/myth-web-core/pom.xml
+2
-2
ResponseAdvice.java
...ore/src/main/java/com/byit/web/advice/ResponseAdvice.java
+6
-10
LoginFilter.java
...y/src/main/java/com/byit/gateway/filters/LoginFilter.java
+5
-5
ZuulRouteDatabaseLocator.java
.../java/com/byit/gateway/zuul/ZuulRouteDatabaseLocator.java
+3
-1
ZuulRouteLocator.java
...src/main/java/com/byit/gateway/zuul/ZuulRouteLocator.java
+2
-2
No files found.
byit-myth-admin/pom.xml
View file @
54cbd841
...
...
@@ -18,10 +18,6 @@
<artifactId>
myth-admin-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
...
...
byit-myth-core/myth-web-core/pom.xml
View file @
54cbd841
...
...
@@ -17,8 +17,8 @@
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-
webmvc
</artifactId>
<groupId>
org.springframework
.boot
</groupId>
<artifactId>
spring-
boot-starter-web
</artifactId>
</dependency>
</dependencies>
...
...
byit-myth-core/myth-web-core/src/main/java/com/byit/web/advice/ResponseAdvice.java
View file @
54cbd841
...
...
@@ -6,7 +6,6 @@ import org.springframework.core.MethodParameter;
import
org.springframework.http.MediaType
;
import
org.springframework.http.server.ServerHttpRequest
;
import
org.springframework.http.server.ServerHttpResponse
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice
;
...
...
@@ -17,17 +16,14 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
* @date: 2019/12/25 16:57
**/
@RestControllerAdvice
public
class
ResponseAdvice
implements
ResponseBodyAdvice
{
public
class
ResponseAdvice
implements
ResponseBodyAdvice
<
Object
>
{
@Override
public
boolean
supports
(
MethodParameter
methodParameter
,
Class
aClass
)
{
if
(
aClass
.
isAnnotationPresent
(
RestController
.
class
)){
return
true
;
}
return
false
;
}
/**
*
* @param
res
返回结果
* @param
body
返回结果
* @param methodParameter 方法参数
* @param mediaType
* @param aClass
...
...
@@ -36,11 +32,11 @@ public class ResponseAdvice implements ResponseBodyAdvice {
* @return
*/
@Override
public
Object
beforeBodyWrite
(
Object
res
,
MethodParameter
methodParameter
,
MediaType
mediaType
,
Class
aClass
,
ServerHttpRequest
serverHttpRequest
,
ServerHttpResponse
serverHttpResponse
)
{
if
(!(
res
instanceof
ResponseResult
)
){
return
JSON
.
toJSONString
(
ResponseResult
.
ok
(
res
))
;
public
Object
beforeBodyWrite
(
Object
body
,
MethodParameter
methodParameter
,
MediaType
mediaType
,
Class
aClass
,
ServerHttpRequest
serverHttpRequest
,
ServerHttpResponse
serverHttpResponse
)
{
if
(
body
instanceof
ResponseResult
){
return
body
;
}
return
res
;
return
JSON
.
toJSONString
(
ResponseResult
.
ok
(
body
))
;
}
...
...
byit-myth-gateway/src/main/java/com/byit/gateway/filters/LoginFilter.java
View file @
54cbd841
...
...
@@ -39,15 +39,15 @@ public class LoginFilter extends ZuulFilter {
public
Object
run
()
{
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
HttpServletRequest
request
=
ctx
.
getRequest
();
log
.
info
(
String
.
format
(
"%s request to %s"
,
request
.
getMethod
(),
request
.
getRequestURL
().
toString
()));
Object
a
=
request
.
getParameter
(
"a"
);
if
(
a
!=
null
)
{
log
.
info
(
"{} request from {}"
,
request
.
getMethod
(),
request
.
getRemoteAddr
());
log
.
info
(
"{} request to {}"
,
request
.
getMethod
(),
request
.
getRequestURL
().
toString
());
String
token
=
request
.
getHeader
(
"token"
);
if
(
null
==
token
||
""
.
equals
(
token
))
{
log
.
warn
(
"param a is empty"
);
ctx
.
setSendZuulResponse
(
false
);
ctx
.
setResponseStatusCode
(
40
1
);
ctx
.
setResponseStatusCode
(
40
3
);
return
false
;
}
log
.
info
(
"param a is : "
+
a
);
return
true
;
}
}
byit-myth-gateway/src/main/java/com/byit/gateway/zuul/ZuulRouteDatabaseLocator.java
View file @
54cbd841
...
...
@@ -34,6 +34,8 @@ public class ZuulRouteDatabaseLocator extends ZuulRouteLocator {
private
String
biz
;
@Value
(
"${gateway.load.balance}"
)
private
String
gatewayLoadBalance
;
@Value
(
"${myth-rpc.registry.env}"
)
private
String
env
;
private
List
<
ZuulRouteEntity
>
locateRouteList
;
...
...
@@ -49,7 +51,7 @@ public class ZuulRouteDatabaseLocator extends ZuulRouteLocator {
public
Map
<
String
,
ZuulRoute
>
loadLocateRoute
()
{
locateRouteList
=
new
ArrayList
<>();
try
{
String
sql
=
"select * from myth_registry where status = 0 and locate('.',`key`) = 0 and biz = '"
+
biz
+
"'"
;
String
sql
=
"select * from myth_registry where status = 0 and
env = '"
+
env
+
"' and
locate('.',`key`) = 0 and biz = '"
+
biz
+
"'"
;
List
<
Map
<
String
,
Object
>>
locateRouteMapList
=
jdbcTemplate
.
queryForList
(
sql
);
logger
.
info
(
locateRouteMapList
.
toString
());
...
...
byit-myth-gateway/src/main/java/com/byit/gateway/zuul/ZuulRouteLocator.java
View file @
54cbd841
...
...
@@ -77,8 +77,8 @@ public abstract class ZuulRouteLocator extends SimpleRouteLocator implements Ref
/**
* 复制查询出来的数据的属性
*/
public
Map
<
String
,
ZuulRoute
>
handle
(
List
<
ZuulRouteEntity
>
locateRouteList
)
{
if
(
CollectionUtils
.
isEmpty
(
locateRouteList
))
{
public
Map
<
String
,
ZuulRoute
>
handle
(
List
<
ZuulRouteEntity
>
locateRouteList
)
{
if
(
CollectionUtils
.
isEmpty
(
locateRouteList
))
{
return
null
;
}
Map
<
String
,
ZuulRoute
>
routes
=
new
LinkedHashMap
<>();
...
...
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