Commit b4d9a200 authored by zhangc's avatar zhangc

添加数据发送查询接口

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