Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dm_project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
dm_project
Commits
da3c8b94
Commit
da3c8b94
authored
Jan 29, 2021
by
ysongq
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dm_dev' into dm_dev
parents
deb9ea2e
86d6f621
Changes
54
Hide whitespace changes
Inline
Side-by-side
Showing
54 changed files
with
2142 additions
and
899 deletions
+2142
-899
api_gateway.sql
database/zc/api_gateway.sql
+13
-15
TagConstants.java
...src/main/java/com/jz/dm/common/constant/TagConstants.java
+6
-0
GatewayResultCode.java
...c/main/java/com/jz/dm/common/enums/GatewayResultCode.java
+9
-1
AuthTypeEnum.java
...c/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
+1
-1
DateUtil.java
...gateway/src/main/java/com/jz/dm/common/util/DateUtil.java
+18
-0
RandomUtil.java
...teway/src/main/java/com/jz/dm/common/util/RandomUtil.java
+5
-0
HttpDownload.java
.../main/java/com/jz/dm/common/util/stream/HttpDownload.java
+108
-6
ApiInterfaceController.java
...ain/java/com/jz/dm/controller/ApiInterfaceController.java
+29
-12
AuthController.java
...ay/src/main/java/com/jz/dm/controller/AuthController.java
+10
-0
GatewayController.java
...src/main/java/com/jz/dm/controller/GatewayController.java
+3
-1
OrganizationManageController.java
...va/com/jz/dm/controller/OrganizationManageController.java
+0
-10
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+77
-43
AuthFilter.java
...apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
+28
-18
FilterChainImpl.java
...teway/src/main/java/com/jz/dm/filter/FilterChainImpl.java
+6
-5
VerifySignFilter.java
...eway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
+24
-20
DefaultOpenApiDispatcher.java
...main/java/com/jz/dm/gateway/DefaultOpenApiDispatcher.java
+8
-8
ApiInterfaceMapper.java
...ay/src/main/java/com/jz/dm/mapper/ApiInterfaceMapper.java
+27
-1
ApiAuth.java
...ateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
+9
-0
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+16
-32
ApiInterfaceCustom.java
...main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
+14
-0
ApiInterfaceFile.java
...c/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
+1
-7
ApiOrg.java
...gateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
+7
-0
ApiServiceApplyDto.java
...rc/main/java/com/jz/dm/models/dto/ApiServiceApplyDto.java
+44
-0
GatewayRequest.java
.../src/main/java/com/jz/dm/models/enity/GatewayRequest.java
+4
-0
AuthUserApiReq.java
...c/main/java/com/jz/dm/models/req/auth/AuthUserApiReq.java
+2
-2
ServiceAuthReq.java
...c/main/java/com/jz/dm/models/req/auth/ServiceAuthReq.java
+30
-0
CreateFolderReq.java
...ain/java/com/jz/dm/models/req/folder/CreateFolderReq.java
+40
-0
MakeBigDataApiReq.java
...ain/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
+0
-83
OrganizationManageAddReq.java
...dels/req/organizationManage/OrganizationManageAddReq.java
+15
-9
OrganizationManageListQueryReq.java
...eq/organizationManage/OrganizationManageListQueryReq.java
+5
-0
ApiInterfaceReq.java
...n/java/com/jz/dm/models/req/producer/ApiInterfaceReq.java
+113
-0
MakeBigDataApiReq.java
...java/com/jz/dm/models/req/producer/MakeBigDataApiReq.java
+81
-0
MakeDataBankApiReq.java
...ava/com/jz/dm/models/req/producer/MakeDataBankApiReq.java
+18
-7
MakeRealCustomApiReq.java
...a/com/jz/dm/models/req/producer/MakeRealCustomApiReq.java
+1
-1
ServiceIssueReq.java
...n/java/com/jz/dm/models/req/producer/ServiceIssueReq.java
+31
-0
SourceConfigReq.java
...n/java/com/jz/dm/models/req/producer/SourceConfigReq.java
+1
-1
ApiInterfaceService.java
.../src/main/java/com/jz/dm/service/ApiInterfaceService.java
+27
-6
AuthService.java
...igateway/src/main/java/com/jz/dm/service/AuthService.java
+7
-0
OrganizationManageService.java
...ain/java/com/jz/dm/service/OrganizationManageService.java
+0
-6
ProducerService.java
...eway/src/main/java/com/jz/dm/service/ProducerService.java
+45
-28
ApiInterfaceServiceImpl.java
.../java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
+70
-25
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+50
-32
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+98
-96
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+510
-304
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+247
-54
ApiQueryTestService.java
...n/java/com/jz/dm/service/request/ApiQueryTestService.java
+93
-0
SystemLogAspect.java
...y/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
+34
-30
application-test.yml
jz-dm-apigateway/src/main/resources/application-test.yml
+18
-11
ApiInterfaceMapper.xml
...igateway/src/main/resources/mapper/ApiInterfaceMapper.xml
+39
-6
ApiReqTest.java
...teway/src/test/java/com/jz/dm/gateway/api/ApiReqTest.java
+3
-4
TestOrganizationManage.java
...st/java/com/jz/dm/gateway/org/TestOrganizationManage.java
+2
-4
TestRedisUserSave.java
...test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
+3
-3
TestStr.java
...teway/src/test/java/com/jz/dm/gateway/orther/TestStr.java
+90
-5
TestStreamReq.java
...src/test/java/com/jz/dm/gateway/orther/TestStreamReq.java
+2
-2
No files found.
database/zc/api_gateway.sql
View file @
da3c8b94
...
@@ -4,24 +4,20 @@ CREATE TABLE `t_api_interface` (
...
@@ -4,24 +4,20 @@ CREATE TABLE `t_api_interface` (
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api 信息表自增ID'
,
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api 信息表自增ID'
,
`api_key`
varchar
(
200
)
NOT
NULL
COMMENT
'api唯一标识'
,
`api_key`
varchar
(
200
)
NOT
NULL
COMMENT
'api唯一标识'
,
`api_name`
varchar
(
100
)
DEFAULT
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_protocl`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'api请求协议:http,https'
,
`api_path`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'请求地址'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`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
'接口功能'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`test_example`
varchar
(
255
)
NULL
DEFAULT
NULL
COMMENT
'测试实例'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`output_type`
varchar
(
50
)
NULL
DEFAULT
'JSON'
COMMENT
'输出类型:flow 流形式输出, json格式输出'
,
`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
'版本号'
,
`version`
varchar
(
20
)
DEFAULT
'v1.0'
COMMENT
'版本号'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`file_id`
bigint
(
20
)
NO
T
NULL
COMMENT
'文件夹id'
,
`file_id`
bigint
(
20
)
DEFAUL
T
NULL
COMMENT
'文件夹id'
,
`
req
_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限流类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`
limit
_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限流类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`req_frequency`
bigint
(
20
)
DEFAULT
'100'
COMMENT
'限制次数'
,
`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
'备注'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
...
@@ -37,24 +33,24 @@ DROP TABLE IF EXISTS `t_api_interface_custom`;
...
@@ -37,24 +33,24 @@ DROP TABLE IF EXISTS `t_api_interface_custom`;
CREATE
TABLE
`t_api_interface_custom`
(
CREATE
TABLE
`t_api_interface_custom`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api 信息表自增ID'
,
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api 信息表自增ID'
,
`api_key`
varchar
(
200
)
NOT
NULL
COMMENT
'api唯一标识'
,
`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自定义'
,
`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_source`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'数据源id'
,
`es_data_base`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'源数据库名称'
,
`es_data_base`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'源数据库名称'
,
`es_table`
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
'请求参数'
,
`request_param`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求参数'
,
`response_param`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应参数'
,
`response_param`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应参数'
,
`req_headers`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求头'
,
`req_headers`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求头'
,
`resp_code`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应状态码'
,
`resp_code`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应状态码'
,
`api_example`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api返回样例'
,
`api_example`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api返回样例'
,
`inbox_param`
varchar
(
300
)
NULL
DEFAULT
NULL
COMMENT
'固定参数'
,
`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_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
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`
),
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`API_ID_UNIQ_INDEX`
(
`api_interface_id`
)
USING
BTREE
UNIQUE
KEY
`API_ID_UNIQ_INDEX`
(
`api_interface_id`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api自定义信息表'
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api自定义信息表'
;
...
@@ -64,7 +60,7 @@ DROP TABLE IF EXISTS `t_api_interface_file`;
...
@@ -64,7 +60,7 @@ DROP TABLE IF EXISTS `t_api_interface_file`;
CREATE
TABLE
`t_api_interface_file`
(
CREATE
TABLE
`t_api_interface_file`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api文件表自增ID'
,
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api文件表自增ID'
,
`project_id`
bigint
(
20
)
NOT
NULL
COMMENT
'项目编号'
,
`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_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件名称'
,
`file_en_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件英文名称'
,
`file_en_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件英文名称'
,
`parent_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'父类id'
,
`parent_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'父类id'
,
...
@@ -91,6 +87,7 @@ CREATE TABLE `t_api_org` (
...
@@ -91,6 +87,7 @@ CREATE TABLE `t_api_org` (
`org_type`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织类型:OUT 外部组织, IN 内部组织'
,
`org_type`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织类型:OUT 外部组织, IN 内部组织'
,
`status`
tinyint
(
2
)
DEFAULT
'1'
COMMENT
'状态: 0- 注销 1- 正常'
,
`status`
tinyint
(
2
)
DEFAULT
'1'
COMMENT
'状态: 0- 注销 1- 正常'
,
`org_mail`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织邮箱'
,
`org_mail`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织邮箱'
,
`org_folder_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'组织所在文件夹id'
,
`org_sort`
int
(
10
)
DEFAULT
'999'
COMMENT
'组织排序'
,
`org_sort`
int
(
10
)
DEFAULT
'999'
COMMENT
'组织排序'
,
`parent_id`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'父类组织编码'
,
`parent_id`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'父类组织编码'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
...
@@ -118,6 +115,7 @@ CREATE TABLE `t_api_auth` (
...
@@ -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 永久有效'
,
`auth_mode`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效'
,
`valid_start_time`
datetime
DEFAULT
NULL
COMMENT
'开始时间'
,
`valid_start_time`
datetime
DEFAULT
NULL
COMMENT
'开始时间'
,
`valid_end_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 已处理'
,
`handler`
tinyint
(
2
)
NULL
DEFAULT
'0'
COMMENT
'处理状态:0 未处理, 1 已处理'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(VALID-正常 UN_VALID-无效)'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(VALID-正常 UN_VALID-无效)'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/constant/TagConstants.java
View file @
da3c8b94
...
@@ -30,4 +30,10 @@ public class TagConstants {
...
@@ -30,4 +30,10 @@ public class TagConstants {
//redis限流相关
//redis限流相关
public
static
final
String
OPEN_API_REDIS_LIMIT_KEY
=
"jz:openapi:redis:limit:"
;
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:"
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/GatewayResultCode.java
View file @
da3c8b94
...
@@ -37,7 +37,6 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -37,7 +37,6 @@ public enum GatewayResultCode implements ResultCode {
ILLEGAL_TIMETEMP
(
"ILLEGAL_TIMETEMP"
,
"无效时间戳"
),
ILLEGAL_TIMETEMP
(
"ILLEGAL_TIMETEMP"
,
"无效时间戳"
),
/** 请求次数受限 */
/** 请求次数受限 */
REQUEST_LIMIT_EXCEPTION
(
"REQUEST_LIMIT_EXCEPTION"
,
"请求次数受限"
),
REQUEST_LIMIT_EXCEPTION
(
"REQUEST_LIMIT_EXCEPTION"
,
"请求次数受限"
),
...
@@ -60,6 +59,12 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -60,6 +59,12 @@ public enum GatewayResultCode implements ResultCode {
/** API状态异常 */
/** API状态异常 */
API_STATUS_EXCEPTION
(
"API_STATUS_EXCEPTION"
,
"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"
,
"请求组织状态异常"
),
ORG_STATE_EXCEPTION
(
"ORG_STATE_EXCEPTION"
,
"请求组织状态异常"
),
/** 请求信息不存在 */
/** 请求信息不存在 */
...
@@ -70,6 +75,9 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -70,6 +75,9 @@ public enum GatewayResultCode implements ResultCode {
/** 单次调用金额不足 */
/** 单次调用金额不足 */
CALL_AMOUNT_NOT_ENOUGH
(
"CALL_AMOUNT_NOT_ENOUGH"
,
"单次调用金额不足"
),
CALL_AMOUNT_NOT_ENOUGH
(
"CALL_AMOUNT_NOT_ENOUGH"
,
"单次调用金额不足"
),
/** 认证API已过有效期 */
AUTH_EXCEED_TIME
(
"AUTH_EXCEED_TIME"
,
"认证API已过有效期"
),
/** 输出类型错误 */
/** 输出类型错误 */
OUTPUT_TYPE_EXCEPTION
(
"OUTPUT_TYPE_EXCEPTION"
,
"输出类型错误!"
);
OUTPUT_TYPE_EXCEPTION
(
"OUTPUT_TYPE_EXCEPTION"
,
"输出类型错误!"
);
/**
/**
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
View file @
da3c8b94
...
@@ -30,7 +30,7 @@ public enum AuthTypeEnum {
...
@@ -30,7 +30,7 @@ public enum AuthTypeEnum {
return
text
;
return
text
;
}
}
public
static
AuthTypeEnum
fromTypeName
(
String
typeName
)
{
public
static
AuthTypeEnum
from
Auth
TypeName
(
String
typeName
)
{
for
(
AuthTypeEnum
type
:
AuthTypeEnum
.
values
())
{
for
(
AuthTypeEnum
type
:
AuthTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
return
type
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/DateUtil.java
View file @
da3c8b94
...
@@ -43,6 +43,24 @@ public class DateUtil {
...
@@ -43,6 +43,24 @@ public class DateUtil {
c
.
set
(
Calendar
.
SECOND
,
59
);
c
.
set
(
Calendar
.
SECOND
,
59
);
return
(
c
.
getTimeInMillis
()
-
System
.
currentTimeMillis
())
/
1000
;
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
)
{
public
static
void
main
(
String
[]
args
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//System.out.println(calculateNowResidueTime());
//System.out.println(calculateNowResidueTime());
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/RandomUtil.java
View file @
da3c8b94
...
@@ -125,6 +125,11 @@ public class RandomUtil {
...
@@ -125,6 +125,11 @@ public class RandomUtil {
builder
.
append
(
userNum
);
builder
.
append
(
userNum
);
}
}
coding
=
getCodeInfo
(
userId
,
coding
,
builder
,
month
,
day
,
hour
,
minute
,
second
);
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
;
return
coding
;
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/stream/HttpDownload.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
common
.
util
.
stream
;
package
com
.
jz
.
dm
.
common
.
util
.
stream
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.*
;
import
org.apache.http.*
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
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
org.apache.http.impl.client.CloseableHttpClient
;
import
java.io.File
;
import
java.io.File
;
...
@@ -14,6 +19,7 @@ import java.text.MessageFormat;
...
@@ -14,6 +19,7 @@ import java.text.MessageFormat;
import
static
com
.
jz
.
common
.
utils
.
HttpClientPool
.
getHttpClient
;
import
static
com
.
jz
.
common
.
utils
.
HttpClientPool
.
getHttpClient
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.sentinel.project.util
* @PACKAGE_NAME: com.sentinel.project.util
...
@@ -48,8 +54,90 @@ public class HttpDownload {
...
@@ -48,8 +54,90 @@ public class HttpDownload {
* @param url
* @param url
* @return
* @return
*/
*/
public
static
void
download
(
String
url
)
{
public
static
void
getDownload
(
String
url
)
{
download
(
url
,
null
);
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 {
...
@@ -81,8 +169,8 @@ public class HttpDownload {
}
}
if
(
filepath
!=
null
)
{
if
(
filepath
!=
null
)
{
fileName
=
filepath
+
splash
+
fileName
;
fileName
=
filepath
+
splash
+
fileName
;
}
else
{
}
else
{
fileName
=
splash
+
fileName
;
fileName
=
splash
+
fileName
;
}
}
File
file
=
new
File
(
fileName
);
File
file
=
new
File
(
fileName
);
file
.
getParentFile
().
mkdirs
();
file
.
getParentFile
().
mkdirs
();
...
@@ -185,8 +273,22 @@ public class HttpDownload {
...
@@ -185,8 +273,22 @@ public class HttpDownload {
String
docx
=
"http://192.168.1.140:8090/api/download/docx"
;
String
docx
=
"http://192.168.1.140:8090/api/download/docx"
;
String
pdf
=
"http://192.168.1.140:8090/api/download/pdf"
;
String
pdf
=
"http://192.168.1.140:8090/api/download/pdf"
;
String
xlsx
=
"http://192.168.1.140:8090/api/download/xlsx"
;
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"
;
postDownloadFolder
(
postDownload
,
jsonObject
,
null
);
HttpDownload
.
download
(
xlsx
,
filepath
);
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiInterfaceController.java
View file @
da3c8b94
...
@@ -31,18 +31,26 @@ public class ApiInterfaceController {
...
@@ -31,18 +31,26 @@ public class ApiInterfaceController {
/**
/**
* @Description:API列表查询
* @Description:API列表查询
* @return: API列表
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-24
* @Date: 2020-12-24
*/
*/
@ApiOperation
(
"API列表查询"
)
@ApiOperation
(
"API
---(已调用列表)
列表查询"
)
@PostMapping
(
value
=
"/listApiInterface"
)
@PostMapping
(
value
=
"/listApiInterface"
)
public
Mono
<
Result
>
getApiInterfaceCallList
(
@RequestBody
@Valid
ApiInterfaceInfoListReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiInterfaceService
.
listCallApiInterface
(
req
)));
}
/**
* @Description:API列表查询
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"API---(未调用列表)列表查询"
)
@PostMapping
(
value
=
"/listUnCallApiInterface"
)
public
Mono
<
Result
>
getApiInterfaceList
(
@RequestBody
@Valid
ApiInterfaceInfoListReq
req
)
{
public
Mono
<
Result
>
getApiInterfaceList
(
@RequestBody
@Valid
ApiInterfaceInfoListReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiInterfaceService
.
listApiInterface
(
req
)));
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiInterfaceService
.
list
UnCall
ApiInterface
(
req
)));
}
}
/**
/**
* @Description:API详情查询
* @Description:API详情查询
* @return: API详情查询
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-24
* @Date: 2020-12-24
*/
*/
...
@@ -53,7 +61,6 @@ public class ApiInterfaceController {
...
@@ -53,7 +61,6 @@ public class ApiInterfaceController {
}
}
/**
/**
* @Description:API删除
* @Description:API删除
* @return: API删除
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-24
* @Date: 2020-12-24
*/
*/
...
@@ -64,7 +71,6 @@ public class ApiInterfaceController {
...
@@ -64,7 +71,6 @@ public class ApiInterfaceController {
}
}
/**
/**
* @Description:DMP-API删除
* @Description:DMP-API删除
* @return: DMP-API删除
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-24
* @Date: 2020-12-24
*/
*/
...
@@ -74,16 +80,27 @@ public class ApiInterfaceController {
...
@@ -74,16 +80,27 @@ public class ApiInterfaceController {
@RequestParam
(
name
=
"apiKey"
)
String
apiKey
)
{
@RequestParam
(
name
=
"apiKey"
)
String
apiKey
)
{
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
dmpDeleteAuth
(
type
,
apiKey
));
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
dmpDeleteAuth
(
type
,
apiKey
));
}
}
/**
* @Description:数据修改发送状态接口
* @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测试调用
* @Description: 已发送到数据银行API列表
* @return: DMP-API删除
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-24
* @Date: 2020-12-24
*/
*/
@ApiOperation
(
"API调用测试接口"
)
@ApiOperation
(
"已发送到数据银行API列表"
)
@GetMapping
(
value
=
"/apiTestApiInterface"
)
@GetMapping
(
value
=
"/listSendDataBank"
)
public
Mono
<
Result
>
apiTestApiInterface
(
@RequestParam
(
name
=
"apiKey"
)
String
apiKey
)
{
public
Mono
<
Result
>
listSendDataBank
(
@RequestParam
(
name
=
"pageNum"
,
defaultValue
=
"1"
,
required
=
false
)
String
pageNum
,
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
apiTestInterface
(
apiKey
));
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"20"
,
required
=
false
)
String
pageSize
)
{
return
Mono
.
fromSupplier
(()
->
apiInterfaceService
.
getSendDataBankList
(
pageNum
,
pageSize
));
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/AuthController.java
View file @
da3c8b94
...
@@ -29,6 +29,16 @@ public class AuthController {
...
@@ -29,6 +29,16 @@ public class AuthController {
@Autowired
@Autowired
private
AuthService
authService
;
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认证
* @Description:商城用户API认证
* @return: 商城用户API认证
* @return: 商城用户API认证
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/GatewayController.java
View file @
da3c8b94
...
@@ -12,6 +12,7 @@ import io.swagger.annotations.Api;
...
@@ -12,6 +12,7 @@ import io.swagger.annotations.Api;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
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.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -32,7 +33,8 @@ public class GatewayController {
...
@@ -32,7 +33,8 @@ public class GatewayController {
@Autowired
@Autowired
private
GatewayService
gatewayService
;
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
,
public
String
gateway
(
@RequestBody
String
json
,
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
)
{
HttpServletResponse
httpServletResponse
)
{
GatewayRequest
gatewayRequest
=
JSON
.
parseObject
(
json
,
GatewayRequest
.
class
);
GatewayRequest
gatewayRequest
=
JSON
.
parseObject
(
json
,
GatewayRequest
.
class
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/OrganizationManageController.java
View file @
da3c8b94
...
@@ -62,16 +62,6 @@ public class OrganizationManageController {
...
@@ -62,16 +62,6 @@ public class OrganizationManageController {
public
Mono
<
Result
>
add
(
@RequestBody
@Valid
OrganizationManageAddReq
req
)
{
public
Mono
<
Result
>
add
(
@RequestBody
@Valid
OrganizationManageAddReq
req
)
{
return
Mono
.
fromSupplier
(()
->
organizationManageService
.
add
(
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:注销组织
* @Description:注销组织
* @Author: Mr.zhang
* @Author: Mr.zhang
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ProducerController.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
controller
;
package
com
.
jz
.
dm
.
controller
;
import
com.jz.common.utils.Result
;
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
com.jz.dm.service.ProducerService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -46,115 +48,147 @@ public class ProducerController {
...
@@ -46,115 +48,147 @@ public class ProducerController {
*/
*/
@ApiOperation
(
"创建项目文件夹"
)
@ApiOperation
(
"创建项目文件夹"
)
@PostMapping
(
value
=
"/createProjectFolder"
)
@PostMapping
(
value
=
"/createProjectFolder"
)
public
Mono
<
Result
>
createProjectFolder
(
@RequestParam
(
name
=
"projectId"
)
Long
projectId
,
public
Mono
<
Result
>
createProjectFolder
(
@RequestBody
@Valid
CreateFolderReq
req
)
{
@RequestParam
(
name
=
"parentId"
)
Long
parentId
,
return
Mono
.
fromSupplier
(()
->
producerService
.
createProjectFolder
(
req
));
@RequestParam
(
name
=
"currentUser"
)
String
currentUser
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
createProjectFolder
(
projectId
,
parentId
,
currentUser
));
}
}
/**
/**
* @Description:
Api制作(自定义DMP)
* @Description:
服务发布列表
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
@ApiOperation
(
"
Api制作(自定义DMP)
"
)
@ApiOperation
(
"
服务发布列表
"
)
@PostMapping
(
value
=
"/
addCustomApi
"
)
@PostMapping
(
value
=
"/
getServiceIssueList
"
)
public
Mono
<
Result
>
makeCustomApi
(
@RequestBody
@Valid
ApiInterfac
eReq
req
)
{
public
Mono
<
Result
>
getServiceIssueList
(
@RequestBody
@Valid
ServiceIssu
eReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addCustomApi
(
req
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
getServiceIssueList
(
req
));
}
}
/**
/**
* @Description:
Api制作(数据银行)
* @Description:
服务发布/服务取消
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
@ApiOperation
(
"Api制作(数据银行)"
)
@ApiOperation
(
"服务发布/服务取消"
)
@PostMapping
(
value
=
"/addDataBankApiInfo"
)
@GetMapping
(
value
=
"/optionApiIssueStatus"
)
public
Mono
<
Result
>
addDataBankApiInfo
(
@RequestBody
@Valid
MakeDataBankApiReq
req
)
{
public
Mono
<
Result
>
optionApiIssueStatus
(
@RequestParam
(
name
=
"id"
)
Long
id
,
return
Mono
.
fromSupplier
(()
->
producerService
.
addDataBankApiInfo
(
req
));
@RequestParam
(
name
=
"optStatus"
)
Boolean
optStatus
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
optionApiIssueStatus
(
id
,
optStatus
));
}
}
/**
/**
* @Description:
Api制作(实时接入)
* @Description:
获取APIID
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
@ApiOperation
(
"Api制作(
实时接入
)"
)
@ApiOperation
(
"Api制作(
获取ApiId
)"
)
@PostMapping
(
value
=
"/
realMakeApi
"
)
@PostMapping
(
value
=
"/
getCustomApiId
"
)
public
Mono
<
Result
>
realCustomApi
(
@RequestBody
@Valid
MakeRealCustomApiReq
req
)
{
public
Mono
<
Result
>
getCustomApiId
(
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addRealCustomApi
(
req
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
getCustomApiId
(
));
}
}
/**
/**
* @Description:Api制作(大数据查询/标签查询)
* @Description:Api制作(第三方)
* @return:
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
@ApiOperation
(
"Api制作(
大数据查询/标签查询
)"
)
@ApiOperation
(
"Api制作(
第三方
)"
)
@PostMapping
(
value
=
"/
makeBigData
Api"
)
@PostMapping
(
value
=
"/
addCustom
Api"
)
public
Mono
<
Result
>
bigDataMakeApi
(
@RequestBody
@Valid
MakeBigDataApi
Req
req
)
{
public
Mono
<
Result
>
makeCustomApi
(
@RequestBody
@Valid
ApiInterface
Req
req
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
addBigDataMakeApi
(
req
));
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
saveInterfaceAPi
(
req
)
));
}
}
/**
/**
* @Description:保存API基本信息/自定义API
* @Description:Api制作(数据查询/标签查询)
* @return: (保存API基本信息)
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
@ApiOperation
(
"
保存API基本信息
"
)
@ApiOperation
(
"
Api制作(数据查询/标签查询)
"
)
@PostMapping
(
value
=
"/
saveInterface
"
)
@PostMapping
(
value
=
"/
addDataTableSelect
"
)
public
Mono
<
Result
>
saveInsetInterface
(
@RequestBody
@Valid
ApiInterfaceReq
req
)
{
public
Mono
<
Result
>
bigDataMakeApi
(
@RequestBody
@Valid
ApiInterfaceReq
req
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
saveInterfaceAP
i
(
req
));
return
Mono
.
fromSupplier
(()
->
producerService
.
addBigDataMakeAp
i
(
req
));
}
}
/**
/**
* @Description:Api制作(大数据查询/标签查询)保存修改的api信息
* @Description:Api制作(大数据查询/标签查询)保存修改的api信息
* @return: (自定义更新同时使用)
* @return: (自定义更新同时使用)
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
@ApiOperation
(
"保存修改的api信息"
)
/*
@ApiOperation("保存修改的api信息")
@PostMapping(value = "/saveUpdate")
@PostMapping(value = "/saveUpdate")
public Mono<Result> saveUpdateAPiInfo(@RequestBody @Valid ApiInterfaceReq req) {
public Mono<Result> saveUpdateAPiInfo(@RequestBody @Valid ApiInterfaceReq req) {
return Mono.fromSupplier(() -> producerService.saveUpdateAPiInfo(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:获取数据源配置
* @Description:获取数据源配置
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
/*
@ApiOperation("获取数据源配置")
@ApiOperation("获取数据源配置")
@PostMapping(value = "/getSourceConfig")
@PostMapping(value = "/getSourceConfig")
public Mono<Result> getSourceConfig(@RequestBody @Valid SourceConfigReq req) {
public Mono<Result> getSourceConfig(@RequestBody @Valid SourceConfigReq req) {
return Mono.fromSupplier(() -> producerService.getSourceConfig(req));
return Mono.fromSupplier(() -> producerService.getSourceConfig(req));
}
}
/**
*/
/**
* @Description:获取索引
* @Description:获取索引
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
/*
@ApiOperation("获取索引")
@ApiOperation("获取索引")
@GetMapping(value = "/getIndicess")
@GetMapping(value = "/getIndicess")
public Mono<Result> getSourceWarehouseList(@RequestParam(name = "id") Long id) {
public Mono<Result> getSourceWarehouseList(@RequestParam(name = "id") Long id) {
return Mono.fromSupplier(() -> producerService.getSourceWarehouseList(id));
return Mono.fromSupplier(() -> producerService.getSourceWarehouseList(id));
}
}
/**
*/
/**
* @Description:获取某个索引下的type
* @Description:获取某个索引下的type
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
/*
@ApiOperation("获取某个索引下的type")
@ApiOperation("获取某个索引下的type")
@GetMapping(value = "/getIndicesTypes")
@GetMapping(value = "/getIndicesTypes")
public Mono<Result> getIndicesTypes(@RequestParam(name = "indices") String indices,
public Mono<Result> getIndicesTypes(@RequestParam(name = "indices") String indices,
@RequestParam(name = "id") Long id) {
@RequestParam(name = "id") Long id) {
return Mono.fromSupplier(() -> producerService.getIndicesTypes(indices,id));
return Mono.fromSupplier(() -> producerService.getIndicesTypes(indices,id));
}
}
/**
*/
/**
* @Description:获取某个索引 type的fields
* @Description:获取某个索引 type的fields
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
/*
@ApiOperation("获取某个索引 type的fields")
@ApiOperation("获取某个索引 type的fields")
@GetMapping(value = "/getIndicesTypesFields")
@GetMapping(value = "/getIndicesTypesFields")
public Mono<Result> getIndicesTypesFields(@RequestParam(name = "indices") String indices,
public Mono<Result> getIndicesTypesFields(@RequestParam(name = "indices") String indices,
...
@@ -174,5 +208,5 @@ public class ProducerController {
...
@@ -174,5 +208,5 @@ public class ProducerController {
@GetMapping(value = "/getRedisObj")
@GetMapping(value = "/getRedisObj")
public Result getObjOnRedis() {
public Result getObjOnRedis() {
return producerService.getObjOnRedis();
return producerService.getObjOnRedis();
}
}
*/
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
View file @
da3c8b94
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.dm.common.constant.Constants
;
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.GatewayResultCode
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.auth.AuthReqTypeEnum
;
import
com.jz.dm.common.enums.auth.AuthReqTypeEnum
;
...
@@ -89,7 +90,11 @@ public class AuthFilter extends AbstractFilter {
...
@@ -89,7 +90,11 @@ public class AuthFilter extends AbstractFilter {
}
}
}
}
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getParams
());
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"
);
String
authCode
=
parameter
.
getString
(
"authCode"
);
ApiAuth
authAuth
=
authService
.
getAuthUser
(
authCode
,
apiInterface
.
getId
());
ApiAuth
authAuth
=
authService
.
getAuthUser
(
authCode
,
apiInterface
.
getId
());
if
(
null
==
authAuth
)
{
if
(
null
==
authAuth
)
{
...
@@ -107,7 +112,7 @@ public class AuthFilter extends AbstractFilter {
...
@@ -107,7 +112,7 @@ public class AuthFilter extends AbstractFilter {
if
(!
apiOrg
.
getStatus
())
{
if
(!
apiOrg
.
getStatus
())
{
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
}
}
checkBill
(
request
,
authCode
,
authAuth
,
apiOrg
);
checkBill
(
request
,
authCode
,
authAuth
);
}
}
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -121,7 +126,6 @@ public class AuthFilter extends AbstractFilter {
...
@@ -121,7 +126,6 @@ public class AuthFilter extends AbstractFilter {
response
.
clearAttributes
();
response
.
clearAttributes
();
response
.
setCode
(
GatewayResultCode
.
UNKNOWN_EXCEPTION
.
getCode
());
response
.
setCode
(
GatewayResultCode
.
UNKNOWN_EXCEPTION
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
UNKNOWN_EXCEPTION
.
getMsg
());
response
.
setMsg
(
GatewayResultCode
.
UNKNOWN_EXCEPTION
.
getMsg
());
}
}
}
}
...
@@ -132,19 +136,24 @@ public class AuthFilter extends AbstractFilter {
...
@@ -132,19 +136,24 @@ public class AuthFilter extends AbstractFilter {
* @param request
* @param request
* @param authCode
* @param authCode
* @param authAuth
* @param authAuth
* @param apiOrg
* @throws ParseException
* @throws ParseException
*/
*/
private
void
checkBill
(
GatewayRequest
request
,
String
authCode
,
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
())
{
switch
(
authAuth
.
getAuthMode
())
{
case
"POWER_CALL_MODE"
:
//按次调用
case
"POWER_CALL_MODE"
:
//按次调用
//查询数据银行银行余额是否充足
Date
validExprDate
=
authAuth
.
getValidExprDate
();
getDataAmountResult
(
request
);
if
(
currentDate
.
after
(
validExprDate
))
{
//超出时间
throw
new
GatewayException
(
GatewayResultCode
.
AUTH_EXCEED_TIME
);
}
try
{
//记录请求次数(每天限制请求次数)
try
{
//记录请求次数(每天限制请求次数)
// String limitKey = TagConstants.OPEN_API_REDIS_LIMIT_KEY + authCode;
//查询数据银行银行余额是否充足
String
limitKey
=
authCode
;
getDataAmountResult
(
request
);
String
reqValue
=
(
String
)
redisUtils
.
getObj
(
limitKey
);
String
limitKey
=
TagConstants
.
OPEN_API_REDIS_LIMIT_KEY
+
authCode
;
Integer
reqValue
=
(
Integer
)
redisUtils
.
getObj
(
limitKey
);
long
timeOut
=
0
;
long
timeOut
=
0
;
if
(
AuthReqTypeEnum
.
DAY
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按天
if
(
AuthReqTypeEnum
.
DAY
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按天
timeOut
=
DateUtil
.
calculateNowResidueTime
();
timeOut
=
DateUtil
.
calculateNowResidueTime
();
...
@@ -154,11 +163,11 @@ public class AuthFilter extends AbstractFilter {
...
@@ -154,11 +163,11 @@ public class AuthFilter extends AbstractFilter {
//暂时不支持年
//暂时不支持年
}
}
if
(
null
!=
reqValue
)
{
if
(
null
!=
reqValue
)
{
Integer
value
=
Integer
.
valueOf
(
reqValue
);
/* Integer value = Integer.valueOf(reqValue);*/
if
(
v
alue
>
authAuth
.
getReqFrequency
())
{
//超出最大请求次数
if
(
reqV
alue
>
authAuth
.
getReqFrequency
())
{
//超出最大请求次数
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_LIMIT_EXCEPTION
);
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_LIMIT_EXCEPTION
);
}
else
if
(
v
alue
<=
authAuth
.
getReqFrequency
())
{
}
else
if
(
reqV
alue
<=
authAuth
.
getReqFrequency
())
{
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
v
alue
+
1
,
timeOut
);
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
reqV
alue
+
1
,
timeOut
);
}
}
}
else
{
}
else
{
redisUtils
.
set
(
limitKey
,
1
,
timeOut
);
redisUtils
.
set
(
limitKey
,
1
,
timeOut
);
...
@@ -170,9 +179,6 @@ public class AuthFilter extends AbstractFilter {
...
@@ -170,9 +179,6 @@ public class AuthFilter extends AbstractFilter {
}
}
break
;
break
;
case
"RECORD_TIME_MODE"
:
//按时间调用
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
();
Date
validEndTime
=
authAuth
.
getValidEndTime
();
//如果 date1 在 date2 之前,before 返回 true,否则返回 false
//如果 date1 在 date2 之前,before 返回 true,否则返回 false
if
(
currentDate
.
after
(
validEndTime
))
{
//超出时间
if
(
currentDate
.
after
(
validEndTime
))
{
//超出时间
...
@@ -181,6 +187,10 @@ public class AuthFilter extends AbstractFilter {
...
@@ -181,6 +187,10 @@ public class AuthFilter extends AbstractFilter {
}
}
break
;
break
;
case
"PERMANENT_TIME_MODE"
:
//永久有效(直接跳出)
case
"PERMANENT_TIME_MODE"
:
//永久有效(直接跳出)
Date
validExpr
=
authAuth
.
getValidExprDate
();
if
(
currentDate
.
after
(
validExpr
))
{
//超出时间
throw
new
GatewayException
(
GatewayResultCode
.
AUTH_EXCEED_TIME
);
}
break
;
break
;
default
:
default
:
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
...
@@ -217,7 +227,7 @@ public class AuthFilter extends AbstractFilter {
...
@@ -217,7 +227,7 @@ public class AuthFilter extends AbstractFilter {
pObject
.
put
(
"assetsId"
,
assetsId
);
pObject
.
put
(
"assetsId"
,
assetsId
);
pObject
.
put
(
"userId"
,
userId
);
pObject
.
put
(
"userId"
,
userId
);
pObject
.
put
(
"dataPrice"
,
dataPrice
);
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
);
JSONObject
result
=
JSONObject
.
parseObject
(
respResult
);
if
(
null
!=
result
)
{
if
(
null
!=
result
)
{
if
(
200
!=
result
.
getInteger
(
"code"
))
{
if
(
200
!=
result
.
getInteger
(
"code"
))
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/FilterChainImpl.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
filter
;
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.exception.OpenApiException
;
import
com.jz.dm.common.exception.OpenApiException
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.common.util.ResultCode
;
import
com.jz.dm.common.util.ResultCode
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -19,13 +19,14 @@ import java.util.List;
...
@@ -19,13 +19,14 @@ import java.util.List;
*/
*/
public
class
FilterChainImpl
implements
FilterChain
{
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
>();
private
final
List
<
Filter
>
filters
=
new
ArrayList
<
Filter
>();
public
FilterChainImpl
()
{
}
public
FilterChainImpl
()
{
}
public
FilterChainImpl
(
List
<
Filter
>
filters
)
{
public
FilterChainImpl
(
List
<
Filter
>
filters
)
{
addFilters
(
filters
);
addFilters
(
filters
);
...
@@ -42,7 +43,7 @@ public class FilterChainImpl implements FilterChain {
...
@@ -42,7 +43,7 @@ public class FilterChainImpl implements FilterChain {
}
catch
(
OpenApiException
ex
)
{
}
catch
(
OpenApiException
ex
)
{
ResultCode
resultCode
=
ex
.
getResultCode
();
ResultCode
resultCode
=
ex
.
getResultCode
();
LogUtil
.
error
(
LOGGER
,
ex
,
"doFilter occur exception,code="
+
resultCode
.
getCode
()
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
.
setCode
(
ex
.
getResultCode
().
getCode
());
response
.
setMsg
(
ex
.
getResultCode
().
getMsg
());
response
.
setMsg
(
ex
.
getResultCode
().
getMsg
());
}
catch
(
Throwable
ex
)
{
}
catch
(
Throwable
ex
)
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
View file @
da3c8b94
...
@@ -19,15 +19,16 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -19,15 +19,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
/**
* @Description: 验签过滤器(验证签名信息)
* @Description: 验签过滤器(验证签名信息)
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2021-1-6
* @Date: 2021-1-6
*/
*/
@Component
@Component
public
class
VerifySignFilter
extends
AbstractFilter
{
public
class
VerifySignFilter
extends
AbstractFilter
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
VerifySignFilter
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
VerifySignFilter
.
class
);
@Autowired
@Autowired
private
ApiInterfaceService
apiInterfaceService
;
private
ApiInterfaceService
apiInterfaceService
;
@Override
@Override
public
int
getOrder
()
{
public
int
getOrder
()
{
return
Constants
.
FILTER_ORDER_3
;
return
Constants
.
FILTER_ORDER_3
;
...
@@ -37,26 +38,29 @@ public class VerifySignFilter extends AbstractFilter {
...
@@ -37,26 +38,29 @@ public class VerifySignFilter extends AbstractFilter {
public
String
getFilterName
()
{
public
String
getFilterName
()
{
return
"VerifySignFilter"
;
return
"VerifySignFilter"
;
}
}
@Override
@Override
protected
void
internalDoFilter
(
GatewayRequest
request
,
GatewayResponse
response
,
protected
void
internalDoFilter
(
GatewayRequest
request
,
GatewayResponse
response
,
FilterChain
chain
)
{
FilterChain
chain
)
{
try
{
try
{
//对签约参数进行字典排序
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
request
.
getSignType
());
if
(!
jsonObject
.
getBoolean
(
"isTest"
))
{
//是否测试调用
if
(
StringUtils
.
isNotBlank
(
signParams
)){
//对签约参数进行字典排序
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
request
.
getSignType
());
String
authCode
=
jsonObject
.
getString
(
"authCode"
);
if
(
StringUtils
.
isNotBlank
(
signParams
))
{
//需要传入授权码
String
authCode
=
jsonObject
.
getString
(
"authCode"
);
ApiAuth
apiAuthInfo
=
apiInterfaceService
.
getApiAuthInfo
(
request
.
getApiKey
(),
authCode
);
//需要传入授权码
if
(
null
==
apiAuthInfo
){
ApiAuth
apiAuthInfo
=
apiInterfaceService
.
getApiAuthInfo
(
request
.
getApiKey
(),
authCode
);
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
if
(
null
==
apiAuthInfo
)
{
}
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
String
sign
=
Md5
.
encrypt
(
signParams
,
apiAuthInfo
.
getSalt
());
}
if
(!
request
.
getSign
().
equals
(
sign
)){
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
);
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
}
}
}
else
{
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
}
}
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
catch
(
SignatureException
ex
)
{
}
catch
(
SignatureException
ex
)
{
...
@@ -66,8 +70,8 @@ public class VerifySignFilter extends AbstractFilter {
...
@@ -66,8 +70,8 @@ public class VerifySignFilter extends AbstractFilter {
response
.
setCode
(
ex
.
getResultCode
().
getCode
());
response
.
setCode
(
ex
.
getResultCode
().
getCode
());
response
.
setMsg
(
ex
.
getResultCode
().
getMsg
());
response
.
setMsg
(
ex
.
getResultCode
().
getMsg
());
}
catch
(
Throwable
ex
)
{
}
catch
(
Throwable
ex
)
{
if
(
ex
instanceof
GatewayException
)
{
if
(
ex
instanceof
GatewayException
)
{
throw
(
GatewayException
)
ex
;
throw
(
GatewayException
)
ex
;
}
}
LogUtil
.
error
(
LOGGER
,
ex
,
LogUtil
.
error
(
LOGGER
,
ex
,
"signatureFilter doFilter error. response="
+
response
.
getResponse
());
"signatureFilter doFilter error. response="
+
response
.
getResponse
());
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/DefaultOpenApiDispatcher.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
gateway
;
package
com
.
jz
.
dm
.
gateway
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.OpenApiException
;
import
com.jz.dm.common.exception.OpenApiException
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.OpenApiResponse
;
...
@@ -65,18 +66,17 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
...
@@ -65,18 +66,17 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
response
.
setMsg
(
OpenApiResultCode
.
ILLEGAL_INTERFACE
.
getMsg
());
response
.
setMsg
(
OpenApiResultCode
.
ILLEGAL_INTERFACE
.
getMsg
());
return
JSON
.
toJSONString
(
response
.
getAttributes
());
return
JSON
.
toJSONString
(
response
.
getAttributes
());
}
}
try
{
try
{
OpenApiRequest
request
=
new
OpenApiRequest
(
context
.
getOpenApiParams
());
OpenApiRequest
request
=
new
OpenApiRequest
(
context
.
getOpenApiParams
());
request
.
setApiKey
(
context
.
getApiKey
());
request
.
setApiKey
(
context
.
getApiKey
());
request
.
setExtAttributes
(
context
.
getExtAttributes
());
request
.
setExtAttributes
(
context
.
getExtAttributes
());
openApiService
.
doService
(
request
,
response
);
openApiService
.
doService
(
request
,
response
);
}
catch
(
Throwable
ex
)
{
}
catch
(
Throwable
ex
)
{
if
(
ex
instanceof
OpenApiException
)
{
if
(
ex
instanceof
OpenApiException
)
{
OpenApiException
oae
=
(
OpenApiException
)
ex
;
throw
(
OpenApiException
)
ex
;
response
.
setCode
(
oae
.
getResultCode
().
getCode
());
}
else
if
(
ex
instanceof
GatewayException
){
response
.
setMsg
(
oae
.
getResultCode
().
getMsg
())
;
throw
(
GatewayException
)
ex
;
}
else
{
}
else
{
LOGGER
.
error
(
"OpenApiService doService error,DispatchContext="
+
context
,
ex
);
LOGGER
.
error
(
"OpenApiService doService error,DispatchContext="
+
context
,
ex
);
response
.
setCode
(
OpenApiResultCode
.
UNKNOWN_EXCEPTION
.
getCode
());
response
.
setCode
(
OpenApiResultCode
.
UNKNOWN_EXCEPTION
.
getCode
());
response
.
setMsg
(
OpenApiResultCode
.
UNKNOWN_EXCEPTION
.
getMsg
());
response
.
setMsg
(
OpenApiResultCode
.
UNKNOWN_EXCEPTION
.
getMsg
());
...
@@ -84,8 +84,8 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
...
@@ -84,8 +84,8 @@ public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
return
JSON
.
toJSONString
(
response
.
getAttributes
());
return
JSON
.
toJSONString
(
response
.
getAttributes
());
}
}
if
(
StringUtil
.
isEmpty
(
response
.
getCode
()))
{
if
(
StringUtil
.
isEmpty
(
response
.
getCode
()))
{
response
.
setCode
(
OpenApiResultCode
.
SUCCESS
.
getCode
());
response
.
setCode
(
OpenApiResultCode
.
UNKNOWN_EXCEPTION
.
getCode
());
response
.
setMsg
(
OpenApiResultCode
.
SUCCESS
.
getMsg
());
response
.
setMsg
(
OpenApiResultCode
.
UNKNOWN_EXCEPTION
.
getMsg
());
}
}
return
JSON
.
toJSONString
(
response
.
getAttributes
());
return
JSON
.
toJSONString
(
response
.
getAttributes
());
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiInterfaceMapper.java
View file @
da3c8b94
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.dto.ApiServiceApplyDto
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -21,13 +22,21 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
...
@@ -21,13 +22,21 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
/**
/**
* 查询API列表信息
* 查询
(已调用)
API列表信息
* @param page
* @param page
* @param query
* @param query
* @return
* @return
*/
*/
IPage
<
ApiInterface
>
listApiInterfaceInfo
(
IPage
<
ApiInterface
>
page
,
@Param
(
"ew"
)
Wrapper
<
ApiInterface
>
query
);
IPage
<
ApiInterface
>
listApiInterfaceInfo
(
IPage
<
ApiInterface
>
page
,
@Param
(
"ew"
)
Wrapper
<
ApiInterface
>
query
);
/**
* 查询(未调用)API列表信息
* @param page
* @param query
* @return
*/
IPage
<
ApiInterface
>
listCallApiInterfaceInfo
(
IPage
<
ApiInterface
>
page
,
@Param
(
"ew"
)
Wrapper
<
ApiInterface
>
query
);
/**
/**
* 查询API详情信息
* 查询API详情信息
* @param req
* @param req
...
@@ -42,4 +51,21 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
...
@@ -42,4 +51,21 @@ public interface ApiInterfaceMapper extends BaseMapper<ApiInterface> {
* @return
* @return
*/
*/
ApiInterfaceCustom
getTestData
(
String
apiKey
);
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
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
View file @
da3c8b94
...
@@ -97,6 +97,15 @@ public class ApiAuth extends BaseObject implements Serializable {
...
@@ -97,6 +97,15 @@ public class ApiAuth extends BaseObject implements Serializable {
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
validEndTime
;
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 已处理
* 处理状态:0 未处理, 1 已处理
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
da3c8b94
...
@@ -38,12 +38,6 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -38,12 +38,6 @@ public class ApiInterface extends BaseObject implements Serializable {
@JsonIgnore
@JsonIgnore
private
String
apiName
;
private
String
apiName
;
/**
* api描述
*/
@TableField
(
"api_desc"
)
private
String
apiDesc
;
/**
/**
* api请求协议:http,https
* api请求协议:http,https
*/
*/
...
@@ -51,41 +45,29 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -51,41 +45,29 @@ public class ApiInterface extends BaseObject implements Serializable {
private
String
apiProtocl
;
private
String
apiProtocl
;
/**
/**
*
api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 5 DMP标签查询 6.DMP大数据表查询 7 DMP自定义'
*
接入类型:对应字典表key
*/
*/
@TableField
(
"api_type"
)
@TableField
(
"api_type"
)
private
String
apiType
;
private
String
apiType
;
/**
* 请求地址
*/
@TableField
(
"api_path"
)
private
String
apiPath
;
/**
/**
* 目标url
* 目标url
*/
*/
@TableField
(
"target_url"
)
@TableField
(
"target_url"
)
private
String
targetUrl
;
private
String
targetUrl
;
/**
/**
* 接入类型:对应字典表key
* 请求方式:GET POST
*/
@TableField
(
"join_type"
)
private
String
joinType
;
/**
* 测试实例
*/
*/
@TableField
(
"test_example"
)
@TableField
(
"req_type"
)
private
String
testExample
;
private
String
reqType
;
/**
/**
* '输出类型:flow 流形式输出, json格式输出',
* '输出类型:flow 流形式输出, json格式输出',
*/
*/
@TableField
(
"output_type"
)
@TableField
(
"output_type"
)
private
String
outputType
;
private
String
outputType
;
/**
* 是否分页:0 false ,1 true
*/
@TableField
(
"page"
)
private
Boolean
page
;
/**
/**
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
...
@@ -113,8 +95,8 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -113,8 +95,8 @@ public class ApiInterface extends BaseObject implements Serializable {
/**
/**
* 限流类型:DAY 按天,MONTH 按月, YEAR 按年
* 限流类型:DAY 按天,MONTH 按月, YEAR 按年
*/
*/
@TableField
(
"
req
_type"
)
@TableField
(
"
limit
_type"
)
private
String
req
Type
;
private
String
limit
Type
;
/**
/**
* 限制次数
* 限制次数
...
@@ -127,17 +109,19 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -127,17 +109,19 @@ public class ApiInterface extends BaseObject implements Serializable {
@TableField
(
"timeout"
)
@TableField
(
"timeout"
)
private
String
timeout
;
private
String
timeout
;
/**
* 是否测试数据:0 否,1 是
*/
@TableField
(
"is_test"
)
private
Integer
isTest
;
/**
/**
* 文件夹id
* 文件夹id
*/
*/
@TableField
(
"file_id"
)
@TableField
(
"file_id"
)
private
Long
fileId
;
private
Long
fileId
;
/**
* 是否发送到数据银行
*/
@TableField
(
"is_send_bank"
)
private
Boolean
isSendBank
;
/*-----------------------------------保存数据库时忽略字段--------------------------------*/
/*-----------------------------------保存数据库时忽略字段--------------------------------*/
/**
/**
* 请求总次数
* 请求总次数
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
View file @
da3c8b94
...
@@ -93,5 +93,19 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
...
@@ -93,5 +93,19 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
*/
*/
@TableField
(
"inbox_param"
)
@TableField
(
"inbox_param"
)
private
String
inboxParam
;
private
String
inboxParam
;
/**
* 最大行数
*/
@TableField
(
"max_row"
)
private
Long
maxRow
;
/**
* 每页返回行数
*/
@TableField
(
"page_row"
)
private
Long
pageRow
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
View file @
da3c8b94
...
@@ -31,17 +31,11 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
...
@@ -31,17 +31,11 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
private
Long
projectId
;
private
Long
projectId
;
/**
/**
* 文件来源:
1 DMP 2 数据银行
* 文件来源:
,1 API制做,2 组织创建
*/
*/
@TableField
(
"file_source"
)
@TableField
(
"file_source"
)
private
String
fileSource
;
private
String
fileSource
;
///**
//* 文件类型:1 文件夹 ,2 文件
//*/
//@TableField("file_type")
//private String fileType;
/**
/**
* 文件名称
* 文件名称
*/
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
View file @
da3c8b94
...
@@ -55,6 +55,13 @@ public class ApiOrg extends BaseObject implements Serializable {
...
@@ -55,6 +55,13 @@ public class ApiOrg extends BaseObject implements Serializable {
*/
*/
@TableField
(
"linkman"
)
@TableField
(
"linkman"
)
private
String
linkman
;
private
String
linkman
;
/**
* 组织目录文件夹
*/
@TableField
(
"org_folder_id"
)
private
Long
orgFolderId
;
/**
/**
* 组织类型 OUT 外部组织 IN 内部组织
* 组织类型 OUT 外部组织 IN 内部组织
*/
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/dto/ApiServiceApplyDto.java
0 → 100644
View file @
da3c8b94
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
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/enity/GatewayRequest.java
View file @
da3c8b94
...
@@ -49,6 +49,10 @@ public class GatewayRequest implements Serializable {
...
@@ -49,6 +49,10 @@ public class GatewayRequest implements Serializable {
@ApiModelProperty
(
value
=
"请求参数,JSON格式"
)
@ApiModelProperty
(
value
=
"请求参数,JSON格式"
)
private
String
params
;
private
String
params
;
@ApiModelProperty
(
value
=
"是否测试请求"
)
private
Boolean
isTest
;
@ApiModelProperty
(
value
=
"扩展属性"
)
@ApiModelProperty
(
value
=
"扩展属性"
)
private
final
Map
<
String
,
Attribute
>
extAttributes
=
new
HashMap
<
String
,
Attribute
>();
private
final
Map
<
String
,
Attribute
>
extAttributes
=
new
HashMap
<
String
,
Attribute
>();
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthUserApiReq.java
View file @
da3c8b94
...
@@ -38,9 +38,9 @@ public class AuthUserApiReq implements Serializable {
...
@@ -38,9 +38,9 @@ public class AuthUserApiReq implements Serializable {
@NotNull
(
message
=
"组织编码不能为空"
)
@NotNull
(
message
=
"组织编码不能为空"
)
private
String
orgCode
;
private
String
orgCode
;
/*
@ApiModelProperty(value = "授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权",required = true)
@ApiModelProperty
(
value
=
"授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权"
,
required
=
true
)
@NotNull
(
message
=
"授权类型不能为空"
)
@NotNull
(
message
=
"授权类型不能为空"
)
private String authType;
*/
private
String
authType
;
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@NotNull
(
message
=
"授权方式不能为空"
)
@NotNull
(
message
=
"授权方式不能为空"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/ServiceAuthReq.java
0 → 100644
View file @
da3c8b94
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
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/folder/CreateFolderReq.java
0 → 100644
View file @
da3c8b94
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
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
deleted
100644 → 0
View file @
deb9ea2e
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;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageAddReq.java
View file @
da3c8b94
...
@@ -20,14 +20,10 @@ import java.io.Serializable;
...
@@ -20,14 +20,10 @@ import java.io.Serializable;
@ApiModel
(
"组织管理详情请求体"
)
@ApiModel
(
"组织管理详情请求体"
)
public
class
OrganizationManageAddReq
implements
Serializable
{
public
class
OrganizationManageAddReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"组织类型:INT 内部组织 OUT 外部组织"
,
required
=
true
)
/*
@ApiModelProperty(value = "组织类型:INT 内部组织 OUT 外部组织",required = true)
@NotNull(message = "组织类型不能为空!")
@NotNull(message = "组织类型不能为空!")
private String orgType;
private String orgType;
@ApiModelProperty
(
value
=
"组织名称"
,
required
=
true
)
@NotNull
(
message
=
"组织名称不能为空"
)
private
String
orgName
;
@ApiModelProperty(value = "组织描述",required = false)
@ApiModelProperty(value = "组织描述",required = false)
private String orgDesc;
private String orgDesc;
...
@@ -35,21 +31,31 @@ public class OrganizationManageAddReq implements Serializable {
...
@@ -35,21 +31,31 @@ public class OrganizationManageAddReq implements Serializable {
private String orgCnName;
private String orgCnName;
@ApiModelProperty(value = "组织邮箱",required = false)
@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
;
private
String
orgPhone
;
@ApiModelProperty
(
value
=
"组织联系人"
,
required
=
false
)
@ApiModelProperty
(
value
=
"组织联系人"
,
required
=
true
)
@NotNull
(
message
=
"组织联系人不能为空"
)
private
String
linkman
;
private
String
linkman
;
@ApiModelProperty
(
value
=
"文件夹Id"
,
required
=
true
)
@NotNull
(
message
=
"文件夹Id不能为空"
)
private
Long
orgFolderId
;
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
private
String
remark
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
private
String
createUser
;
private
String
createUser
;
@ApiModelProperty
(
value
=
"
创建
用户"
,
required
=
false
)
@ApiModelProperty
(
value
=
"
更新
用户"
,
required
=
false
)
private
String
updateUser
;
private
String
updateUser
;
@ApiModelProperty
(
value
=
"id ----更新时必传"
,
required
=
false
)
@ApiModelProperty
(
value
=
"id ----更新时必传"
,
required
=
false
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageListQueryReq.java
View file @
da3c8b94
...
@@ -29,4 +29,9 @@ public class OrganizationManageListQueryReq extends BasePageBean implements Seri
...
@@ -29,4 +29,9 @@ public class OrganizationManageListQueryReq extends BasePageBean implements Seri
@ApiModelProperty
(
value
=
"组织联系人"
)
@ApiModelProperty
(
value
=
"组织联系人"
)
private
String
linkman
;
private
String
linkman
;
@ApiModelProperty
(
value
=
"组织文件夹"
)
private
Long
fileId
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
make
/ApiInterfaceReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
producer
/ApiInterfaceReq.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
models
.
req
.
make
;
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -20,33 +20,39 @@ import java.io.Serializable;
...
@@ -20,33 +20,39 @@ import java.io.Serializable;
@ApiModel
(
value
=
"api基本信息"
)
@ApiModel
(
value
=
"api基本信息"
)
public
class
ApiInterfaceReq
implements
Serializable
{
public
class
ApiInterfaceReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"传输方式:http https"
,
required
=
true
)
@ApiModelProperty
(
value
=
"传输方式:http https"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
@NotNull
(
message
=
"传输方式不能为空"
)
public
String
transMode
;
public
String
apiProtocl
;
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@NotNull
(
message
=
"加密方式不能为空"
)
@NotNull
(
message
=
"加密方式不能为空"
)
public
String
signType
;
public
String
signType
;
@ApiModelProperty
(
value
=
"
接入
类型:对应字典表key"
,
required
=
true
)
@ApiModelProperty
(
value
=
"
Api
类型:对应字典表key"
,
required
=
true
)
@NotNull
(
message
=
"
接入
类型不能为空"
)
@NotNull
(
message
=
"
Api
类型不能为空"
)
public
String
join
Type
;
public
String
api
Type
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
true
)
@ApiModelProperty
(
value
=
"apiKey"
,
required
=
true
)
@NotNull
(
message
=
"目标地址不能为空"
)
@NotNull
(
message
=
"apiKey不能为空"
)
public
String
apiKey
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
false
)
public
String
targetUrl
;
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"请求方式:GET POST"
,
required
=
true
)
@NotNull
(
message
=
"请求方式不能为空"
)
public
String
reqType
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@NotNull
(
message
=
"超时时间不能为空"
)
@NotNull
(
message
=
"超时时间不能为空"
)
public
String
timeout
;
public
String
timeout
;
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月, YEAR 按年"
,
required
=
true
)
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月, YEAR 按年"
,
required
=
true
)
@NotNull
(
message
=
"限流类型不能为空"
)
@NotNull
(
message
=
"限流类型不能为空"
)
public
String
reqType
;
public
String
limitType
;
@ApiModelProperty
(
value
=
"API名称"
,
required
=
false
)
public
String
apiName
;
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
false
)
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
false
)
public
Long
reqFrequency
;
public
Long
reqFrequency
;
...
@@ -54,16 +60,40 @@ public class ApiInterfaceReq implements Serializable {
...
@@ -54,16 +60,40 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"父类文件id,一级文件夹传入0"
,
required
=
false
)
@ApiModelProperty
(
value
=
"文件夹Id"
,
required
=
true
)
public
Long
parentId
;
@NotNull
(
message
=
"文件夹Id不能为空"
)
@ApiModelProperty
(
value
=
"文件id"
,
required
=
false
)
public
Long
fileId
;
public
Long
fileId
;
@ApiModelProperty
(
value
=
"项目
id
"
,
required
=
true
)
@ApiModelProperty
(
value
=
"项目
编号
"
,
required
=
true
)
@NotNull
(
message
=
"项目
id
不能为空"
)
@NotNull
(
message
=
"项目
编号
不能为空"
)
public
Long
projectId
;
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
)
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
public
String
status
;
public
String
status
;
...
@@ -72,10 +102,12 @@ public class ApiInterfaceReq implements Serializable {
...
@@ -72,10 +102,12 @@ public class ApiInterfaceReq implements Serializable {
public
Long
id
;
public
Long
id
;
@ApiModelProperty
(
value
=
"创建用户"
,
hidden
=
true
)
@ApiModelProperty
(
value
=
"创建用户"
,
hidden
=
true
)
public
String
createUser
;
public
String
createUser
;
@ApiModelProperty
(
value
=
"创建用户"
,
hidden
=
true
)
public
String
updateUser
;
@ApiModelProperty
(
value
=
"api类型:1.数据银行制作大数据表 "
+
/*
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义",hidden = true)
"4 API实时接入 6 标签查询 9自定义",hidden = true)
public
String
apiType
;
public String apiType;
*/
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/producer/MakeBigDataApiReq.java
0 → 100644
View file @
da3c8b94
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;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
make
/MakeDataBankApiReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
producer
/MakeDataBankApiReq.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
models
.
req
.
make
;
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -40,9 +40,13 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -40,9 +40,13 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"输出类型不能为空"
)
@NotNull
(
message
=
"输出类型不能为空"
)
public
String
outputType
;
public
String
outputType
;
@ApiModelProperty
(
value
=
"是否分页:"
,
required
=
true
)
@ApiModelProperty
(
value
=
"请求方式:GET POST"
,
required
=
true
)
@NotNull
(
message
=
"请求方式不能为空"
)
public
String
reqMethod
;
/*@ApiModelProperty(value = "是否分页:",required = true)
@NotNull(message = "是否分页不能为空")
@NotNull(message = "是否分页不能为空")
public
Boolean
page
;
public Boolean page;
*/
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月"
,
required
=
true
)
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月"
,
required
=
true
)
@NotNull
(
message
=
"限流类型不能为空"
)
@NotNull
(
message
=
"限流类型不能为空"
)
...
@@ -52,9 +56,15 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -52,9 +56,15 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"目标地址不能为空"
)
@NotNull
(
message
=
"目标地址不能为空"
)
public
String
targetUrl
;
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"文件id"
,
required
=
true
)
@ApiModelProperty
(
value
=
"当前页"
,
required
=
true
)
@NotNull
(
message
=
"文件id不能为空"
)
public
Integer
pageNum
;
public
Long
fileId
;
@ApiModelProperty
(
value
=
"当前页显示条数"
,
required
=
true
)
public
Integer
pageSize
;
//@ApiModelProperty(value = "文件id",required = true)
//@NotNull(message = "文件id不能为空")
//public Long fileId;
@ApiModelProperty
(
value
=
"签名"
,
required
=
true
)
@ApiModelProperty
(
value
=
"签名"
,
required
=
true
)
@NotNull
(
message
=
"签名不能为空"
)
@NotNull
(
message
=
"签名不能为空"
)
...
@@ -69,7 +79,8 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -69,7 +79,8 @@ public class MakeDataBankApiReq implements Serializable {
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"数据包下载路径"
,
required
=
false
)
public
String
fileLocation
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
false
)
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
false
)
public
String
timeout
;
public
String
timeout
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
make
/MakeRealCustomApiReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
producer
/MakeRealCustomApiReq.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
models
.
req
.
make
;
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
lombok.Data
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/producer/ServiceIssueReq.java
0 → 100644
View file @
da3c8b94
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
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
make
/SourceConfigReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
producer
/SourceConfigReq.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
models
.
req
.
make
;
package
com
.
jz
.
dm
.
models
.
req
.
producer
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiInterfaceService.java
View file @
da3c8b94
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
com.jz.dm.models.req.api.ApiInterfaceInfoListReq
;
import
com.jz.dm.models.req.api.ApiInterfaceInfoListReq
;
...
@@ -41,11 +42,19 @@ public interface ApiInterfaceService {
...
@@ -41,11 +42,19 @@ public interface ApiInterfaceService {
ApiInterface
getReqTargetInfo
(
String
apiKey
);
ApiInterface
getReqTargetInfo
(
String
apiKey
);
/**
/**
*
查询API列表信息
*
API---(已调用列表)列表查询
* @param req
* @param req
* @return
* @return
*/
*/
IPage
<
ApiInterface
>
listApiInterface
(
ApiInterfaceInfoListReq
req
);
IPage
<
ApiInterface
>
listCallApiInterface
(
ApiInterfaceInfoListReq
req
);
/**
* API---(未调用列表)列表查询
* @param req
* @return
*/
IPage
<
ApiInterface
>
listUnCallApiInterface
(
ApiInterfaceInfoListReq
req
);
/**
/**
* 查询API详情
* 查询API详情
...
@@ -77,12 +86,24 @@ public interface ApiInterfaceService {
...
@@ -77,12 +86,24 @@ public interface ApiInterfaceService {
Result
dmpDeleteAuth
(
String
type
,
String
apiKey
);
Result
dmpDeleteAuth
(
String
type
,
String
apiKey
);
/**
/**
*
api测试接口
*
获取api自定义信息
* @param api
Key
* @param api
InterfaceId
* @return
* @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
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/AuthService.java
View file @
da3c8b94
...
@@ -84,4 +84,11 @@ public interface AuthService {
...
@@ -84,4 +84,11 @@ public interface AuthService {
* @return
* @return
*/
*/
Result
getAuthNameList
(
String
key
);
Result
getAuthNameList
(
String
key
);
/**
* 获取服务授权列表
* @param req
* @return
*/
Result
getServiceAuthList
(
ServiceAuthReq
req
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/OrganizationManageService.java
View file @
da3c8b94
...
@@ -38,12 +38,6 @@ public interface OrganizationManageService {
...
@@ -38,12 +38,6 @@ public interface OrganizationManageService {
*/
*/
Result
add
(
OrganizationManageAddReq
req
);
Result
add
(
OrganizationManageAddReq
req
);
/**
* 更新组织信息
* @param req
* @return
*/
//Result update(OrganizationManageUpdateReq req);
/**
/**
* 根据id注销组织
* 根据id注销组织
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/ProducerService.java
View file @
da3c8b94
package
com
.
jz
.
dm
.
service
;
package
com
.
jz
.
dm
.
service
;
import
com.jz.common.utils.Result
;
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
* @author ZC
...
@@ -13,40 +15,29 @@ import com.jz.dm.models.req.make.*;
...
@@ -13,40 +15,29 @@ import com.jz.dm.models.req.make.*;
* @Description:
* @Description:
**/
**/
public
interface
ProducerService
{
public
interface
ProducerService
{
/**
* 制作自定义APi
* @param req
* @return
*/
Result
addCustomApi
(
ApiInterfaceReq
req
);
/**
/**
* Api制作(实时接入)
* Api制作(实时接入)
* @param req
* @param req
* @return
* @return
*/
*/
Result
addRealCustomApi
(
MakeRealCustomApiReq
req
);
// Result addRealCustomApi(MakeRealCustomApiReq req);
/**
* Api制作(大数据查询/标签查询)
* @param req
* @return
*/
Result
addBigDataMakeApi
(
MakeBigDataApiReq
req
);
/**
/**
* 获取数据源配置
* 获取数据源配置
* @param req
* @param req
* @return
* @return
*/
*/
Result
getSourceConfig
(
SourceConfigReq
req
);
//
Result getSourceConfig(SourceConfigReq req);
/**
/**
* 获取数据库列表
* 获取数据库列表
* @param id
* @param id
* @return
* @return
*/
*/
Result
getSourceWarehouseList
(
Long
id
);
//
Result getSourceWarehouseList(Long id);
/**
/**
* 获取某个索引下的type
* 获取某个索引下的type
...
@@ -54,7 +45,7 @@ public interface ProducerService {
...
@@ -54,7 +45,7 @@ public interface ProducerService {
* @param id
* @param id
* @return
* @return
*/
*/
Result
getIndicesTypes
(
String
indices
,
Long
id
);
//
Result getIndicesTypes(String indices, Long id);
/**
/**
* 获取某个索引 type的fields
* 获取某个索引 type的fields
...
@@ -63,23 +54,28 @@ public interface ProducerService {
...
@@ -63,23 +54,28 @@ public interface ProducerService {
* @param id
* @param id
* @return
* @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信息
* 保存修改的api信息
* @param req
* @param req
* @return
* @return
*/
*/
Result
saveUpdateAPiInfo
(
ApiInterfaceReq
req
);
//
Result saveUpdateAPiInfo(ApiInterfaceReq req);
/**
/**
*
数据银行制作API/数据包
*
Api制作(数据查询/标签查询)
* @param req
* @param req
* @return
* @return
*/
*/
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
);
Result
addBigDataMakeApi
(
ApiInterfaceReq
req
);
/**
/**
* 保存 API基本信息
* 保存 API基本信息
* @param req
* @param req
...
@@ -96,15 +92,36 @@ public interface ProducerService {
...
@@ -96,15 +92,36 @@ public interface ProducerService {
/**
/**
* 创建文件夹
* 创建文件夹
* @param projectId
* @param req
* @param parentId
* @return
* @param currentUser
*/
Result
createProjectFolder
(
CreateFolderReq
req
);
/**
* 获取生成后的APIId
* @return
* @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
();
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
View file @
da3c8b94
...
@@ -11,15 +11,16 @@ import com.jz.dm.common.enums.GeneralStatusTypeEnum;
...
@@ -11,15 +11,16 @@ import com.jz.dm.common.enums.GeneralStatusTypeEnum;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiInterfaceCustomMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.dto.ApiCallDataDto
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
com.jz.dm.models.req.api.ApiInterfaceDetailReq
;
import
com.jz.dm.models.req.api.ApiInterfaceInfoListReq
;
import
com.jz.dm.models.req.api.ApiInterfaceInfoListReq
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.ApiInterfaceService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -49,26 +50,25 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
...
@@ -49,26 +50,25 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
@Resource
@Resource
private
ApiInterfaceMapper
apiInterfaceMapper
;
private
ApiInterfaceMapper
apiInterfaceMapper
;
@Resource
@Resource
private
ApiInterfaceCustomMapper
apiInterfaceCustomMapper
;
@Resource
private
ApiAuthMapper
apiAuthMapper
;
private
ApiAuthMapper
apiAuthMapper
;
@Autowired
@Autowired
private
HttpsUtils
httpsUtils
;
private
HttpsUtils
httpsUtils
;
/**
/**
*
获取API列表信息
*
API---(调用列表)列表查询
*
*
* @param req
* @param req
* @return
* @return
*/
*/
@Override
@Override
public
IPage
<
ApiInterface
>
listApiInterface
(
ApiInterfaceInfoListReq
req
)
{
public
IPage
<
ApiInterface
>
list
Call
ApiInterface
(
ApiInterfaceInfoListReq
req
)
{
IPage
<
ApiInterface
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
IPage
<
ApiInterface
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
/*if (StringUtils.isNotBlank(req.getApiKey())){
if
(
StringUtils
.
isNotBlank
(
req
.
getApiKey
())){
query.eq("api_key",req.getApiKey());
query
.
eq
(
"ai.api_key"
,
req
.
getApiKey
());
}*/
}
/* if (StringUtils.isNotBlank(req.getStatus())){
query.eq("status",req.getStatus());
}*/
query
.
eq
(
"ai.is_deleted"
,
0
);
query
.
eq
(
"ai.is_deleted"
,
0
);
query
.
orderByDesc
(
"ai.create_date"
);
query
.
orderByDesc
(
"ai.create_date"
);
query
.
groupBy
(
"ai.create_date"
);
query
.
groupBy
(
"ai.create_date"
);
...
@@ -76,6 +76,24 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
...
@@ -76,6 +76,24 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
}
}
/**
* API---(未调用列表)列表查询
* @param req
* @return
*/
@Override
public
IPage
<
ApiInterface
>
listUnCallApiInterface
(
ApiInterfaceInfoListReq
req
)
{
IPage
<
ApiInterface
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
req
.
getApiKey
())){
query
.
eq
(
"ai.api_key"
,
req
.
getApiKey
());
}
query
.
isNull
(
"ar.api_key"
);
query
.
eq
(
"ai.is_deleted"
,
0
);
query
.
orderByDesc
(
"ai.create_date"
);
return
apiInterfaceMapper
.
listCallApiInterfaceInfo
(
page
,
query
);
}
/**
/**
* 获取API详情信息
* 获取API详情信息
*
*
...
@@ -206,28 +224,20 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
...
@@ -206,28 +224,20 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
return
authCall
+
authDateCall
;
return
authCall
+
authDateCall
;
}
}
/**
/**
* api测试接口
* 获取api自定义信息
*
* @param apiInterfaceId
* @param apiKey
* @return
* @return
*/
*/
@Override
@Override
public
Result
apiTestInterface
(
String
apiKey
)
{
public
ApiInterfaceCustom
getApiCustomInfo
(
Long
apiInterfaceId
)
{
ApiInterfaceCustom
apiInterfaceCustom
=
apiInterfaceMapper
.
getTestData
(
apiKey
);
QueryWrapper
<
ApiInterfaceCustom
>
queryWra
=
new
QueryWrapper
<>();
if
(
null
==
apiInterfaceCustom
)
{
queryWra
.
eq
(
"api_interface_id"
,
apiInterfaceId
);
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_FOUND
);
queryWra
.
eq
(
"is_deleted"
,
0
);
}
return
apiInterfaceCustomMapper
.
selectOne
(
queryWra
)
;
/* if (StringUtils.isNotBlank(apiInterfaceCustom.getApiExample())){
httpsUtils.doGet(testUrl,"");
}else {
}*/
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
}
}
/**
/**
* 获取用户授权信息
* 获取用户授权信息
*
*
...
@@ -275,4 +285,39 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
...
@@ -275,4 +285,39 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiInterfaceMapper
.
selectOne
(
query
);
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
));
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
da3c8b94
...
@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
...
@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.enums.auth.AuthTypeEnum
;
import
com.jz.common.utils.Result
;
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.GeneralStatusTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.
enums.org.OrgStatusEnum
;
import
com.jz.dm.common.
util.DateUtil
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
...
@@ -19,6 +17,7 @@ import com.jz.dm.mapper.ApiOrgMapper;
...
@@ -19,6 +17,7 @@ import com.jz.dm.mapper.ApiOrgMapper;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiOrg
;
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.dto.AuthInfoDto
;
import
com.jz.dm.models.req.auth.*
;
import
com.jz.dm.models.req.auth.*
;
import
com.jz.dm.models.resp.AuthUserResponse
;
import
com.jz.dm.models.resp.AuthUserResponse
;
...
@@ -34,6 +33,7 @@ import javax.annotation.Resource;
...
@@ -34,6 +33,7 @@ import javax.annotation.Resource;
import
java.util.Date
;
import
java.util.Date
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthModeEnum
.
fromTypeModeName
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthModeEnum
.
fromTypeModeName
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthTypeEnum
.
fromAuthTypeName
;
/**
/**
* @author ZC
* @author ZC
...
@@ -89,6 +89,29 @@ public class AuthServiceImpl implements AuthService {
...
@@ -89,6 +89,29 @@ public class AuthServiceImpl implements AuthService {
return
Result
.
of_success
(
apiAuthMapper
.
selectAuthDetail
(
req
));
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认证信息
* 添加dmp认证信息
*
*
...
@@ -102,20 +125,23 @@ public class AuthServiceImpl implements AuthService {
...
@@ -102,20 +125,23 @@ public class AuthServiceImpl implements AuthService {
if
(
null
==
apiInterface
)
{
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
"api授权信息不存在!"
);
return
Result
.
of_error
(
"api授权信息不存在!"
);
}
}
if
(
ApiStatusEnum
.
DRAFT
.
name
().
equals
(
apiInterface
.
getStatus
())){
return
Result
.
of_error
(
"api未发布,无法授权"
);
}
if
(
ApiStatusEnum
.
EXPIRY
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
if
(
ApiStatusEnum
.
EXPIRY
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
return
Result
.
of_error
(
"api已下架,无法授权"
);
return
Result
.
of_error
(
"api已下架,无法授权"
);
}
}
ApiOrg
apiOrg
=
apiOrgMapper
.
selectOne
(
new
QueryWrapper
<
ApiOrg
>().
eq
(
"org_code"
,
req
.
getOrgCode
()));
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
(
"组织信息不存在!"
);
return
Result
.
of_error
(
"组织信息不存在!"
);
}
}
//授权验证
//授权验证
//
if (StringUtils.isNotBlank(req.getAuthType())){
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
())){
// if (null == from
TypeName(req.getAuthType())){
if
(
null
==
fromAuth
TypeName
(
req
.
getAuthType
())){
//
return Result.of_error("授权类型不存在!");
return
Result
.
of_error
(
"授权类型不存在!"
);
//
}
}
//
}
}
//验证授权方式
//验证授权方式
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
()))
{
if
(
null
==
fromTypeModeName
(
req
.
getAuthMode
()))
{
if
(
null
==
fromTypeModeName
(
req
.
getAuthMode
()))
{
...
@@ -130,7 +156,7 @@ public class AuthServiceImpl implements AuthService {
...
@@ -130,7 +156,7 @@ public class AuthServiceImpl implements AuthService {
if
(
StringUtils
.
isBlank
(
apiOrg
.
getOrgCode
()))
{
if
(
StringUtils
.
isBlank
(
apiOrg
.
getOrgCode
()))
{
return
Result
.
of_error
(
"内部授权组织编码不能为空!!"
);
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 {
...
@@ -149,16 +175,19 @@ public class AuthServiceImpl implements AuthService {
if
(
ApiStatusEnum
.
SOLDOUT
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
if
(
ApiStatusEnum
.
SOLDOUT
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
return
Result
.
of_error
(
"api已下架,无法授权"
);
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
()));
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
(
"组织信息不存在!"
);
return
Result
.
of_error
(
"组织信息不存在!"
);
}
}
//授权验证
//授权验证
//
if (StringUtils.isNotBlank(req.getAuthType())){
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
())){
// if (null == from
TypeName(req.getAuthType())){
if
(
null
==
fromAuth
TypeName
(
req
.
getAuthType
())){
//
return Result.of_error("授权类型不存在!");
return
Result
.
of_error
(
"授权类型不存在!"
);
//
}
}
//
}
}
//验证授权方式
//验证授权方式
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
()))
{
if
(
null
==
fromTypeModeName
(
req
.
getAuthMode
()))
{
if
(
null
==
fromTypeModeName
(
req
.
getAuthMode
()))
{
...
@@ -181,7 +210,7 @@ public class AuthServiceImpl implements AuthService {
...
@@ -181,7 +210,7 @@ public class AuthServiceImpl implements AuthService {
if
(
StringUtils
.
isBlank
(
req
.
getUserId
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getUserId
()))
{
return
Result
.
of_error
(
"外部授权用户Id不能为空"
);
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 {
...
@@ -190,11 +219,10 @@ public class AuthServiceImpl implements AuthService {
* @param apiInterface
* @param apiInterface
* @param apiOrg
* @param apiOrg
* @param req
* @param req
* @param orgType
* @return
* @return
*/
*/
private
Result
saveAuthInfo
(
ApiInterface
apiInterface
,
ApiOrg
apiOrg
,
private
Result
saveAuthInfo
(
ApiInterface
apiInterface
,
ApiOrg
apiOrg
,
AuthUserApiReq
req
,
String
orgType
)
{
AuthUserApiReq
req
)
{
AuthUserResponse
response
=
new
AuthUserResponse
();
AuthUserResponse
response
=
new
AuthUserResponse
();
ApiAuth
apiAuth
=
new
ApiAuth
();
ApiAuth
apiAuth
=
new
ApiAuth
();
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
...
@@ -202,21 +230,11 @@ public class AuthServiceImpl implements AuthService {
...
@@ -202,21 +230,11 @@ public class AuthServiceImpl implements AuthService {
apiAuth
.
setApiOrgId
(
apiOrg
.
getId
());
apiAuth
.
setApiOrgId
(
apiOrg
.
getId
());
apiAuth
.
setReqType
(
apiInterface
.
getReqType
());
apiAuth
.
setReqType
(
apiInterface
.
getReqType
());
apiAuth
.
setReqFrequency
(
apiInterface
.
getReqFrequency
());
apiAuth
.
setReqFrequency
(
apiInterface
.
getReqFrequency
());
if
(
Constants
.
AUTH_INT
.
equals
(
orgType
))
{
//内部授权
if
(!
AuthModeEnum
.
RECORD_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
())){
apiAuth
.
setAuthType
(
AuthTypeEnum
.
DMP_AUTH
.
name
());
apiAuth
.
setValidExprDate
(
DateUtil
.
getAssignYearDate
(
99
));
//过期时间
}
else
{
apiAuth
.
setAuthType
(
AuthTypeEnum
.
DATA_BANK_AUTH
.
name
());
}
}
//商城只有外部授权
//商城只有外部授权
String
authCode
=
""
;
String
authCode
=
getAuthCode
(
apiOrg
.
getOrgCode
(),
""
,
""
);
//内部组织
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
salt
=
RandomUtil
.
getStringRandom
(
8
);
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
apiAuth
.
setAuthCode
(
authCode
);
//授权码
apiAuth
.
setAuthCode
(
authCode
);
//授权码
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
View file @
da3c8b94
...
@@ -6,10 +6,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
...
@@ -6,10 +6,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.mapper.ApiInterfaceFileMapper
;
import
com.jz.dm.common.enums.org.OrgStatusEnum
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.mapper.ApiOrgMapper
;
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.domian.ApiOrg
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageAddReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageAddReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq
;
...
@@ -23,8 +22,6 @@ import org.springframework.stereotype.Service;
...
@@ -23,8 +22,6 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.Date
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
org
.
OrgTypeEnum
.
fromOrgTypeEnumName
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PACKAGE_NAME: com.jz.dm.service.impl
...
@@ -40,6 +37,8 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -40,6 +37,8 @@ public class OrganizationManageImpl implements OrganizationManageService {
@Resource
@Resource
private
ApiOrgMapper
apiOrgMapper
;
private
ApiOrgMapper
apiOrgMapper
;
@Resource
private
ApiInterfaceFileMapper
apiInterfaceFileMapper
;
/**
/**
* 组织列表信息查询
* 组织列表信息查询
...
@@ -52,14 +51,17 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -52,14 +51,17 @@ public class OrganizationManageImpl implements OrganizationManageService {
IPage
<
ApiOrg
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
IPage
<
ApiOrg
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
())){
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
query
.
like
(
"org_name"
,
req
.
getOrgName
());
query
.
like
(
"org_name"
,
req
.
getOrgName
());
}
if
(
StringUtils
.
isNotBlank
(
req
.
getLinkman
()))
{
query
.
like
(
"linkman"
,
req
.
getLinkman
());
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
get
Linkman
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
get
OrgCode
()))
{
query
.
like
(
"linkman"
,
req
.
getLinkman
());
query
.
eq
(
"org_code"
,
req
.
getOrgCode
());
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgCode
()
)){
if
(
null
!=
req
.
getFileId
(
)){
query
.
eq
(
"org_
code"
,
req
.
getOrgCode
());
query
.
eq
(
"org_
folder_id"
,
req
.
getFileId
());
}
}
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
query
.
orderByDesc
(
"create_date"
);
query
.
orderByDesc
(
"create_date"
);
...
@@ -89,53 +91,101 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -89,53 +91,101 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/
*/
@Override
@Override
public
Result
add
(
OrganizationManageAddReq
req
)
{
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
());
ApiOrg
org
=
apiOrgMapper
.
selectById
(
req
.
getId
());
if
(
null
==
org
){
if
(
null
==
org
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
}
}
org
.
setUpdateDate
(
new
Date
());
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
())
&&
!
req
.
getOrgName
().
equals
(
org
.
getOrgName
()))
{
if
(
apiOrgMapper
.
updateById
(
apiOrg
)
>
0
){
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
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
}
}
else
{
//添加
//添加组织
}
else
{
ApiOrg
apiOrg
=
new
ApiOrg
();
BeanUtils
.
copyProperties
(
req
,
apiOrg
);
Result
result
=
addOrg
(
req
,
apiOrg
);
Result
result
=
addOrg
(
req
,
apiOrg
);
if
(
result
!=
null
)
return
result
;
if
(
result
!=
null
)
return
result
;
}
}
return
Result
.
of_error
(
ResultMsg
.
FAILURE
);
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 req
* @param apiOrg
* @param apiOrg
* @return
* @return
*/
*/
private
Result
addOrg
(
OrganizationManageAddReq
req
,
ApiOrg
apiOrg
)
{
private
Result
addOrg
(
OrganizationManageAddReq
req
,
ApiOrg
apiOrg
)
{
String
coding
=
""
;
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
ApiOrg
orgNameInfo
=
getOrgNameInfo
(
req
.
getOrgName
());
if
(
checkOrgName
(
req
.
getOrgName
()))
{
if
(
null
!=
orgNameInfo
)
{
return
Result
.
of_error
(
"组织名称已存在!"
);
return
Result
.
of_error
(
"组织名称已存在!"
);
}
}
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
()))
{
//生成组织编码
if
(
null
==
fromOrgTypeEnumName
(
req
.
getOrgType
())){
String
orgCode
=
generateCode
(
6
);
return
Result
.
of_error
(
"组织类型不存在!"
);
if
(
StringUtils
.
isBlank
(
orgCode
))
{
}
}
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
))
{
return
Result
.
of_error
(
"生成组织编码异常!"
);
return
Result
.
of_error
(
"生成组织编码异常!"
);
}
}
apiOrg
.
setOrgCode
(
coding
);
//组织编码
apiOrg
.
setOrgCode
(
orgCode
);
//组织编码
if
(
apiOrgMapper
.
insert
(
apiOrg
)
>
0
)
{
if
(
apiOrgMapper
.
insert
(
apiOrg
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
}
...
@@ -143,54 +193,23 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -143,54 +193,23 @@ public class OrganizationManageImpl implements OrganizationManageService {
}
}
/**
/**
* 获取组织编码(去重)
* 生成组织编码
*
* @param num 生成位数
* @param orgName 组织名称
* @param type 生成类型
* @return
* @return
*/
*/
private
String
generateCode
(
String
orgName
,
String
type
)
{
private
String
generateCode
(
int
num
)
{
String
coding
=
""
;
QueryWrapper
<
ApiOrg
>
queryWra
=
new
QueryWrapper
<>();
coding
=
RandomUtil
.
generateOrgCoding
(
orgName
,
type
);
queryWra
.
select
(
"org_code"
);
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
queryWra
.
last
(
"where id IN (SELECT MAX(id) FROM t_api_org)"
);
query
.
eq
(
"org_code"
,
coding
);
ApiOrg
apiOrg
=
apiOrgMapper
.
selectOne
(
queryWra
);
ApiOrg
org
=
apiOrgMapper
.
selectOne
(
query
);
String
orgCode
=
null
;
if
(
null
!=
org
)
{
if
(
null
!=
apiOrg
)
{
coding
=
RandomUtil
.
generateOrgCoding
(
orgName
,
type
);
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 +224,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -205,7 +224,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
}
}
UpdateWrapper
<
ApiOrg
>
delete
=
new
UpdateWrapper
<>();
UpdateWrapper
<
ApiOrg
>
delete
=
new
UpdateWrapper
<>();
delete
.
set
(
"is_deleted"
,
1
);
delete
.
set
(
"is_deleted"
,
1
);
delete
.
set
(
"status"
,
0
);
delete
.
set
(
"status"
,
0
);
delete
.
eq
(
"id"
,
id
);
delete
.
eq
(
"id"
,
id
);
if
(
apiOrgMapper
.
update
(
null
,
delete
)
>
0
)
{
if
(
apiOrgMapper
.
update
(
null
,
delete
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
...
@@ -223,26 +242,9 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -223,26 +242,9 @@ public class OrganizationManageImpl implements OrganizationManageService {
public
ApiOrg
getAuthOrganization
(
Long
apiOrgId
)
{
public
ApiOrg
getAuthOrganization
(
Long
apiOrgId
)
{
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"id"
,
apiOrgId
);
query
.
eq
(
"id"
,
apiOrgId
);
query
.
eq
(
"status"
,
OrgStatusEnum
.
NORMAL
.
name
()
);
query
.
eq
(
"status"
,
1
);
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiOrgMapper
.
selectOne
(
query
);
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
;
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
da3c8b94
...
@@ -3,21 +3,28 @@ package com.jz.dm.service.impl;
...
@@ -3,21 +3,28 @@ package com.jz.dm.service.impl;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.jz.common.constant.ResultCode
;
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.constant.ResultMsg
;
import
com.jz.common.exception.ResponseException
;
import
com.jz.common.exception.ResponseException
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.Md5
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.common.utils.Result
;
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.GeneralStatusTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
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.common.util.RandomUtil
;
import
com.jz.dm.mapper.*
;
import
com.jz.dm.mapper.*
;
import
com.jz.dm.models.domian.*
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.req.make.*
;
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.dto.ApiServiceApplyDto
;
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.ApiInterfaceService
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.ProducerService
;
import
com.jz.dm.service.ProducerService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -33,7 +40,6 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -33,7 +40,6 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.*
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
apiInterface
.
ApiStatusEnum
.
fromApiStatusName
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthReqTypeEnum
.
fromAuthReqTypeEnum
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthReqTypeEnum
.
fromAuthReqTypeEnum
;
/**
/**
...
@@ -72,23 +78,23 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -72,23 +78,23 @@ public class ProducerServiceImpl implements ProducerService {
private
int
maxTimeout
;
private
int
maxTimeout
;
@Value
(
"${dmp.openapi.timeout.default}"
)
@Value
(
"${dmp.openapi.timeout.default}"
)
private
int
defaultTimeout
;
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
}"
)
@Value
(
"${
data.select.flowUrl
}"
)
private
String
dataBankToken
;
private
String
flowUrl
;
/**
/**
* 获取文件列表
* 获取文件列表
*
*
* @param projectId
* @param projectId
* @param pageSize
* @param pageNum
* @return
* @return
*/
*/
@Override
@Override
...
@@ -100,174 +106,191 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -100,174 +106,191 @@ public class ProducerServiceImpl implements ProducerService {
/**
/**
* 创建文件夹
* 创建文件夹
*
*
* @param projectId
* @param req
* @param parentId
* @param currentUser
* @return
* @return
*/
*/
@Override
@Override
public
Result
createProjectFolder
(
Long
projectId
,
Long
parentId
,
String
currentUser
)
{
public
Result
createProjectFolder
(
CreateFolderReq
req
)
{
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
if
(
null
!=
req
.
getParentId
())
{
query
.
eq
(
"id"
,
parentId
);
ApiInterfaceFile
interfaceFile
=
apiInterfaceFileMapper
.
selectById
(
req
.
getParentId
());
query
.
eq
(
"is_deleted"
,
0
);
if
(
null
==
interfaceFile
)
{
ApiInterfaceFile
apiInterfaceFile
=
apiInterfaceFileMapper
.
selectOne
(
query
);
return
Result
.
of_error
(
"父级文件夹不存在!"
);
if
(
null
==
apiInterfaceFile
)
{
}
return
Result
.
of_error
(
"父级文件夹不存在!"
);
if
(!
req
.
getFileSource
().
equals
(
interfaceFile
.
getFileSource
())){
}
return
Result
.
of_error
(
"父级文件类型错误!"
);
ApiInterfaceFile
instanceFile
=
new
ApiInterfaceFile
();
}
instanceFile
.
setProjectId
(
projectId
);
}
instanceFile
.
setFileSource
(
"1"
);
//文件来源:1 DMP 2 数据银行
if
(
StringUtils
.
isNotBlank
(
req
.
getFileSource
())
&&
instanceFile
.
setParentId
(
parentId
);
"1"
.
equals
(
req
.
getFileSource
()))
{
//api制作创建文件夹
instanceFile
.
setStatus
(
GeneralStatusTypeEnum
.
VALID
.
name
());
if
(
null
==
req
.
getProjectId
())
{
instanceFile
.
setCreateUser
(
currentUser
);
return
Result
.
of_error
(
"项目id不存在!"
);
instanceFile
.
setRemark
(
"DMP创建层级文件夹"
);
}
if
(
apiInterfaceFileMapper
.
insert
(
instanceFile
)
>
0
)
{
if
(!
addFolder
(
req
))
{
return
Result
.
of_error
(
ResultMsg
.
INSERT_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
}
else
if
(
StringUtils
.
isNotBlank
(
req
.
getFileSource
())
&&
"2"
.
equals
(
req
.
getFileSource
()))
{
//组织创建文件夹
if
(!
addFolder
(
req
))
{
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
}
}
return
Result
.
of_error
(
ResultMsg
.
INSERT_FAIL
);
return
Result
.
of_error
(
ResultMsg
.
INSERT_FAIL
);
}
}
/**
/**
*
DMP制作自定义Api
*
添加文件夹
*
*
* @param req
* @param req
* @return
* @return
*/
*/
@Override
private
boolean
addFolder
(
CreateFolderReq
req
)
{
public
Result
addCustomApi
(
ApiInterfaceReq
req
)
{
ApiInterfaceFile
interfaceFile
=
new
ApiInterfaceFile
();
return
saveInterfaceAPi
(
req
);
BeanUtils
.
copyProperties
(
req
,
interfaceFile
);
interfaceFile
.
setStatus
(
GeneralStatusTypeEnum
.
VALID
.
name
());
if
(
null
==
interfaceFile
.
getParentId
()
||
""
.
equals
(
interfaceFile
.
getParentId
())){
interfaceFile
.
setParentId
(
0L
);
//默认父类id为零
}
if
(
apiInterfaceFileMapper
.
insert
(
interfaceFile
)
==
0
)
{
return
true
;
}
return
false
;
}
}
/**
/**
*
数据银行制作API/数据包/自定义
*
获取服务发布列表
*
*
* @param req
* @param req
* @return
* @return
*/
*/
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
getServiceIssueList
(
ServiceIssueReq
req
)
{
public
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
)
{
IPage
<
ApiServiceApplyDto
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiServiceApplyDto
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"file_source"
,
"2"
);
if
(
null
!=
req
.
getFileId
())
{
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"ai.file_id"
,
req
.
getFileId
());
List
<
ApiInterfaceFile
>
fileSource
=
apiInterfaceFileMapper
.
selectList
(
query
);
if
(
fileSource
.
size
()
==
0
||
fileSource
.
size
()
>=
2
)
{
return
Result
.
of_error
(
"文件夹信息异常!"
);
}
}
// if (StringUtils.isNotBlank(req.getOutputType()) &&
if
(
StringUtils
.
isNotBlank
(
req
.
getApiName
()))
{
// (!req.getOutputType().contains(ApiInfoOutTypeEnum.JSON.name()) ||
query
.
eq
(
"ai.api_name"
,
req
.
getApiName
());
// !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
();
if
(
StringUtils
.
isNotBlank
(
req
.
getApiId
()))
{
String
signResult
=
Md5
.
encrypt
(
signStr
,
""
);
query
.
eq
(
"ai.api_key"
,
req
.
getApiId
());
if
(!
signResult
.
equals
(
req
.
getSign
()))
{
return
Result
.
of_error
(
"签名错误!"
);
}
}
String
apiKey
=
getApiKey
();
query
.
eq
(
"ai.is_deleted"
,
0
);
switch
(
req
.
getJoinType
())
{
query
.
orderByDesc
(
"ai.create_date"
);
case
"10006"
:
//数据银行三方上传
return
Result
.
of_success
(
apiInterfaceMapper
.
listApiIssueService
(
page
,
query
));
saveDataBanker
(
req
,
apiKey
,
"3"
);
break
;
case
"10007"
:
//数据银行数据包上传
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 id
* @param apiKey apiKey
* @param optStatus
* @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
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
}
/**
* 保存api基本信息
*
* @param req
* @param apiKey
* @param apiType
* @return
* @return
*/
*/
private
ApiInterface
saveApiInterFace
(
MakeDataBankApiReq
req
,
@Override
String
apiKey
,
String
apiType
)
{
public
Result
optionApiIssueStatus
(
Long
id
,
Boolean
optStatus
)
{
ApiInterface
anInterface
=
new
ApiInterface
();
int
updateStatus
=
0
;
anInterface
.
setApiType
(
apiType
);
//数据银行制作大数据表
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
id
);
anInterface
.
setStatus
(
ProducerStatusTypeEnum
.
ISSUE
.
name
());
//发布
if
(
null
==
apiInterface
)
{
anInterface
.
setApiKey
(
apiKey
);
//apiKey
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_FOUND
);
BeanUtils
.
copyProperties
(
req
,
anInterface
);
if
(
apiInterfaceMapper
.
insert
(
anInterface
)
==
0
)
{
throw
ResponseException
.
of
(
ResultCode
.
FAILURE
,
"保存api基本信息异常!"
);
}
}
return
anInterface
;
//修改前后状态一致,无需修改直接返回
if
(
optStatus
.
equals
(
apiInterface
.
getStatus
()))
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
if
(
optStatus
)
{
//发布
UpdateWrapper
<
ApiInterface
>
updateWra
=
new
UpdateWrapper
<>();
updateWra
.
set
(
"status"
,
ApiStatusEnum
.
ISSUE
.
name
());
updateWra
.
eq
(
"id"
,
id
);
updateStatus
=
apiInterfaceMapper
.
update
(
null
,
updateWra
);
}
else
{
//取消发布
if
(
apiInterface
.
getIsSendBank
())
{
return
Result
.
of_error
(
"API信息已锁定,无法取消发布"
);
}
UpdateWrapper
<
ApiInterface
>
updateWra
=
new
UpdateWrapper
<>();
updateWra
.
set
(
"status"
,
ApiStatusEnum
.
DRAFT
.
name
());
updateWra
.
eq
(
"id"
,
id
);
updateStatus
=
apiInterfaceMapper
.
update
(
null
,
updateWra
);
}
if
(
updateStatus
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
return
Result
.
of_error
(
ResultMsg
.
UPDATE_FAIL
);
}
}
/**
/**
*
保存APi扩展信息
*
获取ApiId
*
*
* @param req
* @param apiKey
* @param interFaceId
* @return
* @return
*/
*/
private
ApiInterfaceCustom
saveApiInterFaceCustom
(
MakeDataBankApiReq
req
,
String
apiKey
,
@Override
Long
interFaceId
)
{
public
Result
getCustomApiId
()
{
ApiInterfaceCustom
interfaceCustom
=
new
ApiInterfaceCustom
();
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
,
getApiKey
());
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
* @param req
* @return
* @return
*/
*/
@Override
@Override
public
Result
addRealCustomApi
(
MakeRealCustomApiReq
req
)
{
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
addBigDataMakeApi
(
ApiInterfaceReq
req
)
{
return
null
;
ApiInterface
anInterface
=
apiInterfaceService
.
getApiInfo
(
req
.
apiKey
);
if
(
null
!=
anInterface
){
return
Result
.
of_error
(
"API已存在!"
);
}
if
(
"10002"
.
equals
(
req
.
getApiType
()))
{
//数据查询
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
.
getLimitType
()))
{
if
(
null
==
fromAuthReqTypeEnum
(
req
.
getLimitType
()))
{
return
Result
.
of_error
(
"限流类型不存在!"
);
}
}
//校验文件夹信息
if
(
checkFileifExist
(
req
.
getFileId
(),
req
.
getProjectId
()))
{
return
Result
.
of_error
(
"目标文件夹不存在!"
);
}
//保存表字段信息
saveTableField
(
req
);
if
(
null
!=
req
.
getId
())
{
//更新
if
(
saveUpdateAPiBaseData
(
req
)
||
saveUpdateApiExtendData
(
req
))
{
throw
ResponseException
.
of_error
(
ResultMsg
.
UPDATE_FAIL
);
}
}
else
{
//保存
ApiInterface
apiInterface
=
saveApiBaseData
(
req
);
if
(
saveApiExtendData
(
req
,
apiInterface
.
getId
()))
{
throw
ResponseException
.
of_error
(
ResultMsg
.
INSERT_FAIL
);
}
}
//保存缓存信息
saveObjOnRedis
(
req
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
}
/**
/**
*
DMP大数据查询/标签查询
*
数据表查询 && 保存表字段信息
*
*
* @param req
* @param req
* @return
*/
*/
@Override
private
void
saveTableField
(
ApiInterfaceReq
req
)
{
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
if
(
StringUtils
.
isBlank
(
req
.
getTableFields
())){
public
Result
addBigDataMakeApi
(
MakeBigDataApiReq
req
)
{
return
;
ApiInterface
apiInterface
=
apiInterfaceService
.
getApiInfo
(
req
.
getApiKey
());
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
"API基本信息为空!"
);
}
}
QueryWrapper
<
ApiOpenApiEsFields
>
queryOpenApi
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOpenApiEsFields
>
queryOpenApi
=
new
QueryWrapper
<>();
queryOpenApi
.
eq
(
"es_database"
,
req
.
getEsDataBase
());
queryOpenApi
.
eq
(
"es_database"
,
req
.
getEsDataBase
());
...
@@ -299,33 +322,10 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -299,33 +322,10 @@ public class ProducerServiceImpl implements ProducerService {
if
(
CollectionUtils
.
isNotEmpty
(
listApiEsFields
))
{
if
(
CollectionUtils
.
isNotEmpty
(
listApiEsFields
))
{
apiOpenApiEsFieldsMapper
.
insetBatch
(
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
());
}
}
/**
/**
* DMP保存api基本信息/自定义API
* DMP保存api基本信息/自定义API
(三方查询)
*
*
* @param req
* @param req
* @return
* @return
...
@@ -333,181 +333,191 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -333,181 +333,191 @@ public class ProducerServiceImpl implements ProducerService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
if
(
StringUtils
.
isNotBlank
(
req
.
getReqType
()))
{
ApiInterface
anInterface
=
apiInterfaceService
.
getApiInfo
(
req
.
apiKey
);
if
(
null
==
fromAuthReqTypeEnum
(
req
.
getReqType
()))
{
if
(
null
!=
anInterface
){
return
Result
.
of_error
(
"API已存在!"
);
}
if
(
StringUtils
.
isNotBlank
(
req
.
getLimitType
()))
{
if
(
null
==
fromAuthReqTypeEnum
(
req
.
getLimitType
()))
{
return
Result
.
of_error
(
"限流类型不存在!"
);
return
Result
.
of_error
(
"限流类型不存在!"
);
}
}
}
}
//生成ApiKey
if
(
StringUtils
.
isBlank
(
req
.
getSignType
())
||
"0"
.
equals
(
req
.
getSignType
()))
{
String
apiKey
=
getApiKey
();
return
Result
.
of_error
(
"加密类型错误!"
);
ApiInterface
apiInterface
=
new
ApiInterface
();
if
(
null
==
req
.
getFileId
())
{
//创建下级文件夹
Long
fileId
=
checkFileExist
(
req
.
getProjectId
(),
req
.
getParentId
(),
req
.
getCreateUser
());
req
.
setFileId
(
fileId
);
}
}
BeanUtils
.
copyProperties
(
req
,
apiInterface
);
if
(
null
!=
req
.
getReqFrequency
())
{
apiInterface
.
setApiKey
(
apiKey
);
if
(
req
.
getReqFrequency
()
<=
0
)
{
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
return
Result
.
of_error
(
"限流次数不能小于或者等于零"
);
apiInterface
.
setStatus
(
ApiStatusEnum
.
ISSUE
.
name
());
//发布
}
if
(
"10004"
.
equals
(
req
.
getJoinType
()))
{
//dmp自定义
apiInterface
.
setApiType
(
"7"
);
}
else
if
(
"10002"
.
equals
(
req
.
getJoinType
()))
{
//大数据表查询
apiInterface
.
setApiType
(
"6"
);
}
}
Long
timeout
=
Long
.
parseLong
(
req
.
getTimeout
());
if
(
StringUtils
.
isBlank
(
req
.
getTargetUrl
())){
if
(
timeout
==
null
||
timeout
==
0
)
{
return
Result
.
of_error
(
"目标地址不存在!"
);
apiInterface
.
setTimeout
(
String
.
valueOf
(
defaultTimeout
));
}
else
if
(
timeout
<
0
)
{
return
Result
.
of_error
(
"接口超时时间最小0ms"
);
}
else
if
(
timeout
>
maxTimeout
)
{
return
Result
.
of_success
(
"接口超时时间最大5000ms"
);
}
}
if
(
apiInterfaceMapper
.
insert
(
apiInterface
)
==
0
)
{
//校验文件夹信息
throw
ResponseException
.
of_error
(
"保存Api信息失败!"
);
if
(
checkFileifExist
(
req
.
getFileId
(),
req
.
getProjectId
()))
{
return
Result
.
of_error
(
"目标文件夹不存在!"
);
}
}
JSONObject
object
=
new
JSONObject
();
ApiInterface
apiInterface
=
saveApiBaseData
(
req
);
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
if
(
saveApiExtendData
(
req
,
apiInterface
.
getId
()))
{
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
throw
ResponseException
.
of_error
(
"保存Api扩展信息失败!"
);
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
}
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
,
apiKey
);
//缓存API信息
saveObjOnRedis
(
req
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
}
/**
/**
* 缓存数据
* 保存APi扩展信息
* @param id
* @param req
* @return
*/
private
boolean
saveApiExtendData
(
ApiInterfaceReq
req
,
Long
id
)
{
ApiInterfaceCustom
custom
=
new
ApiInterfaceCustom
();
BeanUtils
.
copyProperties
(
req
,
custom
);
custom
.
setApiInterfaceId
(
id
);
if
(
apiInterfaceCustomMapper
.
insert
(
custom
)
==
0
)
{
return
true
;
}
return
false
;
}
/**
* 保存ApiInterfance基本信息
*
*
* @param
apiKey
* @param
req
* @
param params
* @
return
*/
*/
private
void
saveObjOnRedis
(
String
apiKey
,
JSONObject
params
)
{
private
ApiInterface
saveApiBaseData
(
ApiInterfaceReq
req
)
{
if
(
StringUtils
.
isBlank
(
apiKey
)
||
null
==
params
)
{
ApiInterface
apiInterface
=
new
ApiInterface
();
log
.
info
(
"--------------缓存数据为空"
);
BeanUtils
.
copyProperties
(
req
,
apiInterface
);
return
;
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"
);
}
}
try
{
apiInterface
.
setTimeout
(
req
.
getTimeout
());
String
paramKey
=
redisUtils
.
get
(
apiKey
);
if
(
"10002"
.
equals
(
req
.
getApiType
()))
{
//数据表查询时添加
if
(
null
!=
paramKey
)
{
if
(
ApiInfoOutTypeEnum
.
JSON
.
name
().
equals
(
req
.
getOutType
()))
{
redisUtils
.
del
(
apiKey
);
apiInterface
.
setTargetUrl
(
jsonUrl
);
}
else
if
(
ApiInfoOutTypeEnum
.
FLOW
.
name
().
equals
(
req
.
getOutType
()))
{
apiInterface
.
setTargetUrl
(
flowUrl
);
}
}
redisUtils
.
set
(
apiKey
,
params
.
toString
());
}
catch
(
Exception
ex
)
{
log
.
error
(
"缓存api制作数据异常:{}"
,
ex
.
getMessage
());
ex
.
printStackTrace
();
}
}
if
(
apiInterfaceMapper
.
insert
(
apiInterface
)
==
0
)
{
throw
ResponseException
.
of_error
(
"添加API基本信息异常!"
);
}
return
apiInterface
;
}
}
/**
/**
* 校验文件夹
信息
* 校验文件夹
是否存在
*
*
* @param folderId
* @param projectId
* @param projectId
* @param parentId
* @param userName
* @return
*/
*/
private
Long
checkFileExist
(
Long
projectId
,
Long
parentId
,
String
userName
)
{
private
Boolean
checkFileifExist
(
Long
folderId
,
Long
projectId
)
{
if
(
null
==
parentId
)
{
if
(
null
==
folderId
)
{
throw
ResponseException
.
of_error
(
"父文件id不能为空"
);
return
true
;
}
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
)
{
QueryWrapper
<
ApiInterfaceFile
>
queryWra
=
new
QueryWrapper
<>();
//查询父类是否存在
queryWra
.
eq
(
"file_source"
,
1
);
//Api制作
ApiInterfaceFile
apiInterfaceFile
=
queryWra
.
eq
(
"project_id"
,
projectId
);
apiInterfaceFileMapper
.
selectOne
(
new
QueryWrapper
<
ApiInterfaceFile
>().
eq
(
"parent_id"
,
parentId
));
queryWra
.
eq
(
"id"
,
folderId
);
if
(
null
==
apiInterfaceFile
&&
0
==
parentId
)
{
queryWra
.
eq
(
"is_deleted"
,
0
);
file
=
new
ApiInterfaceFile
();
ApiInterfaceFile
apiInterfaceFile
=
apiInterfaceFileMapper
.
selectOne
(
queryWra
);
file
.
setProjectId
(
projectId
);
if
(
null
==
apiInterfaceFile
)
{
file
.
setFileSource
(
"1"
);
//dmp
return
true
;
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
f
ile
.
getId
()
;
return
f
alse
;
}
}
/**
/**
* 保存修改的api信息
* 保存修改的api
基本
信息
*
*
* @param req
* @param req
* @return
* @return
*/
*/
@Override
private
Boolean
saveUpdateAPiBaseData
(
ApiInterfaceReq
req
)
{
public
Result
saveUpdateAPiInfo
(
ApiInterfaceReq
req
)
{
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
if
(
null
==
apiInterface
)
{
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_FOUND
);
throw
ResponseException
.
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
(
"更新状态不存在!"
);
}
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
()))
{
if
(!
canChange
(
apiInterface
.
getStatus
(),
req
.
getStatus
()))
{
if
(!
canChange
(
apiInterface
.
getStatus
(),
req
.
getStatus
()))
{
String
errorMsg
=
String
.
format
(
"api当前状态为%s不可变更为%s"
,
String
errorMsg
=
String
.
format
(
"api当前状态为%s不可变更为%s"
,
ApiStatusEnum
.
valueOf
(
apiInterface
.
getStatus
()).
getText
(),
ApiStatusEnum
.
valueOf
(
apiInterface
.
getStatus
()).
getText
(),
ApiStatusEnum
.
valueOf
(
req
.
getStatus
()).
getText
());
ApiStatusEnum
.
valueOf
(
req
.
getStatus
()).
getText
());
return
Result
.
of_error
(
errorMsg
);
throw
ResponseException
.
of_error
(
errorMsg
);
}
}
if
(
null
!=
req
.
getReqFrequency
())
{
if
(
req
.
getReqFrequency
()
<=
0
)
{
return
Result
.
of_error
(
"限流次数不能小于或者等于零"
);
}
}
}
}
apiInterface
.
setApiType
(
req
.
getApiType
());
apiInterface
.
setApiType
(
req
.
getApiType
());
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setReqType
(
req
.
getReqType
());
apiInterface
.
setReqFrequency
(
req
.
getReqFrequency
());
apiInterface
.
setReqFrequency
(
req
.
getReqFrequency
());
apiInterface
.
setVersion
(
RandomUtil
.
generateVersion
(
apiInterface
.
getVersion
()));
//版本自动累加
apiInterface
.
setVersion
(
RandomUtil
.
generateVersion
(
apiInterface
.
getVersion
()));
//版本自动累加
apiInterface
.
setSignType
(
req
.
getSignType
());
apiInterface
.
setSignType
(
req
.
getSignType
());
apiInterface
.
setApiFunction
(
req
.
getApiFunction
());
apiInterface
.
setApiFunction
(
req
.
getApiFunction
());
apiInterface
.
setStatus
(
req
.
getStatus
());
apiInterface
.
setStatus
(
req
.
getStatus
());
apiInterface
.
setApiProtocl
(
req
.
get
TransMode
());
//传输方式 https http
apiInterface
.
setApiProtocl
(
req
.
get
ApiProtocl
());
//传输方式 https http
apiInterface
.
setUpdateDate
(
new
Date
());
apiInterface
.
setUpdateDate
(
new
Date
());
apiInterface
.
setUpdateUser
(
req
.
getCreateUser
());
apiInterface
.
setUpdateUser
(
req
.
getCreateUser
());
if
(
StringUtils
.
isNotBlank
(
req
.
getTargetUrl
()))
{
apiInterface
.
setTargetUrl
(
req
.
getTargetUrl
());
apiInterface
.
setTargetUrl
(
req
.
getTargetUrl
());
}
Long
timeout
=
Long
.
parseLong
(
req
.
getTimeout
());
Long
timeout
=
Long
.
parseLong
(
req
.
getTimeout
());
if
(
timeout
==
null
||
timeout
==
0
)
{
if
(
timeout
==
null
||
timeout
==
0
)
{
apiInterface
.
setTimeout
(
String
.
valueOf
(
defaultTimeout
));
apiInterface
.
setTimeout
(
String
.
valueOf
(
defaultTimeout
));
}
else
if
(
timeout
<
0
)
{
}
else
if
(
timeout
<
0
)
{
return
Result
.
of_error
(
"接口超时时间最小0ms"
);
throw
ResponseException
.
of_error
(
"接口超时时间最小0ms"
);
}
else
if
(
timeout
>
maxTimeout
)
{
}
else
if
(
timeout
>
maxTimeout
)
{
return
Result
.
of_success
(
"接口超时时间最大5000ms"
);
throw
ResponseException
.
of_error
(
"接口超时时间最大5000ms"
);
}
}
apiInterface
.
setTimeout
(
req
.
getTimeout
());
apiInterface
.
setTimeout
(
req
.
getTimeout
());
if
(
apiInterfaceMapper
.
updateById
(
apiInterface
)
>
0
)
{
if
(
apiInterfaceMapper
.
updateById
(
apiInterface
)
==
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
)
;
return
true
;
}
}
JSONObject
object
=
new
JSONObject
();
return
false
;
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
}
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
/**
return
Result
.
of_success
(
ResultMsg
.
UPDATE_FAIL
);
* 保存更新数据扩展信息
*
* @param req
* @return
*/
private
Boolean
saveUpdateApiExtendData
(
ApiInterfaceReq
req
)
{
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
ApiInterfaceCustom
interfaceCustom
=
null
;
if
(
null
!=
apiInterface
)
{
QueryWrapper
<
ApiInterfaceCustom
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"api_interface_id"
,
req
.
getId
());
query
.
eq
(
"api_key"
,
apiInterface
.
getApiKey
());
query
.
eq
(
"is_deleted"
,
0
);
interfaceCustom
=
apiInterfaceCustomMapper
.
selectOne
(
query
);
}
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
;
}
}
/**
/**
...
@@ -538,11 +548,223 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -538,11 +548,223 @@ 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
.
getReqType
())
||
StringUtils
.
isBlank
(
req
.
getApiType
()))
{
log
.
info
(
"--------------缓存数据为空"
);
return
;
}
try
{
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"outputType"
,
ApiInfoOutTypeEnum
.
JSON
.
name
());
object
.
put
(
"reqType"
,
req
.
getReqType
());
object
.
put
(
"apiType"
,
req
.
getApiType
());
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
* @param req
* @return
* @return
*/
*/
/*
@Override
@Override
public Result getSourceConfig(SourceConfigReq req) {
public Result getSourceConfig(SourceConfigReq req) {
if (StringUtils.isBlank(req.getApiKey())) {
if (StringUtils.isBlank(req.getApiKey())) {
...
@@ -565,12 +787,12 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -565,12 +787,12 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_success(ResultMsg.SUCCESS);
return Result.of_success(ResultMsg.SUCCESS);
}
}
/**
*/
/**
* 获取数据源库配置
* 获取数据源库配置
*
*
* @param id
* @param id
* @return
* @return
*/
*/
/*
@Override
@Override
public Result getSourceWarehouseList(Long id) {
public Result getSourceWarehouseList(Long id) {
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
...
@@ -596,13 +818,13 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -596,13 +818,13 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_success(result);
return Result.of_success(result);
}
}
/**
*/
/**
* 获取某个索引下的type
* 获取某个索引下的type
*
*
* @param indices
* @param indices
* @param id
* @param id
* @return
* @return
*/
*/
/*
@Override
@Override
public Result getIndicesTypes(String indices, Long id) {
public Result getIndicesTypes(String indices, Long id) {
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
...
@@ -618,14 +840,14 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -618,14 +840,14 @@ public class ProducerServiceImpl implements ProducerService {
return Result.of_success(resp);
return Result.of_success(resp);
}
}
/**
*/
/**
* 获取某个索引 type的fields
* 获取某个索引 type的fields
*
*
* @param indices
* @param indices
* @param type
* @param type
* @param id
* @param id
* @return
* @return
*/
*/
/*
@Override
@Override
public Result getIndicesTypesFields(String indices, String type, Long id) {
public Result getIndicesTypesFields(String indices, String type, Long id) {
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
ApiSyncingDatasource datasource = apiSyncingDatasourceMapper.selectById(id);
...
@@ -647,31 +869,15 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -647,31 +869,15 @@ public class ProducerServiceImpl implements ProducerService {
e.printStackTrace();
e.printStackTrace();
}
}
return Result.of_success(resp);
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() {
public Result saveObjOnRedis() {
MakeDataBankApiReq bankApiReq = new MakeDataBankApiReq();
MakeDataBankApiReq bankApiReq = new MakeDataBankApiReq();
/* bankApiReq.setTransMode("HTTPS");
*/
/* bankApiReq.setTransMode("HTTPS");
bankApiReq.setSignType("MD5");
bankApiReq.setSignType("MD5");
bankApiReq.setJoinType("10004");
bankApiReq.setJoinType("10004");
bankApiReq.setOutputType("JSON");
bankApiReq.setOutputType("JSON");
...
@@ -684,7 +890,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -684,7 +890,7 @@ public class ProducerServiceImpl implements ProducerService {
bankApiReq.setApiDesc("4444");
bankApiReq.setApiDesc("4444");
bankApiReq.setTimeout("5000");
bankApiReq.setTimeout("5000");
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(bankApiReq);
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();
JSONObject object = new JSONObject();
object.put("targetUrl", "www.baidu.common");
object.put("targetUrl", "www.baidu.common");
object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
object.put("outputType", ApiInfoOutTypeEnum.JSON.name());
...
@@ -699,5 +905,5 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -699,5 +905,5 @@ public class ProducerServiceImpl implements ProducerService {
JSONObject jsonObject = JSONObject.parseObject(apiKeyTest002);
JSONObject jsonObject = JSONObject.parseObject(apiKeyTest002);
System.out.println(jsonObject);
System.out.println(jsonObject);
return Result.ok();
return Result.ok();
}
}
*/
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
da3c8b94
...
@@ -15,11 +15,13 @@ import com.jz.dm.common.util.stream.HttpDownload;
...
@@ -15,11 +15,13 @@ import com.jz.dm.common.util.stream.HttpDownload;
import
com.jz.dm.gateway.OpenApiService
;
import
com.jz.dm.gateway.OpenApiService
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -27,6 +29,9 @@ import org.springframework.stereotype.Service;
...
@@ -27,6 +29,9 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -61,9 +66,13 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
...
@@ -61,9 +66,13 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
@Autowired
@Autowired
private
HttpsUtils
httpsUtils
;
private
HttpsUtils
httpsUtils
;
/**
* 数据银行扣款链接
*/
@Value
(
"${data.bank.balanceUrl}"
)
@Value
(
"${data.bank.balanceUrl}"
)
private
String
balanceUrl
;
private
String
balanceUrl
;
/**
/**
* API请求逻辑处理
* API请求逻辑处理
*
*
...
@@ -74,40 +83,42 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
...
@@ -74,40 +83,42 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
@ApiLogAspect
(
description
=
"API请求日志"
)
@ApiLogAspect
(
description
=
"API请求日志"
)
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@SentinelResource
(
value
=
"api.gateway"
,
fallback
=
"fallbackGateway"
)
@SentinelResource
(
value
=
"api.gateway"
,
fallback
=
"fallbackGateway"
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRE
S_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRE
D
)
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getOpenApiParams
());
String
authCode
=
parameter
.
getString
(
"authCode"
);
if
(
StringUtils
.
isBlank
(
authCode
))
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
verifyApiInterface
(
apiInterfaceService
.
getApiInfo
(
request
.
getApiKey
()));
ApiAuth
apiAuth
=
authService
.
getAuthInfo
(
authCode
);
verifyAuth
(
apiAuth
);
String
reqParams
=
parameter
.
getString
(
"reqParams"
);
Map
paramMap
=
null
;
if
(
StringUtils
.
isNotBlank
(
reqParams
))
{
paramMap
=
(
Map
)
JSONObject
.
parseObject
(
reqParams
);
}
//取出缓存数据
String
redisReqParam
=
redisUtils
.
get
(
request
.
getApiKey
());
boolean
bResult
=
false
;
boolean
bResult
=
false
;
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getOpenApiParams
());
ApiInterface
apiInterface
=
apiInterfaceService
.
getApiInfo
(
request
.
getApiKey
());
ApiAuth
apiAuth
=
null
;
JSONObject
jsonParams
=
null
;
try
{
try
{
String
reqParams
=
parameter
.
getString
(
"reqParams"
);
Map
paramMap
=
null
;
if
(
StringUtils
.
isNotBlank
(
reqParams
))
{
jsonParams
=
JSONObject
.
parseObject
(
reqParams
);
paramMap
=
JSONObject
.
parseObject
(
jsonParams
.
getString
(
"request_fileds"
),
Map
.
class
);
jsonParams
.
put
(
"is_test"
,
false
);
}
String
authCode
=
parameter
.
getString
(
"authCode"
);
if
(
StringUtils
.
isBlank
(
authCode
))
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
verifyApiInterface
(
apiInterface
);
apiAuth
=
authService
.
getAuthInfo
(
authCode
);
verifyAuth
(
apiAuth
);
//取出缓存数据
/* String redisReqParam = redisUtils.get(request.getApiKey());*/
String
redisReqParam
=
null
;
if
(
StringUtils
.
isNotBlank
(
redisReqParam
))
{
//redis中存在
if
(
StringUtils
.
isNotBlank
(
redisReqParam
))
{
//redis中存在
//解析出API制作成功时的参数配置
//解析出API制作成功时的参数配置
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
redisReqParam
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
redisReqParam
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
bResult
=
rangRequestTarget
(
outputType
,
targetUrl
,
paramMap
,
response
);
String
apiType
=
jsonObject
.
getString
(
"apiType"
);
bResult
=
rangRequestTarget
(
outputType
,
targetUrl
,
paramMap
,
jsonParams
,
apiType
,
apiInterface
,
response
);
}
else
{
//不存在查询数据库
}
else
{
//不存在查询数据库
ApiInterface
apiInterface
=
apiInterfaceService
.
getReqTargetInfo
(
request
.
getApiKey
());
if
(
null
==
apiInterface
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
}
bResult
=
rangRequestTarget
(
apiInterface
.
getOutputType
(),
bResult
=
rangRequestTarget
(
apiInterface
.
getOutputType
(),
apiInterface
.
getTargetUrl
(),
paramMap
,
response
);
apiInterface
.
getTargetUrl
(),
paramMap
,
jsonParams
,
apiInterface
.
getApiType
(),
apiInterface
,
response
);
}
}
//调用成功请求数据银行扣款
//调用成功请求数据银行扣款
if
(
AuthModeEnum
.
POWER_CALL_MODE
.
name
().
equals
(
apiAuth
.
getAuthMode
()))
{
if
(
AuthModeEnum
.
POWER_CALL_MODE
.
name
().
equals
(
apiAuth
.
getAuthMode
()))
{
...
@@ -137,52 +148,234 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
...
@@ -137,52 +148,234 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param outputType
* @param outputType
* @param targetUrl
* @param targetUrl
* @param param
* @param param
* @param apiType
* @param response
* @param response
*/
*/
private
boolean
rangRequestTarget
(
String
outputType
,
String
targetUrl
,
private
boolean
rangRequestTarget
(
String
outputType
,
String
targetUrl
,
Map
<
String
,
String
>
param
,
OpenApiResponse
response
)
{
Map
<
String
,
String
>
param
,
JSONObject
jsonParams
,
String
apiType
,
ApiInterface
apiInterface
,
OpenApiResponse
response
)
{
if
(
StringUtils
.
isBlank
(
outputType
))
{
if
(
StringUtils
.
isBlank
(
outputType
))
{
outputType
=
ApiInfoOutTypeEnum
.
JSON
.
name
();
outputType
=
ApiInfoOutTypeEnum
.
JSON
.
name
();
}
}
if
(
StringUtils
.
isBlank
(
targetUrl
))
{
if
(
StringUtils
.
isBlank
(
targetUrl
))
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_PARAM_EMPTY
);
}
if
(
StringUtils
.
isBlank
(
apiType
))
{
throw
new
GatewayException
(
GatewayResultCode
.
API_TYPE_ERROR
);
}
}
if
(
"10002"
.
equals
(
apiType
)
||
"10009"
.
equals
(
apiType
))
{
//数据表查询
return
dataTableSelect
(
outputType
,
targetUrl
,
param
,
jsonParams
,
apiInterface
,
response
);
}
else
if
(
"10004"
.
equals
(
apiType
)
||
"10008"
.
equals
(
apiType
))
{
//三方查询
return
thirdSelect
(
targetUrl
,
apiInterface
,
jsonParams
,
response
);
}
else
if
(
"10005"
.
equals
(
apiType
)
||
"10007"
.
equals
(
apiType
))
{
//数据包查询
return
dataBagDownload
(
targetUrl
,
jsonParams
,
response
);
}
else
{
throw
new
GatewayException
(
GatewayResultCode
.
API_TYPE_ERROR
);
}
}
/**
* 三方查询 $$ 数据银行+DMP
*
* @param targetUrl
* @param apiInterface
* @param response
* @return
*/
private
boolean
thirdSelect
(
String
targetUrl
,
ApiInterface
apiInterface
,
JSONObject
jsonParams
,
OpenApiResponse
response
)
{
if
(
"POST"
.
equalsIgnoreCase
(
apiInterface
.
getReqType
()))
{
return
callMethodResponse
(
httpsUtils
.
submitPost
(
targetUrl
,
jsonParams
.
toString
()),
response
);
}
else
{
Map
map
=
JSONObject
.
parseObject
(
jsonParams
.
toString
(),
Map
.
class
);
return
callMethodResponse
(
httpsUtils
.
doGet
(
targetUrl
,
map
),
response
);
}
}
/**
* 数据包下载 $$ 数据银行+DMP
* @param targetUrl
* @param param
* @return
*/
private
boolean
dataBagDownload
(
String
targetUrl
,
JSONObject
param
,
OpenApiResponse
response
)
{
String
fileLocation
=
param
.
getString
(
"file_location"
);
String
datasourceId
=
param
.
getString
(
"datasourceId"
);
if
(
null
==
fileLocation
||
null
==
datasourceId
)
{
throw
new
GatewayException
(
GatewayResultCode
.
DATA_BIG_ADDR_UNEXIST
);
}
JSONObject
requestParams
=
new
JSONObject
();
requestParams
.
put
(
"file_location"
,
fileLocation
);
requestParams
.
put
(
"datasourceId"
,
datasourceId
);
HttpDownload
.
postDownload
(
targetUrl
,
requestParams
);
response
.
setCode
(
GatewayResultCode
.
SUCCESS
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
SUCCESS
.
getMsg
());
return
true
;
}
/**
* 数据表查询
*
* @param outputType
* @param targetUrl
* @param param
* @param apiInterface
* @param response
* @return
*/
protected
boolean
dataTableSelect
(
String
outputType
,
String
targetUrl
,
Map
<
String
,
String
>
param
,
JSONObject
jsonParams
,
ApiInterface
apiInterface
,
OpenApiResponse
response
)
{
ApiInterfaceCustom
apiCustomInfo
=
checkParamLegal
(
param
,
apiInterface
);
if
(
ApiInfoOutTypeEnum
.
FLOW
.
name
().
equals
(
outputType
))
{
//文件流形式请求
if
(
ApiInfoOutTypeEnum
.
FLOW
.
name
().
equals
(
outputType
))
{
//文件流形式请求
StringBuilder
builder
=
new
StringBuilder
();
return
flowRequestMethod
(
targetUrl
,
param
,
response
,
apiCustomInfo
);
builder
.
append
(
targetUrl
).
append
(
"?"
);
}
else
if
(
ApiInfoOutTypeEnum
.
JSON
.
name
().
equals
(
outputType
))
{
//json格式请求
for
(
Map
.
Entry
<
String
,
String
>
entry
:
param
.
entrySet
())
{
return
jsonRequestMethod
(
targetUrl
,
param
,
jsonParams
,
response
,
apiCustomInfo
);
String
key
=
entry
.
getKey
();
}
else
{
String
value
=
entry
.
getValue
();
throw
new
GatewayException
(
GatewayResultCode
.
OUTPUT_TYPE_EXCEPTION
);
builder
.
append
(
key
).
append
(
LoggingConstants
.
AND_EQUAL
)
}
.
append
(
value
).
append
(
LoggingConstants
.
AND_SPILT
);
}
/**
* 校验参数合法性
*
* @param param
* @param apiInterface
* @return
*/
private
ApiInterfaceCustom
checkParamLegal
(
Map
<
String
,
String
>
param
,
ApiInterface
apiInterface
)
{
ApiInterfaceCustom
apiCustomInfo
=
apiInterfaceService
.
getApiCustomInfo
(
apiInterface
.
getId
());
boolean
tag
=
false
;
if
(
null
!=
apiCustomInfo
)
{
List
<
Map
>
mapList
=
JSONObject
.
parseArray
(
apiCustomInfo
.
getRequestParam
(),
Map
.
class
);
if
(
CollectionUtils
.
isNotEmpty
(
mapList
))
{
for
(
Map
map
:
mapList
)
{
if
((
Boolean
)
map
.
get
(
"required"
))
{
String
name
=
(
String
)
map
.
get
(
"name"
);
String
field
=
param
.
get
(
name
);
if
(
null
==
field
)
{
tag
=
true
;
}
}
}
if
(
tag
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_PARAM_EMPTY
);
}
}
}
String
baseUrl
=
builder
.
substring
(
0
,
builder
.
length
()
-
1
);
}
HttpDownload
.
download
(
baseUrl
);
return
apiCustomInfo
;
}
/**
* 数据查询---flow流请求方式
*
* @param targetUrl
* @param param
* @param response
* @return
*/
private
boolean
flowRequestMethod
(
String
targetUrl
,
Map
<
String
,
String
>
param
,
OpenApiResponse
response
,
ApiInterfaceCustom
apiCustomInfo
)
{
String
dataSize
=
param
.
get
(
"dataSize"
);
Integer
valueOf
=
-
1
;
if
(
StringUtils
.
isNotBlank
(
dataSize
))
{
valueOf
=
Integer
.
valueOf
(
dataSize
);
}
String
request$Filed
=
null
;
net
.
sf
.
json
.
JSONObject
reqParams
=
net
.
sf
.
json
.
JSONObject
.
fromObject
(
param
);
try
{
request$Filed
=
URLEncoder
.
encode
(
reqParams
.
toString
(),
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
log
.
error
(
"流下载入参编码异常-------"
,
e
.
getMessage
());
}
JSONObject
requestParams
=
new
JSONObject
();
requestParams
.
put
(
"datasourceId"
,
apiCustomInfo
.
getEsDataSource
());
requestParams
.
put
(
"query_database"
,
apiCustomInfo
.
getEsDataBase
());
requestParams
.
put
(
"query_table"
,
apiCustomInfo
.
getEsTable
());
requestParams
.
put
(
"request_fileds"
,
request$Filed
);
requestParams
.
put
(
"response_fields"
,
assembleResponseParams
(
apiCustomInfo
.
getResponseParam
()));
requestParams
.
put
(
"data_size"
,
valueOf
);
HttpDownload
.
postDownload
(
targetUrl
,
requestParams
);
response
.
setCode
(
GatewayResultCode
.
SUCCESS
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
SUCCESS
.
getMsg
());
return
true
;
}
/**
* 数据查询--json请求方式
*
* @param targetUrl
* @param param
* @param response
* @param apiCustomInfo
* @return
*/
private
boolean
jsonRequestMethod
(
String
targetUrl
,
Map
<
String
,
String
>
param
,
JSONObject
jsonParams
,
OpenApiResponse
response
,
ApiInterfaceCustom
apiCustomInfo
)
{
JSONObject
params
=
new
JSONObject
();
try
{
params
.
put
(
"datasourceId"
,
apiCustomInfo
.
getEsDataSource
());
//数据源id
params
.
put
(
"query_database"
,
apiCustomInfo
.
getEsDataBase
());
//数据源库名称
params
.
put
(
"query_table"
,
apiCustomInfo
.
getEsTable
());
//数据源库表
net
.
sf
.
json
.
JSONObject
reqParams
=
net
.
sf
.
json
.
JSONObject
.
fromObject
(
param
);
params
.
put
(
"request_fileds"
,
reqParams
);
//请求参数
params
.
put
(
"response_fields"
,
assembleResponseParams
(
apiCustomInfo
.
getResponseParam
()));
//响应参数
params
.
put
(
"is_test"
,
jsonParams
.
get
(
"is_test"
));
//是否是测试
Integer
pageNum
=
jsonParams
.
getInteger
(
"page_num"
);
Integer
pageSize
=
jsonParams
.
getInteger
(
"page_size"
);
params
.
put
(
"page_size"
,
apiCustomInfo
.
getPageRow
());
params
.
put
(
"page_num"
,
1
);
if
(
null
!=
pageNum
)
{
params
.
put
(
"page_num"
,
pageNum
);
}
if
(
null
!=
pageSize
)
{
params
.
put
(
"page_size"
,
pageSize
);
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"数据转换异常:{}"
,
ex
.
getMessage
());
ex
.
printStackTrace
();
}
String
respResult
=
httpsUtils
.
submitPost
(
targetUrl
,
params
.
toString
());
return
callMethodResponse
(
respResult
,
response
);
}
/**
* 组装响应参数
*
* @param respParams
* @return
*/