Commit da3c8b94 authored by ysongq's avatar ysongq

Merge remote-tracking branch 'origin/dm_dev' into dm_dev

parents deb9ea2e 86d6f621
......@@ -4,24 +4,20 @@ CREATE TABLE `t_api_interface` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'api 信息表自增ID',
`api_key` varchar(200) NOT NULL COMMENT 'api唯一标识',
`api_name` varchar(100) DEFAULT NULL COMMENT 'api名称',
`api_desc` varchar(300) DEFAULT NULL COMMENT 'api描述',
`api_protocl` varchar(32) DEFAULT NULL COMMENT 'api请求协议:http,https',
`api_path` varchar(100) DEFAULT NULL COMMENT '请求地址',
`target_url` varchar(100) DEFAULT NULL COMMENT '目标url',
`api_type` varchar(50) NULL DEFAULT '' COMMENT 'api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 6 标签查询 9自定义',
`api_type` varchar(50) NULL DEFAULT '' COMMENT '接入类型:字典表对应key值',
`req_type` varchar(20) NULL DEFAULT NULL COMMENT '请求方式: GET, POST',
`api_function` varchar(200) DEFAULT NULL COMMENT '接口功能',
`join_type` varchar(50) NULL DEFAULT NULL COMMENT '接入类型:字典表对应key值',
`test_example` varchar(255) NULL DEFAULT NULL COMMENT '测试实例',
`status` varchar(50) NOT NULL COMMENT '状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)',
`status` varchar(50) NOT NULL COMMENT '状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)',
`output_type` varchar(50) NULL DEFAULT 'JSON' COMMENT '输出类型:flow 流形式输出, json格式输出',
`page` tinyint(2) NULL DEFAULT '0' COMMENT '是否分页:0 false ,1 true',
`version` varchar(20) DEFAULT 'v1.0' COMMENT '版本号',
`sign_type` varchar(50) DEFAULT NULL COMMENT '加密方式: MD5 RSA',
`timeout` varchar(50) DEFAULT NULL COMMENT '超时时间',
`file_id` bigint(20) NOT NULL COMMENT '文件夹id',
`req_type` varchar(20) DEFAULT NULL COMMENT '限流类型:DAY 按天,MONTH 按月, YEAR 按年',
`file_id` bigint(20) DEFAULT NULL COMMENT '文件夹id',
`limit_type` varchar(20) DEFAULT NULL COMMENT '限流类型:DAY 按天,MONTH 按月, YEAR 按年',
`req_frequency` bigint(20) DEFAULT '100' COMMENT '限制次数',
`is_test` tinyint(2) NOT NULL DEFAULT '0' COMMENT '是否测试数据:0 否,1 是',
`is_send_bank` tinyint(2) NULL DEFAULT 0 COMMENT '是否发送到数据银行: 0 false ,1 true '
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_user` varchar(100) DEFAULT NULL COMMENT '创建人',
......@@ -37,24 +33,24 @@ DROP TABLE IF EXISTS `t_api_interface_custom`;
CREATE TABLE `t_api_interface_custom` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'api 信息表自增ID',
`api_key` varchar(200) NOT NULL COMMENT 'api唯一标识',
`api_interface_id` bigint(20) NOT NULL COMMENT 'api表自增id',
`api_type` varchar(50) DEFAULT '' COMMENT 'api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 5 DMP标签查询 6.DMP大数据表查询 7 DMP自定义',
`es_data_source` varchar(100) DEFAULT NULL COMMENT '数据源id',
`es_data_base` varchar(100) DEFAULT NULL COMMENT '源数据库名称',
`es_table` varchar(100) DEFAULT NULL COMMENT '源数据表名称',
`handle_type` varchar(50) DEFAULT NULL COMMENT '处理类型',
`request_param` varchar(300) DEFAULT NULL COMMENT '请求参数',
`response_param` varchar(300) DEFAULT NULL COMMENT '响应参数',
`req_headers` varchar(300) DEFAULT NULL COMMENT '请求头',
`resp_code` varchar(300) DEFAULT NULL COMMENT '响应状态码',
`api_example` varchar(300) DEFAULT NULL COMMENT 'api返回样例',
`inbox_param` varchar(300) NULL DEFAULT NULL COMMENT '固定参数',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`page_num` int(10) NULL DEFAULT 1000000 COMMENT '最大行数',
`page_size` int(10) NULL DEFAULT 1000 COMMENT '每页返回行数',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_user` varchar(100) DEFAULT NULL COMMENT '创建人',
`update_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`update_user` varchar(100) DEFAULT NULL COMMENT '更新人',
`is_deleted` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`is_deleted` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
PRIMARY KEY (`id`),
UNIQUE KEY `API_ID_UNIQ_INDEX` (`api_interface_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='api自定义信息表';
......@@ -64,7 +60,7 @@ DROP TABLE IF EXISTS `t_api_interface_file`;
CREATE TABLE `t_api_interface_file` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'api文件表自增ID',
`project_id` bigint(20) NOT NULL COMMENT '项目编号',
`file_source` varchar(50) DEFAULT NULL COMMENT '文件来源:,1 dmp, 2 数据银行',
`file_source` varchar(50) DEFAULT NULL COMMENT '文件来源:,1 API制做,2 组织创建',
`file_name` varchar(50) DEFAULT NULL COMMENT '文件名称',
`file_en_name` varchar(50) DEFAULT NULL COMMENT '文件英文名称',
`parent_id` bigint(20) DEFAULT NULL COMMENT '父类id',
......@@ -91,6 +87,7 @@ CREATE TABLE `t_api_org` (
`org_type` varchar(20) NULL DEFAULT NULL COMMENT '组织类型:OUT 外部组织, IN 内部组织',
`status` tinyint(2) DEFAULT '1' COMMENT '状态: 0- 注销 1- 正常',
`org_mail` varchar(100) DEFAULT NULL COMMENT '组织邮箱',
`org_folder_id` bigint(20) DEFAULT NULL COMMENT '组织所在文件夹id',
`org_sort` int(10) DEFAULT '999' COMMENT '组织排序',
`parent_id` varchar(100) DEFAULT NULL COMMENT '父类组织编码',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
......@@ -118,6 +115,7 @@ CREATE TABLE `t_api_auth` (
`auth_mode` varchar(50) DEFAULT NULL COMMENT '授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效',
`valid_start_time` datetime DEFAULT NULL COMMENT '开始时间',
`valid_end_time` datetime DEFAULT NULL COMMENT '结束时间',
`valid_expr_date` datetime DEFAULT NULL COMMENT '有效截止时间',
`handler` tinyint(2) NULL DEFAULT '0' COMMENT '处理状态:0 未处理, 1 已处理',
`status` varchar(50) NOT NULL COMMENT '状态(VALID-正常 UN_VALID-无效)',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
......
......@@ -30,4 +30,10 @@ public class TagConstants {
//redis限流相关
public static final String OPEN_API_REDIS_LIMIT_KEY = "jz:openapi:redis:limit:";
//API缓存Key
public static final String OPEN_API_CACHE_KEY = "jz:openapi:cache:";
}
......@@ -37,7 +37,6 @@ public enum GatewayResultCode implements ResultCode {
ILLEGAL_TIMETEMP("ILLEGAL_TIMETEMP", "无效时间戳"),
/** 请求次数受限 */
REQUEST_LIMIT_EXCEPTION("REQUEST_LIMIT_EXCEPTION", "请求次数受限"),
......@@ -60,6 +59,12 @@ public enum GatewayResultCode implements ResultCode {
/** API状态异常 */
API_STATUS_EXCEPTION("API_STATUS_EXCEPTION", "API状态异常"),
/** API类型错误 */
API_TYPE_ERROR("API_TYPE_ERROR", "API类型错误"),
/** 文件地址不存在 */
DATA_BIG_ADDR_UNEXIST("DATA_BIG_ADDR_UNEXIST", "文件地址不存在!"),
/** 请求组织状态异常 */
ORG_STATE_EXCEPTION("ORG_STATE_EXCEPTION", "请求组织状态异常"),
/** 请求信息不存在 */
......@@ -70,6 +75,9 @@ public enum GatewayResultCode implements ResultCode {
/** 单次调用金额不足 */
CALL_AMOUNT_NOT_ENOUGH("CALL_AMOUNT_NOT_ENOUGH", "单次调用金额不足"),
/** 认证API已过有效期 */
AUTH_EXCEED_TIME("AUTH_EXCEED_TIME", "认证API已过有效期"),
/** 输出类型错误 */
OUTPUT_TYPE_EXCEPTION("OUTPUT_TYPE_EXCEPTION", "输出类型错误!");
/**
......
......@@ -30,7 +30,7 @@ public enum AuthTypeEnum {
return text;
}
public static AuthTypeEnum fromTypeName(String typeName) {
public static AuthTypeEnum fromAuthTypeName(String typeName) {
for (AuthTypeEnum type : AuthTypeEnum.values()) {
if (type.name().equals(typeName)) {
return type;
......
......@@ -43,6 +43,24 @@ public class DateUtil {
c.set(Calendar.SECOND, 59);
return (c.getTimeInMillis() - System.currentTimeMillis()) / 1000;
}
/**
* 获取指定年份的时间
* @param year
* @return
*/
public static Date getAssignYearDate(Integer year){
Calendar cal = Calendar.getInstance();
/* int year =cal.get(Calendar.YEAR)+1;
int month=cal.get(Calendar.MONTH)+1;
cal.add(Calendar.MONTH, 0);*/
//Date date = cal.getTime(); //结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
cal.set(Calendar.YEAR,cal.get(Calendar.YEAR)+year);
Date date=cal.getTime();
System.out.println(sdf.format(date));
return date;
}
public static void main(String[] args) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//System.out.println(calculateNowResidueTime());
......
......@@ -125,6 +125,11 @@ public class RandomUtil {
builder.append(userNum);
}
coding = getCodeInfo(userId, coding, builder, month, day, hour, minute, second);
}else { //无内外部之分
if (StringUtils.isBlank(orgCode)) {
return "";
}
coding = getCodeInfo(orgCode, coding, builder, month, day, hour, minute, second);
}
return coding;
}
......
package com.jz.dm.common.util.stream;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.*;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import java.io.File;
......@@ -14,6 +19,7 @@ import java.text.MessageFormat;
import static com.jz.common.utils.HttpClientPool.getHttpClient;
/**
* @author ZC
* @PACKAGE_NAME: com.sentinel.project.util
......@@ -48,8 +54,90 @@ public class HttpDownload {
* @param url
* @return
*/
public static void download(String url) {
download(url, null);
public static void getDownload(String url) {
download(url, null);
}
/**
* 根据url下载文件,文件名从response header头中获取
*
* @param url
* @param params
*/
public static void postDownload(String url, JSONObject params) {
postDownloadFolder(url, params,null);
}
/**
* 根据url下载文件,保存到filepath中
*
* @param url
* @param params
* @param filepath
*/
private static void postDownloadFolder(String url, JSONObject params,String filepath) {
CloseableHttpClient httpClient = getHttpClient();
InputStream is = null;
FileOutputStream fileOut = null;
CloseableHttpResponse response = null;
try {
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Content-Type","application/json" );
if (StringUtils.isNotBlank(params.toString())) {
httpPost.setEntity(new StringEntity(params.toString(), Consts.UTF_8));
}
response = httpClient.execute(httpPost);
Header[] allHeaders = response.getAllHeaders();
for (Header header : allHeaders) {
System.out.println(MessageFormat.format("header:{0}={1}", header.getName(), header.getValue()));
}
String fileName = response.getHeaders("Content-Disposition")[0].getValue().split("filename=")[1];
System.out.println("文件名为" + fileName);
HttpEntity entity = response.getEntity();
is = entity.getContent();
if (fileName == null) {
fileName = getFilePath(response);
}
if (filepath != null) {
fileName = filepath + splash + fileName;
} else {
fileName = splash + fileName;
}
File file = new File(fileName);
file.getParentFile().mkdirs();
fileOut = new FileOutputStream(file);
/**
* 根据实际运行效果 设置缓冲区大小
*/
byte[] buffer = new byte[cache];
int ch = 0;
while ((ch = is.read(buffer)) != -1) {
fileOut.write(buffer, 0, ch);
}
fileOut.flush();
log.info("文件下载成功!");
} catch (Exception e) {
log.info("数据下载异常:{}", e.getMessage());
e.printStackTrace();
}finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != fileOut) {
try {
fileOut.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
/**
......@@ -81,8 +169,8 @@ public class HttpDownload {
}
if (filepath != null) {
fileName = filepath + splash + fileName;
}else {
fileName= splash + fileName;
} else {
fileName = splash + fileName;
}
File file = new File(fileName);
file.getParentFile().mkdirs();
......@@ -185,8 +273,22 @@ public class HttpDownload {
String docx = "http://192.168.1.140:8090/api/download/docx";
String pdf = "http://192.168.1.140:8090/api/download/pdf";
String xlsx = "http://192.168.1.140:8090/api/download/xlsx";
String getDownload ="http://192.168.1.140:8082/api/data/query/streaming?datasourceId=2&query_database=product&query_table=table1&request_fileds=%7b%22flelds1%22:%20%22xxxx%22,%20%22field2%22:%22xxxx%22%7d&response_fields=field1,field2,field3,field4&data_size=100";
String postDownload="http://192.168.1.140:8082/api/data/query/streaming1";
//String filepath = "C:\\Users\\key\\Desktop\\ideaIU-2019.3.3";
//HttpDownload.download(xlsx, null);
//getDownload(getDownload);
JSONObject jsonObject = new JSONObject();
jsonObject.put("datasourceId",1);
jsonObject.put("query_database","product");
jsonObject.put("query_table","table1");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("flelds1","xxxxx");
jsonObject1.put("field2","xxxxx");
jsonObject.put("request_fileds",jsonObject1);
jsonObject.put("response_fields","field1,field2,field3,field4");
jsonObject.put("data_size",100);
String filepath = "C:\\Users\\key\\Desktop\\ideaIU-2019.3.3";
HttpDownload.download(xlsx, filepath);
postDownloadFolder(postDownload,jsonObject,null);
}
}
......@@ -31,18 +31,26 @@ public class ApiInterfaceController {
/**
* @Description:API列表查询
* @return: API列表
* @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列表查询
* @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详情查询
* @return: API详情查询
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
......@@ -53,7 +61,6 @@ public class ApiInterfaceController {
}
/**
* @Description:API删除
* @return: API删除
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
......@@ -64,7 +71,6 @@ public class ApiInterfaceController {
}
/**
* @Description:DMP-API删除
* @return: DMP-API删除
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
......@@ -74,16 +80,27 @@ public class ApiInterfaceController {
@RequestParam (name="apiKey")String apiKey) {
return Mono.fromSupplier(() -> apiInterfaceService.dmpDeleteAuth(type,apiKey));
}
/**
* @Description:数据修改发送状态接口
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation("数据修改发送状态接口")
@GetMapping(value = "/updateSendStatus")
public Mono<Result> updateApiSendStatus(@RequestParam (name="apiKey")String apiKey) {
return Mono.fromSupplier(() -> apiInterfaceService.updateApiSendStatus(apiKey));
}
/**
* @Description:API测试调用
* @return: DMP-API删除
* @Description: 已发送到数据银行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));
@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));
}
}
......@@ -29,6 +29,16 @@ public class AuthController {
@Autowired
private AuthService authService;
/**
* @Description:服务授权列表
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("服务授权列表")
@PostMapping(value = "/getServiceAuthList")
public Mono<Result> getServiceAuthList(@RequestBody @Valid ServiceAuthReq req) {
return Mono.fromSupplier(() -> authService.getServiceAuthList(req));
}
/**
* @Description:商城用户API认证
* @return: 商城用户API认证
......
......@@ -12,6 +12,7 @@ import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -32,7 +33,8 @@ public class GatewayController {
@Autowired
private GatewayService gatewayService;
@RequestMapping(value = "/gateway", consumes = "application/json")
//@RequestMapping(value = "/gateway", consumes = "application/json")
@PostMapping(value="/gateway",consumes = "application/json")
public String gateway(@RequestBody String json, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
GatewayRequest gatewayRequest = JSON.parseObject(json, GatewayRequest.class);
......
......@@ -62,16 +62,6 @@ public class OrganizationManageController {
public Mono<Result> add(@RequestBody @Valid OrganizationManageAddReq req) {
return Mono.fromSupplier(() -> organizationManageService.add(req));
}
/**
* @Description:更新组织信息
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
/* @ApiOperation("更新组织信息")
@PostMapping(value = "/update")
public Mono<Result> update(@RequestBody @Valid OrganizationManageUpdateReq req) {
return Mono.fromSupplier(() -> organizationManageService.update(req));
}*/
/**
* @Description:注销组织
* @Author: Mr.zhang
......
package com.jz.dm.controller;
import com.jz.common.utils.Result;
import com.jz.dm.models.req.make.*;
import com.jz.dm.models.req.folder.CreateFolderReq;
import com.jz.dm.models.req.producer.ApiInterfaceReq;
import com.jz.dm.models.req.producer.ServiceIssueReq;
import com.jz.dm.service.ProducerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -46,115 +48,147 @@ public class ProducerController {
*/
@ApiOperation("创建项目文件夹")
@PostMapping(value = "/createProjectFolder")
public Mono<Result> createProjectFolder(@RequestParam(name = "projectId")Long projectId,
@RequestParam(name = "parentId")Long parentId,
@RequestParam(name = "currentUser") String currentUser ) {
return Mono.fromSupplier(() -> producerService.createProjectFolder(projectId,parentId,currentUser));
public Mono<Result> createProjectFolder(@RequestBody @Valid CreateFolderReq req) {
return Mono.fromSupplier(() -> producerService.createProjectFolder(req));
}
/**
* @Description:Api制作(自定义DMP)
* @Description:服务发布列表
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("Api制作(自定义DMP)")
@PostMapping(value = "/addCustomApi")
public Mono<Result> makeCustomApi(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> Result.of_success(producerService.addCustomApi(req)));
@ApiOperation("服务发布列表")
@PostMapping(value = "/getServiceIssueList")
public Mono<Result> getServiceIssueList(@RequestBody @Valid ServiceIssueReq req) {
return Mono.fromSupplier(() -> producerService.getServiceIssueList(req));
}
/**
* @Description:Api制作(数据银行)
* @Description:服务发布/服务取消
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("Api制作(数据银行)")
@PostMapping(value = "/addDataBankApiInfo")
public Mono<Result> addDataBankApiInfo(@RequestBody @Valid MakeDataBankApiReq req) {
return Mono.fromSupplier(() -> producerService.addDataBankApiInfo(req));
@ApiOperation("服务发布/服务取消")
@GetMapping(value = "/optionApiIssueStatus")
public Mono<Result> optionApiIssueStatus(@RequestParam(name = "id")Long id,
@RequestParam(name="optStatus")Boolean optStatus) {
return Mono.fromSupplier(() -> producerService.optionApiIssueStatus(id,optStatus));
}
/**
* @Description:Api制作(实时接入)
* @Description:获取APIID
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("Api制作(实时接入)")
@PostMapping(value = "/realMakeApi")
public Mono<Result> realCustomApi(@RequestBody @Valid MakeRealCustomApiReq req) {
return Mono.fromSupplier(() -> Result.of_success(producerService.addRealCustomApi(req)));
@ApiOperation("Api制作(获取ApiId)")
@PostMapping(value = "/getCustomApiId")
public Mono<Result> getCustomApiId() {
return Mono.fromSupplier(() ->producerService.getCustomApiId());
}
/**
* @Description:Api制作(大数据查询/标签查询)
* @return:
* @Description:Api制作(第三方)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("Api制作(大数据查询/标签查询)")
@PostMapping(value = "/makeBigDataApi")
public Mono<Result> bigDataMakeApi(@RequestBody @Valid MakeBigDataApiReq req) {
return Mono.fromSupplier(() -> producerService.addBigDataMakeApi(req));
@ApiOperation("Api制作(第三方)")
@PostMapping(value = "/addCustomApi")
public Mono<Result> makeCustomApi(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> Result.of_success(producerService.saveInterfaceAPi(req)));
}
/**
* @Description:保存API基本信息/自定义API
* @return: (保存API基本信息)
* @Description:Api制作(数据查询/标签查询)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("保存API基本信息")
@PostMapping(value = "/saveInterface")
public Mono<Result> saveInsetInterface(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> producerService.saveInterfaceAPi(req));
@ApiOperation("Api制作(数据查询/标签查询)")
@PostMapping(value = "/addDataTableSelect")
public Mono<Result> bigDataMakeApi(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> producerService.addBigDataMakeApi(req));
}
/**
* @Description:Api制作(大数据查询/标签查询)保存修改的api信息
* @return: (自定义更新同时使用)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("保存修改的api信息")
/* @ApiOperation("保存修改的api信息")
@PostMapping(value = "/saveUpdate")
public Mono<Result> saveUpdateAPiInfo(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> producerService.saveUpdateAPiInfo(req));
}*/
/* *//**
* @Description:Api制作(数据银行)
* @Author: Mr.zhang
* @Date: 2020-12-26
*//*
@ApiOperation("Api制作(数据银行)")
@PostMapping(value = "/addDataBankApiInfo")
public Mono<Result> addDataBankApiInfo(@RequestBody @Valid MakeDataBankApiReq req) {
return Mono.fromSupplier(() -> producerService.addDataBankApiInfo(req));
}
*//**
* @Description:Api制作(实时接入)
* @Author: Mr.zhang
* @Date: 2020-12-26
*//*
@ApiOperation("Api制作(实时接入)")
@PostMapping(value = "/realMakeApi")
public Mono<Result> realCustomApi(@RequestBody @Valid MakeRealCustomApiReq req) {
return Mono.fromSupplier(() -> Result.of_success(producerService.addRealCustomApi(req)));
}*/
/**
* @Description:保存API基本信息/自定义API
* @return: (保存API基本信息)
* @Author: Mr.zhang
* @Date: 2020-12-26
*//*
@ApiOperation("保存API基本信息")
@PostMapping(value = "/saveInterface")
public Mono<Result> saveInsetInterface(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> producerService.saveInterfaceAPi(req));
}*/
/*
*//**
* @Description:获取数据源配置
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
*//*
@ApiOperation("获取数据源配置")
@PostMapping(value = "/getSourceConfig")
public Mono<Result> getSourceConfig(@RequestBody @Valid SourceConfigReq req) {
return Mono.fromSupplier(() -> producerService.getSourceConfig(req));
}
/**
*//**
* @Description:获取索引
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
*//*
@ApiOperation("获取索引")
@GetMapping(value = "/getIndicess")
public Mono<Result> getSourceWarehouseList(@RequestParam(name = "id") Long id) {
return Mono.fromSupplier(() -> producerService.getSourceWarehouseList(id));
}
/**
*//**
* @Description:获取某个索引下的type
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
*//*
@ApiOperation("获取某个索引下的type")
@GetMapping(value = "/getIndicesTypes")
public Mono<Result> getIndicesTypes(@RequestParam(name = "indices") String indices,
@RequestParam(name = "id") Long id) {
return Mono.fromSupplier(() -> producerService.getIndicesTypes(indices,id));
}
/**
*//**
* @Description:获取某个索引 type的fields
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
*//*
@ApiOperation("获取某个索引 type的fields")
@GetMapping(value = "/getIndicesTypesFields")
public Mono<Result> getIndicesTypesFields(@RequestParam(name = "indices") String indices,
......@@ -174,5 +208,5 @@ public class ProducerController {
@GetMapping(value = "/getRedisObj")
public Result getObjOnRedis() {
return producerService.getObjOnRedis();
}
}*/
}
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.jz.common.utils.HttpsUtils;
import com.jz.common.utils.RedisUtils;
import com.jz.dm.common.constant.Constants;
import com.jz.dm.common.constant.TagConstants;
import com.jz.dm.common.enums.GatewayResultCode;
import com.jz.dm.common.enums.apiInterface.ApiStatusEnum;
import com.jz.dm.common.enums.auth.AuthReqTypeEnum;
......@@ -89,7 +90,11 @@ public class AuthFilter extends AbstractFilter {
}
}
JSONObject parameter = JSONObject.parseObject(request.getParams());
if (null != parameter) {
if (null == parameter) {
throw new GatewayException(GatewayResultCode.REQUEST_PARAM_EMPTY);
}
Boolean isTest = parameter.getBoolean("isTest");
if (!isTest) {//是否测试数据
String authCode = parameter.getString("authCode");
ApiAuth authAuth = authService.getAuthUser(authCode, apiInterface.getId());
if (null == authAuth) {
......@@ -107,7 +112,7 @@ public class AuthFilter extends AbstractFilter {
if (!apiOrg.getStatus()) {
throw new GatewayException(GatewayResultCode.ORG_STATE_EXCEPTION);
}
checkBill(request, authCode, authAuth, apiOrg);
checkBill(request, authCode, authAuth);
}
chain.doFilter(request, response);
} catch (Exception e) {
......@@ -121,7 +126,6 @@ public class AuthFilter extends AbstractFilter {
response.clearAttributes();
response.setCode(GatewayResultCode.UNKNOWN_EXCEPTION.getCode());
response.setMsg(GatewayResultCode.UNKNOWN_EXCEPTION.getMsg());
}
}
......@@ -132,19 +136,24 @@ public class AuthFilter extends AbstractFilter {
* @param request
* @param authCode
* @param authAuth
* @param apiOrg
* @throws ParseException
*/
private void checkBill(GatewayRequest request, String authCode,
ApiAuth authAuth, ApiOrg apiOrg) throws ParseException {
ApiAuth authAuth) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat(Constants.DATE_TIME_FORMAT);
String formatDate = dateFormat.format(new Date());
Date currentDate = dateFormat.parse(formatDate);
switch (authAuth.getAuthMode()) {
case "POWER_CALL_MODE": //按次调用
//查询数据银行银行余额是否充足
getDataAmountResult(request);
Date validExprDate = authAuth.getValidExprDate();
if (currentDate.after(validExprDate)) {//超出时间
throw new GatewayException(GatewayResultCode.AUTH_EXCEED_TIME);
}
try { //记录请求次数(每天限制请求次数)
// String limitKey = TagConstants.OPEN_API_REDIS_LIMIT_KEY + authCode;
String limitKey = authCode;
String reqValue = (String)redisUtils.getObj(limitKey);
//查询数据银行银行余额是否充足
getDataAmountResult(request);
String limitKey = TagConstants.OPEN_API_REDIS_LIMIT_KEY + authCode;
Integer reqValue = (Integer) redisUtils.getObj(limitKey);
long timeOut = 0;
if (AuthReqTypeEnum.DAY.name().equals(authAuth.getReqType())) { //按天
timeOut = DateUtil.calculateNowResidueTime();
......@@ -154,11 +163,11 @@ public class AuthFilter extends AbstractFilter {
//暂时不支持年
}
if (null != reqValue) {
Integer value = Integer.valueOf(reqValue);
if (value > authAuth.getReqFrequency()) {//超出最大请求次数
/* Integer value = Integer.valueOf(reqValue);*/
if (reqValue > authAuth.getReqFrequency()) {//超出最大请求次数
throw new GatewayException(GatewayResultCode.REQUEST_LIMIT_EXCEPTION);
} else if (value <= authAuth.getReqFrequency()) {
redisUtils.delAndAdd(limitKey, limitKey, value + 1, timeOut);
} else if (reqValue <= authAuth.getReqFrequency()) {
redisUtils.delAndAdd(limitKey, limitKey, reqValue + 1, timeOut);
}
} else {
redisUtils.set(limitKey, 1, timeOut);
......@@ -170,9 +179,6 @@ public class AuthFilter extends AbstractFilter {
}
break;
case "RECORD_TIME_MODE": //按时间调用
SimpleDateFormat dateFormat = new SimpleDateFormat(Constants.DATE_TIME_FORMAT);
String formatDate = dateFormat.format(new Date());
Date currentDate = dateFormat.parse(formatDate);
Date validEndTime = authAuth.getValidEndTime();
//如果 date1 在 date2 之前,before 返回 true,否则返回 false
if (currentDate.after(validEndTime)) {//超出时间
......@@ -181,6 +187,10 @@ public class AuthFilter extends AbstractFilter {
}
break;
case "PERMANENT_TIME_MODE"://永久有效(直接跳出)
Date validExpr = authAuth.getValidExprDate();
if (currentDate.after(validExpr)) {//超出时间
throw new GatewayException(GatewayResultCode.AUTH_EXCEED_TIME);
}
break;
default:
throw new GatewayException(GatewayResultCode.ILLEGAL_REQUEST);
......@@ -217,7 +227,7 @@ public class AuthFilter extends AbstractFilter {
pObject.put("assetsId", assetsId);
pObject.put("userId", userId);
pObject.put("dataPrice", dataPrice);
String respResult = httpUtils.submitPost(balanceUrl+"/mall/financeCustomerAssets/findAssets", pObject.toString());
String respResult = httpUtils.submitPost(balanceUrl + "/mall/financeCustomerAssets/findAssets", pObject.toString());
JSONObject result = JSONObject.parseObject(respResult);
if (null != result) {
if (200 != result.getInteger("code")) {
......
package com.jz.dm.filter;
import com.jz.dm.common.enums.GatewayResultCode;
import com.jz.dm.common.exception.OpenApiException;
import com.jz.dm.common.util.LogUtil;
import com.jz.dm.common.util.ResultCode;
import com.jz.dm.models.enity.GatewayRequest;
import com.jz.dm.models.enity.GatewayResponse;
import com.jz.dm.common.enums.GatewayResultCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -19,13 +19,14 @@ import java.util.List;
*/
public class FilterChainImpl implements FilterChain {
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
private int pos = 0;
private int pos = 0;
private final List<Filter> filters = new ArrayList<Filter>();
public FilterChainImpl() { }
public FilterChainImpl() {
}
public FilterChainImpl(List<Filter> filters) {
addFilters(filters);
......@@ -42,7 +43,7 @@ public class FilterChainImpl implements FilterChain {
} catch (OpenApiException ex) {
ResultCode resultCode = ex.getResultCode();
LogUtil.error(LOGGER, ex, "doFilter occur exception,code=" + resultCode.getCode()
+ ",msg=" + resultCode.getMsg() + ",request=" + request);
+ ",msg=" + resultCode.getMsg() + ",request=" + request);
response.setCode(ex.getResultCode().getCode());
response.setMsg(ex.getResultCode().getMsg());
} catch (Throwable ex) {
......
......@@ -19,15 +19,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @Description: 验签过滤器(验证签名信息)
* @Author: Mr.zhang
* @Date: 2021-1-6
*/
* @Description: 验签过滤器(验证签名信息)
* @Author: Mr.zhang
* @Date: 2021-1-6
*/
@Component
public class VerifySignFilter extends AbstractFilter {
private static final Logger LOGGER = LoggerFactory.getLogger(VerifySignFilter.class);
@Autowired
private ApiInterfaceService apiInterfaceService;
@Override
public int getOrder() {
return Constants.FILTER_ORDER_3;
......@@ -37,26 +38,29 @@ public class VerifySignFilter extends AbstractFilter {
public String getFilterName() {
return "VerifySignFilter";
}
@Override
protected void internalDoFilter(GatewayRequest request, GatewayResponse response,
FilterChain chain) {
try {
//对签约参数进行字典排序
String signParams = MapUtil.getSignValue(request.getApiKey(),request.getMethod(),request.getSignType());
if (StringUtils.isNotBlank(signParams)){
JSONObject jsonObject = JSONObject.parseObject(request.getParams());
String authCode = jsonObject.getString("authCode");
//需要传入授权码
ApiAuth apiAuthInfo = apiInterfaceService.getApiAuthInfo(request.getApiKey(),authCode );
if (null == apiAuthInfo){
throw new GatewayException(GatewayResultCode.ILLEGAL_REQUEST);
}
String sign = Md5.encrypt(signParams, apiAuthInfo.getSalt());
if (!request.getSign().equals(sign)){
JSONObject jsonObject = JSONObject.parseObject(request.getParams());
if (!jsonObject.getBoolean("isTest")) {//是否测试调用
//对签约参数进行字典排序
String signParams = MapUtil.getSignValue(request.getApiKey(), request.getMethod(), request.getSignType());
if (StringUtils.isNotBlank(signParams)) {
String authCode = jsonObject.getString("authCode");
//需要传入授权码
ApiAuth apiAuthInfo = apiInterfaceService.getApiAuthInfo(request.getApiKey(), authCode);
if (null == apiAuthInfo) {
throw new GatewayException(GatewayResultCode.ILLEGAL_REQUEST);
}
String sign = Md5.encrypt(signParams, apiAuthInfo.getSalt());
if (!request.getSign().equals(sign)) {
throw new GatewayException(GatewayResultCode.SIGN_ERROR);
}
} else {
throw new GatewayException(GatewayResultCode.SIGN_ERROR);
}
}else {
throw new GatewayException(GatewayResultCode.SIGN_ERROR);
}
chain.doFilter(request, response);
} catch (SignatureException ex) {
......@@ -66,8 +70,8 @@ public class VerifySignFilter extends AbstractFilter {
response.setCode(ex.getResultCode().getCode());
response.setMsg(ex.getResultCode().getMsg());
} catch (Throwable ex) {
if(ex instanceof GatewayException){
throw(GatewayException) ex;
if (ex instanceof GatewayException) {
throw (GatewayException) ex;
}
LogUtil.error(LOGGER, ex,
"signatureFilter doFilter error. response=" + response.getResponse());
......
package com.jz.dm.gateway;
import com.alibaba.fastjson.JSON;
import com.jz.dm.common.exception.GatewayException;
import com.jz.dm.common.exception.OpenApiException;
import com.jz.dm.common.util.OpenApiRequest;
import com.jz.dm.common.util.OpenApiResponse;
......@@ -65,18 +66,17 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
response.setMsg(OpenApiResultCode.ILLEGAL_INTERFACE.getMsg());
return JSON.toJSONString(response.getAttributes());
}
try {
OpenApiRequest request = new OpenApiRequest(context.getOpenApiParams());
request.setApiKey(context.getApiKey());
request.setExtAttributes(context.getExtAttributes());
openApiService.doService(request, response);
} catch (Throwable ex) {
}catch (Throwable ex) {
if (ex instanceof OpenApiException) {
OpenApiException oae = (OpenApiException) ex;
response.setCode(oae.getResultCode().getCode());
response.setMsg(oae.getResultCode().getMsg());
} else {
throw(OpenApiException) ex;
} else if (ex instanceof GatewayException){
throw(GatewayException) ex;
}else{
LOGGER.error("OpenApiService doService error,DispatchContext=" + context, ex);
response.setCode(OpenApiResultCode.UNKNOWN_EXCEPTION.getCode());
response.setMsg(OpenApiResultCode.UNKNOWN_EXCEPTION.getMsg());
......@@ -84,8 +84,8 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
return JSON.toJSONString(response.getAttributes());
}
if (StringUtil.isEmpty(response.getCode())) {
response.setCode(OpenApiResultCode.SUCCESS.getCode());
response.setMsg(OpenApiResultCode.SUCCESS.getMsg());
response.setCode(OpenApiResultCode.UNKNOWN_EXCEPTION.getCode());
response.setMsg(OpenApiResultCode.UNKNOWN_EXCEPTION.getMsg());
}
return JSON.toJSONString(response.getAttributes());
}
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.models.domian.ApiInterfaceCustom;
import com.jz.dm.models.dto.ApiServiceApplyDto;
import com.jz.dm.models.req.api.ApiInterfaceDetailReq;
import org.apache.ibatis.annotations.Param;
......@@ -21,13 +22,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 +51,21 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
* @return
*/
ApiInterfaceCustom getTestData(String apiKey);
/**
* 查询服务发布列表
* @param page
* @param query
* @return
*/
IPage<ApiServiceApplyDto > listApiIssueService(IPage<ApiServiceApplyDto> page, @Param("ew") Wrapper<ApiServiceApplyDto> query);
/**
* 查询服务授权列表
* @param page
* @param query
* @return
*/
IPage<ApiServiceApplyDto > listApiAuthService(IPage<ApiServiceApplyDto> page, @Param("ew") Wrapper<ApiServiceApplyDto> query);
}
......@@ -97,6 +97,15 @@ public class ApiAuth extends BaseObject implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date validEndTime;
/**
* 有效截止时间
*/
@ApiModelProperty("有效截止时间")
@TableField("valid_expr_date")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date validExprDate;
/**
* 处理状态:0 未处理, 1 已处理
......
......@@ -38,12 +38,6 @@ public class ApiInterface extends BaseObject implements Serializable {
@JsonIgnore
private String apiName;
/**
* api描述
*/
@TableField("api_desc")
private String apiDesc;
/**
* api请求协议:http,https
*/
......@@ -51,41 +45,29 @@ public class ApiInterface extends BaseObject implements Serializable {
private String apiProtocl;
/**
* api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 5 DMP标签查询 6.DMP大数据表查询 7 DMP自定义'
* 接入类型:对应字典表key
*/
@TableField("api_type")
private String apiType;
/**
* 请求地址
*/
@TableField("api_path")
private String apiPath;
/**
* 目标url
*/
@TableField("target_url")
private String targetUrl;
/**
* 接入类型:对应字典表key
*/
@TableField("join_type")
private String joinType;
/**
* 测试实例
* 请求方式:GET POST
*/
@TableField("test_example")
private String testExample;
@TableField("req_type")
private String reqType;
/**
* '输出类型:flow 流形式输出, json格式输出',
*/
@TableField("output_type")
private String outputType;
/**
* 是否分页:0 false ,1 true
*/
@TableField("page")
private Boolean page;
/**
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
......@@ -113,8 +95,8 @@ public class ApiInterface extends BaseObject implements Serializable {
/**
* 限流类型:DAY 按天,MONTH 按月, YEAR 按年
*/
@TableField("req_type")
private String reqType;
@TableField("limit_type")
private String limitType;
/**
* 限制次数
......@@ -127,17 +109,19 @@ public class ApiInterface extends BaseObject implements Serializable {
@TableField("timeout")
private String timeout;
/**
* 是否测试数据:0 否,1 是
*/
@TableField("is_test")
private Integer isTest;
/**
* 文件夹id
*/
@TableField("file_id")
private Long fileId;
/**
* 是否发送到数据银行
*/
@TableField("is_send_bank")
private Boolean isSendBank;
/*-----------------------------------保存数据库时忽略字段--------------------------------*/
/**
* 请求总次数
......
......@@ -93,5 +93,19 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
*/
@TableField("inbox_param")
private String inboxParam;
/**
* 最大行数
*/
@TableField("max_row")
private Long maxRow;
/**
* 每页返回行数
*/
@TableField("page_row")
private Long pageRow;
}
......@@ -31,17 +31,11 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
private Long projectId;
/**
* 文件来源:1 DMP 2 数据银行
* 文件来源:,1 API制做,2 组织创建
*/
@TableField("file_source")
private String fileSource;
///**
//* 文件类型:1 文件夹 ,2 文件
//*/
//@TableField("file_type")
//private String fileType;
/**
* 文件名称
*/
......
......@@ -55,6 +55,13 @@ public class ApiOrg extends BaseObject implements Serializable {
*/
@TableField("linkman")
private String linkman;
/**
* 组织目录文件夹
*/
@TableField("org_folder_id")
private Long orgFolderId;
/**
* 组织类型 OUT 外部组织 IN 内部组织
*/
......
package com.jz.dm.models.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.dto
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiServiceApplyDto
* @DATE: 2021-1-28/11:10
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel(value = "服务发布/授权应用类")
public class ApiServiceApplyDto implements Serializable {
@ApiModelProperty(value = "apiId")
private String apiId;
@ApiModelProperty(value = "api名称")
private String apiName;
@ApiModelProperty(value = "api类型")
private String apiType;
@ApiModelProperty(value = "返回类型")
private String outputType;
@ApiModelProperty(value = "请求方式")
private String reqType;
@ApiModelProperty(value = "最大数据量")
private Long maxRow;
@ApiModelProperty(value = "每页行数")
private Long pageRow;
@ApiModelProperty(value = "描述")
private String apiFunction;
@ApiModelProperty(value = "是否发布到数据银行,0 false 1 true")
private Boolean isSendBank;
@ApiModelProperty(value = "授权码")
private String authCode;
}
......@@ -49,6 +49,10 @@ public class GatewayRequest implements Serializable {
@ApiModelProperty(value="请求参数,JSON格式")
private String params;
@ApiModelProperty(value="是否测试请求")
private Boolean isTest;
@ApiModelProperty(value="扩展属性")
private final Map<String, Attribute> extAttributes = new HashMap<String, Attribute>();
......
......@@ -38,9 +38,9 @@ public class AuthUserApiReq implements Serializable {
@NotNull(message = "组织编码不能为空")
private String orgCode;
/* @ApiModelProperty(value = "授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权",required = true)
@ApiModelProperty(value = "授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权",required = true)
@NotNull(message = "授权类型不能为空")
private String authType;*/
private String authType;
@ApiModelProperty(value = "授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效",required = true)
@NotNull(message = "授权方式不能为空")
......
package com.jz.dm.models.req.auth;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req.auth
* @PROJECT_NAME: jz-dm-parent
* @NAME: ServiceAuthReq
* @DATE: 2021-1-28/11:50
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel(value = "服务授权请求体")
public class ServiceAuthReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "文件夹id",required = false)
private Long folderId;
@ApiModelProperty(value = "api名称",required = false)
private String apiName;
@ApiModelProperty(value = "apiId",required = false)
private String apiId;
}
package com.jz.dm.models.req.folder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: CreateFolderReq
* @DATE: 2021-1-27/18:12
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Data
@ApiModel("创建文件请求体")
public class CreateFolderReq implements Serializable {
@ApiModelProperty(value = "项目id",required = false)
private Long projectId;
@ApiModelProperty(value = "父类文件夹id ,创建同级不传",required = false)
private Long parentId;
@ApiModelProperty(value = "文件夹名称",required = true)
@NotBlank(message = "文件夹名称不能为空!")
private String fileName;
@ApiModelProperty(value = "文件来源:,1 API制做,2 组织创建",required = true)
@NotBlank(message = "文件来源不能为空")
private String fileSource;
@ApiModelProperty(value = "创建用户",required = false)
private String createUser;
}
package com.jz.dm.models.req.make;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeBigDataApiReq
* @DATE: 2020-12-26/13:08
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel("Api制作大数据查询/标签查询请求体")
public class MakeBigDataApiReq implements Serializable {
@ApiModelProperty(value = "id--更新时id不能为空",required = false)
private Long id;
/* @ApiModelProperty(value = "数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义",required = true)
@NotNull(message = "apiType不能为空")
private String apiType;*/
@ApiModelProperty(value = "apiKey",required = false)
@NotNull(message = "apiKey不能为空")
public String apiKey;
//@ApiModelProperty(value = "是否分页",required = false)
//public Boolean page;
@ApiModelProperty(value = "数据源Id",required = true)
@NotNull(message = "数据源Id不能为空")
private String esDataSource;
@ApiModelProperty(value = "源库名称",required = true)
@NotNull(message = "源库名称不能为空")
private String esDataBase;
@ApiModelProperty(value = "源表名称",required = true)
@NotNull(message = "源表名称不能为空")
private String esTable;
@ApiModelProperty(value = "处理类型",required = true)
@NotNull(message = "处理类型不能为空")
private String handleType;
@ApiModelProperty(value = "请求参数",required = true)
@NotNull(message = "请求参数不能为空")
private String requestParam;
@ApiModelProperty(value = "返回参数",required = true)
@NotNull(message = "返回参数不能为空")
private String responseParam;
@ApiModelProperty(value = "段列表",required = true)
@NotNull(message = "字段列表不能为空")
private String tableFields;
@ApiModelProperty(value = "创建用户",required = false)
public String createUser;
//@ApiModelProperty(value = "项目id",required = true)
//@NotNull(message="项目id不能为空")
//public Long projectId;
//@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
//public Long parentId;
//
//@ApiModelProperty(value = "文件id",required = false)
//public Long fileId;
}
......@@ -20,14 +20,10 @@ import java.io.Serializable;
@ApiModel("组织管理详情请求体")
public class OrganizationManageAddReq implements Serializable {
@ApiModelProperty(value = "组织类型:INT 内部组织 OUT 外部组织",required = true)
/*@ApiModelProperty(value = "组织类型:INT 内部组织 OUT 外部组织",required = true)
@NotNull(message = "组织类型不能为空!")
private String orgType;
@ApiModelProperty(value = "组织名称",required = true)
@NotNull(message = "组织名称不能为空")
private String orgName;
@ApiModelProperty(value = "组织描述",required = false)
private String orgDesc;
......@@ -35,21 +31,31 @@ public class OrganizationManageAddReq implements Serializable {
private String orgCnName;
@ApiModelProperty(value = "组织邮箱",required = false)
private String orgMail;
private String orgMail;*/
@ApiModelProperty(value = "组织名称",required = true)
@NotNull(message = "组织名称不能为空")
private String orgName;
@ApiModelProperty(value = "组织电话",required = false)
@ApiModelProperty(value = "组织电话",required = true)
@NotNull(message="组织电话不能为空")
private String orgPhone;
@ApiModelProperty(value = "组织联系人",required = false)
@ApiModelProperty(value = "组织联系人",required = true)
@NotNull(message="组织联系人不能为空")
private String linkman;
@ApiModelProperty(value = "文件夹Id",required = true)
@NotNull(message="文件夹Id不能为空")
private Long orgFolderId;
@ApiModelProperty(value = "备注",required = false)
private String remark;
@ApiModelProperty(value = "创建用户",required = false)
private String createUser;
@ApiModelProperty(value = "创建用户",required = false)
@ApiModelProperty(value = "更新用户",required = false)
private String updateUser;
@ApiModelProperty(value = "id ----更新时必传",required = false)
......
......@@ -29,4 +29,9 @@ public class OrganizationManageListQueryReq extends BasePageBean implements Seri
@ApiModelProperty(value = "组织联系人")
private String linkman;
@ApiModelProperty(value = "组织文件夹")
private Long fileId;
}
package com.jz.dm.models.req.make;
package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -20,33 +20,39 @@ import java.io.Serializable;
@ApiModel(value = "api基本信息")
public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "接口描述",required = false)
public String apiDesc;
@ApiModelProperty(value = "传输方式:http https",required = true)
@NotNull(message = "传输方式不能为空")
public String transMode;
public String apiProtocl;
@ApiModelProperty(value = "加密方式0 无,1:MD5 2:RSA",required = true)
@NotNull(message = "加密方式不能为空")
public String signType;
@ApiModelProperty(value = "接入类型:对应字典表key",required = true)
@NotNull(message = "接入类型不能为空")
public String joinType;
@ApiModelProperty(value = "Api类型:对应字典表key",required = true)
@NotNull(message = "Api类型不能为空")
public String apiType;
@ApiModelProperty(value = "目标地址",required = true)
@NotNull(message="目标地址不能为空")
@ApiModelProperty(value = "apiKey",required = true)
@NotNull(message = "apiKey不能为空")
public String apiKey;
@ApiModelProperty(value = "目标地址",required = false)
public String targetUrl;
@ApiModelProperty(value = "请求方式:GET POST",required = true)
@NotNull(message="请求方式不能为空")
public String reqType;
@ApiModelProperty(value = "超时时间",required = true)
@NotNull(message="超时时间不能为空")
public String timeout;
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年",required = true)
@NotNull(message = "限流类型不能为空")
public String reqType;
public String limitType;
@ApiModelProperty(value = "API名称",required = false)
public String apiName;
@ApiModelProperty(value = "限制次数",required = false)
public Long reqFrequency;
......@@ -54,16 +60,40 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "api描述",required = false)
public String apiFunction;
@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
public Long parentId;
@ApiModelProperty(value = "文件id",required = false)
@ApiModelProperty(value = "文件夹Id",required = true)
@NotNull(message="文件夹Id不能为空")
public Long fileId;
@ApiModelProperty(value = "项目id",required = true)
@NotNull(message="项目id不能为空")
@ApiModelProperty(value = "项目编号",required = true)
@NotNull(message="项目编号不能为空")
public Long projectId;
@ApiModelProperty(value = "输出类型:JSON 文件流形式",required = false)
public String outType;
@ApiModelProperty(value = "最大行数:",required = false)
public Long maxRow;
@ApiModelProperty(value = "每页返回数据数:",required = false)
public Long pageRow;
@ApiModelProperty(value = "请求参数:",required = false)
public String requestParam;
@ApiModelProperty(value = "响应参数:",required = false)
public String responseParam;
@ApiModelProperty(value = "参数字段:",required = false)
public String tableFields;
@ApiModelProperty(value = "数据源id",required = false)
public String esDataSource;
@ApiModelProperty(value = "数据库名称",required = false)
public String esDataBase;
@ApiModelProperty(value = "数据表名称",required = false)
public String esTable;
@ApiModelProperty(value = "状态",required = false)
public String status;
......@@ -72,10 +102,12 @@ public class ApiInterfaceReq implements Serializable {
public Long id;
@ApiModelProperty(value = "创建用户",hidden = true)
public String createUser;
@ApiModelProperty(value = "创建用户",hidden = true)
public String updateUser;
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
/* @ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义",hidden = true)
public String apiType;
public String apiType;*/
}
package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeBigDataApiReq
* @DATE: 2020-12-26/13:08
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel("Api制作大数据查询/标签查询请求体")
public class MakeBigDataApiReq implements Serializable {
// @ApiModelProperty(value = "id--更新时id不能为空",required = false)
// private Long id;
//
///* @ApiModelProperty(value = "数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义",required = true)
// @NotNull(message = "apiType不能为空")
// private String apiType;*/
//
// @ApiModelProperty(value = "apiKey",required = false)
// @NotNull(message = "apiKey不能为空")
// public String apiKey;
//
// //@ApiModelProperty(value = "是否分页",required = false)
// //public Boolean page;
//
// @ApiModelProperty(value = "数据源Id",required = true)
// @NotNull(message = "数据源Id不能为空")
// private String esDataSource;
//
// @ApiModelProperty(value = "源库名称",required = true)
// @NotNull(message = "源库名称不能为空")
// private String esDataBase;
//
// @ApiModelProperty(value = "源表名称",required = true)
// @NotNull(message = "源表名称不能为空")
// private String esTable;
//
// @ApiModelProperty(value = "处理类型",required = true)
// @NotNull(message = "处理类型不能为空")
// private String handleType;
//
//
// @ApiModelProperty(value = "请求参数",required = true)
// @NotNull(message = "请求参数不能为空")
// private String requestParam;
//
// @ApiModelProperty(value = "返回参数",required = true)
// @NotNull(message = "返回参数不能为空")
// private String responseParam;
//
// @ApiModelProperty(value = "段列表",required = true)
// @NotNull(message = "字段列表不能为空")
// private String tableFields;
//
// @ApiModelProperty(value = "创建用户",required = false)
// public String createUser;
//
// //@ApiModelProperty(value = "项目id",required = true)
// //@NotNull(message="项目id不能为空")
// //public Long projectId;
//
// //@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
// //public Long parentId;
// //
// //@ApiModelProperty(value = "文件id",required = false)
// //public Long fileId;
}
package com.jz.dm.models.req.make;
package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -40,9 +40,13 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull(message = "输出类型不能为空")
public String outputType;
@ApiModelProperty(value = "是否分页:",required = true)
@ApiModelProperty(value = "请求方式:GET POST",required = true)
@NotNull(message = "请求方式不能为空")
public String reqMethod;
/*@ApiModelProperty(value = "是否分页:",required = true)
@NotNull(message = "是否分页不能为空")
public Boolean page;
public Boolean page;*/
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月",required = true)
@NotNull(message = "限流类型不能为空")
......@@ -52,9 +56,15 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull(message = "目标地址不能为空")
public String targetUrl;
@ApiModelProperty(value = "文件id",required = true)
@NotNull(message = "文件id不能为空")
public Long fileId;
@ApiModelProperty(value = "当前页",required = true)
public Integer pageNum;
@ApiModelProperty(value = "当前页显示条数",required = true)
public Integer pageSize;
//@ApiModelProperty(value = "文件id",required = true)
//@NotNull(message = "文件id不能为空")
//public Long fileId;
@ApiModelProperty(value = "签名",required = true)
@NotNull(message = "签名不能为空")
......@@ -69,7 +79,8 @@ public class MakeDataBankApiReq implements Serializable {
@ApiModelProperty(value = "接口描述",required = false)
public String apiDesc;
@ApiModelProperty(value = "数据包下载路径",required = false)
public String fileLocation;
@ApiModelProperty(value = "超时时间",required = false)
public String timeout;
......
package com.jz.dm.models.req.make;
package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
......
package com.jz.dm.models.req.producer;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req.producer
* @PROJECT_NAME: jz-dm-parent
* @NAME: ServiceIssueReq
* @DATE: 2021-1-28/11:00
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel(value = "服务发布请求体")
public class ServiceIssueReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "文件夹id",required = false)
private Long fileId;
@ApiModelProperty(value = "api名称",required = false)
private String apiName;
@ApiModelProperty(value = "apiId",required = false)
private String apiId;
}
package com.jz.dm.models.req.make;
package com.jz.dm.models.req.producer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......
......@@ -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,24 @@ public interface ApiInterfaceService {
Result dmpDeleteAuth(String type,String apiKey);
/**
* api测试接口
* @param apiKey
* 获取api自定义信息
* @param apiInterfaceId
* @return
*/
Result apiTestInterface(String apiKey);
ApiInterfaceCustom getApiCustomInfo(Long apiInterfaceId);
/**
* 更新数据银行调用状态
* @param apiKey
* @return
*/
Result updateApiSendStatus(String apiKey);
/**
* 获取已发送到数据API列表
* @param pageNum
* @param pageSize
* @return
*/
Result getSendDataBankList(String pageNum, String pageSize);
}
......@@ -84,4 +84,11 @@ public interface AuthService {
* @return
*/
Result getAuthNameList(String key);
/**
* 获取服务授权列表
* @param req
* @return
*/
Result getServiceAuthList(ServiceAuthReq req);
}
......@@ -38,12 +38,6 @@ public interface OrganizationManageService {
*/
Result add(OrganizationManageAddReq req);
/**
* 更新组织信息
* @param req
* @return
*/
//Result update(OrganizationManageUpdateReq req);
/**
* 根据id注销组织
......
package com.jz.dm.service;
import com.jz.common.utils.Result;
import com.jz.dm.models.req.make.*;
import com.jz.dm.models.req.folder.CreateFolderReq;
import com.jz.dm.models.req.producer.ApiInterfaceReq;
import com.jz.dm.models.req.producer.ServiceIssueReq;
/**
* @author ZC
......@@ -13,40 +15,29 @@ import com.jz.dm.models.req.make.*;
* @Description:
**/
public interface ProducerService {
/**
* 制作自定义APi
* @param req
* @return
*/
Result addCustomApi(ApiInterfaceReq req);
/**
* Api制作(实时接入)
* @param req
* @return
*/
Result addRealCustomApi(MakeRealCustomApiReq req);
// Result addRealCustomApi(MakeRealCustomApiReq req);
/**
* Api制作(大数据查询/标签查询)
* @param req
* @return
*/
Result addBigDataMakeApi(MakeBigDataApiReq req);
/**
* 获取数据源配置
* @param req
* @return
*/
Result getSourceConfig(SourceConfigReq req);
// Result getSourceConfig(SourceConfigReq req);
/**
* 获取数据库列表
* @param id
* @return
*/
Result getSourceWarehouseList(Long id);
// Result getSourceWarehouseList(Long id);
/**
* 获取某个索引下的type
......@@ -54,7 +45,7 @@ public interface ProducerService {
* @param id
* @return
*/
Result getIndicesTypes(String indices, Long id);
// Result getIndicesTypes(String indices, Long id);
/**
* 获取某个索引 type的fields
......@@ -63,23 +54,28 @@ public interface ProducerService {
* @param id
* @return
*/
Result getIndicesTypesFields(String indices, String type, Long id);
// Result getIndicesTypesFields(String indices, String type, Long id);
/**
* 数据银行制作API/数据包
* @param req
* @return
*/
// Result addDataBankApiInfo(MakeDataBankApiReq req);
/**
* 保存修改的api信息
* @param req
* @return
*/
Result saveUpdateAPiInfo(ApiInterfaceReq req);
//Result saveUpdateAPiInfo(ApiInterfaceReq req);
/**
* 数据银行制作API/数据包
* Api制作(数据查询/标签查询)
* @param req
* @return
*/
Result addDataBankApiInfo(MakeDataBankApiReq req);
Result addBigDataMakeApi(ApiInterfaceReq req);
/**
* 保存 API基本信息
* @param req
......@@ -96,15 +92,36 @@ public interface ProducerService {
/**
* 创建文件夹
* @param projectId
* @param parentId
* @param currentUser
* @param req
* @return
*/
Result createProjectFolder(CreateFolderReq req);
/**
* 获取生成后的APIId
* @return
*/
Result createProjectFolder(Long projectId, Long parentId,String currentUser);
Result getCustomApiId();
/**
* 获取服务发布列表
* @param req
* @return
*/
Result getServiceIssueList(ServiceIssueReq req);
/**
* 服务发布/取消操作
* @param id
* @param optStatus
* @return
*/
Result optionApiIssueStatus(Long id, Boolean optStatus);
//Result saveObjOnRedis();
//Result getObjOnRedis();
Result saveObjOnRedis();
Result getObjOnRedis();
}
......@@ -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,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) ;
}
/**
* 获取用户授权信息
*
......@@ -275,4 +285,39 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
query.eq("is_deleted", 0);
return apiInterfaceMapper.selectOne(query);
}
/**
* 更新APi是否发送到数据银行状态
* @param apiKey
* @return
*/
@Override
public Result updateApiSendStatus(String apiKey) {
QueryWrapper<ApiInterface> queryWra = new QueryWrapper<>();
queryWra.eq("api_key",apiKey);
queryWra.eq("is_deleted",0);
ApiInterface apiInterface = apiInterfaceMapper.selectOne(queryWra);
if (null == apiInterface){
return Result.of_error(ResultMsg.DATA_NOT_FOUND);
}
UpdateWrapper<ApiInterface> updateWra = new UpdateWrapper<>();
updateWra.set("is_send_bank",0);
if (apiInterfaceMapper.update(null,updateWra) > 0){
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
return Result.of_error(ResultMsg.UPDATE_FAIL);
}
@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);
QueryWrapper<ApiInterface > query = new QueryWrapper<>();
query.eq("is_send_bank",1);
query.eq("status",ApiStatusEnum.ISSUE.name());
query.eq("is_deleted",0);
return Result.of_success(apiInterfaceMapper.selectPage(page, query));
}
}
......@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jz.common.constant.ResultMsg;
import com.jz.common.enums.auth.AuthTypeEnum;
import com.jz.common.utils.Result;
import com.jz.dm.common.constant.Constants;
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.common.enums.org.OrgStatusEnum;
import com.jz.dm.common.util.DateUtil;
import com.jz.dm.common.util.RandomUtil;
import com.jz.dm.mapper.ApiAuthMapper;
import com.jz.dm.mapper.ApiInterfaceMapper;
......@@ -19,6 +17,7 @@ import com.jz.dm.mapper.ApiOrgMapper;
import com.jz.dm.models.domian.ApiAuth;
import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.models.domian.ApiOrg;
import com.jz.dm.models.dto.ApiServiceApplyDto;
import com.jz.dm.models.dto.AuthInfoDto;
import com.jz.dm.models.req.auth.*;
import com.jz.dm.models.resp.AuthUserResponse;
......@@ -34,6 +33,7 @@ import javax.annotation.Resource;
import java.util.Date;
import static com.jz.dm.common.enums.auth.AuthModeEnum.fromTypeModeName;
import static com.jz.dm.common.enums.auth.AuthTypeEnum.fromAuthTypeName;
/**
* @author ZC
......@@ -89,6 +89,29 @@ public class AuthServiceImpl implements AuthService {
return Result.of_success(apiAuthMapper.selectAuthDetail(req));
}
/**
* 获取服务授权列表
* @param req
* @return
*/
@Override
public Result getServiceAuthList(ServiceAuthReq req) {
IPage<ApiServiceApplyDto> page = new Page<>(req.getPageNum(), req.getPageSize());
QueryWrapper<ApiServiceApplyDto> query = new QueryWrapper<>();
if (null != req.getFolderId()){
query.eq("ai.file_id",req.getFolderId());
}
if (StringUtils.isNotBlank(req.getApiName())){
query.eq("ai.api_name",req.getApiName());
}
if (StringUtils.isNotBlank(req.getApiId())){
query.eq("ai.api_key",req.getApiId());
}
query.eq("ai.is_deleted",0);
query.orderByDesc("ai.create_time");
return Result.of_success(apiInterfaceMapper.listApiAuthService(page, query));
}
/**
* 添加dmp认证信息
*
......@@ -102,20 +125,23 @@ public class AuthServiceImpl implements AuthService {
if (null == apiInterface) {
return Result.of_error("api授权信息不存在!");
}
if (ApiStatusEnum.DRAFT.name().equals(apiInterface.getStatus())){
return Result.of_error("api未发布,无法授权");
}
if (ApiStatusEnum.EXPIRY.name().equals(apiInterface.getStatus())) {
return Result.of_error("api已下架,无法授权");
}
ApiOrg apiOrg = apiOrgMapper.selectOne(new QueryWrapper<ApiOrg>().eq("org_code", req.getOrgCode()));
if (null == apiOrg || OrgStatusEnum.CANCEL.name().equals(apiOrg)) {
if (null == apiOrg || !apiOrg.getStatus()) {
return Result.of_error("组织信息不存在!");
}
//授权验证
//if (StringUtils.isNotBlank(req.getAuthType())){
// if (null == fromTypeName(req.getAuthType())){
// return Result.of_error("授权类型不存在!");
// }
//}
if (StringUtils.isNotBlank(req.getAuthType())){
if (null == fromAuthTypeName(req.getAuthType())){
return Result.of_error("授权类型不存在!");
}
}
//验证授权方式
if (StringUtils.isNotBlank(req.getAuthMode())) {
if (null == fromTypeModeName(req.getAuthMode())) {
......@@ -130,7 +156,7 @@ public class AuthServiceImpl implements AuthService {
if (StringUtils.isBlank(apiOrg.getOrgCode())) {
return Result.of_error("内部授权组织编码不能为空!!");
}
return saveAuthInfo(apiInterface, apiOrg, req, Constants.AUTH_INT);
return saveAuthInfo(apiInterface, apiOrg, req);
}
/**
......@@ -149,16 +175,19 @@ public class AuthServiceImpl implements AuthService {
if (ApiStatusEnum.SOLDOUT.name().equals(apiInterface.getStatus())) {
return Result.of_error("api已下架,无法授权");
}
if (ApiStatusEnum.DRAFT.name().equals(apiInterface.getStatus())){
return Result.of_error("api未发布,无法授权");
}
ApiOrg apiOrg = apiOrgMapper.selectOne(new QueryWrapper<ApiOrg>().eq("org_code", req.getOrgCode()));
if (null == apiOrg || OrgStatusEnum.CANCEL.name().equals(apiOrg)) {
if (null == apiOrg || !apiOrg.getStatus()) {
return Result.of_error("组织信息不存在!");
}
//授权验证
//if (StringUtils.isNotBlank(req.getAuthType())){
// if (null == fromTypeName(req.getAuthType())){
// return Result.of_error("授权类型不存在!");
// }
//}
if (StringUtils.isNotBlank(req.getAuthType())){
if (null == fromAuthTypeName(req.getAuthType())){
return Result.of_error("授权类型不存在!");
}
}
//验证授权方式
if (StringUtils.isNotBlank(req.getAuthMode())) {
if (null == fromTypeModeName(req.getAuthMode())) {
......@@ -181,7 +210,7 @@ public class AuthServiceImpl implements AuthService {
if (StringUtils.isBlank(req.getUserId())) {
return Result.of_error("外部授权用户Id不能为空");
}
return saveAuthInfo(apiInterface, apiOrg, req, Constants.AUTH_OUT);
return saveAuthInfo(apiInterface, apiOrg, req);
}
/**
......@@ -190,11 +219,10 @@ public class AuthServiceImpl implements AuthService {
* @param apiInterface
* @param apiOrg
* @param req
* @param orgType
* @return
*/
private Result saveAuthInfo(ApiInterface apiInterface, ApiOrg apiOrg,
AuthUserApiReq req, String orgType) {
AuthUserApiReq req) {
AuthUserResponse response = new AuthUserResponse();
ApiAuth apiAuth = new ApiAuth();
BeanUtils.copyProperties(req, apiAuth);
......@@ -202,21 +230,11 @@ public class AuthServiceImpl implements AuthService {
apiAuth.setApiOrgId(apiOrg.getId());
apiAuth.setReqType(apiInterface.getReqType());
apiAuth.setReqFrequency(apiInterface.getReqFrequency());
if (Constants.AUTH_INT.equals(orgType)) {//内部授权
apiAuth.setAuthType(AuthTypeEnum.DMP_AUTH.name());
} else {
apiAuth.setAuthType(AuthTypeEnum.DATA_BANK_AUTH.name());
if (!AuthModeEnum.RECORD_TIME_MODE.name().equals(req.getAuthMode())){
apiAuth.setValidExprDate(DateUtil.getAssignYearDate(99));//过期时间
}
//商城只有外部授权
String authCode = "";
//内部组织
if (StringUtils.isNotBlank(orgType) && Constants.AUTH_INT.equalsIgnoreCase(orgType)) {
authCode = getAuthCode(apiOrg.getOrgCode(), "", Constants.AUTH_INT);
//外部组织
} else if (StringUtils.isNotBlank(orgType)
&& Constants.AUTH_OUT.equalsIgnoreCase(orgType)) {
authCode = getAuthCode("", req.getUserId(), Constants.AUTH_OUT);
}
String authCode = getAuthCode(apiOrg.getOrgCode(), "","");
//生成盐值
String salt = RandomUtil.getStringRandom(8);
apiAuth.setAuthCode(authCode);//授权码
......
package com.jz.dm.service.request;
import com.alibaba.fastjson.JSONObject;
import com.jz.common.utils.RedisUtils;
import com.jz.dm.common.enums.GatewayResultCode;
import com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum;
import com.jz.dm.common.exception.GatewayException;
import com.jz.dm.common.util.OpenApiRequest;
import com.jz.dm.common.util.OpenApiResponse;
import com.jz.dm.gateway.OpenApiService;
import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.service.ApiInterfaceService;
import com.jz.dm.web.annotation.AccessLimit;
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.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Map;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiQueryTestService
* @DATE: 2021-1-25/10:13
* @DAY_NAME_SHORT: 周一
* @Description:
**/
@Service("apiQueryTestService")
@Slf4j
public class ApiQueryTestService extends ApiParamVerify implements OpenApiService {
@Override
public String getOpenApiMethod() {
return "test";
}
@Override
public String getOpenApiVersion() {
return "v1.0.0";
}
@Autowired
private ApiQueryService apiQueryService;
@Resource
private ApiInterfaceService apiInterfaceService;
@Autowired
private RedisUtils redisUtils;
/**
* API测试实现
* @param request
* @param response
*/
@Override
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
@AccessLimit(sec = 1,limit = 1000)
public void doService(OpenApiRequest request, OpenApiResponse response) {
JSONObject parameter = JSONObject.parseObject(request.getOpenApiParams());
ApiInterface apiInterface = apiInterfaceService.getApiInfo(request.getApiKey());
verifyApiInterface(apiInterface);
String reqParams = parameter.getString("reqParams");
JSONObject jsonParams = null;
Map paramMap = null;
if (StringUtils.isNotBlank(reqParams)) {
jsonParams = JSONObject.parseObject(reqParams);
paramMap = JSONObject.parseObject(jsonParams.getString("request_fileds"), Map.class);
jsonParams.put("is_test",true);
}
//取出缓存数据
// String redisReqParam = redisUtils.get(request.getApiKey());
String redisReqParam = null;
if (StringUtils.isNotBlank(redisReqParam)) {//redis中存在
//解析出API制作成功时的参数配置
JSONObject jsonObject = JSONObject.parseObject(redisReqParam);
String targetUrl = jsonObject.getString("targetUrl");
String outputType = jsonObject.getString("outputType");
if (StringUtils.isBlank(outputType)) {
outputType = ApiInfoOutTypeEnum.JSON.name();
}
if (StringUtils.isBlank(targetUrl)) {
throw new GatewayException(GatewayResultCode.REQUEST_PARAM_EMPTY);
}
apiQueryService.dataTableSelect(outputType, targetUrl, paramMap,
jsonParams, apiInterface, response);
} else {//不存在查询数据库
apiQueryService.dataTableSelect(apiInterface.getOutputType(),
apiInterface.getTargetUrl(), paramMap, jsonParams, apiInterface, response);
}
}
}
......@@ -69,7 +69,6 @@ public class SystemLogAspect {
}
@Around("aroundAspect()")
public void doAround(ProceedingJoinPoint joinPoint) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
......@@ -81,8 +80,9 @@ public class SystemLogAspect {
params += JsonUtils.objectToJson(joinPoint.getArgs()[i]) + ";";
}
}
if (StringUtils.isNotBlank(params)){
params= params.substring(0,params.length()-1).split(";")[0];;
if (StringUtils.isNotBlank(params)) {
params = params.substring(0, params.length() - 1).split(";")[0];
;
}
//获取请求路径
String url = UrlUtil.getServerUrl(request);
......@@ -95,33 +95,37 @@ public class SystemLogAspect {
String paramsList = jsonObject.getString("openApiParams");
com.alibaba.fastjson.JSONObject jsonParamsList = com.alibaba.fastjson.JSONObject.parseObject(paramsList);
ApiReqLog reqLog = new ApiReqLog();
JSONObject jsonResult =null;
try {
reqLog.setRequestIp(ip);
reqLog.setApiKey(jsonObject.getString("apiKey"));
reqLog.setRequestParams(params);
reqLog.setResponseParams("");//响应参数
reqLog.setRequestUrl(url);
reqLog.setRequestMethod(contextPath);
reqLog.setEncryMode(jsonObject.getString("signType")); //加密方式:MD5,RSA
reqLog.setEncryMode("MD5"); //加密方式暂时写死MD5
reqLog.setTransMode(request.getMethod());//传输方式 GET POST
reqLog.setRequestToken(jsonParamsList.getString("authCode"));
reqLog.setRequestStartTime(new Date());
reqLog.setRemark(getServiceMethodDescription(joinPoint));
log.info("请求参数:",reqLog);
if (null != reqLog) {
apiReqLogMapper.insert(reqLog);
JSONObject jsonResult = null;
Boolean isTest = jsonParamsList.getBoolean("isTest");
//不保存测试数据
if (!isTest) {
try {
reqLog.setRequestIp(ip);
reqLog.setApiKey(jsonObject.getString("apiKey"));
reqLog.setRequestParams(params);
reqLog.setResponseParams("");//响应参数
reqLog.setRequestUrl(url);
reqLog.setRequestMethod(contextPath);
reqLog.setEncryMode(jsonObject.getString("signType")); //加密方式:MD5,RSA
//reqLog.setEncryMode("MD5"); //加密方式暂时写死MD5
reqLog.setTransMode(request.getMethod());//传输方式 GET POST
reqLog.setRequestToken(jsonParamsList.getString("authCode"));
reqLog.setRequestStartTime(new Date());
reqLog.setRemark(getServiceMethodDescription(joinPoint));
log.info("请求参数:", reqLog);
if (null != reqLog) {
apiReqLogMapper.insert(reqLog);
}
Object result = joinPoint.proceed(joinPoint.getArgs());
jsonResult = JSONObject.fromObject(result);
log.info("around响应结果为{}", jsonResult);
apiLogService.updateLog(reqLog.getId(), jsonResult);
} catch (GatewayException ex) {
log.info("切面处理保存异常信息:{}", ex.getMessage());
apiLogService.updateLog(reqLog.getId(), jsonResult);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
Object result = joinPoint.proceed(joinPoint.getArgs());
jsonResult = JSONObject.fromObject(result);
log.info("around响应结果为{}", jsonResult);
apiLogService.updateLog(reqLog.getId(), jsonResult);
} catch (GatewayException ex) {
log.info("切面处理保存异常信息:{}",ex.getMessage());
apiLogService.updateLog(reqLog.getId(), jsonResult);
}catch (Throwable throwable){
throwable.printStackTrace();
}
}
/*@Before("beforeAspect()")
......@@ -204,7 +208,7 @@ public class SystemLogAspect {
// log.error("异常信息{}", e.getMessage());
// }
// }
// }
/**
* 获取注解中对方法的描述信息 用于service层注解
......
......@@ -77,9 +77,16 @@ dmp:
ignoreRedis: true
openapi:
timeout:
default: 5000
max: 5000
default: 10000
max: 10000
#logback日志配置
logging:
config: classpath:logback-dev.xml
level:
com:
zhl:
springbootlogback: off
#流处理配置
windows: #文件流输出地址设置
name: stream
......@@ -95,17 +102,17 @@ sentinel: #sentinel每秒中最大的请求个数
data:
bank:
balanceUrl: http://192.168.1.139:8081 #余额信息url #扣款信通知url
select: #大数据查询请求链接
jsonUrl: http://192.168.1.140:8082/api/data/query/json
flowUrl: http://192.168.1.140:8082/api/data/query/streaming
#token: #dataBank 制作验签
# dataBank: dataBank123
token: #dataBank 制作验签
dataBank: dataBank123
#logback日志配置
logging:
config: classpath:logback-dev.xml
level:
com:
zhl:
springbootlogback: off
......@@ -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,
......@@ -40,5 +43,35 @@
AND ai.api_key =#{apiKey}
</select>
<select id="listApiIssueService" resultType="com.jz.dm.models.dto.ApiServiceApplyDto">
SELECT ai.api_key AS apiId,
ai.api_name AS apiName,
ai.api_type AS apiType,
ai.output_type AS outputType,
ai.req_type AS reqType,
ai.api_function AS apiFunction,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
aic.is_send_bank AS isSendBank
FROM t_api_interface AS ai JOIN t_api_interface_custom AS aic
ON ai.id =aic.api_interface_id AND aic.is_deleted =0
${ew.customSqlSegment}
</select>
<select id="listApiAuthService" resultType="com.jz.dm.models.dto.ApiServiceApplyDto">
SELECT ai.api_key AS apiId,
ai.api_name AS apiName,
ai.api_type AS apiType,
ai.output_type AS outputType,
ai.req_type AS reqType,
ai.api_function AS apiFunction,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
au.auth_code AS authCode
FROM t_api_interface AS ai
JOIN t_api_interface_custom AS aic ON ai.id =aic.api_interface_id AND aic.is_deleted =0
JOIN t_api_auth AS au ON au.api_interface_id = ai.id AND aic.is_deleted =0
${ew.customSqlSegment}
</select>
</mapper>
\ No newline at end of file
......@@ -27,15 +27,14 @@ public class ApiReqTest extends SpringTestCase {
public void TestGatewayReq() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("apiKey", "sE862E97j7Yzo049");
jsonObject.put("apiKey", "8trDpp4WRl92850o");
jsonObject.put("method", "query");
jsonObject.put("signType", "MD5");
long time = System.currentTimeMillis();
jsonObject.put("timestamp", String.valueOf(time));
JSONObject params = new JSONObject();
params.put("authCode", "202100000001118191258T718d78591J");
params.put("selectType", "10006");
params.put("authCode", "2021000000011118104856J1QR4u9Afm");
params.put("reqParams", new JSONObject());
jsonObject.put("params",params);
try {
......@@ -44,7 +43,7 @@ public class ApiReqTest extends SpringTestCase {
String signType = jsonObject.getString("signType");
String signature = MapUtil.getSignValue(apiKey, method, signType);
String salt = Md5.encrypt(signature, "33tgT3g2");
String salt = Md5.encrypt(signature, "7330lQl2");
jsonObject.put("sign", salt);
String response = httpsUtils.submitPost(url, jsonObject.toString());
System.out.println(response);
......
......@@ -2,10 +2,8 @@ package com.jz.dm.gateway.org;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jz.common.utils.Result;
import com.jz.dm.common.enums.auth.AuthTypeEnum;
import com.jz.dm.gateway.SpringTestCase;
import com.jz.dm.models.domian.ApiOrg;
import com.jz.dm.models.req.organizationManage.OrganizationManageAddReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq;
import com.jz.dm.service.OrganizationManageService;
......@@ -53,7 +51,7 @@ public class TestOrganizationManage extends SpringTestCase {
*/
@Test
public void addOrg(){
OrganizationManageAddReq req = new OrganizationManageAddReq();
/* OrganizationManageAddReq req = new OrganizationManageAddReq();
req.setOrgName("数据银行");
req.setOrgDesc("粗这次");
req.setOrgCnName("databank");
......@@ -62,7 +60,7 @@ public class TestOrganizationManage extends SpringTestCase {
req.setOrgPhone("18279668524");
req.setOrgType(AuthTypeEnum.DATA_BANK_AUTH.name());
Result result = organizationManageService.add(req);
System.out.println(result.getMessage());
System.out.println(result.getMessage());*/
}
/**
......
......@@ -2,7 +2,7 @@ package com.jz.dm.gateway.orther;
import com.jz.dm.common.util.RedisSerializableUtil;
import com.jz.dm.gateway.SpringTestCase;
import com.jz.dm.models.req.make.MakeDataBankApiReq;
import com.jz.dm.models.req.producer.MakeDataBankApiReq;
import net.sf.json.JSONObject;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -43,10 +43,10 @@ public class TestRedisUserSave extends SpringTestCase {
bankApiReq.setSignType("MD5");
bankApiReq.setJoinType("10004");
bankApiReq.setOutputType("JSON");
bankApiReq.setPage(false);
//bankApiReq.setPage(false);
bankApiReq.setReqType("DAY");
bankApiReq.setTargetUrl("www.baidu.com");
bankApiReq.setFileId(1L);
//bankApiReq.setFileId(1L);
bankApiReq.setSign("F2A8E3CFE528D6AE5C5B075046653F3E");
bankApiReq.setReqFrequency(0L);
bankApiReq.setApiDesc("4444");
......
package com.jz.dm.gateway.orther;
import com.alibaba.fastjson.JSONObject;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @ClassName:
* @Author: Carl
......@@ -8,10 +14,89 @@ package com.jz.dm.gateway.orther;
*/
public class TestStr {
public static void main(String[] args) {
String str = "/picture/logo/T6gxlv137nFA555z.jpg";
// String[] split = str.split("\\/");
System.out.println(str.substring(0, str.lastIndexOf("/") + 1));
String substring = str.substring(str.lastIndexOf("."));
System.out.println(substring);
Calendar cal = Calendar.getInstance();
/* int year =cal.get(Calendar.YEAR)+1;
int month=cal.get(Calendar.MONTH)+1;
cal.add(Calendar.MONTH, 0);*/
//Date date = cal.getTime(); //结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
cal.set(Calendar.YEAR,cal.get(Calendar.YEAR)+2);
Date date=cal.getTime();
System.out.println( sdf.format(date));
//String stereo = "000101";
// Integer valueOf = Integer.valueOf(stereo);
// System.out.println(valueOf);
}
public void resolveParameter(){
String str ="[{\"name\":\"flelds1\",\"bindName\":\"flelds1\",\"type\":\"BIGINT\",\"sampleValue\":\"1\",\"defaultValue\":\"1\",\"required\":true,\"desc\":\"\"},{\"name\":\"flelds2\",\"bindName\":\"flelds2\",\"type\":\"BIGINT\",\"sampleValue\":\"1\",\"defaultValue\":\"1\",\"required\":true,\"desc\":\"\"}]";
String str2="[{\"name\":\"field1\",\"bindName\":\"field1\",\"type\":\"STRING\",\"sampleValue\":\"1\",\"desc\":\"\"},{\"name\":\"field2\",\"bindName\":\"field2\",\"type\":\"BIGINT\",\"sampleValue\":\"1\",\"desc\":\"\"},{\"name\":\"field3\",\"bindName\":\"field3\",\"type\":\"BIGINT\",\"sampleValue\":\"1\",\"desc\":\"\"},{\"name\":\"field4\",\"bindName\":\"field4\",\"type\":\"STRING\",\"sampleValue\":\"1\",\"desc\":\"\"}]";
List<Map> maps = JSONObject.parseArray(str2, Map.class);
for (Map map : maps) {
System.out.println("map:"+map);
}
}
/**
* 获取集合信息
*/
public static void getList() {
List<String> list1 = new ArrayList<String>();
list1.add("1");
list1.add("2");
list1.add("3");
list1.add("4");
list1.add("5");
List<String> list2 = new ArrayList<String>();
list2.add("1");
list2.add("2");
list2.add("3");
list2.add("4");
list2.add("5");
list2.add("7");
list2.add("9");
// 交集
List<String> intersection = list1.stream().filter(item -> list2.contains(item)).collect(Collectors.toList());
System.out.println("---交集 intersection---");
intersection.parallelStream().forEach(System.out::println);
// 差集 (list1 - list2)
List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(Collectors.toList());
System.out.println("---差集 reduce1 (list1 - list2)---");
reduce1.parallelStream().forEach(System.out::println);
// 差集 (list2 - list1)
List<String> reduce2 = list2.stream().filter(item -> !list1.contains(item)).collect(Collectors.toList());
System.out.println("---差集 reduce2 (list2 - list1)---");
reduce2.parallelStream().forEach(System.out::println);
//合拼差
reduce1.addAll(reduce2);
System.out.println("---合拼差 reduce1 (list2 -> list1)---");
reduce1.parallelStream().forEach(System.out::println);
// 并集
List<String> listAll = list1.parallelStream().collect(Collectors.toList());
List<String> listAll2 = list2.parallelStream().collect(Collectors.toList());
listAll.addAll(listAll2);
System.out.println("---并集 listAll---");
listAll.parallelStream().forEachOrdered(System.out::println);
// 去重并集
List<String> listAllDistinct = listAll.stream().distinct().collect(Collectors.toList());
System.out.println("---得到去重并集 listAllDistinct---");
listAllDistinct.parallelStream().forEachOrdered(System.out::println);
System.out.println("---原来的List1---");
list1.parallelStream().forEachOrdered(System.out::println);
System.out.println("---原来的List2---");
list2.parallelStream().forEachOrdered(System.out::println);
}
}
......@@ -3,7 +3,7 @@ package com.jz.dm.gateway.orther;
import com.jz.dm.gateway.SpringTestCase;
import lombok.extern.slf4j.Slf4j;
import static com.jz.dm.common.util.stream.HttpDownload.download;
import static com.jz.dm.common.util.stream.HttpDownload.getDownload;
/**
* @author ZC
......@@ -21,6 +21,6 @@ public class TestStreamReq extends SpringTestCase {
//@Test
public void testStreamReq() {
download(baseUrl);
getDownload(baseUrl);
}
}
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