Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dm_project
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
姚本章
dm_project
Commits
edbf048a
Commit
edbf048a
authored
Jan 22, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加未调用列表接口
parent
1ef7d947
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
52 deletions
+84
-52
ApiInterfaceController.java
...ain/java/com/jz/dm/controller/ApiInterfaceController.java
+14
-13
ApiInterfaceMapper.java
...ay/src/main/java/com/jz/dm/mapper/ApiInterfaceMapper.java
+12
-1
ApiInterfaceService.java
.../src/main/java/com/jz/dm/service/ApiInterfaceService.java
+14
-7
ApiInterfaceServiceImpl.java
.../java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
+35
-25
ApiInterfaceMapper.xml
...igateway/src/main/resources/mapper/ApiInterfaceMapper.xml
+9
-6
No files found.
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiInterfaceController.java
View file @
edbf048a
...
...
@@ -35,10 +35,21 @@ public class ApiInterfaceController {
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"API列表查询"
)
@ApiOperation
(
"API
---(已调用列表)
列表查询"
)
@PostMapping
(
value
=
"/listApiInterface"
)
public
Mono
<
Result
>
getApiInterfaceCallList
(
@RequestBody
@Valid
ApiInterfaceInfoListReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiInterfaceService
.
listCallApiInterface
(
req
)));
}
/**
* @Description:API列表查询
* @return: API列表
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"API---(未调用列表)列表查询"
)
@PostMapping
(
value
=
"/listUnCallApiInterface"
)
public
Mono
<
Result
>
getApiInterfaceList
(
@RequestBody
@Valid
ApiInterfaceInfoListReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiInterfaceService
.
listApiInterface
(
req
)));
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiInterfaceService
.
list
UnCall
ApiInterface
(
req
)));
}
/**
* @Description:API详情查询
...
...
@@ -74,16 +85,6 @@ public class ApiInterfaceController {
@RequestParam
(
name
=
"apiKey"
)
String
apiKey
)
{
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
dmpDeleteAuth
(
type
,
apiKey
));
}
/**
* @Description:API测试调用
* @return: DMP-API删除
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"API调用测试接口"
)
@GetMapping
(
value
=
"/apiTestApiInterface"
)
public
Mono
<
Result
>
apiTestApiInterface
(
@RequestParam
(
name
=
"apiKey"
)
String
apiKey
)
{
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
apiTestInterface
(
apiKey
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiInterfaceMapper.java
View file @
edbf048a
...
...
@@ -21,13 +21,21 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
/**
* 查询API列表信息
* 查询
(已调用)
API列表信息
* @param page
* @param query
* @return
*/
IPage
<
ApiInterface
>
listApiInterfaceInfo
(
IPage
<
ApiInterface
>
page
,
@Param
(
"ew"
)
Wrapper
<
ApiInterface
>
query
);
/**
* 查询(未调用)API列表信息
* @param page
* @param query
* @return
*/
IPage
<
ApiInterface
>
listCallApiInterfaceInfo
(
IPage
<
ApiInterface
>
page
,
@Param
(
"ew"
)
Wrapper
<
ApiInterface
>
query
);
/**
* 查询API详情信息
* @param req
...
...
@@ -42,4 +50,7 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
* @return
*/
ApiInterfaceCustom
getTestData
(
String
apiKey
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiInterfaceService.java
View file @
edbf048a
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
com.jz.dm.models.req.api.ApiInterfaceInfoListReq
;
...
...
@@ -41,11 +42,19 @@ public interface ApiInterfaceService {
ApiInterface
getReqTargetInfo
(
String
apiKey
);
/**
*
查询API列表信息
*
API---(已调用列表)列表查询
* @param req
* @return
*/
IPage
<
ApiInterface
>
listApiInterface
(
ApiInterfaceInfoListReq
req
);
IPage
<
ApiInterface
>
listCallApiInterface
(
ApiInterfaceInfoListReq
req
);
/**
* API---(未调用列表)列表查询
* @param req
* @return
*/
IPage
<
ApiInterface
>
listUnCallApiInterface
(
ApiInterfaceInfoListReq
req
);
/**
* 查询API详情
...
...
@@ -77,12 +86,10 @@ public interface ApiInterfaceService {
Result
dmpDeleteAuth
(
String
type
,
String
apiKey
);
/**
*
api测试接口
* @param api
Key
*
获取api自定义信息
* @param api
InterfaceId
* @return
*/
Result
apiTestInterface
(
String
apiKey
);
ApiInterfaceCustom
getApiCustomInfo
(
Long
apiInterfaceId
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
View file @
edbf048a
...
...
@@ -11,15 +11,16 @@ import com.jz.dm.common.enums.GeneralStatusTypeEnum;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiInterfaceCustomMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.dto.ApiCallDataDto
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
com.jz.dm.models.req.api.ApiInterfaceInfoListReq
;
import
com.jz.dm.service.ApiInterfaceService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -49,26 +50,25 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
@Resource
private
ApiInterfaceMapper
apiInterfaceMapper
;
@Resource
private
ApiInterfaceCustomMapper
apiInterfaceCustomMapper
;
@Resource
private
ApiAuthMapper
apiAuthMapper
;
@Autowired
private
HttpsUtils
httpsUtils
;
/**
*
获取API列表信息
*
API---(调用列表)列表查询
*
* @param req
* @return
*/
@Override
public
IPage
<
ApiInterface
>
listApiInterface
(
ApiInterfaceInfoListReq
req
)
{
public
IPage
<
ApiInterface
>
list
Call
ApiInterface
(
ApiInterfaceInfoListReq
req
)
{
IPage
<
ApiInterface
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
/*if (StringUtils.isNotBlank(req.getApiKey())){
query.eq("api_key",req.getApiKey());
}*/
/* if (StringUtils.isNotBlank(req.getStatus())){
query.eq("status",req.getStatus());
}*/
if
(
StringUtils
.
isNotBlank
(
req
.
getApiKey
())){
query
.
eq
(
"ai.api_key"
,
req
.
getApiKey
());
}
query
.
eq
(
"ai.is_deleted"
,
0
);
query
.
orderByDesc
(
"ai.create_date"
);
query
.
groupBy
(
"ai.create_date"
);
...
...
@@ -76,6 +76,24 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
}
/**
* API---(未调用列表)列表查询
* @param req
* @return
*/
@Override
public
IPage
<
ApiInterface
>
listUnCallApiInterface
(
ApiInterfaceInfoListReq
req
)
{
IPage
<
ApiInterface
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
req
.
getApiKey
())){
query
.
eq
(
"ai.api_key"
,
req
.
getApiKey
());
}
query
.
isNull
(
"ar.api_key"
);
query
.
eq
(
"ai.is_deleted"
,
0
);
query
.
orderByDesc
(
"ai.create_date"
);
return
apiInterfaceMapper
.
listCallApiInterfaceInfo
(
page
,
query
);
}
/**
* 获取API详情信息
*
...
...
@@ -206,28 +224,20 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
return
authCall
+
authDateCall
;
}
/**
* api测试接口
*
* @param apiKey
* 获取api自定义信息
* @param apiInterfaceId
* @return
*/
@Override
public
Result
apiTestInterface
(
String
apiKey
)
{
ApiInterfaceCustom
apiInterfaceCustom
=
apiInterfaceMapper
.
getTestData
(
apiKey
);
if
(
null
==
apiInterfaceCustom
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_FOUND
);
}
/* if (StringUtils.isNotBlank(apiInterfaceCustom.getApiExample())){
httpsUtils.doGet(testUrl,"");
}else {
}*/
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
public
ApiInterfaceCustom
getApiCustomInfo
(
Long
apiInterfaceId
)
{
QueryWrapper
<
ApiInterfaceCustom
>
queryWra
=
new
QueryWrapper
<>();
queryWra
.
eq
(
"api_interface_id"
,
apiInterfaceId
);
queryWra
.
eq
(
"is_deleted"
,
0
);
return
apiInterfaceCustomMapper
.
selectOne
(
queryWra
)
;
}
/**
* 获取用户授权信息
*
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiInterfaceMapper.xml
View file @
edbf048a
...
...
@@ -11,18 +11,21 @@
<select
id=
"listApiInterfaceInfo"
resultType=
"com.jz.dm.models.domian.ApiInterface"
>
SELECT ai.*,
/* ai.id AS id,
ai.api_key AS apiKey,
ai.join_type AS joinType,
ai.create_user AS createUser,*/
COUNT(ar.id) AS callStat,
SUM(ar.request_consuming) AS requestTimeStat
FROM t_api_interface AS ai
LEFT JOIN t_api_req_log AS ar ON ai.api_key =ar.api_key
AND ar.is_deleted =0
JOIN t_api_req_log AS ar ON ai.api_key =ar.api_key AND ar.is_deleted =0
AND DATE_FORMAT(CURDATE(), '%Y%m') = DATE_FORMAT(ar.create_date, '%Y%m')
${ew.customSqlSegment}
</select>
<select
id=
"listCallApiInterfaceInfo"
resultType=
"com.jz.dm.models.domian.ApiInterface"
>
SELECT
ai.*
FROM t_api_interface AS ai
LEFT JOIN t_api_req_log AS ar ON ai.api_key = ar.api_key AND ar.is_deleted =0
${ew.customSqlSegment}
</select>
<select
id=
"selectDetail"
resultType=
"com.jz.dm.models.domian.ApiInterface"
>
SELECT ai.*,
aic.request_param AS requestParam,
...
...
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