Commit b4d9a200 authored by zhangc's avatar zhangc

添加数据发送查询接口

parent 49bc0f72
...@@ -3,6 +3,7 @@ package com.jz.dm.controller; ...@@ -3,6 +3,7 @@ package com.jz.dm.controller;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
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.models.resp.SendDataReq;
import com.jz.dm.service.ApiInterfaceService; import com.jz.dm.service.ApiInterfaceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -97,10 +98,9 @@ public class ApiInterfaceController { ...@@ -97,10 +98,9 @@ public class ApiInterfaceController {
* @Date: 2020-12-24 * @Date: 2020-12-24
*/ */
@ApiOperation("已发送到数据银行API列表") @ApiOperation("已发送到数据银行API列表")
@GetMapping(value = "/listSendDataBank") @PostMapping(value = "/listSendDataBank")
public Mono<Result> listSendDataBank(@RequestParam (name="pageNum",defaultValue = "1",required = false)String pageNum, public Mono<Result> listSendDataBank(@RequestBody @Valid SendDataReq req) {
@RequestParam (name="pageSize",defaultValue = "20",required = false)String pageSize) { return Mono.fromSupplier(() -> apiInterfaceService.getSendDataBankList(req));
return Mono.fromSupplier(() -> apiInterfaceService.getSendDataBankList(pageNum, pageSize));
} }
} }
...@@ -2,7 +2,6 @@ package com.jz.dm.models.domian; ...@@ -2,7 +2,6 @@ package com.jz.dm.models.domian;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jz.dm.common.base.BaseObject; import com.jz.dm.common.base.BaseObject;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
...@@ -35,7 +34,6 @@ public class ApiInterface extends BaseObject implements Serializable { ...@@ -35,7 +34,6 @@ public class ApiInterface extends BaseObject implements Serializable {
* api名称 * api名称
*/ */
@TableField("api_name") @TableField("api_name")
@JsonIgnore
private String apiName; private String apiName;
/** /**
......
package com.jz.dm.models.resp;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.resp
* @PROJECT_NAME: jz-dm-parent
* @NAME: SendDataReq
* @DATE: 2021-1-29/17:35
* @DAY_NAME_SHORT: 周五
* @Description:
**/
@Data
@ApiModel
@Builder
public class SendDataReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "关键词")
private String key;
@ApiModelProperty(value = "数据类型")
private String apiType;
@ApiModelProperty(value = "数据格式:Json Flow")
private String outputType;
@ApiModelProperty(value = "创建开始时间")
private String startTime;
@ApiModelProperty(value = "创建结束时间")
private String endTime;
}
...@@ -7,6 +7,7 @@ import com.jz.dm.models.domian.ApiInterface; ...@@ -7,6 +7,7 @@ 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.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.models.resp.SendDataReq;
/** /**
* @author ZC * @author ZC
...@@ -101,9 +102,8 @@ public interface ApiInterfaceService { ...@@ -101,9 +102,8 @@ public interface ApiInterfaceService {
/** /**
* 获取已发送到数据API列表 * 获取已发送到数据API列表
* @param pageNum * @param req
* @param pageSize
* @return * @return
*/ */
Result getSendDataBankList(String pageNum, String pageSize); Result getSendDataBankList(SendDataReq req);
} }
...@@ -18,6 +18,7 @@ import com.jz.dm.models.domian.ApiInterface; ...@@ -18,6 +18,7 @@ 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.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.models.resp.SendDataReq;
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.apache.commons.lang3.StringUtils;
...@@ -309,12 +310,25 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService { ...@@ -309,12 +310,25 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
return Result.of_error(ResultMsg.UPDATE_FAIL); return Result.of_error(ResultMsg.UPDATE_FAIL);
} }
/**
*
* @param req
* @return
*/
@Override @Override
public Result getSendDataBankList(String pageNum, String pageSize) { public Result getSendDataBankList(SendDataReq req) {
Integer pageN = Integer.valueOf(pageNum); IPage<ApiInterface> page = new Page<>(req.getPageNum(), req.getPageSize());
Integer pageS = Integer.valueOf(pageSize);
IPage<ApiInterface> page = new Page<>(pageN, pageS);
QueryWrapper<ApiInterface > query = new QueryWrapper<>(); QueryWrapper<ApiInterface > query = new QueryWrapper<>();
if (StringUtils.isNotBlank(req.getApiType())){
query.eq("api_type",req.getApiType());
}
if (StringUtils.isNotBlank(req.getOutputType())){
query.eq("output_type",req.getOutputType());
}
if (StringUtils.isNotBlank(req.getStartTime()) && StringUtils.isNotBlank(req.getEndTime())){
query.between("create_date",req.getStartTime(),req.getEndTime());
}
query.and(wrapper -> wrapper.like("api_name",req.getKey()));
query.eq("is_send_bank",1); query.eq("is_send_bank",1);
query.eq("status",ApiStatusEnum.ISSUE.name()); query.eq("status",ApiStatusEnum.ISSUE.name());
query.eq("is_deleted",0); query.eq("is_deleted",0);
......
...@@ -103,8 +103,8 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService { ...@@ -103,8 +103,8 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
apiAuth = authService.getAuthInfo(authCode); apiAuth = authService.getAuthInfo(authCode);
verifyAuth(apiAuth); verifyAuth(apiAuth);
//取出缓存数据 //取出缓存数据
String redisReqParam = redisUtils.get(request.getApiKey()); //String redisReqParam = redisUtils.get(request.getApiKey());
// String redisReqParam = null; String redisReqParam = null;
if (StringUtils.isNotBlank(redisReqParam)) {//redis中存在 if (StringUtils.isNotBlank(redisReqParam)) {//redis中存在
//解析出API制作成功时的参数配置 //解析出API制作成功时的参数配置
JSONObject jsonObject = JSONObject.parseObject(redisReqParam); JSONObject jsonObject = JSONObject.parseObject(redisReqParam);
......
...@@ -72,8 +72,8 @@ public class ApiQueryTestService extends ApiParamVerify implements OpenApiServic ...@@ -72,8 +72,8 @@ public class ApiQueryTestService extends ApiParamVerify implements OpenApiServic
jsonParams.put("is_test",true); jsonParams.put("is_test",true);
} }
//取出缓存数据 //取出缓存数据
String redisReqParam = redisUtils.get(request.getApiKey()); // String redisReqParam = redisUtils.get(request.getApiKey());
//String redisReqParam = null; String redisReqParam = null;
if (StringUtils.isNotBlank(redisReqParam)) {//redis中存在 if (StringUtils.isNotBlank(redisReqParam)) {//redis中存在
//解析出API制作成功时的参数配置 //解析出API制作成功时的参数配置
JSONObject jsonObject = JSONObject.parseObject(redisReqParam); JSONObject jsonObject = JSONObject.parseObject(redisReqParam);
......
...@@ -18,6 +18,7 @@ import net.sf.json.JSONObject; ...@@ -18,6 +18,7 @@ import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
...@@ -59,9 +60,9 @@ public class SystemLogAspect { ...@@ -59,9 +60,9 @@ public class SystemLogAspect {
}*/ }*/
//最终通知切入点 //最终通知切入点
/* @Pointcut("@annotation(com.jz.dm.web.annotation.ApiLogAspect)") @Pointcut("@annotation(com.jz.dm.web.annotation.ApiLogAspect)")
public void lastAspect() { public void lastAspect() {
}*/ }
//环绕通知切入点 //环绕通知切入点
@Pointcut("@annotation(com.jz.dm.web.annotation.ApiLogAspect)") @Pointcut("@annotation(com.jz.dm.web.annotation.ApiLogAspect)")
...@@ -82,7 +83,6 @@ public class SystemLogAspect { ...@@ -82,7 +83,6 @@ public class SystemLogAspect {
} }
if (StringUtils.isNotBlank(params)) { if (StringUtils.isNotBlank(params)) {
params = params.substring(0, params.length() - 1).split(";")[0]; params = params.substring(0, params.length() - 1).split(";")[0];
;
} }
//获取请求路径 //获取请求路径
String url = UrlUtil.getServerUrl(request); String url = UrlUtil.getServerUrl(request);
...@@ -116,10 +116,10 @@ public class SystemLogAspect { ...@@ -116,10 +116,10 @@ public class SystemLogAspect {
if (null != reqLog) { if (null != reqLog) {
apiReqLogMapper.insert(reqLog); apiReqLogMapper.insert(reqLog);
} }
Object result = joinPoint.proceed(joinPoint.getArgs()); /* Object result = joinPoint.proceed(joinPoint.getArgs());
jsonResult = JSONObject.fromObject(result); jsonResult = JSONObject.fromObject(result);
log.info("around响应结果为{}", jsonResult); log.info("around响应结果为{}", jsonResult);
apiLogService.updateLog(reqLog.getId(), jsonResult); apiLogService.updateLog(reqLog.getId(), jsonResult);*/
} catch (GatewayException ex) { } catch (GatewayException ex) {
log.info("切面处理保存异常信息:{}", ex.getMessage()); log.info("切面处理保存异常信息:{}", ex.getMessage());
apiLogService.updateLog(reqLog.getId(), jsonResult); apiLogService.updateLog(reqLog.getId(), jsonResult);
...@@ -176,39 +176,41 @@ public class SystemLogAspect { ...@@ -176,39 +176,41 @@ public class SystemLogAspect {
* 返回异常通知,返回抛出异常的时候执行的通知,可以获得返回的异常 * 返回异常通知,返回抛出异常的时候执行的通知,可以获得返回的异常
* 可以访问到异常对象,且可以指定在出现特定异常的时候再执行通知代码 * 可以访问到异常对象,且可以指定在出现特定异常的时候再执行通知代码
*/ */
//@AfterReturning(value = "lastAspect()", returning = "result") @AfterReturning(value = "lastAspect()", returning = "result")
//public void afterReturn(JoinPoint joinPoint, Object result) { public void afterReturn(JoinPoint joinPoint, Object result) {
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
// .getRequest(); .getRequest();
// log.info("~~~~~~~~~~~~~~~~~~~~~~最终通知执行~~~~~~~~~~~~~~~~~~~~~~~~"); log.info("~~~~~~~~~~~~~~~~~~~~~~最终通知执行~~~~~~~~~~~~~~~~~~~~~~~~");
// String classType = joinPoint.getTarget().getClass().getName(); String classType = joinPoint.getTarget().getClass().getName();
// try { try {
// Class<?> clazz = Class.forName(classType); Class<?> clazz = Class.forName(classType);
// String clazzName = clazz.getName(); String clazzName = clazz.getName();
// // 拦截的方法名称。当前正在执行的方法 // 拦截的方法名称。当前正在执行的方法
// String methodName = joinPoint.getSignature().getName(); String methodName = joinPoint.getSignature().getName();
// // 获取方法的参数 // 获取方法的参数
// Object[] args = joinPoint.getArgs(); Object[] args = joinPoint.getArgs();
// // 获取传入参数的键值对 // 获取传入参数的键值对
// Map<String, Object> map = (Map<String, Object>) //Map<String, Object> map = (Map<String, Object>)
// getFieldsName(this.getClass(), clazzName, methodName, // getFieldsName(this.getClass(), clazzName, methodName,
// args); // args);
// // 将request中的参数转化为键值对,方便取出 // 将request中的参数转化为键值对,方便取出
// // Map<String, Object> requestMap = (Map<String, Object>) map.get("request"); // Map<String, Object> requestMap = (Map<String, Object>) map.get("request");
// // 获取返回方法的参数 // 获取返回方法的参数
// JSONObject jsonObject = JSONObject.fromObject(result); JSONObject jsonObject = JSONObject.fromObject(args[1]);
// Map mapResult = (Map) jsonObject; Map mapResult = (Map) jsonObject;
// //将返回的result参数取出 //将返回的result参数取出
// Map<String, Object> res = (Map<String, Object>) mapResult.get("data"); /* Map<String, Object> res = (Map<String, Object>) mapResult.get("data");
// Integer id = (Integer) res.get("id"); Integer id = (Integer) res.get("id");*/
// JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("attributes");
// // apiLogService.updateLog(id.longValue(), data); log.info("最终通知得到结果:{}",jsonObject);
// } catch (Exception e) { // apiLogService.updateLog(reqLog.getId(), jsonResult);
// log.error("~~~~~~~~~~~~~~~~~~~~~~~最终通知异常~~~~~~~~~~~~~~~~~~~~~~~"); // apiLogService.updateLog(id.longValue(), data);
// log.error("异常信息{}", e.getMessage()); } catch (Exception e) {
// } log.error("~~~~~~~~~~~~~~~~~~~~~~~最终通知异常~~~~~~~~~~~~~~~~~~~~~~~");
log.error("异常信息{}", e.getMessage());
}
// } }
/** /**
* 获取注解中对方法的描述信息 用于service层注解 * 获取注解中对方法的描述信息 用于service层注解
......
...@@ -81,6 +81,5 @@ public class AccessLimitInterceptor implements HandlerInterceptor { ...@@ -81,6 +81,5 @@ public class AccessLimitInterceptor implements HandlerInterceptor {
@Override @Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
} }
} }
...@@ -27,7 +27,7 @@ public class ApiReqTest extends SpringTestCase { ...@@ -27,7 +27,7 @@ public class ApiReqTest extends SpringTestCase {
public void TestGatewayReq() { public void TestGatewayReq() {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("apiKey", "fM59D6210E3K436m"); jsonObject.put("apiKey", "Y18q7v2Rq332H3ox");
jsonObject.put("method", "query"); jsonObject.put("method", "query");
jsonObject.put("signType", "MD5"); jsonObject.put("signType", "MD5");
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
...@@ -35,7 +35,7 @@ public class ApiReqTest extends SpringTestCase { ...@@ -35,7 +35,7 @@ public class ApiReqTest extends SpringTestCase {
jsonObject.put("timestamp", date); jsonObject.put("timestamp", date);
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("authCode", "20210000000111181048520T38nzc5x7"); params.put("authCode", "20210000021281934021n275Hn63qaxP");
params.put("reqParams", new JSONObject()); params.put("reqParams", new JSONObject());
jsonObject.put("params",params); jsonObject.put("params",params);
try { try {
...@@ -44,10 +44,10 @@ public class ApiReqTest extends SpringTestCase { ...@@ -44,10 +44,10 @@ public class ApiReqTest extends SpringTestCase {
String signType = jsonObject.getString("signType"); String signType = jsonObject.getString("signType");
String signature = MapUtil.getSignValue(apiKey, method, signType); String signature = MapUtil.getSignValue(apiKey, method, signType);
String sign = Md5.encrypt(signature, "IE36FItU"); String sign = Md5.encrypt(signature, "RPf8HL36");
jsonObject.put("sign", sign); jsonObject.put("sign", sign);
/* String response = httpsUtils.submitPost(url, jsonObject.toString());*/ /* String response = httpsUtils.submitPost(url, jsonObject.toString());*/
System.out.println("时间戳为:"+date+"--签名为:{}"+sign); System.out.println("时间戳为:"+date+"--签名为:=="+sign);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
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