Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
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
姚本章
jz-dmp-service
Commits
7413cc0f
Commit
7413cc0f
authored
Feb 25, 2021
by
mcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
83685b10
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
204 additions
and
215 deletions
+204
-215
GatewayApiConstant.java
src/main/java/com/jz/common/constant/GatewayApiConstant.java
+66
-30
DmpApiMangeController.java
...modules/controller/dataService/DmpApiMangeController.java
+3
-6
DmpApiServiceMangeController.java
.../controller/dataService/DmpApiServiceMangeController.java
+29
-9
ApiInterfaceReq.java
.../modules/controller/dataService/bean/ApiInterfaceReq.java
+67
-38
DmpApiMangeService.java
...n/java/com/jz/dmp/modules/service/DmpApiMangeService.java
+3
-1
DmpApiServiceMangeService.java
...com/jz/dmp/modules/service/DmpApiServiceMangeService.java
+10
-3
DmpApiMangeServiceImpl.java
...m/jz/dmp/modules/service/impl/DmpApiMangeServiceImpl.java
+2
-21
DmpApiServiceMangeServiceImpl.java
...p/modules/service/impl/DmpApiServiceMangeServiceImpl.java
+24
-107
No files found.
src/main/java/com/jz/common/constant/GatewayApiConstant.java
View file @
7413cc0f
package
com
.
jz
.
common
.
constant
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.web.HttpClientUtils
;
import
com.jz.dmp.modules.service.impl.DmpApiServiceMangeServiceImpl
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Map
;
/**
* @ClassName: GatewayApiConstant
* @Description: 服务网关api地址
...
...
@@ -11,82 +20,109 @@ public class GatewayApiConstant {
//列表分页查询url
public
static
final
String
orgListPage
=
"/api/organization/listOrg"
;
//删除组织url
public
static
final
String
delOrg
=
"/api/organization/logoutOrg"
;
//新增组织url
public
static
final
String
addOrg
=
"/api/organization/add"
;
//编辑组织url
public
static
final
String
updateOrg
=
"/api/organization/update"
;
//根据组织id获取组织详情url
public
static
final
String
orgDetail
=
"/api/organization/getOrgDetail"
;
//授权给他人的API-列表分页查询url
public
static
final
String
apiAuthListPage
=
"/api/auth/auth-list"
;
//取消授权url
public
static
final
String
cancelApiAuth
=
"/api/auth/update-auth-info"
;
//发布的API-API列表分页查询url
public
static
final
String
apiListPage
=
"/api/interface/listApiInterface"
;
//删除APIurl
public
static
final
String
delApi
=
"/api/interface/delDMPApiInterface"
;
//根据apiid获取API详情url
public
static
final
String
getApiInfo
=
"/api/interface/getApiInterfaceDetail"
;
//授权给组织url
public
static
final
String
apiAuthToOrg
=
"/api/auth/dmp-auth-api"
;
//测试url
public
static
final
String
testApi
=
"/api/interface/apiTestApiInterface"
;
public
static
final
String
testApi
=
"/api/request/gateway"
;
//查看日志url
public
static
final
String
checkApiLog
=
"/api/logging/listApiLog"
;
//授权模糊查询组织信息url
public
static
final
String
authOrgList
=
"/api/auth/getAuthNameList"
;
//保存API(第三方)基本信息url
public
static
final
String
addApiInfo
=
"/api/producer/addCustomApi"
;
//保存API(大数据查询/标签查询)url
public
static
final
String
addApiBigData
=
"/api/producer/makeBigDataApi"
;
public
static
final
String
addApiBigData
=
"/api/producer/addDataTableSelect"
;
//编辑API(第三方)基本信息url
public
static
final
String
updateApiInfo
=
"/api/producer/saveUpdate"
;
//API计量调用次数和执行时长url
public
static
final
String
countAPiCallStat
=
"/api/logging/countAPiCallStat"
;
public
static
final
String
countAPiCallStat
=
"/api/interface/countAPiCallStat"
;
//API计量--API未调用列表url
public
static
final
String
notCalledList
=
"/api/interface/listUnCallApiInterface"
;
public
static
final
String
notCalledList
=
"/api/interface/listUnCallApi"
;
//API计量--API已调用列表url
public
static
final
String
listCallApi
=
"/api/interface/listCallApi"
;
//服务发布/服务取消url
public
static
final
String
apiPublishCancel
=
"/api/producer/optionApiIssueStatus"
;
//盐值重置url
public
static
final
String
saltReset
=
"/api/auth/reset-salt"
;
//授权管理-api列表url
public
static
final
String
authApiList
=
"/api/auth/getServiceAuthList"
;
//授权
public
static
final
String
authUserApi
=
"/api/auth/user-auth-api"
;
//上传(发送给数据银行)
public
static
final
String
serverUpload
=
"/api/producer/serverUpload"
;
//日志详情
public
static
final
String
logDetails
=
"/api/logging/getReqDetail"
;
//服务开发 api列表
public
static
final
String
listServerApplyApi
=
"/api/interface/listServerApplyApi"
;
//获取文件夹树
public
static
final
String
folderTree
=
"/api/producer/getFileCatalog"
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
GatewayApiConstant
.
class
);
/*
* post 请求获取数据
* */
public
static
JsonResult
postRequest2GetData
(
String
url
,
String
param
)
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
String
resultData
=
HttpClientUtils
.
post
(
url
,
param
);
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"failed!"
);
}
logger
.
info
(
"#################响应结果数据{}"
+
resultData
);
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
jsonObject
.
containsKey
(
"code"
))
{
if
(
"200"
.
equals
(
jsonObject
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
jsonObject
.
get
(
"data"
));
}
}
if
(
jsonObject
.
containsKey
(
"message"
))
{
logger
.
info
(
jsonObject
.
get
(
"message"
).
toString
());
result
.
setMessage
(
jsonObject
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
}
return
result
;
}
/*
* get 请求获取数据
* */
public
static
JsonResult
getRequest2GetData
(
String
url
,
Map
params
)
{
JsonResult
result
=
new
JsonResult
();
String
returnData
=
HttpClientUtils
.
getJsonForParam
(
url
,
params
);
if
(
StringUtils
.
isEmpty
(
returnData
))
{
throw
new
RuntimeException
(
"查询失败!"
);
}
logger
.
info
(
"#################响应结果{}"
+
returnData
);
Map
map
=
JSONObject
.
parseObject
(
returnData
);
if
(
map
.
containsKey
(
"code"
))
{
if
(
"200"
.
equals
(
map
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
map
.
get
(
"data"
));
}
}
if
(
map
.
containsKey
(
"message"
))
{
logger
.
info
(
map
.
get
(
"message"
).
toString
());
result
.
setMessage
(
map
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
}
return
result
;
}
}
src/main/java/com/jz/dmp/modules/controller/dataService/DmpApiMangeController.java
View file @
7413cc0f
...
...
@@ -17,6 +17,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Map
;
/**
* 数据服务Api管理--调用gateway 接口
...
...
@@ -178,14 +179,10 @@ public class DmpApiMangeController {
*/
@ApiOperation
(
value
=
"API测试"
,
notes
=
"API测试"
)
@GetMapping
(
value
=
"/apiTestInfo"
)
@ApiImplicitParam
(
name
=
"apiKey"
,
value
=
"apiKey"
,
required
=
true
)
public
JsonResult
getApiTestInfo
(
@RequestParam
String
apiKey
,
HttpServletRequest
httpRequest
)
{
if
(
StringUtils
.
isEmpty
(
apiKey
))
{
return
JsonResult
.
error
(
ResultCode
.
PARAMS_ERROR
,
"apiKey不能为空!"
);
}
public
JsonResult
getApiTestInfo
(
@RequestBody
Map
<
String
,
Object
>
params
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpApiMangeService
.
apiTestInfo
(
apiKey
);
jsonResult
=
dmpApiMangeService
.
apiTestInfo
(
params
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
...
...
src/main/java/com/jz/dmp/modules/controller/dataService/DmpApiServiceMangeController.java
View file @
7413cc0f
...
...
@@ -49,12 +49,12 @@ public class DmpApiServiceMangeController {
private
OfflineSynchService
offlineSynchService
;
/**
*
保存
API(第三方)基本信息
*
制作/编辑
API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation
(
value
=
"
保存API(第三方)"
,
notes
=
"保存
API(第三方)"
)
@ApiOperation
(
value
=
"
制作/编辑API(第三方)"
,
notes
=
"保存/编辑
API(第三方)"
)
@PostMapping
(
value
=
"/saveApi"
)
public
JsonResult
saveApiInfo
(
@RequestBody
@Validated
ApiInterfaceReq
req
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
...
...
@@ -69,14 +69,14 @@ public class DmpApiServiceMangeController {
}
/**
*
保存
API(大数据查询/标签查询)
*
制作/编辑
API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation
(
value
=
"
保存API(大数据查询/标签查询)"
,
notes
=
"保存
API(大数据查询/标签查询)"
)
@ApiOperation
(
value
=
"
制作/编辑API(大数据查询/标签查询)"
,
notes
=
"制作/编辑
API(大数据查询/标签查询)"
)
@PostMapping
(
value
=
"/saveApiBigData"
)
public
JsonResult
saveApiBigDataInfo
(
@RequestBody
@Validated
MakeBigDataApi
Req
req
,
HttpServletRequest
httpRequest
)
{
public
JsonResult
saveApiBigDataInfo
(
@RequestBody
@Validated
ApiInterface
Req
req
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpApiServiceMangeService
.
saveApiBigDataInfo
(
req
);
...
...
@@ -94,7 +94,7 @@ public class DmpApiServiceMangeController {
* @author Bellamy
* @since 2021-01-20
*/
@ApiOperation
(
value
=
"编辑API(第三方)"
,
notes
=
"编辑API(第三方)"
)
/*
@ApiOperation(value = "编辑API(第三方)", notes = "编辑API(第三方)")
@PostMapping(value = "/updataApi")
public JsonResult updateApiInfo(@RequestBody @Validated ApiInterfaceReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
...
...
@@ -106,7 +106,7 @@ public class DmpApiServiceMangeController {
e.printStackTrace();
}
return jsonResult;
}
}
*/
/**
* 编辑API(大数据查询/标签查询)
...
...
@@ -114,7 +114,7 @@ public class DmpApiServiceMangeController {
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation
(
value
=
"编辑API(大数据查询/标签查询)"
,
notes
=
"编辑API(大数据查询/标签查询)"
)
/*
@ApiOperation(value = "编辑API(大数据查询/标签查询)", notes = "编辑API(大数据查询/标签查询)")
@PostMapping(value = "/updateApiBigData")
public JsonResult updateApiBigDataInfo(@RequestBody @Validated MakeBigDataApiReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
...
...
@@ -126,7 +126,7 @@ public class DmpApiServiceMangeController {
e.printStackTrace();
}
return jsonResult;
}
}
*/
/**
* API计量调用次数和执行时长
...
...
@@ -189,6 +189,26 @@ public class DmpApiServiceMangeController {
return
jsonResult
;
}
/**
* API计量--API已调用列表
*
* @author Bellamy
* @since 2021-02-25
*/
@ApiOperation
(
value
=
"API计量--API已调用列表"
,
notes
=
"API计量--API已调用列表"
)
@PostMapping
(
value
=
"/listCallApi"
)
public
JsonResult
listCallApi
(
@RequestBody
@Validated
ApiInterfaceInfoListReq
req
,
HttpServletRequest
httpRequest
)
{
JsonResult
jsonResult
=
new
JsonResult
();
try
{
jsonResult
=
dmpApiServiceMangeService
.
listCallApi
(
req
);
}
catch
(
Exception
e
)
{
jsonResult
.
setMessage
(
e
.
getMessage
());
jsonResult
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
e
.
printStackTrace
();
}
return
jsonResult
;
}
/**
* 获取数据源库——下拉框
*
...
...
src/main/java/com/jz/dmp/modules/controller/dataService/bean/ApiInterfaceReq.java
View file @
7413cc0f
...
...
@@ -19,64 +19,93 @@ import java.io.Serializable;
public
class
ApiInterfaceReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"传输方式:http https"
,
required
=
true
)
@ApiModelProperty
(
value
=
"传输方式:0,http 1.https"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
public
String
transMode
;
public
Integer
apiProtocl
;
@ApiModelProperty
(
value
=
"加密方式
0 无,1:MD5 2:RSA"
,
required
=
true
)
@ApiModelProperty
(
value
=
"加密方式
,1:MD5 2:RSA"
,
required
=
true
)
@NotNull
(
message
=
"加密方式不能为空"
)
public
String
signType
;
public
Integer
signType
;
@ApiModelProperty
(
value
=
"Api类型:对应字典表key"
,
required
=
true
)
@NotNull
(
message
=
"Api类型不能为空"
)
public
String
apiType
;
@ApiModelProperty
(
value
=
"
接入类型:对应字典表key"
,
required
=
true
)
@NotNull
(
message
=
"
接入类型
不能为空"
)
public
String
joinType
;
@ApiModelProperty
(
value
=
"
apiKey"
,
required
=
true
)
@NotNull
(
message
=
"
apiKey
不能为空"
)
public
String
apiKey
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
true
)
@NotNull
(
message
=
"目标地址不能为空"
)
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
false
)
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@NotNull
(
message
=
"超时时间不能为空"
)
public
String
timeout
;
@ApiModelProperty
(
value
=
"请求方式:GET POST"
,
required
=
true
)
@NotNull
(
message
=
"请求方式不能为空"
)
public
String
reqType
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@NotNull
(
message
=
"超时时间不能为空"
)
public
Integer
timeout
;
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月, YEAR 按年"
,
required
=
true
)
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月, YEAR 按年"
,
required
=
true
)
@NotNull
(
message
=
"限流类型不能为空"
)
public
String
req
Type
;
public
String
limit
Type
;
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
false
)
@ApiModelProperty
(
value
=
"API名称"
,
required
=
false
)
public
String
apiName
;
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
false
)
public
Long
reqFrequency
;
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"父类文件id,一级文件夹传入0"
,
required
=
false
)
public
Long
parentId
;
@ApiModelProperty
(
value
=
"文件id"
,
required
=
false
)
@ApiModelProperty
(
value
=
"文件夹Id"
,
required
=
true
)
@NotNull
(
message
=
"文件夹Id不能为空"
)
public
Long
fileId
;
@ApiModelProperty
(
value
=
"项目id"
,
required
=
true
)
@NotNull
(
message
=
"项目id
不能为空"
)
public
Long
projectId
;
/* @ApiModelProperty(value = "项目编号",
required = true)
@NotNull(message
="项目编号
不能为空")
public Long projectId;
*/
@ApiModelProperty
(
value
=
"
状态"
,
required
=
false
)
public
String
status
;
@ApiModelProperty
(
value
=
"
输出类型:JSON 文件流形式"
,
required
=
false
)
public
String
outputType
;
@ApiModelProperty
(
value
=
"
更新时传入api自增id"
,
required
=
false
)
public
Long
id
;
@ApiModelProperty
(
value
=
"
最大行数:"
,
required
=
false
)
public
Long
maxRow
;
@ApiModelProperty
(
value
=
"
创建用户"
)
public
String
createUser
;
@ApiModelProperty
(
value
=
"
每页返回数据数:"
,
required
=
false
)
public
Long
pageRow
;
@ApiModelProperty
(
value
=
"api类型:1.数据银行制作大数据表 "
+
"2 数据银行制作数据包,3,数据银行制作自定义API "
+
"4 API实时接入 6 标签查询 9自定义"
,
hidden
=
true
)
public
String
apiType
;
@ApiModelProperty
(
value
=
"请求参数:"
,
required
=
false
)
public
String
requestParam
;
@ApiModelProperty
(
value
=
"请求方式"
)
public
String
reqMethod
;
@ApiModelProperty
(
value
=
"响应参数:"
,
required
=
false
)
public
String
responseParam
;
@ApiModelProperty
(
value
=
"固定参数:"
,
required
=
false
)
public
String
inboxParam
;
@ApiModelProperty
(
value
=
"参数字段:"
,
required
=
false
)
public
String
tableFields
;
@ApiModelProperty
(
value
=
"数据源id"
,
required
=
false
)
public
String
esDataSource
;
@ApiModelProperty
(
value
=
"数据库名称"
,
required
=
false
)
public
String
esDataBase
;
@ApiModelProperty
(
value
=
"数据表名称"
,
required
=
false
)
public
String
esTable
;
@ApiModelProperty
(
value
=
"更新时传入api自增id"
,
required
=
false
)
public
Long
id
;
@ApiModelProperty
(
value
=
"创建用户"
,
hidden
=
true
)
public
String
createUser
;
@ApiModelProperty
(
value
=
"更新用户"
,
hidden
=
true
)
public
String
updateUser
;
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
public
String
status
;
}
src/main/java/com/jz/dmp/modules/service/DmpApiMangeService.java
View file @
7413cc0f
...
...
@@ -3,6 +3,8 @@ package com.jz.dmp.modules.service;
import
com.jz.common.constant.JsonResult
;
import
com.jz.dmp.modules.controller.dataService.bean.*
;
import
java.util.Map
;
/**
* @ClassName: DmpApiMangeService
* @Description: 数据服务Api管理
...
...
@@ -66,7 +68,7 @@ public interface DmpApiMangeService {
* @author Bellamy
* @since 2021-01-19
*/
JsonResult
apiTestInfo
(
String
apiKey
)
throws
Exception
;
JsonResult
apiTestInfo
(
Map
<
String
,
Object
>
params
)
throws
Exception
;
/**
* 查看日志
...
...
src/main/java/com/jz/dmp/modules/service/DmpApiServiceMangeService.java
View file @
7413cc0f
...
...
@@ -17,7 +17,7 @@ import java.util.List;
public
interface
DmpApiServiceMangeService
{
/**
* 保存API(第三方)基本信息
* 保存
/编辑
API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
...
...
@@ -25,12 +25,12 @@ public interface DmpApiServiceMangeService {
JsonResult
saveApiInfo
(
ApiInterfaceReq
req
)
throws
Exception
;
/**
*
保存
API(大数据查询/标签查询)
*
制作/编辑
API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult
saveApiBigDataInfo
(
MakeBigDataApi
Req
req
)
throws
Exception
;
JsonResult
saveApiBigDataInfo
(
ApiInterface
Req
req
)
throws
Exception
;
/**
* 编辑API(第三方)基本信息
...
...
@@ -98,4 +98,11 @@ public interface DmpApiServiceMangeService {
*/
JsonResult
getFolderTree
(
String
projectId
,
String
orgCode
)
throws
Exception
;
/**
* API计量--API已调用列表
*
* @author Bellamy
* @since 2021-02-25
*/
JsonResult
listCallApi
(
ApiInterfaceInfoListReq
req
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/com/jz/dmp/modules/service/impl/DmpApiMangeServiceImpl.java
View file @
7413cc0f
...
...
@@ -226,28 +226,9 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService {
* @since 2021-01-19
*/
@Override
public
JsonResult
apiTestInfo
(
String
apiKey
)
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
public
JsonResult
apiTestInfo
(
Map
<
String
,
Object
>
params
)
throws
Exception
{
String
url
=
gatewayUrl
+
GatewayApiConstant
.
testApi
;
Map
params
=
new
HashMap
();
params
.
put
(
"apiKey"
,
apiKey
);
String
returnData
=
HttpClientUtils
.
getJsonForParam
(
url
,
params
);
if
(
StringUtils
.
isEmpty
(
returnData
))
{
throw
new
RuntimeException
(
"测试失败!"
);
}
logger
.
info
(
"#################响应结果{}"
+
returnData
);
Map
map
=
JSONObject
.
parseObject
(
returnData
);
if
(
map
.
containsKey
(
"code"
))
{
if
(
"200"
.
equals
(
map
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
map
.
get
(
"data"
));
}
}
if
(
map
.
containsKey
(
"message"
))
{
logger
.
info
(
map
.
get
(
"message"
).
toString
());
result
.
setMessage
(
map
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
}
JsonResult
result
=
GatewayApiConstant
.
postRequest2GetData
(
url
,
JSONObject
.
toJSONString
(
params
));
return
result
;
}
...
...
src/main/java/com/jz/dmp/modules/service/impl/DmpApiServiceMangeServiceImpl.java
View file @
7413cc0f
...
...
@@ -45,77 +45,31 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
private
OfflineSynchDao
offlineSynchDao
;
/**
* 保存API(第三方)基本信息
* 保存
/编辑
API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
*/
@Override
public
JsonResult
saveApiInfo
(
ApiInterfaceReq
req
)
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
String
url
=
gatewayUrl
+
GatewayApiConstant
.
addApiInfo
;
req
.
setCreateUser
(
SessionUtils
.
getCurrentUserName
());
String
resultData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
req
));
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"保存失败!"
);
}
logger
.
info
(
"#################响应结果数据{}"
+
resultData
);
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
jsonObject
.
containsKey
(
"code"
))
{
if
(
"200"
.
equals
(
jsonObject
.
get
(
"code"
).
toString
()))
{
Map
apiKey
=
JSONObject
.
parseObject
(
jsonObject
.
get
(
"data"
).
toString
());
result
.
setData
(
apiKey
.
get
(
"data"
));
// 新增API数据的apiKey
return
result
;
}
}
if
(
jsonObject
.
containsKey
(
"message"
))
{
logger
.
info
(
jsonObject
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
result
.
setMessage
(
jsonObject
.
get
(
"message"
).
toString
());
}
JsonResult
result
=
GatewayApiConstant
.
postRequest2GetData
(
url
,
JSONObject
.
toJSONString
(
req
));
return
result
;
}
/**
*
保存
API(大数据查询/标签查询)
*
制作/编辑
API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
@Override
public
JsonResult
saveApiBigDataInfo
(
MakeBigDataApiReq
req
)
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
ApiInterfaceReq
baseInfo
=
new
ApiInterfaceReq
();
BeanUtils
.
copyProperties
(
req
,
baseInfo
);
//保存API基本信息
JsonResult
apiKeyData
=
saveApiInfo
(
baseInfo
);
String
apiKey
=
apiKeyData
.
getData
().
toString
();
if
(
StringUtils
.
isNotEmpty
(
apiKey
))
{
logger
.
info
(
"######apiKey="
+
apiKey
);
req
.
setApiKey
(
apiKey
);
req
.
setCreateUser
(
SessionUtils
.
getCurrentUserName
());
String
url
=
gatewayUrl
+
GatewayApiConstant
.
addApiBigData
;
//保存API(大数据查询/标签查询)
String
resultData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
req
));
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"保存失败!"
);
}
logger
.
info
(
"#################响应结果数据{}"
+
resultData
);
public
JsonResult
saveApiBigDataInfo
(
ApiInterfaceReq
req
)
throws
Exception
{
String
url
=
gatewayUrl
+
GatewayApiConstant
.
addApiBigData
;
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
jsonObject
.
containsKey
(
"code"
))
{
if
(
"200"
.
equals
(
jsonObject
.
get
(
"code"
).
toString
()))
{
return
result
;
}
}
if
(
jsonObject
.
containsKey
(
"message"
))
{
logger
.
info
(
jsonObject
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
result
.
setMessage
(
jsonObject
.
get
(
"message"
).
toString
());
}
}
req
.
setCreateUser
(
SessionUtils
.
getCurrentUserName
());
JsonResult
result
=
GatewayApiConstant
.
postRequest2GetData
(
url
,
JSONObject
.
toJSONString
(
req
));
return
result
;
}
...
...
@@ -199,27 +153,10 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
*/
@Override
public
JsonResult
getCountAPiCallStat
()
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
String
url
=
gatewayUrl
+
GatewayApiConstant
.
countAPiCallStat
;
Map
params
=
new
HashMap
();
params
.
put
(
"date"
,
DateUtils
.
currentDate
());
String
returnData
=
HttpClientUtils
.
getJsonForParam
(
url
,
params
);
if
(
StringUtils
.
isEmpty
(
returnData
))
{
throw
new
RuntimeException
(
"查询失败!"
);
}
logger
.
info
(
"#################响应结果{}"
+
returnData
);
Map
map
=
JSONObject
.
parseObject
(
returnData
);
if
(
map
.
containsKey
(
"code"
))
{
if
(
"200"
.
equals
(
map
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
map
.
get
(
"data"
));
}
}
if
(
map
.
containsKey
(
"message"
))
{
logger
.
info
(
map
.
get
(
"message"
).
toString
());
result
.
setMessage
(
map
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
}
JsonResult
result
=
GatewayApiConstant
.
getRequest2GetData
(
url
,
params
);
return
result
;
}
...
...
@@ -260,25 +197,22 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
*/
@Override
public
JsonResult
queryApiNotCalledListPage
(
ApiInterfaceInfoListReq
req
)
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
String
url
=
gatewayUrl
+
GatewayApiConstant
.
notCalledList
;
String
resultData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
req
));
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"查询失败!"
);
}
logger
.
info
(
"#################响应结果数据{}"
+
resultData
);
JsonResult
result
=
GatewayApiConstant
.
postRequest2GetData
(
url
,
JSONObject
.
toJSONString
(
req
));
return
result
;
}
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
jsonObject
.
containsKey
(
"code"
))
{
if
(
"200"
.
equals
(
jsonObject
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
jsonObject
.
get
(
"data"
));
}
}
if
(
jsonObject
.
containsKey
(
"message"
))
{
logger
.
info
(
jsonObject
.
get
(
"message"
).
toString
());
result
.
setMessage
(
jsonObject
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
)
;
}
/**
* API计量--API已调用列表
*
* @param req
* @author Bellamy
* @since 2021-02-25
*/
@Override
public
JsonResult
listCallApi
(
ApiInterfaceInfoListReq
req
)
throws
Exception
{
String
url
=
gatewayUrl
+
GatewayApiConstant
.
listCallApi
;
JsonResult
result
=
GatewayApiConstant
.
postRequest2GetData
(
url
,
JSONObject
.
toJSONString
(
req
));
return
result
;
}
...
...
@@ -291,25 +225,8 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
*/
@Override
public
JsonResult
apiListPaging
(
ApiInterfaceInfoListReq
req
)
throws
Exception
{
JsonResult
result
=
new
JsonResult
();
String
url
=
gatewayUrl
+
GatewayApiConstant
.
listServerApplyApi
;
String
resultData
=
HttpClientUtils
.
post
(
url
,
JSONObject
.
toJSONString
(
req
));
if
(
StringUtils
.
isEmpty
(
resultData
))
{
throw
new
RuntimeException
(
"查询失败!"
);
}
logger
.
info
(
"#################响应结果数据{}"
+
resultData
);
Map
jsonObject
=
JSONObject
.
parseObject
(
resultData
);
if
(
jsonObject
.
containsKey
(
"code"
))
{
if
(
"200"
.
equals
(
jsonObject
.
get
(
"code"
).
toString
()))
{
return
JsonResult
.
ok
(
jsonObject
.
get
(
"data"
));
}
}
if
(
jsonObject
.
containsKey
(
"message"
))
{
logger
.
info
(
jsonObject
.
get
(
"message"
).
toString
());
result
.
setMessage
(
jsonObject
.
get
(
"message"
).
toString
());
result
.
setCode
(
ResultCode
.
INTERNAL_SERVER_ERROR
);
}
JsonResult
result
=
GatewayApiConstant
.
postRequest2GetData
(
url
,
JSONObject
.
toJSONString
(
req
));
return
result
;
}
...
...
@@ -328,7 +245,7 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
String
url
=
gatewayUrl
+
GatewayApiConstant
.
folderTree
;
Map
params
=
new
HashMap
();
if
(
StringUtils
.
isNotEmpty
(
projectId
))
{
if
(
StringUtils
.
isNotEmpty
(
projectId
))
{
params
.
put
(
"projectId"
,
projectId
);
}
params
.
put
(
"orgCode"
,
orgCode
);
...
...
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