Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
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
常超
map-parent
Commits
9d0c7827
Commit
9d0c7827
authored
Dec 26, 2022
by
宋珺琪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
服务概述接口(重庆)
parent
107fa145
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
170 additions
and
0 deletions
+170
-0
common/common_utils/src/main/java/com/founder/commonutils/model/newPublicEntity/PortEntity.java
+54
-0
common/common_utils/src/main/java/com/founder/commonutils/util/HttpUtil.java
+108
-0
service/publicapi/src/main/java/com/founder/publicapi/controller/PortServiceController/PortController.java
+0
-0
service/publicapi/src/main/java/com/founder/publicapi/mapper/mysqlMapper/PortMapper.java
+8
-0
No files found.
common/common_utils/src/main/java/com/founder/commonutils/model/newPublicEntity/PortEntity.java
0 → 100644
View file @
9d0c7827
package
com
.
founder
.
commonutils
.
model
.
newPublicEntity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
@Data
@TableName
(
"sk_Interface"
)
@ApiModel
(
value
=
"服务概述接口表"
,
description
=
""
)
public
class
PortEntity
{
@TableId
(
type
=
IdType
.
INPUT
)
@TableField
(
"id"
)
private
String
id
;
@TableField
(
"first_module"
)
private
String
firstModule
;
@TableField
(
"second_module"
)
private
String
secondModule
;
@TableField
(
"api_name"
)
private
String
apiName
;
@TableField
(
"url"
)
private
String
url
;
@TableField
(
"method"
)
private
String
method
;
@TableField
(
"headers"
)
private
String
headers
;
@TableField
(
"default_params"
)
private
String
defaultParams
;
@TableField
(
"call_time"
)
private
String
callTime
;
@TableField
(
"return_param"
)
private
String
returnParam
;
@TableField
(
"state"
)
private
String
state
;
// 0未测试 1成功 2未成功
@TableField
(
"is_delete"
)
private
String
isDelete
;
//0未删除 1删除
}
common/common_utils/src/main/java/com/founder/commonutils/util/HttpUtil.java
View file @
9d0c7827
package
com
.
founder
.
commonutils
.
util
;
import
org.apache.cxf.helpers.IOUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.params.ClientPNames
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.entity.ContentType
;
import
org.apache.http.entity.InputStreamEntity
;
import
org.apache.http.entity.StringEntity
;
...
...
@@ -397,4 +400,109 @@ public class HttpUtil {
public
static
boolean
ckeckEmpty
(
String
string
)
{
return
(
null
==
string
)
||
(
""
.
equals
(
string
));
}
public
static
String
fwdoPost
(
String
url
,
Map
<
String
,
String
>
map
,
String
token
)
throws
Exception
{
String
result
=
""
;
CloseableHttpClient
client
=
null
;
CloseableHttpResponse
response
=
null
;
RequestConfig
defaultRequestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
550000
).
setConnectTimeout
(
550000
)
.
setConnectionRequestTimeout
(
550000
).
setStaleConnectionCheckEnabled
(
true
).
build
();
client
=
HttpClients
.
custom
().
setDefaultRequestConfig
(
defaultRequestConfig
).
build
();
// client = HttpClients.createDefault();
URIBuilder
uriBuilder
=
new
URIBuilder
(
url
);
HttpPost
httpPost
=
new
HttpPost
(
uriBuilder
.
build
());
httpPost
.
setHeader
(
"Connection"
,
"Keep-Alive"
);
httpPost
.
setHeader
(
"Charset"
,
"UTF-8"
);
httpPost
.
setHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
httpPost
.
setHeader
(
"Authorization"
,
token
);
Iterator
<
Entry
<
String
,
String
>>
it
=
map
.
entrySet
().
iterator
();
List
<
NameValuePair
>
params
=
new
ArrayList
<
NameValuePair
>();
while
(
it
.
hasNext
())
{
Map
.
Entry
<
String
,
String
>
entry
=
it
.
next
();
NameValuePair
pair
=
new
BasicNameValuePair
(
entry
.
getKey
(),
entry
.
getValue
());
params
.
add
(
pair
);
}
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
params
,
"UTF-8"
));
try
{
response
=
client
.
execute
(
httpPost
);
if
(
response
!=
null
)
{
HttpEntity
resEntity
=
response
.
getEntity
();
if
(
resEntity
!=
null
)
{
result
=
EntityUtils
.
toString
(
resEntity
,
"UTF-8"
);
}
}
}
catch
(
ClientProtocolException
e
)
{
throw
new
RuntimeException
(
"创建连接失败"
+
e
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"创建连接失败"
+
e
);
}
return
result
;
}
public
static
String
fwdoPostJson
(
String
url
,
String
json
,
String
token
)
{
// 创建Httpclient对象
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
response
=
null
;
String
resultString
=
""
;
try
{
// 创建Http Post请求
HttpPost
httpPost
=
new
HttpPost
(
url
);
// 创建请求内容
StringEntity
entity
=
new
StringEntity
(
json
,
ContentType
.
APPLICATION_JSON
);
httpPost
.
setEntity
(
entity
);
httpPost
.
setHeader
(
"Authorization"
,
token
);
// 执行http请求
response
=
httpClient
.
execute
(
httpPost
);
resultString
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
response
.
close
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
return
resultString
;
}
public
static
String
fwdoGet
(
String
url
,
Map
<
String
,
String
>
params
,
String
token
)
{
String
apiUrl
=
url
;
StringBuffer
param
=
new
StringBuffer
();
int
i
=
0
;
for
(
String
key
:
params
.
keySet
())
{
if
(
i
==
0
)
param
.
append
(
"?"
);
else
param
.
append
(
"&"
);
param
.
append
(
key
).
append
(
"="
).
append
(
params
.
get
(
key
));
i
++;
}
apiUrl
+=
param
;
String
result
=
null
;
HttpClient
httpClient
=
null
;
httpClient
=
HttpClients
.
createDefault
();
try
{
HttpGet
httpGet
=
new
HttpGet
(
apiUrl
);
httpGet
.
setHeader
(
"Authorization"
,
token
);
HttpResponse
response
=
httpClient
.
execute
(
httpGet
);
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
InputStream
instream
=
entity
.
getContent
();
result
=
IOUtils
.
toString
(
instream
,
"UTF-8"
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
}
service/publicapi/src/main/java/com/founder/publicapi/controller/PortServiceController/PortController.java
0 → 100644
View file @
9d0c7827
This diff is collapsed.
Click to expand it.
service/publicapi/src/main/java/com/founder/publicapi/mapper/mysqlMapper/PortMapper.java
0 → 100644
View file @
9d0c7827
package
com
.
founder
.
publicapi
.
mapper
.
mysqlMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.founder.commonutils.model.newPublicEntity.PortEntity
;
public
interface
PortMapper
extends
BaseMapper
<
PortEntity
>
{
}
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