Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
enterprise-service-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
enterprise-service-platform
Commits
ab0e77e2
Commit
ab0e77e2
authored
Mar 24, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改配置文件
parent
46b82b0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
10 deletions
+21
-10
enterprise-service-manager/src/main/java/com/mortals/xhx/busiz/web/ProxyController.java
.../main/java/com/mortals/xhx/busiz/web/ProxyController.java
+21
-10
No files found.
enterprise-service-manager/src/main/java/com/mortals/xhx/busiz/web/ProxyController.java
View file @
ab0e77e2
...
@@ -2,6 +2,7 @@ package com.mortals.xhx.busiz.web;
...
@@ -2,6 +2,7 @@ package com.mortals.xhx.busiz.web;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -95,8 +96,7 @@ public class ProxyController {
...
@@ -95,8 +96,7 @@ public class ProxyController {
@PostMapping
(
"/post"
)
@PostMapping
(
"/post"
)
@UnAuth
@UnAuth
@CrossOrigin
public
Rest
<
String
>
proxyPost
(
public
ResponseEntity
<
String
>
proxyPost
(
@RequestParam
Map
<
String
,
String
>
params
,
// 透传 Query Params
@RequestParam
Map
<
String
,
String
>
params
,
// 透传 Query Params
@RequestBody
(
required
=
false
)
String
body
,
// 透传 Body
@RequestBody
(
required
=
false
)
String
body
,
// 透传 Body
@RequestHeader
Map
<
String
,
String
>
headers
// 透传 Headers
@RequestHeader
Map
<
String
,
String
>
headers
// 透传 Headers
...
@@ -108,7 +108,10 @@ public class ProxyController {
...
@@ -108,7 +108,10 @@ public class ProxyController {
if
(
ObjectUtils
.
isEmpty
(
path
))
{
if
(
ObjectUtils
.
isEmpty
(
path
))
{
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
"path is empty!"
);
rsp
.
setMsg
(
"path is empty!"
);
return
ResponseEntity
.
ok
().
body
(
JSON
.
toJSONString
(
rsp
));
return
Rest
.
fail
(
rsp
.
getMsg
());
// return ResponseEntity.ok().body(JSON.toJSONString(rsp));
}
}
String
method
=
params
.
getOrDefault
(
"method"
,
"post"
);
String
method
=
params
.
getOrDefault
(
"method"
,
"post"
);
...
@@ -142,13 +145,17 @@ public class ProxyController {
...
@@ -142,13 +145,17 @@ public class ProxyController {
// 发送请求
// 发送请求
try
(
Response
response
=
client
.
newCall
(
requestBuilder
.
build
()).
execute
())
{
try
(
Response
response
=
client
.
newCall
(
requestBuilder
.
build
()).
execute
())
{
if
(!
response
.
isSuccessful
())
{
if
(!
response
.
isSuccessful
())
{
return
ResponseEntity
.
status
(
response
.
code
()).
body
(
response
.
message
());
return
Rest
.
fail
(
response
.
code
(),
response
.
message
());
// return ResponseEntity.status(response.code()).body(response.message());
}
}
return
ResponseEntity
.
status
(
response
.
code
()).
body
(
response
.
body
().
string
());
return
Rest
.
ok
(
response
.
body
().
string
());
// return ResponseEntity.status(response.code()).body(response.body().string());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
"Proxy error: "
+
e
.
getMessage
());
rsp
.
setMsg
(
"Proxy error: "
+
e
.
getMessage
());
return
ResponseEntity
.
ok
().
body
(
JSON
.
toJSONString
(
rsp
));
return
Rest
.
fail
(
rsp
.
getMsg
());
// return ResponseEntity.ok().body(JSON.toJSONString(rsp));
}
}
}
else
if
(
"get"
.
equalsIgnoreCase
(
method
))
{
}
else
if
(
"get"
.
equalsIgnoreCase
(
method
))
{
Request
.
Builder
requestBuilder
=
new
Request
.
Builder
()
Request
.
Builder
requestBuilder
=
new
Request
.
Builder
()
...
@@ -164,19 +171,23 @@ public class ProxyController {
...
@@ -164,19 +171,23 @@ public class ProxyController {
// 发送请求
// 发送请求
try
(
Response
response
=
client
.
newCall
(
requestBuilder
.
build
()).
execute
())
{
try
(
Response
response
=
client
.
newCall
(
requestBuilder
.
build
()).
execute
())
{
if
(!
response
.
isSuccessful
())
{
if
(!
response
.
isSuccessful
())
{
return
ResponseEntity
.
status
(
response
.
code
()).
body
(
response
.
message
());
return
Rest
.
fail
(
response
.
code
(),
response
.
message
());
//return ResponseEntity.status(response.code()).body(response.message());
}
}
return
ResponseEntity
.
status
(
response
.
code
()).
body
(
response
.
body
().
string
());
return
Rest
.
ok
(
response
.
body
().
string
());
// return ResponseEntity.status(response.code()).body(response.body().string());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
"Proxy error: "
+
e
.
getMessage
());
rsp
.
setMsg
(
"Proxy error: "
+
e
.
getMessage
());
return
ResponseEntity
.
ok
().
body
(
JSON
.
toJSONString
(
rsp
));
return
Rest
.
fail
(
rsp
.
getMsg
());
// return ResponseEntity.ok().body(JSON.toJSONString(rsp));
}
}
}
else
{
}
else
{
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
"method is not support!"
);
rsp
.
setMsg
(
"method is not support!"
);
return
ResponseEntity
.
ok
().
body
(
JSON
.
toJSONString
(
rsp
));
return
Rest
.
fail
(
rsp
.
getMsg
());
// return ResponseEntity.ok().body(JSON.toJSONString(rsp));
}
}
}
}
...
...
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