Commit edbf048a authored by zhangc's avatar zhangc

添加未调用列表接口

parent 1ef7d947
......@@ -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.listUnCallApiInterface(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));
}
}
......@@ -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);
}
......@@ -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 apiKey
* 获取api自定义信息
* @param apiInterfaceId
* @return
*/
Result apiTestInterface(String apiKey);
ApiInterfaceCustom getApiCustomInfo(Long apiInterfaceId);
}
......@@ -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 > listCallApiInterface(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,27 +224,19 @@ 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);
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) ;
}
/* if (StringUtils.isNotBlank(apiInterfaceCustom.getApiExample())){
httpsUtils.doGet(testUrl,"");
}else {
}*/
return Result.of_success(ResultMsg.SUCCESS);
}
/**
* 获取用户授权信息
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment