Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
fbc9605e
Commit
fbc9605e
authored
Nov 13, 2023
by
KeYong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新调试信息
parent
b90dfc89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
HttpsGetAndPostUtil.java
...yeejoin/equipmanage/common/utils/HttpsGetAndPostUtil.java
+6
-1
DcsUtil.java
.../src/main/java/com/yeejoin/equipmanage/utils/DcsUtil.java
+12
-1
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/utils/HttpsGetAndPostUtil.java
View file @
fbc9605e
package
com
.
yeejoin
.
equipmanage
.
common
.
utils
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.http.Consts
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
...
...
@@ -70,12 +71,15 @@ public class HttpsGetAndPostUtil {
*
* @throws Exception
*/
public
static
String
sendByHttp
(
Map
<
String
,
String
>
params
,
String
url
)
{
public
static
String
sendByHttp
(
Map
<
String
,
String
>
headerMap
,
Map
<
String
,
String
>
params
,
String
url
)
{
try
{
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
addHeader
(
"Content-type"
,
"application/json; charset=utf-8"
);
httpPost
.
setHeader
(
"Accept"
,
"application/json"
);
for
(
Map
.
Entry
<
String
,
String
>
entry
:
headerMap
.
entrySet
())
{
httpPost
.
setHeader
(
entry
.
getKey
(),
entry
.
getValue
());
}
// 设置参数
MultipartEntityBuilder
builder
=
MultipartEntityBuilder
.
create
();
...
...
@@ -91,6 +95,7 @@ public class HttpsGetAndPostUtil {
httpClient
=
HttpsGetAndPostUtil
.
createSSLClientDefault
();
httpResponse
=
httpClient
.
execute
(
httpPost
);
HttpEntity
httpEntity
=
httpResponse
.
getEntity
();
System
.
out
.
println
(
"新方法返回结果================="
+
JSON
.
toJSONString
(
httpEntity
));
if
(
httpEntity
!=
null
)
{
String
jsObject
=
EntityUtils
.
toString
(
httpEntity
,
"UTF-8"
);
return
jsObject
;
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/utils/DcsUtil.java
View file @
fbc9605e
...
...
@@ -71,7 +71,12 @@ public class DcsUtil {
map
.
put
(
"scope"
,
scope
);
map
.
put
(
"client_id"
,
clientId
);
map
.
put
(
"client_secret"
,
clientSecret
);
String
content
=
HttpsGetAndPostUtil
.
sendByHttp
(
map
,
gettokenUrl
);
String
content
;
if
(
isHttpsUrl
(
gettokenUrl
)){
content
=
HttpsGetAndPostUtil
.
sendByHttp
(
headerMap
,
map
,
gettokenUrl
);
}
else
{
content
=
HttpContentTypeUtil
.
doPostForm
(
gettokenUrl
,
map
);
}
logger
.
info
(
"header:"
+
JSON
.
toJSONString
(
headerMap
)
+
"; body: "
+
JSON
.
toJSONString
(
map
)
+
"; 调用获取token返回:"
+
content
);
if
(
StringUtils
.
isNotBlank
(
content
))
{
AppTokenVo
appTokenVo
=
JSONObject
.
parseObject
(
content
,
AppTokenVo
.
class
);
...
...
@@ -84,4 +89,9 @@ public class DcsUtil {
logger
.
info
(
"accessToken 是----------"
+
accessToken
);
return
accessToken
;
}
public
static
boolean
isHttpsUrl
(
String
url
)
{
String
regex
=
"^https://.*$"
;
return
url
.
matches
(
regex
);
}
}
\ No newline at end of file
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