Commit edbf048a authored by zhangc's avatar zhangc

添加未调用列表接口

parent 1ef7d947
...@@ -35,10 +35,21 @@ public class ApiInterfaceController { ...@@ -35,10 +35,21 @@ public class ApiInterfaceController {
* @Author: Mr.zhang * @Author: Mr.zhang
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
@ApiOperation("API列表查询") @ApiOperation("API---(已调用列表)列表查询")
@PostMapping(value = "/listApiInterface") @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) { 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详情查询 * @Description:API详情查询
...@@ -74,16 +85,6 @@ public class ApiInterfaceController { ...@@ -74,16 +85,6 @@ public class ApiInterfaceController {
@RequestParam (name="apiKey")String apiKey) { @RequestParam (name="apiKey")String apiKey) {
return Mono.fromSupplier(() -> apiInterfaceService.dmpDeleteAuth(type,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> { ...@@ -21,13 +21,21 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
/** /**
* 查询API列表信息 * 查询(已调用)API列表信息
* @param page * @param page
* @param query * @param query
* @return * @return
*/ */
IPage<ApiInterface > listApiInterfaceInfo(IPage<ApiInterface > page, @Param("ew") Wrapper<ApiInterface > query); 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详情信息 * 查询API详情信息
* @param req * @param req
...@@ -42,4 +50,7 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> { ...@@ -42,4 +50,7 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
* @return * @return
*/ */
ApiInterfaceCustom getTestData(String apiKey); ApiInterfaceCustom getTestData(String apiKey);
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.dm.models.domian.ApiAuth; import com.jz.dm.models.domian.ApiAuth;
import com.jz.dm.models.domian.ApiInterface; 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.ApiInterfaceDetailReq;
import com.jz.dm.models.req.api.ApiInterfaceInfoListReq; import com.jz.dm.models.req.api.ApiInterfaceInfoListReq;
...@@ -41,11 +42,19 @@ public interface ApiInterfaceService { ...@@ -41,11 +42,19 @@ public interface ApiInterfaceService {
ApiInterface getReqTargetInfo(String apiKey); ApiInterface getReqTargetInfo(String apiKey);
/** /**
* 查询API列表信息 * API---(已调用列表)列表查询
* @param req * @param req
* @return * @return
*/ */
IPage<ApiInterface > listApiInterface(ApiInterfaceInfoListReq req); IPage<ApiInterface > listCallApiInterface(ApiInterfaceInfoListReq req);
/**
* API---(未调用列表)列表查询
* @param req
* @return
*/
IPage<ApiInterface > listUnCallApiInterface(ApiInterfaceInfoListReq req);
/** /**
* 查询API详情 * 查询API详情
...@@ -77,12 +86,10 @@ public interface ApiInterfaceService { ...@@ -77,12 +86,10 @@ public interface ApiInterfaceService {
Result dmpDeleteAuth(String type,String apiKey); Result dmpDeleteAuth(String type,String apiKey);
/** /**
* api测试接口 * 获取api自定义信息
* @param apiKey * @param apiInterfaceId
* @return * @return
*/ */
Result apiTestInterface(String apiKey); ApiInterfaceCustom getApiCustomInfo(Long apiInterfaceId);
} }
...@@ -11,15 +11,16 @@ import com.jz.dm.common.enums.GeneralStatusTypeEnum; ...@@ -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.apiInterface.ApiStatusEnum;
import com.jz.dm.common.enums.auth.AuthModeEnum; import com.jz.dm.common.enums.auth.AuthModeEnum;
import com.jz.dm.mapper.ApiAuthMapper; import com.jz.dm.mapper.ApiAuthMapper;
import com.jz.dm.mapper.ApiInterfaceCustomMapper;
import com.jz.dm.mapper.ApiInterfaceMapper; import com.jz.dm.mapper.ApiInterfaceMapper;
import com.jz.dm.models.domian.ApiAuth; import com.jz.dm.models.domian.ApiAuth;
import com.jz.dm.models.domian.ApiInterface; import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.models.domian.ApiInterfaceCustom; 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.ApiInterfaceDetailReq;
import com.jz.dm.models.req.api.ApiInterfaceInfoListReq; import com.jz.dm.models.req.api.ApiInterfaceInfoListReq;
import com.jz.dm.service.ApiInterfaceService; import com.jz.dm.service.ApiInterfaceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -49,26 +50,25 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -49,26 +50,25 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
@Resource @Resource
private ApiInterfaceMapper apiInterfaceMapper; private ApiInterfaceMapper apiInterfaceMapper;
@Resource @Resource
private ApiInterfaceCustomMapper apiInterfaceCustomMapper;
@Resource
private ApiAuthMapper apiAuthMapper; private ApiAuthMapper apiAuthMapper;
@Autowired @Autowired
private HttpsUtils httpsUtils; private HttpsUtils httpsUtils;
/** /**
* 获取API列表信息 * API---(调用列表)列表查询
* *
* @param req * @param req
* @return * @return
*/ */
@Override @Override
public IPage<ApiInterface > listApiInterface(ApiInterfaceInfoListReq req) { public IPage<ApiInterface > listCallApiInterface(ApiInterfaceInfoListReq req) {
IPage<ApiInterface > page = new Page<>(req.getPageNum(), req.getPageSize()); IPage<ApiInterface > page = new Page<>(req.getPageNum(), req.getPageSize());
QueryWrapper<ApiInterface > query = new QueryWrapper<>(); QueryWrapper<ApiInterface > query = new QueryWrapper<>();
/*if (StringUtils.isNotBlank(req.getApiKey())){ if (StringUtils.isNotBlank(req.getApiKey())){
query.eq("api_key",req.getApiKey()); query.eq("ai.api_key",req.getApiKey());
}*/ }
/* if (StringUtils.isNotBlank(req.getStatus())){
query.eq("status",req.getStatus());
}*/
query.eq("ai.is_deleted", 0); query.eq("ai.is_deleted", 0);
query.orderByDesc("ai.create_date"); query.orderByDesc("ai.create_date");
query.groupBy("ai.create_date"); query.groupBy("ai.create_date");
...@@ -76,6 +76,24 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -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详情信息 * 获取API详情信息
* *
...@@ -206,27 +224,19 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -206,27 +224,19 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
return authCall + authDateCall; return authCall + authDateCall;
} }
/** /**
* api测试接口 * 获取api自定义信息
* * @param apiInterfaceId
* @param apiKey
* @return * @return
*/ */
@Override @Override
public Result apiTestInterface(String apiKey) { public ApiInterfaceCustom getApiCustomInfo(Long apiInterfaceId) {
ApiInterfaceCustom apiInterfaceCustom= apiInterfaceMapper.getTestData(apiKey); QueryWrapper<ApiInterfaceCustom> queryWra = new QueryWrapper<>();
if (null == apiInterfaceCustom) { queryWra.eq("api_interface_id",apiInterfaceId);
return Result.of_error(ResultMsg.DATA_NOT_FOUND); 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 @@ ...@@ -11,18 +11,21 @@
<select id="listApiInterfaceInfo" resultType="com.jz.dm.models.domian.ApiInterface"> <select id="listApiInterfaceInfo" resultType="com.jz.dm.models.domian.ApiInterface">
SELECT ai.*, 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, COUNT(ar.id) AS callStat,
SUM(ar.request_consuming) AS requestTimeStat SUM(ar.request_consuming) AS requestTimeStat
FROM t_api_interface AS ai FROM t_api_interface AS ai
LEFT JOIN t_api_req_log AS ar ON ai.api_key =ar.api_key JOIN t_api_req_log AS ar ON ai.api_key =ar.api_key AND ar.is_deleted =0
AND ar.is_deleted =0
AND DATE_FORMAT(CURDATE(), '%Y%m') = DATE_FORMAT(ar.create_date, '%Y%m') AND DATE_FORMAT(CURDATE(), '%Y%m') = DATE_FORMAT(ar.create_date, '%Y%m')
${ew.customSqlSegment} ${ew.customSqlSegment}
</select> </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 id="selectDetail" resultType="com.jz.dm.models.domian.ApiInterface">
SELECT ai.*, SELECT ai.*,
aic.request_param AS requestParam, 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