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
8a3e7675
Commit
8a3e7675
authored
Mar 24, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改配置文件
parent
4b4be57a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
4 deletions
+51
-4
enterprise-service-manager/src/main/java/com/mortals/xhx/busiz/web/ProxyController.java
.../main/java/com/mortals/xhx/busiz/web/ProxyController.java
+35
-2
enterprise-service-manager/src/test/java/com/mortals/httpclient/system.http
...-manager/src/test/java/com/mortals/httpclient/system.http
+16
-2
No files found.
enterprise-service-manager/src/main/java/com/mortals/xhx/busiz/web/ProxyController.java
View file @
8a3e7675
...
@@ -8,6 +8,7 @@ import com.mortals.xhx.busiz.rsp.ApiResp;
...
@@ -8,6 +8,7 @@ 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
;
import
okhttp3.*
;
import
okhttp3.*
;
import
org.apache.http.util.TextUtils
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -175,10 +176,14 @@ public class ProxyController {
...
@@ -175,10 +176,14 @@ public class ProxyController {
}
}
}
else
if
(
"get"
.
equalsIgnoreCase
(
method
))
{
}
else
if
(
"get"
.
equalsIgnoreCase
(
method
))
{
Map
<
String
,
String
>
map
=
req
.
toJavaObject
(
Map
.
class
);
String
bodyParams
=
getBodyParams
(
map
);
//url拼接参数
//url拼接参数
Request
.
Builder
requestBuilder
=
new
Request
.
Builder
()
Request
.
Builder
requestBuilder
=
new
Request
.
Builder
()
.
put
(
requestBody
)
.
url
(
url
+
bodyParams
)
.
url
(
url
)
.
get
();
.
get
();
// 透传 Headers(过滤掉 Host 避免冲突)
// 透传 Headers(过滤掉 Host 避免冲突)
headers
.
forEach
((
key
,
value
)
->
{
headers
.
forEach
((
key
,
value
)
->
{
...
@@ -213,6 +218,34 @@ public class ProxyController {
...
@@ -213,6 +218,34 @@ public class ProxyController {
}
}
/**
* 添加参数
*
* @param bodyParams
* @return
*/
private
String
getBodyParams
(
Map
<
String
,
String
>
bodyParams
)
{
//1.添加请求参数
//遍历map中所有参数到builder
if
(
bodyParams
!=
null
&&
bodyParams
.
size
()
>
0
)
{
StringBuffer
stringBuffer
=
new
StringBuffer
(
"?"
);
for
(
String
key
:
bodyParams
.
keySet
())
{
if
(!
TextUtils
.
isEmpty
(
key
)
&&
!
TextUtils
.
isEmpty
(
bodyParams
.
get
(
key
)))
{
//如果参数不是null并且不是"",就拼接起来
stringBuffer
.
append
(
"&"
);
stringBuffer
.
append
(
key
);
stringBuffer
.
append
(
"="
);
stringBuffer
.
append
(
bodyParams
.
get
(
key
));
}
}
return
stringBuffer
.
toString
();
}
else
{
return
""
;
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
enterprise-service-manager/src/test/java/com/mortals/httpclient/system.http
View file @
8a3e7675
...
@@ -63,10 +63,24 @@ Content-Type: application/json
...
@@ -63,10 +63,24 @@ Content-Type: application/json
}
}
###透传代理接口
###透传代理接口
POST {{baseUrl}}/proxy/post
?path=/entservice/ent/life/cycle/interlist&method=post
POST {{baseUrl}}/proxy/post
Content-Type: application/json
Content-Type: application/json
{"page": 1, "size": 10}
{"page": 1,
"size": 10,
"path": "/entservice/ent/life/cycle/interlist",
"method": "post"
}
###透传代理接口get
POST {{baseUrl}}/proxy/post
Content-Type: application/json
{
"id": 1,
"path": "/entservice/ent/life/cycle/interinfo",
"method": "get"
}
###
###
...
...
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