Commit 7f2c7f50 authored by zhangc's avatar zhangc

修改api制作,组织创建相关接口

parent 78fd3f92
......@@ -4,25 +4,21 @@ 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自定义',
`req_method` 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 按年',
`req_frequency` bigint(20) DEFAULT '100' COMMENT '限制次数',
`is_test` tinyint(2) NOT NULL DEFAULT '0' COMMENT '是否测试数据:0 否,1 是',
`api_custom_id` bigint(20) NULL COMMENT 'API扩展表id'
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`create_user` varchar(100) DEFAULT NULL COMMENT '创建人',
......@@ -38,26 +34,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 '固定参数',
`page_num` int(10) NULL DEFAULT '1' COMMENT '当前页',
`page_size` int(10) NULL DEFAULT '100' 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自定义信息表';
......@@ -67,7 +61,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',
......@@ -94,6 +88,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 '备注',
......
......@@ -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:";
}
......@@ -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.CreateFolderReq;
import com.jz.dm.models.req.make.ApiInterfaceReq;
import com.jz.dm.service.ProducerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -46,115 +47,125 @@ 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:获取APIID
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("Api制作(自定义DMP)")
@ApiOperation("Api制作(获取ApiId)")
@PostMapping(value = "/getCustomApiId")
public Mono<Result> getCustomApiId() {
return Mono.fromSupplier(() -> Result.of_success(producerService.getCustomApiId()));
}
/**
* @Description:Api制作(第三方)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("Api制作(第三方)")
@PostMapping(value = "/addCustomApi")
public Mono<Result> makeCustomApi(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> Result.of_success(producerService.addCustomApi(req)));
return Mono.fromSupplier(() -> Result.of_success(producerService.saveInterfaceAPi(req)));
}
/**
* @Description:Api制作(数据查询/标签查询)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("Api制作(数据查询/标签查询)")
@PostMapping(value = "/addDataTableSelect")
public Mono<Result> bigDataMakeApi(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> producerService.addBigDataMakeApi(req));
}
/**
* @Description:Api制作(数据银行)
* @Description:Api制作(大数据查询/标签查询)保存修改的api信息
* @return: (自定义更新同时使用)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
/* @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制作(大数据查询/标签查询)
* @return:
* @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));
}
}*/
/**
* @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:Api制作(大数据查询/标签查询)保存修改的api信息
* @return: (自定义更新同时使用)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation("保存修改的api信息")
@PostMapping(value = "/saveUpdate")
public Mono<Result> saveUpdateAPiInfo(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> producerService.saveUpdateAPiInfo(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 +185,5 @@ public class ProducerController {
@GetMapping(value = "/getRedisObj")
public Result getObjOnRedis() {
return producerService.getObjOnRedis();
}
}*/
}
......@@ -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,16 +45,11 @@ public class ApiInterface extends BaseObject implements Serializable {
private String apiProtocl;
/**
* api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 5 DMP标签查询 6.DMP大数据表查询 7 DMP自定义'
* api类型: 1 API实时接入 2 DMP标签查询 3 数据表查询 4 三方查询'
*/
@TableField("api_type")
private String apiType;
/**
* 请求地址
*/
@TableField("api_path")
private String apiPath;
/**
* 目标url
*/
......@@ -76,21 +65,13 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
@TableField("join_type")
private String joinType;
/**
* 测试实例
*/
@TableField("test_example")
private String testExample;
/**
* '输出类型:flow 流形式输出, json格式输出',
*/
@TableField("output_type")
private String outputType;
/**
* 是否分页:0 false ,1 true
*/
@TableField("page")
private Boolean page;
/**
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
......@@ -132,17 +113,18 @@ 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;
/**
* API扩展表id
*/
@TableField("api_custom_id")
private Long apiCustomId;
/*-----------------------------------保存数据库时忽略字段--------------------------------*/
/**
* 请求总次数
......
......@@ -33,8 +33,8 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
/**
* apiInterfaceId
*/
@TableField("api_interface_id")
private Long apiInterfaceId;
/* @TableField("api_interface_id")
private Long apiInterfaceId;*/
/**
......@@ -94,14 +94,15 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
@TableField("inbox_param")
private String inboxParam;
/**
* 当前页
* 最大行数
*/
@TableField("page_num")
private Integer pageNum;
@TableField("max_row")
private Long maxRow;
/**
* 当前页显示数据
* 每页返回行数
*/
@TableField("page_size")
private Integer pageSize;
@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 内部组织
*/
......
......@@ -20,27 +20,28 @@ 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 = "接入类型不能为空")
@ApiModelProperty(value = "Api类型:对应字典表key",required = true)
@NotNull(message = "Api类型不能为空")
public String joinType;
@ApiModelProperty(value = "apiKey",required = true)
@NotNull(message = "apiKey不能为空")
public String apiKey;
@ApiModelProperty(value = "目标地址",required = true)
@NotNull(message="目标地址不能为空")
public String targetUrl;
@ApiModelProperty(value = "请求方式:GET POST",required = false)
@ApiModelProperty(value = "请求方式:GET POST",required = true)
@NotNull(message="请求方式不能为空")
public String reqMethod;
@ApiModelProperty(value = "超时时间",required = true)
......@@ -51,22 +52,49 @@ public class ApiInterfaceReq implements Serializable {
@NotNull(message = "限流类型不能为空")
public String reqType;
@ApiModelProperty(value = "API名称",required = false)
public String apiName;
@ApiModelProperty(value = "限制次数",required = false)
public Long reqFrequency;
@ApiModelProperty(value = "api描述",required = false)
public String apiFunction;
/* @ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
public Long parentId;
@ApiModelProperty(value = "文件夹Id",required = true)
@NotNull(message="文件夹Id不能为空")
public Long folderId;
@ApiModelProperty(value = "项目编号",required = true)
@NotNull(message="项目编号不能为空")
public Long projectId;
@ApiModelProperty(value = "输出类型:JSON 文件流形式",required = false)
public String outType;
@ApiModelProperty(value = "文件id",required = false)
public Long fileId;
@ApiModelProperty(value = "最大行数:",required = false)
public Long maxRow;
@ApiModelProperty(value = "项目id",required = true)
@NotNull(message="项目id不能为空")
public Long projectId;*/
@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;
......@@ -75,6 +103,8 @@ 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.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
......
......@@ -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)
......
......@@ -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.CreateFolderReq;
import com.jz.dm.models.req.make.ApiInterfaceReq;
/**
* @author ZC
......@@ -13,40 +14,34 @@ 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制作(数据查询/标签查询)
* Api制作(数据查询/标签查询)
* @param req
* @return
*/
Result addBigDataMakeApi(MakeBigDataApiReq req);
Result addBigDataMakeApi(ApiInterfaceReq 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 +49,7 @@ public interface ProducerService {
* @param id
* @return
*/
Result getIndicesTypes(String indices, Long id);
// Result getIndicesTypes(String indices, Long id);
/**
* 获取某个索引 type的fields
......@@ -63,22 +58,22 @@ public interface ProducerService {
* @param id
* @return
*/
Result getIndicesTypesFields(String indices, String type, Long id);
// Result getIndicesTypesFields(String indices, String type, Long id);
/**
* 保存修改的api信息
* 数据银行制作API/数据包
* @param req
* @return
*/
Result saveUpdateAPiInfo(ApiInterfaceReq req);
// Result addDataBankApiInfo(MakeDataBankApiReq req);
/**
* 数据银行制作API/数据包
* 保存修改的api信息
* @param req
* @return
*/
Result addDataBankApiInfo(MakeDataBankApiReq req);
//Result saveUpdateAPiInfo(ApiInterfaceReq req);
/**
* 保存 API基本信息
......@@ -96,15 +91,21 @@ public interface ProducerService {
/**
* 创建文件夹
* @param projectId
* @param parentId
* @param currentUser
* @param req
* @return
*/
Result createProjectFolder(Long projectId, Long parentId,String currentUser);
Result createProjectFolder(CreateFolderReq req);
/**
* 获取生成后的APIId
* @return
*/
Result getCustomApiId();
//Result saveObjOnRedis();
//Result getObjOnRedis();
Result saveObjOnRedis();
Result getObjOnRedis();
}
......@@ -6,10 +6,9 @@ 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.utils.Result;
import com.jz.dm.common.constant.Constants;
import com.jz.dm.common.enums.org.OrgStatusEnum;
import com.jz.dm.common.util.RandomUtil;
import com.jz.dm.mapper.ApiInterfaceFileMapper;
import com.jz.dm.mapper.ApiOrgMapper;
import com.jz.dm.models.domian.ApiInterfaceFile;
import com.jz.dm.models.domian.ApiOrg;
import com.jz.dm.models.req.organizationManage.OrganizationManageAddReq;
import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
......@@ -23,8 +22,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import static com.jz.dm.common.enums.org.OrgTypeEnum.fromOrgTypeEnumName;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
......@@ -40,6 +37,8 @@ public class OrganizationManageImpl implements OrganizationManageService {
@Resource
private ApiOrgMapper apiOrgMapper;
@Resource
private ApiInterfaceFileMapper apiInterfaceFileMapper;
/**
* 组织列表信息查询
......@@ -52,14 +51,14 @@ public class OrganizationManageImpl implements OrganizationManageService {
IPage<ApiOrg> page = new Page<>(req.getPageNum(), req.getPageSize());
QueryWrapper<ApiOrg> query = new QueryWrapper<>();
if (StringUtils.isNotBlank(req.getOrgName())){
query.like("org_name",req.getOrgName());
if (StringUtils.isNotBlank(req.getOrgName())) {
query.like("org_name", req.getOrgName());
}
if (StringUtils.isNotBlank(req.getLinkman())){
query.like("linkman",req.getLinkman());
if (StringUtils.isNotBlank(req.getLinkman())) {
query.like("linkman", req.getLinkman());
}
if (StringUtils.isNotBlank(req.getOrgCode())){
query.eq("org_code",req.getOrgCode());
if (StringUtils.isNotBlank(req.getOrgCode())) {
query.eq("org_code", req.getOrgCode());
}
query.eq("is_deleted", 0);
query.orderByDesc("create_date");
......@@ -89,53 +88,101 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/
@Override
public Result add(OrganizationManageAddReq req) {
ApiOrg apiOrg = new ApiOrg();
BeanUtils.copyProperties(req, apiOrg);
if (null != req.getId()){//更新
//更新组织
if (null != req.getId()) {
ApiOrg org = apiOrgMapper.selectById(req.getId());
if (null == org){
if (null == org) {
return Result.of_error(ResultMsg.DATA_NOT_EXIST);
}
org.setUpdateDate(new Date());
if ( apiOrgMapper.updateById(apiOrg) > 0){
if (StringUtils.isNotBlank(req.getOrgName()) && !req.getOrgName().equals(org.getOrgName())) {
if (checkOrgName(req.getOrgName())) {
return Result.of_error("组织名称已存在!");
}
}
if (null != req.getOrgFolderId() && !req.getOrgFolderId().equals(org.getOrgFolderId())) {
if (checkOrgFolderIsExist(req.getOrgFolderId())) {
return Result.of_error("目标文件夹不存在!");
}
}
org.setUpdateDate(new Date());
org.setOrgName(req.getOrgName());
org.setLinkman(req.getLinkman());
org.setOrgPhone(req.getOrgPhone());
org.setOrgFolderId(req.getOrgFolderId());
if (apiOrgMapper.updateById(org) > 0) {
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
}else {//添加
//添加组织
} else {
ApiOrg apiOrg = new ApiOrg();
BeanUtils.copyProperties(req, apiOrg);
Result result = addOrg(req, apiOrg);
if (result != null) return result;
}
return Result.of_error(ResultMsg.FAILURE);
}
/**
* 校验组织名称是否存在
*
* @param newName
* @return
*/
private boolean checkOrgName(String newName) {
if (StringUtils.isBlank(newName)) {
return true;
}
QueryWrapper<ApiOrg> query = new QueryWrapper<>();
query.eq("org_name", newName);
query.eq("status", 1);
query.eq("is_deleted", 0);
ApiOrg apiOrg = apiOrgMapper.selectOne(query);
if (null != apiOrg) {
return true;
}
return false;
}
/**
* 校验组织文件夹是否存在
*
* @param folderId
* @return
*/
private boolean checkOrgFolderIsExist(Long folderId) {
if (null == folderId) {
return true;
}
QueryWrapper<ApiInterfaceFile> query = new QueryWrapper<>();
query.eq("id", folderId);
query.eq("file_source", 2);
query.eq("is_deleted", 0);
ApiInterfaceFile apiInterfaceFile = apiInterfaceFileMapper.selectOne(query);
if (null != apiInterfaceFile) {
return true;
}
return false;
}
/**
* 添加组织
*
* @param req
* @param apiOrg
* @return
*/
private Result addOrg(OrganizationManageAddReq req, ApiOrg apiOrg) {
String coding = "";
if (StringUtils.isNotBlank(req.getOrgName())) {
ApiOrg orgNameInfo = getOrgNameInfo(req.getOrgName());
if (null != orgNameInfo) {
if (checkOrgName(req.getOrgName())) {
return Result.of_error("组织名称已存在!");
}
}
if (StringUtils.isNotBlank(req.getOrgType())) {
if (null == fromOrgTypeEnumName(req.getOrgType())){
return Result.of_error("组织类型不存在!");
}
}
if (StringUtils.isNotBlank(req.getOrgType()) //内部组织
&& Constants.AUTH_INT.equals(req.getOrgType())) {
coding = generateCode(req.getOrgName(), Constants.AUTH_INT);
} else {
coding = generateCode(req.getOrgName(), Constants.AUTH_OUT);
}
if (StringUtils.isBlank(coding)) {
//生成组织编码
String orgCode = generateCode(6);
if (StringUtils.isBlank(orgCode)) {
return Result.of_error("生成组织编码异常!");
}
apiOrg.setOrgCode(coding);//组织编码
apiOrg.setOrgCode(orgCode);//组织编码
if (apiOrgMapper.insert(apiOrg) > 0) {
return Result.of_success(ResultMsg.INSERT_SUCCESS);
}
......@@ -143,54 +190,23 @@ public class OrganizationManageImpl implements OrganizationManageService {
}
/**
* 获取组织编码(去重)
*
* @param orgName 组织名称
* @param type 生成类型
* 生成组织编码
* @param num 生成位数
* @return
*/
private String generateCode(String orgName, String type) {
String coding = "";
coding = RandomUtil.generateOrgCoding(orgName, type);
QueryWrapper<ApiOrg> query = new QueryWrapper<>();
query.eq("org_code", coding);
ApiOrg org = apiOrgMapper.selectOne(query);
if (null != org) {
coding = RandomUtil.generateOrgCoding(orgName, type);
private String generateCode(int num) {
QueryWrapper<ApiOrg> queryWra = new QueryWrapper<>();
queryWra.select("org_code");
queryWra.last("where id IN (SELECT MAX(id) FROM t_api_org)");
ApiOrg apiOrg = apiOrgMapper.selectOne(queryWra);
String orgCode = null;
if (null != apiOrg) {
Integer maxOrgCode = Integer.valueOf(apiOrg.getOrgCode());
orgCode = String.format("%0" + num + "d",maxOrgCode+1);
}
return coding;
return orgCode;
}
/**
* 更新组织
*
* @param req
* @return
*/
/* @Override
public Result update(OrganizationManageUpdateReq req) {
ApiOrg apiOrg = apiOrgMapper.selectById(req.getId());
if (null == apiOrg) {
return Result.of_error("组织信息不存在!");
}
if (StringUtils.isNotBlank(req.getStatus())) {
if (null == fromTypeName(req.getStatus())) {
return Result.of_error("更新组织状态不存在!");
}
}
//原状态为注销状态不可复原
if (OrgStatusEnum.CANCEL.equals(apiOrg.getStatus())){
return Result.of_error("注销状态不可修改");
}
ApiOrg apiOrgUpdate = new ApiOrg();
BeanUtils.copyProperties(req, apiOrgUpdate);
apiOrgUpdate.setUpdateDate(new Date());
if (apiOrgMapper.updateById(apiOrgUpdate) > 0) {
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
}
return Result.of_success(ResultMsg.UPDATE_FAIL);
}*/
/**
* 注销组织
*
......@@ -205,7 +221,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
}
UpdateWrapper<ApiOrg> delete = new UpdateWrapper<>();
delete.set("is_deleted", 1);
delete.set("status",0);
delete.set("status", 0);
delete.eq("id", id);
if (apiOrgMapper.update(null, delete) > 0) {
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
......@@ -223,26 +239,9 @@ public class OrganizationManageImpl implements OrganizationManageService {
public ApiOrg getAuthOrganization(Long apiOrgId) {
QueryWrapper<ApiOrg> query = new QueryWrapper<>();
query.eq("id", apiOrgId);
query.eq("status",1);
query.eq("status", 1);
query.eq("is_deleted", 0);
return apiOrgMapper.selectOne(query);
}
/**
* 根据名称获取组织信息
*
* @param orgName 组织名称
* @return
*/
private ApiOrg getOrgNameInfo(String orgName) {
QueryWrapper<ApiOrg> query = new QueryWrapper<>();
query.eq("org_name", orgName);
query.eq("is_deleted", 0);
query.eq("status", OrgStatusEnum.NORMAL);
ApiOrg apiOrg = apiOrgMapper.selectOne(query);
if (null != apiOrg) {
return apiOrg;
}
return null;
}
}
......@@ -3,21 +3,23 @@ package com.jz.dm.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jz.common.constant.ResultCode;
import com.jz.common.constant.ResultMsg;
import com.jz.common.exception.ResponseException;
import com.jz.common.utils.HttpsUtils;
import com.jz.common.utils.Md5;
import com.jz.common.utils.RedisUtils;
import com.jz.common.utils.Result;
import com.jz.dm.common.constant.TagConstants;
import com.jz.dm.common.enums.GeneralStatusTypeEnum;
import com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum;
import com.jz.dm.common.enums.apiInterface.ApiStatusEnum;
import com.jz.dm.common.enums.produce.ProducerStatusTypeEnum;
import com.jz.dm.common.util.RandomUtil;
import com.jz.dm.mapper.*;
import com.jz.dm.models.domian.*;
import com.jz.dm.models.req.make.*;
import com.jz.dm.models.domian.ApiInterface;
import com.jz.dm.models.domian.ApiInterfaceCustom;
import com.jz.dm.models.domian.ApiInterfaceFile;
import com.jz.dm.models.domian.ApiOpenApiEsFields;
import com.jz.dm.models.req.CreateFolderReq;
import com.jz.dm.models.req.make.ApiInterfaceReq;
import com.jz.dm.service.ApiInterfaceService;
import com.jz.dm.service.ProducerService;
import lombok.extern.slf4j.Slf4j;
......@@ -33,7 +35,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import static com.jz.dm.common.enums.apiInterface.ApiStatusEnum.fromApiStatusName;
import static com.jz.dm.common.enums.auth.AuthReqTypeEnum.fromAuthReqTypeEnum;
/**
......@@ -72,16 +73,18 @@ public class ProducerServiceImpl implements ProducerService {
private int maxTimeout;
@Value("${dmp.openapi.timeout.default}")
private int defaultTimeout;
//@Value("${dmp.openapi.env.open:false}")
//private boolean envOpen = false;
@Value("${dmp.ignoreRedis}")
private boolean ignoreRedis;
/**
* 数据表查询链接JSON
*/
@Value("${data.select.jsonUrl}")
private String jsonUrl;
/**
* dataBank签名token
* 数据表查询链接flow流
*/
@Value("${token.dataBank}")
private String dataBankToken;
@Value("${data.select.flowUrl}")
private String flowUrl;
/**
* 获取文件列表
......@@ -98,178 +101,114 @@ public class ProducerServiceImpl implements ProducerService {
/**
* 创建文件夹
*
* @param projectId
* @param parentId
* @param currentUser
* @param req
* @return
*/
@Override
public Result createProjectFolder(Long projectId, Long parentId, String currentUser) {
QueryWrapper<ApiInterfaceFile> query = new QueryWrapper<>();
query.eq("id", parentId);
query.eq("is_deleted", 0);
ApiInterfaceFile apiInterfaceFile = apiInterfaceFileMapper.selectOne(query);
if (null == apiInterfaceFile) {
return Result.of_error("父级文件夹不存在!");
}
ApiInterfaceFile instanceFile = new ApiInterfaceFile();
instanceFile.setProjectId(projectId);
instanceFile.setFileSource("1");//文件来源:1 DMP 2 数据银行
instanceFile.setParentId(parentId);
instanceFile.setStatus(GeneralStatusTypeEnum.VALID.name());
instanceFile.setCreateUser(currentUser);
instanceFile.setRemark("DMP创建层级文件夹");
if (apiInterfaceFileMapper.insert(instanceFile) > 0) {
return Result.of_error(ResultMsg.INSERT_SUCCESS);
public Result createProjectFolder(CreateFolderReq req) {
if (null != req.getParentId()) {
if (null == apiInterfaceFileMapper.selectById(req.getParentId())) {
return Result.of_error("父级文件夹不存在!");
}
}
if (StringUtils.isNotBlank(req.getFileSource()) &&
"1".equals(req.getFileSource())) { //api制作创建文件夹
if (null == req.getProjectId()) {
return Result.of_error("项目id不存在!");
}
if (addFolder(req)){
return Result.of_error(ResultMsg.INSERT_FAIL);
}
} else if (StringUtils.isNotBlank(req.getFileSource()) &&
"2".equals(req.getFileSource())) { //组织创建文件夹
if (addFolder(req)){
return Result.of_error(ResultMsg.INSERT_FAIL);
}
}
return Result.of_error(ResultMsg.INSERT_FAIL);
}
/**
* 添加文件夹
* @param req
* @return
*/
private boolean addFolder(CreateFolderReq req) {
ApiInterfaceFile interfaceFile = new ApiInterfaceFile();
BeanUtils.copyProperties(req, interfaceFile);
interfaceFile.setStatus(GeneralStatusTypeEnum.VALID.name());
if (apiInterfaceFileMapper.insert(interfaceFile) == 0) {
return true;
}
return false;
}
/**
* DMP制作自定义Api
* 获取APIID
*
* @param req
* @return
*/
@Override
public Result addCustomApi(ApiInterfaceReq req) {
return saveInterfaceAPi(req);
public Result getCustomApiId() {
return Result.of_success(getApiKey());
}
/**
* 数据银行制作API/数据包/自定义
* 数据查询/标签查询
*
* @param req
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Result addDataBankApiInfo(MakeDataBankApiReq req) {
/* QueryWrapper<ApiInterfaceFile> query = new QueryWrapper<>();
query.eq("file_source", "2");
query.eq("is_deleted", 0);
List<ApiInterfaceFile> fileSource = apiInterfaceFileMapper.selectList(query);
if (fileSource.size() == 0 || fileSource.size() >= 2) {
return Result.of_error("文件夹信息异常!");
}*/
if (StringUtils.isNotBlank(req.getOutputType())) {
if (!req.getOutputType().contains(ApiInfoOutTypeEnum.JSON.name()) ||
!req.getOutputType().contains(ApiInfoOutTypeEnum.FLOW.name())) {
return Result.of_error("输出类型不存在!");
public Result addBigDataMakeApi(ApiInterfaceReq req) {
if ("10002".equals(req.getJoinType())) {//数据查询
if (StringUtils.isBlank(req.getEsDataSource()) ||
StringUtils.isBlank(req.getEsDataBase()) ||
StringUtils.isBlank(req.getEsTable())) {
return Result.of_error("数据源信息不存在!");
}
}
if (null != req.getReqFrequency()) {
if (req.getReqFrequency() <= 0) {
return Result.of_error("限流次数不能小于或者等于零");
}
}
if (StringUtils.isBlank(req.getSignType()) || "0".equals(req.getSignType())) {
return Result.of_error("加密类型错误!");
}
if (StringUtils.isNotBlank(req.getReqType())) {
if (null == fromAuthReqTypeEnum(req.getReqType())) {
return Result.of_error("限流类型不存在!");
}
}
String signStr = dataBankToken + req.getJoinType();
String signResult = Md5.encrypt(signStr, "");
if (!signResult.equals(req.getSign())) {
return Result.of_error("签名错误!");
}
String apiKey = getApiKey();
switch (req.getJoinType()) {
case "10006"://数据银行三方上传
saveDataBanker(req, apiKey, "3");
break;
case "10007"://数据银行数据包上传
if(StringUtils.isNotBlank(req.getFileLocation()))return Result.of_error("文件地址不存在!");
saveDataBanker(req, apiKey, "2");
break;
case "10008"://数据银行制作大数据表
saveDataBanker(req, apiKey, "1");
break;
default:
return Result.of_error("接入类型不存在!");
//校验文件夹信息
if (checkFileifExist(req.getFolderId(), req.getProjectId())) {
return Result.of_error("目标文件夹不存在!");
}
return Result.of_success(ResultMsg.INSERT_SUCCESS, apiKey);
}
/**
* 保存数据银行api信息并缓存
*
* @param req 请求参数
* @param apiKey apiKey
* @param apiType api类型
*/
private void saveDataBanker(MakeDataBankApiReq req, String apiKey, String apiType) {
ApiInterface apiInterface = saveApiInterFace(req, apiKey, apiType);
saveApiInterFaceCustom(req, apiKey, apiInterface.getId());
JSONObject object = new JSONObject();
object.put("targetUrl", req.getTargetUrl());
object.put("outputType", req.getOutputType());
object.put("reqMethod",req.getReqMethod());
saveObjOnRedis(apiInterface.getApiKey(), object);
}
/**
* 保存api基本信息
*
* @param req
* @param apiKey
* @param apiType
* @return
*/
private ApiInterface saveApiInterFace(MakeDataBankApiReq req,
String apiKey, String apiType) {
ApiInterface anInterface = new ApiInterface();
anInterface.setApiType(apiType);//数据银行制作大数据表
anInterface.setStatus(ProducerStatusTypeEnum.ISSUE.name());//发布
anInterface.setApiKey(apiKey);//apiKey
BeanUtils.copyProperties(req, anInterface);
if (apiInterfaceMapper.insert(anInterface) == 0) {
throw ResponseException.of(ResultCode.FAILURE, "保存api基本信息异常!");
//保存表字段信息
saveTableField(req);
if (null != req.getId()) {//更新
if (saveUpdateAPiBaseData(req) || saveUpdateApiExtendData(req)) {
throw ResponseException.of_error(ResultMsg.UPDATE_FAIL);
}
} else { //保存
if (saveApiExtendData(req) || saveApiBaseData(req)) {
throw ResponseException.of_error(ResultMsg.INSERT_FAIL);
}
}
return anInterface;
//保存缓存信息
saveObjOnRedis(req);
return Result.of_success(ResultMsg.INSERT_SUCCESS);
}
/**
* 保存APi扩展信息
* 数据表查询 && 保存表字段信息
*
* @param req
* @param apiKey
* @param interFaceId
* @return
*/
private ApiInterfaceCustom saveApiInterFaceCustom(MakeDataBankApiReq req, String apiKey,
Long interFaceId) {
ApiInterfaceCustom interfaceCustom = new ApiInterfaceCustom();
interfaceCustom.setApiKey(apiKey);
interfaceCustom.setApiInterfaceId(interFaceId);
BeanUtils.copyProperties(req, interfaceCustom);
if (apiInterfaceCustomMapper.insert(interfaceCustom) == 0) {
throw ResponseException.of(ResultCode.FAILURE, "保存api扩展信息异常!");
}
return interfaceCustom;
}
/**
* Api制作(实时接入)
*
* @param req
* @return
*/
@Override
public Result addRealCustomApi(MakeRealCustomApiReq req) {
return null;
}
/**
* DMP大数据查询/标签查询
*
* @param req
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Result addBigDataMakeApi(MakeBigDataApiReq req) {
ApiInterface apiInterface = apiInterfaceService.getApiInfo(req.getApiKey());
if (null == apiInterface) {
return Result.of_error("API基本信息为空!");
}
private void saveTableField(ApiInterfaceReq req) {
QueryWrapper<ApiOpenApiEsFields> queryOpenApi = new QueryWrapper<>();
queryOpenApi.eq("es_database", req.getEsDataBase());
queryOpenApi.eq("es_table", req.getEsTable());
......@@ -300,29 +239,6 @@ public class ProducerServiceImpl implements ProducerService {
if (CollectionUtils.isNotEmpty(listApiEsFields)) {
apiOpenApiEsFieldsMapper.insetBatch(listApiEsFields);
}
/* //调用dmp接口获取数据库连接信息
ApiSyncingDatasource dataSource = apiSyncingDatasourceMapper.selectById(req.getEsDataSource());
if (null != dataSource) {
//esjdbc 连接地址 用于接口中调用获取es数据
redisUtils.set(TagConstants.OPEN_API_ESTAG_JDBC_INFO_NAMESPACE + apiInterface.getApiKey(), dataSource.getJdbcUrl());
}*/
int result = 0;
ApiInterfaceCustom interfaceCustom = new ApiInterfaceCustom();
if (null != req.getId() && !"".equals(req.getId())) {//更新
BeanUtils.copyProperties(req, interfaceCustom);
interfaceCustom.setUpdateDate(new Date());
interfaceCustom.setUpdateUser(req.getCreateUser());
result = apiInterfaceCustomMapper.updateById(interfaceCustom);
} else { //保存
BeanUtils.copyProperties(req, interfaceCustom);
interfaceCustom.setCreateUser(req.getCreateUser());
interfaceCustom.setApiInterfaceId(apiInterface.getId());
result = apiInterfaceCustomMapper.insert(interfaceCustom);
}
if (result <= 0) {
return Result.of_error(ResultMsg.FAILURE);
}
return Result.of_success(ResultMsg.SUCCESS, req.getId());
}
/**
......@@ -339,176 +255,176 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_error("限流类型不存在!");
}
}
//生成ApiKey
String apiKey = getApiKey();
ApiInterface apiInterface = new ApiInterface();
/* if (null == req.getFileId()) {//创建下级文件夹
Long fileId = checkFileExist(req.getProjectId(), req.getParentId(), req.getCreateUser());
req.setFileId(fileId);
}*/
BeanUtils.copyProperties(req, apiInterface);
apiInterface.setApiKey(apiKey);
apiInterface.setApiProtocl(req.getTransMode());//传输方式 https http
apiInterface.setStatus(ApiStatusEnum.ISSUE.name());//发布
if ("10004".equals(req.getJoinType())) {//dmp自定义
apiInterface.setApiType("7");
} else if ("10002".equals(req.getJoinType())) {//大数据表查询
apiInterface.setApiType("6");
if (StringUtils.isBlank(req.getSignType()) || "0".equals(req.getSignType())) {
return Result.of_error("加密类型错误!");
}
Long timeout = Long.parseLong(req.getTimeout());
if (timeout == null || timeout == 0) {
apiInterface.setTimeout(String.valueOf(defaultTimeout));
} else if (timeout < 0) {
return Result.of_error("接口超时时间最小0ms");
} else if (timeout > maxTimeout) {
return Result.of_success("接口超时时间最大5000ms");
if (null != req.getReqFrequency()) {
if (req.getReqFrequency() <= 0) {
return Result.of_error("限流次数不能小于或者等于零");
}
}
if (apiInterfaceMapper.insert(apiInterface) == 0) {
throw ResponseException.of_error("保存Api信息失败!");
//校验文件夹信息
if (checkFileifExist(req.getFolderId(), req.getProjectId())) {
return Result.of_error("目标文件夹不存在!");
}
JSONObject object = new JSONObject();
object.put("targetUrl", req.getTargetUrl());
object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
saveObjOnRedis(apiInterface.getApiKey(), object);
return Result.of_success(ResultMsg.INSERT_SUCCESS, apiKey);
if (saveApiBaseData(req)) {
throw ResponseException.of_error("保存Api基本信息失败!");
}
if (saveApiExtendData(req)) {
throw ResponseException.of_error("保存Api扩展信息失败!");
}
//缓存API信息
saveObjOnRedis(req);
return Result.of_success(ResultMsg.INSERT_SUCCESS);
}
/**
* 缓存数据
* 保存APi扩展信息
*
* @param apiKey
* @param params
* @param req
* @return
*/
private void saveObjOnRedis(String apiKey, JSONObject params) {
if (StringUtils.isBlank(apiKey) || null == params) {
log.info("--------------缓存数据为空");
return;
}
try {
String paramKey = redisUtils.get(apiKey);
if (null != paramKey) {
redisUtils.del(apiKey);
}
redisUtils.set(apiKey, params.toString());
} catch (Exception ex) {
log.error("缓存api制作数据异常:{}", ex.getMessage());
ex.printStackTrace();
private boolean saveApiExtendData(ApiInterfaceReq req) {
ApiInterfaceCustom custom = new ApiInterfaceCustom();
BeanUtils.copyProperties(req, custom);
if (apiInterfaceCustomMapper.insert(custom) == 0) {
return true;
}
return false;
}
/**
* 校验文件夹信息
* 保存ApiInterfance基本信息
*
* @param projectId
* @param parentId
* @param userName
* @param req
* @return
*/
private Long checkFileExist(Long projectId, Long parentId, String userName) {
if (null == parentId) {
throw ResponseException.of_error("父文件id不能为空");
private boolean saveApiBaseData(ApiInterfaceReq req) {
ApiInterface apiInterface = new ApiInterface();
BeanUtils.copyProperties(req, apiInterface);
apiInterface.setStatus(ApiStatusEnum.DRAFT.name());//草稿状态
apiInterface.setOutputType(ApiInfoOutTypeEnum.JSON.name());//输出类型默认为Json
Long timeout = Long.parseLong(req.getTimeout());
if (timeout == null || timeout == 0) {
apiInterface.setTimeout(String.valueOf(defaultTimeout));
} else if (timeout < 0) {
throw ResponseException.of_error("接口超时时间最小0ms");
} else if (timeout > maxTimeout) {
throw ResponseException.of_error("接口超时时间最大5000ms");
}
if (null == projectId) {
throw ResponseException.of_error("项目id不能为空");
apiInterface.setTimeout(req.getTimeout());
if ("10002".equals(req.getJoinType())) {//数据表查询时添加
if (ApiInfoOutTypeEnum.JSON.name().equals(req.getOutType())) {
apiInterface.setTargetUrl(jsonUrl);
} else if (ApiInfoOutTypeEnum.FLOW.name().equals(req.getOutType())) {
apiInterface.setTargetUrl(flowUrl);
}
}
QueryWrapper<ApiInterfaceFile> query = new QueryWrapper<>();
query.eq("project_id", projectId);
query.eq("parent_id", parentId);
ApiInterfaceFile file = apiInterfaceFileMapper.selectOne(query);
if (null == file && 0 != parentId) {
throw ResponseException.of(ResultCode.FAILURE, "父类文件夹不存在!");
if (apiInterfaceMapper.insert(apiInterface) == 0) {
return true;
}
if (null == file) {
//查询父类是否存在
ApiInterfaceFile apiInterfaceFile =
apiInterfaceFileMapper.selectOne(new QueryWrapper<ApiInterfaceFile>().eq("parent_id", parentId));
if (null == apiInterfaceFile && 0 == parentId) {
file = new ApiInterfaceFile();
file.setProjectId(projectId);
file.setFileSource("1");//dmp
file.setParentId(0L);
file.setStatus(GeneralStatusTypeEnum.VALID.name());
file.setCreateUser(userName);
file.setRemark("创建文件夹");
if (apiInterfaceFileMapper.insert(file) == 0) {
throw ResponseException.of_error("创建文件夹失败!");
}
} else {
throw ResponseException.of(ResultCode.FAILURE, "父类文件信息不存在!");
}
return false;
}
/**
* 校验文件夹是否存在
*
* @param folderId
* @param projectId
*/
private Boolean checkFileifExist(Long folderId, Long projectId) {
if (null == folderId) {
return true;
}
return file.getId();
QueryWrapper<ApiInterfaceFile> queryWra = new QueryWrapper<>();
queryWra.eq("file_source", 1);//Api制作
queryWra.eq("project_id", projectId);
queryWra.eq("id", folderId);
queryWra.eq("is_deleted", 0);
ApiInterfaceFile apiInterfaceFile = apiInterfaceFileMapper.selectOne(queryWra);
if (null == apiInterfaceFile) {
return true;
}
return false;
}
/**
* 保存修改的api信息
* 保存修改的api基本信息
*
* @param req
* @return
*/
@Override
public Result saveUpdateAPiInfo(ApiInterfaceReq req) {
private Boolean saveUpdateAPiBaseData(ApiInterfaceReq req) {
ApiInterface apiInterface = apiInterfaceMapper.selectById(req.getId());
if (null == apiInterface) {
return Result.of_error(ResultMsg.DATA_NOT_FOUND);
}
if (StringUtils.isBlank(req.getSignType()) || "0".equals(req.getSignType())) {
return Result.of_error("加密类型错误!");
}
if (StringUtils.isNotBlank(req.getReqType())) {
if (null == fromAuthReqTypeEnum(req.getReqType())) {
return Result.of_error("限流类型不存在!");
}
}
if (StringUtils.isNotBlank(req.getStatus())) {
if (null == fromApiStatusName(req.getStatus())) {
return Result.of_error("更新状态不存在!");
}
throw ResponseException.of_error(ResultMsg.DATA_NOT_FOUND);
}
if (StringUtils.isNotBlank(req.getStatus())) {
if (!canChange(apiInterface.getStatus(), req.getStatus())) {
String errorMsg = String.format("api当前状态为%s不可变更为%s",
ApiStatusEnum.valueOf(apiInterface.getStatus()).getText(),
ApiStatusEnum.valueOf(req.getStatus()).getText());
return Result.of_error(errorMsg);
}
}
if (null != req.getReqFrequency()) {
if (req.getReqFrequency() <= 0) {
return Result.of_error("限流次数不能小于或者等于零");
throw ResponseException.of_error(errorMsg);
}
}
apiInterface.setApiType(req.getApiType());
apiInterface.setApiDesc(req.getApiDesc());
apiInterface.setReqType(req.getReqType());
apiInterface.setReqFrequency(req.getReqFrequency());
apiInterface.setVersion(RandomUtil.generateVersion(apiInterface.getVersion()));//版本自动累加
apiInterface.setSignType(req.getSignType());
apiInterface.setApiFunction(req.getApiFunction());
apiInterface.setStatus(req.getStatus());
apiInterface.setApiProtocl(req.getTransMode());//传输方式 https http
apiInterface.setApiProtocl(req.getApiProtocl());//传输方式 https http
apiInterface.setUpdateDate(new Date());
apiInterface.setUpdateUser(req.getCreateUser());
if (StringUtils.isNotBlank(req.getTargetUrl())) {
apiInterface.setTargetUrl(req.getTargetUrl());
}
apiInterface.setTargetUrl(req.getTargetUrl());
Long timeout = Long.parseLong(req.getTimeout());
if (timeout == null || timeout == 0) {
apiInterface.setTimeout(String.valueOf(defaultTimeout));
} else if (timeout < 0) {
return Result.of_error("接口超时时间最小0ms");
throw ResponseException.of_error("接口超时时间最小0ms");
} else if (timeout > maxTimeout) {
return Result.of_success("接口超时时间最大5000ms");
throw ResponseException.of_error("接口超时时间最大5000ms");
}
apiInterface.setTimeout(req.getTimeout());
if (apiInterfaceMapper.updateById(apiInterface) > 0) {
return Result.of_success(ResultMsg.UPDATE_SUCCESS);
if (apiInterfaceMapper.updateById(apiInterface) == 0) {
return true;
}
JSONObject object = new JSONObject();
object.put("targetUrl", req.getTargetUrl());
object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
saveObjOnRedis(apiInterface.getApiKey(), object);
return Result.of_success(ResultMsg.UPDATE_FAIL);
return false;
}
/**
* 保存更新数据扩展信息
*
* @param req
* @return
*/
private Boolean saveUpdateApiExtendData(ApiInterfaceReq req) {
ApiInterface apiInterface = apiInterfaceMapper.selectById(req.getId());
ApiInterfaceCustom interfaceCustom = null;
if (null != apiInterface) {
interfaceCustom = apiInterfaceCustomMapper.selectById(apiInterface.getApiCustomId());
}
if (null == interfaceCustom) {
throw ResponseException.of_error("更新API扩展信息不存在!");
}
interfaceCustom.setMaxRow(req.getMaxRow());
interfaceCustom.setPageRow(req.getPageRow());
interfaceCustom.setUpdateUser(req.getUpdateUser());
interfaceCustom.setRequestParam(req.getRequestParam());
interfaceCustom.setResponseParam(req.getResponseParam());
if (StringUtils.isNotBlank(req.getEsDataSource())) {
interfaceCustom.setEsDataSource(req.getEsDataSource());
}
if (StringUtils.isNotBlank(req.getEsDataBase())) {
interfaceCustom.setEsDataBase(req.getEsDataBase());
}
if (StringUtils.isNotBlank(req.getEsTable())) {
interfaceCustom.setEsTable(req.getEsTable());
}
if (apiInterfaceCustomMapper.updateById(interfaceCustom) == 0) {
return true;
}
return false;
}
/**
......@@ -539,11 +455,221 @@ public class ProducerServiceImpl implements ProducerService {
/**
* 获取不重复的apiKey
*
* @return
*/
private String getApiKey() {
String random = RandomUtil.getStringRandom(16);
QueryWrapper<ApiInterface> query = new QueryWrapper<>();
query.eq("api_key", random);
query.eq("is_deleted", 0);
ApiInterface apiInterface = apiInterfaceMapper.selectOne(query);
if (null != apiInterface) {
random = RandomUtil.getStringRandom(16);
}
return random;
}
/**
* 缓存数据
*
* @param req
*/
private void saveObjOnRedis(ApiInterfaceReq req) {
if (StringUtils.isBlank(req.getApiKey()) ||
StringUtils.isBlank(req.getOutType()) ||
StringUtils.isBlank(req.getTargetUrl()) ||
StringUtils.isBlank(req.getReqMethod())) {
log.info("--------------缓存数据为空");
return;
}
try {
JSONObject object = new JSONObject();
object.put("targetUrl", req.getTargetUrl());
object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
object.put("reqMethod", req.getReqMethod());
String apiKey = TagConstants.OPEN_API_CACHE_KEY + req.getApiKey();
String paramKey = redisUtils.get(apiKey);
if (null != paramKey) {
redisUtils.del(apiKey);
}
redisUtils.set(apiKey, object.toString());
} catch (Exception ex) {
log.error("缓存api制作数据异常:{}", ex.getMessage());
ex.printStackTrace();
}
}
/* *//**
* 数据银行制作API/数据包/自定义
*
* @param req
* @return
*//*
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Result addDataBankApiInfo(MakeDataBankApiReq req) {
*//* QueryWrapper<ApiInterfaceFile> query = new QueryWrapper<>();
query.eq("file_source", "2");
query.eq("is_deleted", 0);
List<ApiInterfaceFile> fileSource = apiInterfaceFileMapper.selectList(query);
if (fileSource.size() == 0 || fileSource.size() >= 2) {
return Result.of_error("文件夹信息异常!");
}*//*
if (StringUtils.isNotBlank(req.getOutputType())) {
if (!req.getOutputType().contains(ApiInfoOutTypeEnum.JSON.name()) ||
!req.getOutputType().contains(ApiInfoOutTypeEnum.FLOW.name())) {
return Result.of_error("输出类型不存在!");
}
}
if (StringUtils.isNotBlank(req.getReqType())) {
if (null == fromAuthReqTypeEnum(req.getReqType())) {
return Result.of_error("限流类型不存在!");
}
}
String signStr = dataBankToken + req.getJoinType();
String signResult = Md5.encrypt(signStr, "");
if (!signResult.equals(req.getSign())) {
return Result.of_error("签名错误!");
}
String apiKey = getApiKey();
switch (req.getJoinType()) {
case "10006"://数据银行三方上传
saveDataBanker(req, apiKey, "3");
break;
case "10007"://数据银行数据包上传
if (StringUtils.isNotBlank(req.getFileLocation())) return Result.of_error("文件地址不存在!");
saveDataBanker(req, apiKey, "2");
break;
case "10008"://数据银行制作大数据表
saveDataBanker(req, apiKey, "1");
break;
default:
return Result.of_error("接入类型不存在!");
}
return Result.of_success(ResultMsg.INSERT_SUCCESS, apiKey);
}*/
/* *//**
* 保存数据银行api信息并缓存
*
* @param req 请求参数
* @param apiKey apiKey
* @param apiType api类型
*//*
private void saveDataBanker(MakeDataBankApiReq req, String apiKey, String apiType) {
ApiInterface apiInterface = saveApiInterFace(req, apiKey, apiType);
saveApiInterFaceCustom(req, apiKey, apiInterface.getId());
JSONObject object = new JSONObject();
object.put("targetUrl", req.getTargetUrl());
object.put("outputType", req.getOutputType());
object.put("reqMethod", req.getReqMethod());
saveObjOnRedis(apiInterface.getApiKey(), object);
}*/
/* *//**
* 保存api基本信息
*
* @param req
* @param apiKey
* @param apiType
* @return
*//*
private ApiInterface saveApiInterFace(MakeDataBankApiReq req,
String apiKey, String apiType) {
ApiInterface anInterface = new ApiInterface();
anInterface.setApiType(apiType);//数据银行制作大数据表
anInterface.setStatus(ProducerStatusTypeEnum.ISSUE.name());//发布
anInterface.setApiKey(apiKey);//apiKey
BeanUtils.copyProperties(req, anInterface);
if (apiInterfaceMapper.insert(anInterface) == 0) {
throw ResponseException.of(ResultCode.FAILURE, "保存api基本信息异常!");
}
return anInterface;
}*/
/* *//**
* 保存APi扩展信息
*
* @param req
* @param apiKey
* @param interFaceId
* @return
*//*
private ApiInterfaceCustom saveApiInterFaceCustom(MakeDataBankApiReq req, String apiKey,
Long interFaceId) {
ApiInterfaceCustom interfaceCustom = new ApiInterfaceCustom();
interfaceCustom.setApiKey(apiKey);
interfaceCustom.setApiInterfaceId(interFaceId);
BeanUtils.copyProperties(req, interfaceCustom);
if (apiInterfaceCustomMapper.insert(interfaceCustom) == 0) {
throw ResponseException.of(ResultCode.FAILURE, "保存api扩展信息异常!");
}
return interfaceCustom;
}*/
/* *//**
* Api制作(实时接入)
*
* @param req
* @return
*//*
@Override
public Result addRealCustomApi(MakeRealCustomApiReq req) {
return null;
}*/
/* *//**
* 校验文件夹信息
*
* @param projectId
* @param parentId
* @param userName
* @return
*//*
private Long checkFileExist(Long projectId, Long parentId, String userName) {
if (null == parentId) {
throw ResponseException.of_error("父文件id不能为空");
}
if (null == projectId) {
throw ResponseException.of_error("项目id不能为空");
}
QueryWrapper<ApiInterfaceFile> query = new QueryWrapper<>();
query.eq("project_id", projectId);
query.eq("parent_id", parentId);
ApiInterfaceFile file = apiInterfaceFileMapper.selectOne(query);
if (null == file && 0 != parentId) {
throw ResponseException.of(ResultCode.FAILURE, "父类文件夹不存在!");
}
if (null == file) {
//查询父类是否存在
ApiInterfaceFile apiInterfaceFile =
apiInterfaceFileMapper.selectOne(new QueryWrapper<ApiInterfaceFile>().eq("parent_id", parentId));
if (null == apiInterfaceFile && 0 == parentId) {
file = new ApiInterfaceFile();
file.setProjectId(projectId);
file.setFileSource("1");//dmp
file.setParentId(0L);
file.setStatus(GeneralStatusTypeEnum.VALID.name());
file.setCreateUser(userName);
file.setRemark("创建文件夹");
if (apiInterfaceFileMapper.insert(file) == 0) {
throw ResponseException.of_error("创建文件夹失败!");
}
} else {
throw ResponseException.of(ResultCode.FAILURE, "父类文件信息不存在!");
}
}
return file.getId();
}
*/
/* *//**
* 获取数据源配置
*
* @param req
* @return
*/
*//*
@Override
public Result getSourceConfig(SourceConfigReq req) {
if (StringUtils.isBlank(req.getApiKey())) {
......@@ -566,12 +692,12 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_success(ResultMsg.SUCCESS);
}
/**
*//**
* 获取数据源库配置
*
* @param id
* @return
*/
*//*
@Override
public Result getSourceWarehouseList(Long id) {
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
......@@ -597,13 +723,13 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_success(result);
}
/**
*//**
* 获取某个索引下的type
*
* @param indices
* @param id
* @return
*/
*//*
@Override
public Result getIndicesTypes(String indices, Long id) {
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
......@@ -619,14 +745,14 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_success(resp);
}
/**
*//**
* 获取某个索引 type的fields
*
* @param indices
* @param type
* @param id
* @return
*/
*//*
@Override
public Result getIndicesTypesFields(String indices, String type, Long id) {
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
......@@ -648,31 +774,15 @@ public class ProducerServiceImpl implements ProducerService {
e.printStackTrace();
}
return Result.of_success(resp);
}
}*/
/**
* 获取不重复的apiKey
*
* @return
*/
private String getApiKey() {
String random = RandomUtil.getStringRandom(16);
QueryWrapper<ApiInterface> query = new QueryWrapper<>();
query.eq("api_key", random);
query.eq("is_deleted", 0);
ApiInterface apiInterface = apiInterfaceMapper.selectOne(query);
if (null != apiInterface) {
random = RandomUtil.getStringRandom(16);
}
return random;
}
@Override
/* @Override
public Result saveObjOnRedis() {
MakeDataBankApiReq bankApiReq = new MakeDataBankApiReq();
/* bankApiReq.setTransMode("HTTPS");
*//* bankApiReq.setTransMode("HTTPS");
bankApiReq.setSignType("MD5");
bankApiReq.setJoinType("10004");
bankApiReq.setOutputType("JSON");
......@@ -685,7 +795,7 @@ public class ProducerServiceImpl implements ProducerService {
bankApiReq.setApiDesc("4444");
bankApiReq.setTimeout("5000");
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(bankApiReq);
redisUtils.set("apiKeyTest", jsonObject, 300);*/
redisUtils.set("apiKeyTest", jsonObject, 300);*//*
JSONObject object = new JSONObject();
object.put("targetUrl", "www.baidu.common");
object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
......@@ -700,5 +810,5 @@ public class ProducerServiceImpl implements ProducerService {
JSONObject jsonObject = JSONObject.parseObject(apiKeyTest002);
System.out.println(jsonObject);
return Result.ok();
}
}*/
}
......@@ -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,16 @@ 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
......
......@@ -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());*/
}
/**
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
/**
......@@ -15,16 +16,24 @@ import java.util.stream.Collectors;
*/
public class TestStr {
public static void main(String[] args) {
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);
}
Random ran = new Random();
int num = ran.nextInt(999999);
String str = String.format("%06d", num);
System.out.println(str);
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);
}
}
/**
* 获取集合信息
*/
......
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