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
792757f1
Commit
792757f1
authored
Dec 23, 2020
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apigateway架构调整+实体类添加+xml映射
parent
abb8bc5e
Changes
82
Hide whitespace changes
Inline
Side-by-side
Showing
82 changed files
with
1593 additions
and
2079 deletions
+1593
-2079
api_gateway.sql
database/zc/api_gateway.sql
+202
-0
pom.xml
jz-dm-apigateway/pom.xml
+16
-3
ApiGatewayApplication.java
...ateway/src/main/java/com/jz/dm/ApiGatewayApplication.java
+2
-2
Constants.java
...ay/src/main/java/com/jz/dm/common/constant/Constants.java
+1
-8
LoggingConstants.java
...main/java/com/jz/dm/common/constant/LoggingConstants.java
+1
-1
NotifyException.java
...main/java/com/jz/dm/common/exception/NotifyException.java
+0
-76
SecretException.java
...main/java/com/jz/dm/common/exception/SecretException.java
+0
-49
Constants.java
...ateway/src/main/java/com/jz/dm/common/util/Constants.java
+0
-94
HddHashMap.java
...teway/src/main/java/com/jz/dm/common/util/HddHashMap.java
+0
-36
JSONWriter.java
...teway/src/main/java/com/jz/dm/common/util/JSONWriter.java
+11
-2
Md5.java
...m-apigateway/src/main/java/com/jz/dm/common/util/Md5.java
+1
-1
NotifyResultCode.java
...src/main/java/com/jz/dm/common/util/NotifyResultCode.java
+0
-153
OpenApiRequest.java
...y/src/main/java/com/jz/dm/common/util/OpenApiRequest.java
+1
-1
RSA.java
...m-apigateway/src/main/java/com/jz/dm/common/util/RSA.java
+0
-335
RSAUtils.java
...gateway/src/main/java/com/jz/dm/common/util/RSAUtils.java
+0
-174
SignatureUtil.java
...ay/src/main/java/com/jz/dm/common/util/SignatureUtil.java
+0
-447
TtpayUtils.java
...teway/src/main/java/com/jz/dm/common/util/TtpayUtils.java
+0
-89
MybatisPlusConfig.java
...way/src/main/java/com/jz/dm/config/MybatisPlusConfig.java
+3
-6
SwaggerConfiguration.java
.../src/main/java/com/jz/dm/config/SwaggerConfiguration.java
+43
-0
AuthController.java
...ay/src/main/java/com/jz/dm/controller/AuthController.java
+25
-0
GatewayController.java
...src/main/java/com/jz/dm/controller/GatewayController.java
+4
-5
OrganizationManageController.java
...va/com/jz/dm/controller/OrganizationManageController.java
+25
-0
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+25
-0
AbstractFilter.java
...ateway/src/main/java/com/jz/dm/filter/AbstractFilter.java
+3
-3
CheckArgsFilter.java
...teway/src/main/java/com/jz/dm/filter/CheckArgsFilter.java
+11
-9
CheckPostSizeFilter.java
...y/src/main/java/com/jz/dm/filter/CheckPostSizeFilter.java
+5
-5
CheckTimestampFilter.java
.../src/main/java/com/jz/dm/filter/CheckTimestampFilter.java
+7
-7
Filter.java
jz-dm-apigateway/src/main/java/com/jz/dm/filter/Filter.java
+2
-2
FilterChain.java
...pigateway/src/main/java/com/jz/dm/filter/FilterChain.java
+2
-2
FilterChainImpl.java
...teway/src/main/java/com/jz/dm/filter/FilterChainImpl.java
+3
-3
InvokeRouteFilter.java
...way/src/main/java/com/jz/dm/filter/InvokeRouteFilter.java
+6
-6
SignatureFilter.java
...teway/src/main/java/com/jz/dm/filter/SignatureFilter.java
+0
-162
VerifySignFilter.java
...eway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
+9
-17
DefaultOpenApiDispatcher.java
...main/java/com/jz/dm/gateway/DefaultOpenApiDispatcher.java
+2
-2
GatewayService.java
...teway/src/main/java/com/jz/dm/gateway/GatewayService.java
+7
-3
OpenApiDispatcher.java
...ay/src/main/java/com/jz/dm/gateway/OpenApiDispatcher.java
+2
-2
OpenApiService.java
...teway/src/main/java/com/jz/dm/gateway/OpenApiService.java
+1
-1
GatewayServiceImpl.java
.../main/java/com/jz/dm/gateway/impl/GatewayServiceImpl.java
+2
-3
ApiAuthMapper.java
...gateway/src/main/java/com/jz/dm/mapper/ApiAuthMapper.java
+12
-0
ApiInterfaceMapper.java
...ay/src/main/java/com/jz/dm/mapper/ApiInterfaceMapper.java
+16
-0
ApiOpenApiEsFieldsMapper.java
.../main/java/com/jz/dm/mapper/ApiOpenApiEsFieldsMapper.java
+12
-0
ApiOpenApiEsTagconfigMapper.java
...in/java/com/jz/dm/mapper/ApiOpenApiEsTagconfigMapper.java
+11
-0
ApiOrgMapper.java
...igateway/src/main/java/com/jz/dm/mapper/ApiOrgMapper.java
+14
-0
ApiReqLogMapper.java
...teway/src/main/java/com/jz/dm/mapper/ApiReqLogMapper.java
+11
-0
ApiSyncingDatasourceMapper.java
...ain/java/com/jz/dm/mapper/ApiSyncingDatasourceMapper.java
+12
-0
ApiSyncingDatasourceTypeMapper.java
...java/com/jz/dm/mapper/ApiSyncingDatasourceTypeMapper.java
+13
-0
SHA1WithRSA.java
...y/src/main/java/com/jz/dm/model/signtype/SHA1WithRSA.java
+0
-230
SHA256WithRSA.java
...src/main/java/com/jz/dm/model/signtype/SHA256WithRSA.java
+0
-113
ApiAuth.java
...ateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
+96
-0
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+87
-0
ApiOpenApiEsFields.java
...main/java/com/jz/dm/models/domian/ApiOpenApiEsFields.java
+54
-0
ApiOpenApiEsTagconfig.java
...n/java/com/jz/dm/models/domian/ApiOpenApiEsTagconfig.java
+97
-0
ApiOrg.java
...gateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
+73
-0
ApiReqLog.java
...eway/src/main/java/com/jz/dm/models/domian/ApiReqLog.java
+97
-0
ApiSyncingDatasource.java
...in/java/com/jz/dm/models/domian/ApiSyncingDatasource.java
+132
-0
ApiSyncingDatasourceType.java
...ava/com/jz/dm/models/domian/ApiSyncingDatasourceType.java
+108
-0
BaseObject.java
...eway/src/main/java/com/jz/dm/models/enity/BaseObject.java
+77
-0
BaseRequest.java
...way/src/main/java/com/jz/dm/models/enity/BaseRequest.java
+24
-0
DispatchContext.java
...src/main/java/com/jz/dm/models/enity/DispatchContext.java
+1
-1
GatewayRequest.java
.../src/main/java/com/jz/dm/models/enity/GatewayRequest.java
+2
-2
GatewayResponse.java
...src/main/java/com/jz/dm/models/enity/GatewayResponse.java
+1
-1
OpenApi.java
...gateway/src/main/java/com/jz/dm/models/enity/OpenApi.java
+2
-2
RequestContext.java
.../src/main/java/com/jz/dm/models/enity/RequestContext.java
+1
-1
Format.java
...igateway/src/main/java/com/jz/dm/models/enums/Format.java
+11
-0
GatewayResultCode.java
...c/main/java/com/jz/dm/models/enums/GatewayResultCode.java
+2
-7
RouteType.java
...teway/src/main/java/com/jz/dm/models/enums/RouteType.java
+3
-6
AuthService.java
...igateway/src/main/java/com/jz/dm/service/AuthService.java
+13
-0
OrganizationManageService.java
...ain/java/com/jz/dm/service/OrganizationManageService.java
+13
-0
ProducerService.java
...eway/src/main/java/com/jz/dm/service/ProducerService.java
+13
-0
ApiQueryService.java
...in/java/com/jz/dm/service/apirequest/ApiQueryService.java
+14
-6
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+19
-0
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+19
-0
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+19
-0
application-test.yml
jz-dm-apigateway/src/main/resources/application-test.yml
+1
-1
ApiAuthMapper.xml
jz-dm-apigateway/src/main/resources/mapper/ApiAuthMapper.xml
+11
-0
ApiInterfaceMapper.xml
...igateway/src/main/resources/mapper/ApiInterfaceMapper.xml
+12
-0
ApiOpenApiEsFieldsMapper.xml
...ay/src/main/resources/mapper/ApiOpenApiEsFieldsMapper.xml
+11
-0
ApiOpenApiEsTagconfigMapper.xml
...src/main/resources/mapper/ApiOpenApiEsTagconfigMapper.xml
+11
-0
ApiOrgMapper.xml
jz-dm-apigateway/src/main/resources/mapper/ApiOrgMapper.xml
+11
-0
ApiReqLogMapper.xml
...-apigateway/src/main/resources/mapper/ApiReqLogMapper.xml
+11
-0
ApiSyncingDatasourceMapper.xml
.../src/main/resources/mapper/ApiSyncingDatasourceMapper.xml
+11
-0
ApiSyncingDatasourceTypeMapper.xml
.../main/resources/mapper/ApiSyncingDatasourceTypeMapper.xml
+13
-0
No files found.
database/zc/api_gateway.sql
0 → 100644
View file @
792757f1
#
api
信息表
DROP
TABLE
IF
EXISTS
`t_api_interface`
;
CREATE
TABLE
`t_api_interface`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api 信息表自增ID'
,
`api_key`
varchar
(
200
)
NOT
NULL
COMMENT
'api唯一标识'
,
`api_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'api名称'
,
`api_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api描述'
,
`api_protocl`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'api请求协议:http,https'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`status`
varchar
(
20
)
NOT
NULL
COMMENT
'状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)'
,
`version`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'版本号'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`is_test`
tinyint
(
2
)
NOT
NULL
DEFAULT
'0'
COMMENT
'是否测试数据:0 否,1 是'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`api_key_unique`
(
`api_key`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api信息表'
;
#
api
组织信息表
DROP
TABLE
IF
EXISTS
`t_api_org`
;
CREATE
TABLE
`t_api_org`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api组织信息表自增ID'
,
`org_code`
varchar
(
200
)
NOT
NULL
COMMENT
'组织编码(组织唯一标识)'
,
`org_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织名称'
,
`org_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'组织描述'
,
`org_cn_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织英文名称'
,
`status`
varchar
(
100
)
NOT
NULL
COMMENT
'状态(1-正常 2-冻结 3-下架)'
,
`org_mail`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织邮箱'
,
`org_sort`
int
(
10
)
DEFAULT
'999'
COMMENT
'组织排序'
,
`parent_id`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'父类组织编码'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`org_code_unique`
(
`org_code`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api组织信息表'
;
#
api
授权信息表
DROP
TABLE
IF
EXISTS
`t_api_auth`
;
CREATE
TABLE
`t_api_auth`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api授权信息表自增ID'
,
`api_interface_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api信息表id'
,
`api_org_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api组织id'
,
`auth_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'授权类型:1.数据银行购买 2.dmp授权'
,
`auth_code`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'授权码'
,
`salt`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'盐值'
,
`auth_mode`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'授权方式:1.按次调用 2.按月调用 3.按季调用 4.按年调用'
,
`valid_start_time`
datetime
DEFAULT
NULL
COMMENT
'开始时间'
,
`valid_end_time`
datetime
DEFAULT
NULL
COMMENT
'结束时间'
,
`status`
varchar
(
100
)
NOT
NULL
COMMENT
'状态(1-正常 2-作废)'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api授权信息表'
;
#
api
请求日志表
DROP
TABLE
IF
EXISTS
`t_api_req_log`
;
CREATE
TABLE
`t_api_req_log`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api授权信息表自增ID'
,
`request_ip`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'请求ip'
,
`api_key`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'apikey'
,
`request_params`
text
COMMENT
'请求参数'
,
`response_params`
text
COMMENT
'返回参数'
,
`request_url`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'请求路径'
,
`request_method`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'请求方法'
,
`request_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'请求类型(方式)'
,
`encry_mode`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'加密方式:MD5,RSA'
,
`trans_mode`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'传输方式:POST,GET'
,
`request_token`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'客户请求token'
,
`request_time`
datetime
DEFAULT
NULL
COMMENT
'请求时间'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api请求日志表'
;
#
apiEs
字段信息表
DROP
TABLE
IF
EXISTS
`t_api_open_api_es_fields`
;
CREATE
TABLE
`t_api_open_api_es_fields`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'apiEs字段信息表自增ID'
,
`es_database`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'源数据库'
,
`es_table`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'源表'
,
`field_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'字段名称'
,
`field_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'字段类型'
,
`field_desc`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'字段描述'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'apiEs字段信息表'
;
#
apiEs
配置信息表
DROP
TABLE
IF
EXISTS
`t_api_open_api_es_tagconfig`
;
CREATE
TABLE
`t_api_open_api_es_tagconfig`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'apiEs字段信息表自增ID'
,
`project_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'工程id'
,
`app_id`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'app_id'
,
`api_id`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'api_id'
,
`api_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'api类型'
,
`api_key`
varchar
(
200
)
NOT
NULL
COMMENT
'api唯一标识'
,
`es_data_source`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'数据源id'
,
`es_data_base`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'源数据库名称'
,
`es_table`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'源数据表名称'
,
`request_param`
json
DEFAULT
NULL
COMMENT
'请求参数集合'
,
`result_param`
json
DEFAULT
NULL
COMMENT
'响应参数集合'
,
`page`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'是否分页'
,
`handle_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'处理类型'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'apiEs配置信息表'
;
#
api
数据源配置信息表
DROP
TABLE
IF
EXISTS
`t_api_syncing_datasource`
;
CREATE
TABLE
`t_api_syncing_datasource`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api数据源配置信息表自增ID'
,
`datasource_type`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'数据源类型ID'
,
`datasource_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'数据源名称'
,
`datasource_desc`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'数据源描述'
,
`project_id`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'项目编号'
,
`jdbc_url`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'JDBC URL'
,
`db_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'数据库名'
,
`user_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'账号'
,
`password`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'密码'
,
`endpoint`
json
DEFAULT
NULL
COMMENT
'终端信息'
,
`bucket`
json
DEFAULT
NULL
COMMENT
'Bucket信息'
,
`access_id`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'accessId'
,
`access_key`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'accessKey'
,
`protocol`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'FTP协议'
,
`host`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'IP'
,
`port`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'端口'
,
`default_fs`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'NameNode地址'
,
`table_schema`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'表空间'
,
`data_status`
char
(
1
)
NOT
NULL
DEFAULT
'1'
COMMENT
'数据状态'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api数据源配置信息表'
;
#
api
数据源类型信息表
DROP
TABLE
IF
EXISTS
`t_api_syncing_datasource_type`
;
CREATE
TABLE
`t_api_syncing_datasource_type`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'apiEs字段信息表自增ID'
,
`datasource`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'数据源名称'
,
`datasource_catecode`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'数据源分类编码'
,
`datasource_catename`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'数据源分类名称'
,
`datasource_type`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'数据源类型'
,
`img_url`
varchar
(
128
)
DEFAULT
NULL
COMMENT
'数据源图标'
,
`data_status`
char
(
1
)
DEFAULT
NULL
COMMENT
'状态'
,
`is_enabled`
char
(
1
)
DEFAULT
NULL
COMMENT
'是否启用'
,
`datasource_catetype`
varchar
(
6
)
DEFAULT
NULL
,
`driver_class_name`
varchar
(
64
)
DEFAULT
NULL
,
`is_enable_test`
char
(
1
)
DEFAULT
NULL
COMMENT
'是否启用测试'
,
`default_source_script`
longblob
,
`default_target_script`
longblob
,
`is_enable_source`
char
(
1
)
DEFAULT
NULL
COMMENT
'是否启用源'
,
`is_enable_target`
char
(
1
)
DEFAULT
NULL
COMMENT
'是否启用目标'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api数据源类型信息表'
;
\ No newline at end of file
jz-dm-apigateway/pom.xml
View file @
792757f1
...
...
@@ -31,15 +31,19 @@
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.1.1
</version>
</dependency>
<!-- 引入Druid依赖,阿里巴巴所提供的数据源 -->
<dependency>
<!--
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
</dependency>
-->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<version>
1.1.20
</version>
</dependency>
<!-- 提供mysql驱动 -->
<dependency>
<groupId>
mysql
</groupId>
...
...
@@ -74,6 +78,15 @@
<version>
1.18.16
</version>
<scope>
compile
</scope>
</dependency>
<!-- swagger2接口文档 -->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
</dependency>
<dependency>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
swagger-bootstrap-ui
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
jz-dm-apigateway/src/main/java/com/jz/dm/ApiGatewayApplication.java
View file @
792757f1
package
com
.
jz
.
dm
;
import
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
...
@@ -11,12 +12,11 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* @PACKAGE_NAME: com.jz.dm
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiGatewayApplication
* @USER: key
* @DATE: 2020-12-2/16:03
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@SpringBootApplication
@SpringBootApplication
(
exclude
=
DruidDataSourceAutoConfigure
.
class
)
@ComponentScan
(
basePackages
=
{
"com.jz"
})
@MapperScan
(
"com.jz.dm.mapper"
)
@EnableTransactionManagement
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/constant/Constants.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/co
mmon/co
nstant/Constants.java
View file @
792757f1
package
com
.
jz
.
dm
.
constant
;
package
com
.
jz
.
dm
.
co
mmon
.
co
nstant
;
/**
* 常量
...
...
@@ -13,9 +13,6 @@ public class Constants {
*/
public
static
final
String
SIGN_TYPE_RSA2
=
"RSA2"
;
public
static
final
String
SIGN_ALGORITHMS
=
"SHA1WithRSA"
;
public
static
final
String
SIGN_SHA256RSA_ALGORITHMS
=
"SHA256WithRSA"
;
public
static
final
String
ENCRYPT_TYPE_AES
=
"AES"
;
...
...
@@ -35,10 +32,6 @@ public class Constants {
public
static
final
String
CHARSET
=
"charset"
;
//public static final String NOTIFY_URL = "notify_url";
//
//public static final String RETURN_URL = "return_url";
public
static
final
String
ENCRYPT_TYPE
=
"encrypt_type"
;
public
static
final
String
PARAMS
=
"params"
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/constant/LoggingConstants.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/co
mmon/co
nstant/LoggingConstants.java
View file @
792757f1
package
com
.
jz
.
dm
.
constant
;
package
com
.
jz
.
dm
.
co
mmon
.
co
nstant
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/exception/NotifyException.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
common
.
exception
;
import
com.jz.dm.common.util.ResultCode
;
/**
* 通知异常
*
*/
public
class
NotifyException
extends
OpenApiException
{
/** 序列号 */
private
static
final
long
serialVersionUID
=
3391018902219700916L
;
/**
* 构造函数
*
* @param resultCode
*/
public
NotifyException
(
ResultCode
resultCode
)
{
super
(
resultCode
);
}
/**
* 构造函数
*
* @param resultCode
* @param cause
*/
public
NotifyException
(
ResultCode
resultCode
,
Throwable
cause
)
{
super
(
resultCode
,
cause
);
}
/**
* 构造函数
*
* @param resultCode
* @param detailMessage
*/
public
NotifyException
(
ResultCode
resultCode
,
String
detailMessage
)
{
super
(
resultCode
,
detailMessage
);
}
/**
* 构造函数
*
* @param code
* @param msg
*/
public
NotifyException
(
String
code
,
String
msg
)
{
this
(
code
,
msg
,
(
Throwable
)
null
);
}
/**
* 构造函数
*
* @param code
* @param msg
* @param cause
*/
public
NotifyException
(
String
code
,
String
msg
,
Throwable
cause
)
{
super
(
code
,
msg
,
cause
);
}
/**
* 构造函数
*
* @param code
* @param msg
* @param detailMessage
*/
public
NotifyException
(
String
code
,
String
msg
,
String
detailMessage
)
{
super
(
code
,
msg
,
detailMessage
);
}
}
\ No newline at end of file
jz-dm-apigateway/src/main/java/com/jz/dm/common/exception/SecretException.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
common
.
exception
;
import
com.jz.dm.common.util.ResultCode
;
/**
* 加密异常
*
*/
public
class
SecretException
extends
OpenApiException
{
private
static
final
long
serialVersionUID
=
-
8597436175649786898L
;
/**
* 构造函数
* @param resultCode
*/
public
SecretException
(
ResultCode
resultCode
)
{
super
(
resultCode
);
}
/**
* 构造函数
* @param resultCode
* @param detailMessage
*/
public
SecretException
(
ResultCode
resultCode
,
String
detailMessage
)
{
super
(
resultCode
,
detailMessage
);
}
/**
* 构造函数
* @param resultCode
* @param cause
*/
public
SecretException
(
ResultCode
resultCode
,
Throwable
cause
)
{
super
(
resultCode
,
cause
);
}
/**
* 构造函数
* @param resultCode
* @param detailMessage
* @param cause
*/
public
SecretException
(
ResultCode
resultCode
,
String
detailMessage
,
Throwable
cause
)
{
super
(
resultCode
,
detailMessage
,
cause
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/Constants.java
deleted
100644 → 0
View file @
abb8bc5e
/**
* Copyright (c) 2011-2014 All Rights Reserved.
*/
package
com
.
jz
.
dm
.
common
.
util
;
/**
* @author Admin
* @version $Id: Constants.java 2014年9月3日 下午9:03:44 $
*/
public
class
Constants
{
/**
* 默认时间格式
**/
public
static
final
String
DATE_TIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
String
DATE_FORMAT
=
"yyyyMMdd"
;
/**
* 密码的正则表达式
*/
public
static
final
String
PASSWORD_EXG
=
"^(?![^a-zA-Z]+$)(?!\\D+$).{8,30}$"
;
/**
* UTF-8字符集
**/
public
static
final
String
CHARSET_UTF8
=
"UTF-8"
;
/**
* Date默认时区
**/
public
static
final
String
DATE_TIMEZONE
=
"GMT+8"
;
public
static
final
String
PRINCIPAL_NAME_ATTRIBUTE_OMSNAME
=
".OMS_PRINCIPAL_NAME_ATTRIBUTE_NAME"
;
public
static
final
String
PRINCIPAL_NAME_ATTRIBUTE_MCHNAME
=
".MCH_PRINCIPAL_NAME_ATTRIBUTE_NAME"
;
public
static
final
String
PRINCIPAL_NAME_ATTRIBUTE_PROXYNAME
=
".PROXY_PRINCIPAL_NAME_ATTRIBUTE_NAME"
;
public
static
final
String
PRINCIPAL_NAME_ATTRIBUTE_SUPNAME
=
".SUPPLIER_PRINCIPAL_NAME_ATTRIBUTE_NAME"
;
public
static
final
String
PERMISSIONS
=
"permissions"
;
/**
* 登录成功后,继续跳转URL
*/
public
static
final
String
GOTO_KEY
=
"to"
;
/**
* 记录密码控件的密钥key
*/
public
final
static
String
TOKEN
=
"token_%s"
;
// http请求头UA参数
public
static
final
String
UA
=
"user-agent"
;
//缓存名称
public
static
final
String
MEMBER_CACHE_NAME
=
"data:members"
;
public
static
final
String
MERCHANT_CACHE_NAME
=
"data:merchants"
;
public
static
final
String
SECRET_CACHE_NAME
=
"data:secret_keys"
;
public
static
final
String
ADDR_CACHE_NAME
=
"data:addrs"
;
public
static
final
String
PRODUCT_CACHE_NAME
=
"data:products"
;
public
static
final
String
API_WHITE_CACHE_NAME
=
"data:apiwhite"
;
//数据库序列名称
public
static
final
String
SEQ_ACCOUNT
=
"ids:accounts"
;
public
static
final
String
SEQ_ACCOUNT_WATER
=
"ids:accounts:water"
;
//public static final String SEQ_MEMBER = "ids:members";
public
static
final
String
SEQ_RECHARGE
=
"ids:recharges:loop:7"
;
public
static
final
String
SEQ_TRADE_ORDER
=
"ids:tradeorders:loop:7"
;
public
static
final
String
SEQ_PAYMENT
=
"ids:payment:loop:7"
;
public
static
final
String
SEQ_WITHDRAW
=
"ids:withdraws:loop:7"
;
public
static
final
String
SEQ_TRANSFER
=
"ids:transfer:loop:7"
;
/**
* key = 产线名:服务名:用途:数据类型:key
*/
public
static
final
String
VALID_CODE_KEY_PREFIX
=
"data:merchants:valid:string:"
;
public
static
final
String
VALID_CODE_KEY_COUNT_PREFIX
=
"data:merchants:valid:long:"
;
/** 短信签约缓存名称 **/
public
static
final
String
SMS_SIGN_KEY_PREFIX
=
"data:smssign:shortcode:string:"
;
public
static
final
String
SMS_SIGN_VALID_CODE_PREFIX
=
"data:smssign:validcode:string:"
;
public
static
final
String
SMS_SIGN_VALID_CODE_LIMIT_PREFIX
=
"data:smssign:validlimit:string:"
;
public
static
final
String
SMS_BROKER_VALID_CODE_PREFIX
=
"data:smsbroker:valid:string:"
;
/**
* 发送短信验证
*/
public
static
final
String
SEND_PAY_VALID_CODE
=
"sendPayValidCode"
;
public
static
final
String
SEND_EDIT_PASSWORD_VALID_CODE
=
"sendPasswordValidCode"
;
public
static
final
String
SEND_SIGN_VALID_CODE
=
"sendSignValidCode"
;
public
static
final
String
SMS_BROKER_VALID_CODE_TEMPLATE
=
"sendBrokerValidCode"
;
/**
* 代理商分润汇总key
*/
public
static
final
String
PROXY_ALL_FEE_SUMMARY
=
"PROXY_ALL_FEE_SUMMARY"
;
public
static
final
String
PROXYER_Fee
=
"PROXYER_Fee"
;
public
static
final
String
MERCHANT_Fee
=
"MERCHANT_Fee"
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/HddHashMap.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
common
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* HDD HashMap
*
*/
public
class
HddHashMap
extends
HashMap
<
String
,
String
>
{
private
static
final
long
serialVersionUID
=
-
3440305725602261736L
;
public
HddHashMap
()
{
super
();
}
public
HddHashMap
(
Map
<?
extends
String
,
?
extends
String
>
map
)
{
super
(
map
);
}
/**
* if key or value is null, not put into hash map
*
* @see HashMap#put(Object, Object)
*/
@Override
public
String
put
(
String
key
,
String
value
)
{
if
(
StringUtil
.
isNotEmpty
(
key
,
value
))
{
return
super
.
put
(
key
,
value
);
}
else
{
return
null
;
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/JSONWriter.java
View file @
792757f1
...
...
@@ -15,6 +15,15 @@ import java.util.*;
public
class
JSONWriter
{
/**
* 默认时间格式
**/
public
static
final
String
DATE_TIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* Date默认时区
**/
public
static
final
String
DATE_TIMEZONE
=
"GMT+8"
;
private
StringBuffer
buf
=
new
StringBuffer
();
private
Stack
<
Object
>
calls
=
new
Stack
<
Object
>();
private
boolean
emitClassName
=
true
;
...
...
@@ -159,8 +168,8 @@ public class JSONWriter {
private
void
date
(
Date
date
)
{
if
(
this
.
format
==
null
)
{
this
.
format
=
new
SimpleDateFormat
(
Constants
.
DATE_TIME_FORMAT
);
this
.
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
Constants
.
DATE_TIMEZONE
));
this
.
format
=
new
SimpleDateFormat
(
DATE_TIME_FORMAT
);
this
.
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
DATE_TIMEZONE
));
}
add
(
"\""
);
add
(
format
.
format
(
date
));
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/
model/signtype
/Md5.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/
common/util
/Md5.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
.
signtype
;
package
com
.
jz
.
dm
.
common
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/NotifyResultCode.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
common
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 结果码
*
*/
public
enum
NotifyResultCode
implements
ResultCode
{
/** 处理成功 */
SUCCESS
(
"SUCCESS"
,
"处理成功"
),
/** 处理失败 */
FAILED
(
"FAILED"
,
"处理失败"
),
/** 未知异常 */
UNKNOWN_EXCEPTION
(
"UNKNOWN_EXCEPTION"
,
"未知异常"
),
/** 数据库异常 */
DATABASE_EXCEPTION
(
"DATABASE_EXCEPTION"
,
"数据库异常"
),
/** IO异常 */
IO_EXCEPTION
(
"IO_EXCEPTION"
,
"IO异常"
),
/** 参数不能为空 */
PARAM_CAN_NOT_NULL
(
"PARAM_CAN_NOT_NULL"
,
"参数不能为空"
),
/** 参数不能为空 */
PARAM_CAN_NOT_EMPTY
(
"PARAM_CAN_NOT_EMPTY"
,
"参数不能为空"
),
/** 重复发送 */
RETRANSMISSION
(
"RETRANSMISSION"
,
"重复发送"
),
/** 无效参数 */
ILLEGAL_ARGUMENT
(
"ILLEGAL_ARGUMENT"
,
"无效参数"
),
/** 时间格式不合法*/
ILLEGAL_DATE_FORMAT
(
"ILLEGAL_DATE_FORMAT"
,
"时间格式不合法"
),
;
/**
* 初始化保存到map里方便根据code获取
*/
private
static
Map
<
String
,
NotifyResultCode
>
RESULT_CODES
=
new
HashMap
<
String
,
NotifyResultCode
>();
static
{
for
(
NotifyResultCode
resultCode
:
NotifyResultCode
.
values
())
{
RESULT_CODES
.
put
(
resultCode
.
code
,
resultCode
);
}
}
/** 结果码 */
private
String
code
;
/** 结果码信息 */
private
String
msg
;
/** 结果分类 */
private
NotifyResultCode
classification
;
/**
* 构造函数
*
* @param code 结果码
* @param msg 结果码信息
*/
private
NotifyResultCode
(
String
code
,
String
message
)
{
this
(
code
,
message
,
null
);
}
/**
* 构造函数
*
* @param code 结果码
* @param msg 结果码信息
* @param classification 结果分组
*/
private
NotifyResultCode
(
String
code
,
String
msg
,
NotifyResultCode
classification
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
this
.
classification
=
classification
;
}
/**
* 通过枚举<code>code</code>获得枚举
*
* @param code 结果码
* @return 枚举
*/
public
static
NotifyResultCode
getResultCode
(
String
code
)
{
return
RESULT_CODES
.
get
(
code
);
}
/**
* Getter method for property <tt>code</tt>.
*
* @return property value of code
*/
@Override
public
String
getCode
()
{
return
code
;
}
/**
* Setter method for property <tt>code</tt>.
*
* @param code value to be assigned to property code
*/
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
/**
* Getter method for property <tt>msg</tt>.
*
* @return property value of msg
*/
@Override
public
String
getMsg
()
{
return
msg
;
}
/**
* Setter method for property <tt>msg</tt>.
*
* @param msg value to be assigned to property msg
*/
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
/**
* Getter method for property <tt>classification</tt>.
*
* @return property value of classification
*/
public
NotifyResultCode
getClassification
()
{
return
classification
;
}
/**
* Setter method for property <tt>classification</tt>.
*
* @param classification value to be assigned to property classification
*/
public
void
setClassification
(
NotifyResultCode
classification
)
{
this
.
classification
=
classification
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/OpenApiRequest.java
View file @
792757f1
...
...
@@ -16,7 +16,7 @@ import java.util.Map;
*/
public
class
OpenApiRequest
{
private
String
appKey
;
private
String
appKey
;
//apiKey
private
String
openApiParams
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/RSA.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
common
.
util
;
import
org.apache.commons.codec.binary.Base64
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.crypto.Cipher
;
import
java.io.ByteArrayOutputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.security.*
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPublicKey
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
*
* <p>RSA签名,加解密处理核心文件,注意:密钥长度1024</p>
* @author leelun
* @version $Id: RSA.java, v 0.1 2013-11-15 下午2:33:53 lilun Exp $
*/
public
class
RSA
{
/**
* 签名算法
*/
public
static
final
String
SIGNATURE_ALGORITHM
=
"SHA1withRSA"
;
/**
* 加密算法RSA
*/
public
static
final
String
KEY_ALGORITHM
=
"RSA"
;
/**
* RSA最大加密明文大小
*/
private
static
final
int
MAX_ENCRYPT_BLOCK
=
117
;
/**
* RSA最大解密密文大小
*/
private
static
final
int
MAX_DECRYPT_BLOCK
=
128
;
/**
* 获取公钥的key
*/
private
static
final
String
PUBLIC_KEY
=
"RSAPublicKey"
;
/**
* 获取私钥的key
*/
private
static
final
String
PRIVATE_KEY
=
"RSAPrivateKey"
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
RSA
.
class
);
/**
* <p>
* 生成密钥对(公钥和私钥)
* </p>
*
* @return
* @throws Exception
*/
public
static
Map
<
String
,
Object
>
genKeyPair
()
throws
Exception
{
KeyPairGenerator
keyPairGen
=
KeyPairGenerator
.
getInstance
(
KEY_ALGORITHM
);
keyPairGen
.
initialize
(
1024
);
KeyPair
keyPair
=
keyPairGen
.
generateKeyPair
();
RSAPublicKey
publicKey
=
(
RSAPublicKey
)
keyPair
.
getPublic
();
RSAPrivateKey
privateKey
=
(
RSAPrivateKey
)
keyPair
.
getPrivate
();
Map
<
String
,
Object
>
keyMap
=
new
HashMap
<
String
,
Object
>(
2
);
keyMap
.
put
(
PUBLIC_KEY
,
publicKey
);
keyMap
.
put
(
PRIVATE_KEY
,
privateKey
);
return
keyMap
;
}
/**
* 签名字符串
*
* @param text
* 需要签名的字符串
* @param privateKey 私钥(BASE64编码)
*
* @param input_charset
* 编码格式
* @return 签名结果(BASE64编码)
*/
public
static
String
sign
(
String
text
,
String
privateKey
,
String
charset
)
throws
Exception
{
byte
[]
keyBytes
=
Base64
.
decodeBase64
(
privateKey
);
PKCS8EncodedKeySpec
pkcs8KeySpec
=
new
PKCS8EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
KEY_ALGORITHM
);
PrivateKey
privateK
=
keyFactory
.
generatePrivate
(
pkcs8KeySpec
);
Signature
signature
=
Signature
.
getInstance
(
SIGNATURE_ALGORITHM
);
signature
.
initSign
(
privateK
);
signature
.
update
(
getContentBytes
(
text
,
charset
));
byte
[]
result
=
signature
.
sign
();
return
Base64
.
encodeBase64String
(
result
);
}
/**
* 签名字符串
*
* @param text
* 需要签名的字符串
* @param sign
* 客户签名结果
* @param publicKey
* 公钥(BASE64编码)
* @param input_charset
* 编码格式
* @return 验签结果
*/
public
static
boolean
verify
(
String
text
,
String
sign
,
String
publicKey
,
String
charset
)
throws
Exception
{
byte
[]
keyBytes
=
Base64
.
decodeBase64
(
publicKey
);
X509EncodedKeySpec
keySpec
=
new
X509EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
KEY_ALGORITHM
);
PublicKey
publicK
=
keyFactory
.
generatePublic
(
keySpec
);
Signature
signature
=
Signature
.
getInstance
(
SIGNATURE_ALGORITHM
);
signature
.
initVerify
(
publicK
);
signature
.
update
(
getContentBytes
(
text
,
charset
));
return
signature
.
verify
(
Base64
.
decodeBase64
(
sign
));
}
/**
* <P>
* 私钥解密
* </p>
*
* @param encryptedData 已加密数据
* @param privateKey 私钥(BASE64编码)
* @return
* @throws Exception
*/
public
static
byte
[]
decryptByPrivateKey
(
byte
[]
encryptedData
,
String
privateKey
)
throws
Exception
{
byte
[]
keyBytes
=
Base64
.
decodeBase64
(
privateKey
);
PKCS8EncodedKeySpec
pkcs8KeySpec
=
new
PKCS8EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
KEY_ALGORITHM
);
Key
privateK
=
keyFactory
.
generatePrivate
(
pkcs8KeySpec
);
Cipher
cipher
=
Cipher
.
getInstance
(
keyFactory
.
getAlgorithm
());
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
privateK
);
int
inputLen
=
encryptedData
.
length
;
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
int
offSet
=
0
;
byte
[]
cache
;
int
i
=
0
;
// 对数据分段解密
while
(
inputLen
-
offSet
>
0
)
{
if
(
inputLen
-
offSet
>
MAX_DECRYPT_BLOCK
)
{
cache
=
cipher
.
doFinal
(
encryptedData
,
offSet
,
MAX_DECRYPT_BLOCK
);
}
else
{
cache
=
cipher
.
doFinal
(
encryptedData
,
offSet
,
inputLen
-
offSet
);
}
out
.
write
(
cache
,
0
,
cache
.
length
);
i
++;
offSet
=
i
*
MAX_DECRYPT_BLOCK
;
}
byte
[]
decryptedData
=
out
.
toByteArray
();
out
.
close
();
return
decryptedData
;
}
/**
* <p>
* 公钥解密
* </p>
*
* @param encryptedData 已加密数据
* @param publicKey 公钥(BASE64编码)
* @return
* @throws Exception
*/
public
static
byte
[]
decryptByPublicKey
(
byte
[]
encryptedData
,
String
publicKey
)
throws
Exception
{
byte
[]
keyBytes
=
Base64
.
decodeBase64
(
publicKey
);
X509EncodedKeySpec
x509KeySpec
=
new
X509EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
KEY_ALGORITHM
);
Key
publicK
=
keyFactory
.
generatePublic
(
x509KeySpec
);
Cipher
cipher
=
Cipher
.
getInstance
(
keyFactory
.
getAlgorithm
());
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
publicK
);
int
inputLen
=
encryptedData
.
length
;
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
int
offSet
=
0
;
byte
[]
cache
;
int
i
=
0
;
// 对数据分段解密
while
(
inputLen
-
offSet
>
0
)
{
if
(
inputLen
-
offSet
>
MAX_DECRYPT_BLOCK
)
{
cache
=
cipher
.
doFinal
(
encryptedData
,
offSet
,
MAX_DECRYPT_BLOCK
);
}
else
{
cache
=
cipher
.
doFinal
(
encryptedData
,
offSet
,
inputLen
-
offSet
);
}
out
.
write
(
cache
,
0
,
cache
.
length
);
i
++;
offSet
=
i
*
MAX_DECRYPT_BLOCK
;
}
byte
[]
decryptedData
=
out
.
toByteArray
();
out
.
close
();
return
decryptedData
;
}
/**
* <p>
* 公钥加密
* </p>
*
* @param data 源数据
* @param publicKey 公钥(BASE64编码)
* @return
* @throws Exception
*/
public
static
byte
[]
encryptByPublicKey
(
byte
[]
data
,
String
publicKey
)
throws
Exception
{
byte
[]
keyBytes
=
Base64
.
decodeBase64
(
publicKey
);
X509EncodedKeySpec
x509KeySpec
=
new
X509EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
KEY_ALGORITHM
);
Key
publicK
=
keyFactory
.
generatePublic
(
x509KeySpec
);
// 对数据加密
Cipher
cipher
=
Cipher
.
getInstance
(
keyFactory
.
getAlgorithm
());
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
publicK
);
int
inputLen
=
data
.
length
;
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
int
offSet
=
0
;
byte
[]
cache
;
int
i
=
0
;
// 对数据分段加密
while
(
inputLen
-
offSet
>
0
)
{
if
(
inputLen
-
offSet
>
MAX_ENCRYPT_BLOCK
)
{
cache
=
cipher
.
doFinal
(
data
,
offSet
,
MAX_ENCRYPT_BLOCK
);
}
else
{
cache
=
cipher
.
doFinal
(
data
,
offSet
,
inputLen
-
offSet
);
}
out
.
write
(
cache
,
0
,
cache
.
length
);
i
++;
offSet
=
i
*
MAX_ENCRYPT_BLOCK
;
}
byte
[]
encryptedData
=
out
.
toByteArray
();
out
.
close
();
return
encryptedData
;
}
/**
* <p>
* 私钥加密
* </p>
*
* @param data 源数据
* @param privateKey 私钥(BASE64编码)
* @return
* @throws Exception
*/
public
static
byte
[]
encryptByPrivateKey
(
byte
[]
data
,
String
privateKey
)
throws
Exception
{
byte
[]
keyBytes
=
Base64
.
decodeBase64
(
privateKey
);
PKCS8EncodedKeySpec
pkcs8KeySpec
=
new
PKCS8EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
KEY_ALGORITHM
);
Key
privateK
=
keyFactory
.
generatePrivate
(
pkcs8KeySpec
);
Cipher
cipher
=
Cipher
.
getInstance
(
keyFactory
.
getAlgorithm
());
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
privateK
);
int
inputLen
=
data
.
length
;
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
int
offSet
=
0
;
byte
[]
cache
;
int
i
=
0
;
// 对数据分段加密
while
(
inputLen
-
offSet
>
0
)
{
if
(
inputLen
-
offSet
>
MAX_ENCRYPT_BLOCK
)
{
cache
=
cipher
.
doFinal
(
data
,
offSet
,
MAX_ENCRYPT_BLOCK
);
}
else
{
cache
=
cipher
.
doFinal
(
data
,
offSet
,
inputLen
-
offSet
);
}
out
.
write
(
cache
,
0
,
cache
.
length
);
i
++;
offSet
=
i
*
MAX_ENCRYPT_BLOCK
;
}
byte
[]
encryptedData
=
out
.
toByteArray
();
out
.
close
();
return
encryptedData
;
}
/**
* @param content
* @param charset
* @return
* @throws SignatureException
* @throws UnsupportedEncodingException
*/
private
static
byte
[]
getContentBytes
(
String
content
,
String
charset
)
{
if
(
charset
==
null
||
""
.
equals
(
charset
))
{
return
content
.
getBytes
();
}
try
{
return
content
.
getBytes
(
charset
);
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
"签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:"
+
charset
);
}
}
/**
* <p>
* 获取私钥
* </p>
*
* @param keyMap 密钥对
* @return
* @throws Exception
*/
public
static
String
getPrivateKey
(
Map
<
String
,
Object
>
keyMap
)
throws
Exception
{
Key
key
=
(
Key
)
keyMap
.
get
(
PRIVATE_KEY
);
return
Base64
.
encodeBase64String
(
key
.
getEncoded
());
}
/**
* <p>
* 获取公钥
* </p>
*
* @param keyMap 密钥对
* @return
* @throws Exception
*/
public
static
String
getPublicKey
(
Map
<
String
,
Object
>
keyMap
)
throws
Exception
{
Key
key
=
(
Key
)
keyMap
.
get
(
PUBLIC_KEY
);
return
Base64
.
encodeBase64String
(
key
.
getEncoded
());
}
}
\ No newline at end of file
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/RSAUtils.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
common
.
util
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.tomcat.util.http.fileupload.IOUtils
;
import
javax.crypto.Cipher
;
import
java.io.ByteArrayOutputStream
;
import
java.security.*
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPublicKey
;
import
java.security.spec.InvalidKeySpecException
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
RSAUtils
{
public
static
final
String
CHARSET
=
"UTF-8"
;
public
static
final
String
RSA_ALGORITHM
=
"RSA"
;
public
static
Map
<
String
,
String
>
createKeys
(
int
keySize
){
//为RSA算法创建一个KeyPairGenerator对象
KeyPairGenerator
kpg
;
try
{
kpg
=
KeyPairGenerator
.
getInstance
(
RSA_ALGORITHM
);
}
catch
(
NoSuchAlgorithmException
e
){
throw
new
IllegalArgumentException
(
"No such algorithm-->["
+
RSA_ALGORITHM
+
"]"
);
}
//初始化KeyPairGenerator对象,密钥长度
kpg
.
initialize
(
keySize
);
//生成密匙对
KeyPair
keyPair
=
kpg
.
generateKeyPair
();
//得到公钥
Key
publicKey
=
keyPair
.
getPublic
();
String
publicKeyStr
=
Base64
.
encodeBase64URLSafeString
(
publicKey
.
getEncoded
());
//得到私钥
Key
privateKey
=
keyPair
.
getPrivate
();
System
.
out
.
println
(
"私钥格式:"
+
privateKey
.
getFormat
());
String
privateKeyStr
=
Base64
.
encodeBase64URLSafeString
(
privateKey
.
getEncoded
());
Map
<
String
,
String
>
keyPairMap
=
new
HashMap
<
String
,
String
>();
keyPairMap
.
put
(
"publicKey"
,
publicKeyStr
);
keyPairMap
.
put
(
"privateKey"
,
privateKeyStr
);
return
keyPairMap
;
}
/**
* 得到公钥
* @param publicKey 密钥字符串(经过base64编码)
* @throws Exception
*/
public
static
RSAPublicKey
getPublicKey
(
String
publicKey
)
throws
NoSuchAlgorithmException
,
InvalidKeySpecException
{
//通过X509编码的Key指令获得公钥对象
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
RSA_ALGORITHM
);
X509EncodedKeySpec
x509KeySpec
=
new
X509EncodedKeySpec
(
Base64
.
decodeBase64
(
publicKey
));
RSAPublicKey
key
=
(
RSAPublicKey
)
keyFactory
.
generatePublic
(
x509KeySpec
);
return
key
;
}
/**
* 得到私钥
* @param privateKey 密钥字符串(经过base64编码)
* @throws Exception
*/
public
static
RSAPrivateKey
getPrivateKey
(
String
privateKey
)
throws
NoSuchAlgorithmException
,
InvalidKeySpecException
{
//通过PKCS#8编码的Key指令获得私钥对象
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
RSA_ALGORITHM
);
PKCS8EncodedKeySpec
pkcs8KeySpec
=
new
PKCS8EncodedKeySpec
(
Base64
.
decodeBase64
(
privateKey
));
RSAPrivateKey
key
=
(
RSAPrivateKey
)
keyFactory
.
generatePrivate
(
pkcs8KeySpec
);
return
key
;
}
/**
* 公钥加密
* @param data
* @param publicKey
* @return
*/
public
static
String
publicEncrypt
(
String
data
,
RSAPublicKey
publicKey
){
try
{
Cipher
cipher
=
Cipher
.
getInstance
(
RSA_ALGORITHM
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
publicKey
);
return
Base64
.
encodeBase64URLSafeString
(
rsaSplitCodec
(
cipher
,
Cipher
.
ENCRYPT_MODE
,
data
.
getBytes
(
CHARSET
),
publicKey
.
getModulus
().
bitLength
()));
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
"加密字符串["
+
data
+
"]时遇到异常"
,
e
);
}
}
/**
* 私钥解密
* @param data
* @param privateKey
* @return
*/
public
static
String
privateDecrypt
(
String
data
,
RSAPrivateKey
privateKey
){
try
{
Cipher
cipher
=
Cipher
.
getInstance
(
RSA_ALGORITHM
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
privateKey
);
return
new
String
(
rsaSplitCodec
(
cipher
,
Cipher
.
DECRYPT_MODE
,
Base64
.
decodeBase64
(
data
),
privateKey
.
getModulus
().
bitLength
()),
CHARSET
);
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
"解密字符串["
+
data
+
"]时遇到异常"
,
e
);
}
}
/**
* 私钥加密
* @param data
* @param privateKey
* @return
*/
public
static
String
privateEncrypt
(
String
data
,
RSAPrivateKey
privateKey
){
try
{
Cipher
cipher
=
Cipher
.
getInstance
(
RSA_ALGORITHM
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
privateKey
);
return
Base64
.
encodeBase64URLSafeString
(
rsaSplitCodec
(
cipher
,
Cipher
.
ENCRYPT_MODE
,
data
.
getBytes
(
CHARSET
),
privateKey
.
getModulus
().
bitLength
()));
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
"加密字符串["
+
data
+
"]时遇到异常"
,
e
);
}
}
/**
* 公钥解密
* @param data
* @param publicKey
* @return
*/
public
static
String
publicDecrypt
(
String
data
,
RSAPublicKey
publicKey
){
try
{
Cipher
cipher
=
Cipher
.
getInstance
(
RSA_ALGORITHM
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
publicKey
);
return
new
String
(
rsaSplitCodec
(
cipher
,
Cipher
.
DECRYPT_MODE
,
Base64
.
decodeBase64
(
data
),
publicKey
.
getModulus
().
bitLength
()),
CHARSET
);
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
"解密字符串["
+
data
+
"]时遇到异常"
,
e
);
}
}
private
static
byte
[]
rsaSplitCodec
(
Cipher
cipher
,
int
opmode
,
byte
[]
datas
,
int
keySize
){
int
maxBlock
=
0
;
if
(
opmode
==
Cipher
.
DECRYPT_MODE
){
maxBlock
=
keySize
/
8
;
}
else
{
maxBlock
=
keySize
/
8
-
11
;
}
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
int
offSet
=
0
;
byte
[]
buff
;
int
i
=
0
;
try
{
while
(
datas
.
length
>
offSet
){
if
(
datas
.
length
-
offSet
>
maxBlock
){
buff
=
cipher
.
doFinal
(
datas
,
offSet
,
maxBlock
);
}
else
{
buff
=
cipher
.
doFinal
(
datas
,
offSet
,
datas
.
length
-
offSet
);
}
out
.
write
(
buff
,
0
,
buff
.
length
);
i
++;
offSet
=
i
*
maxBlock
;
}
}
catch
(
Exception
e
){
throw
new
RuntimeException
(
"加解密阀值为["
+
maxBlock
+
"]的数据时发生异常"
,
e
);
}
byte
[]
resultDatas
=
out
.
toByteArray
();
IOUtils
.
closeQuietly
(
out
);
return
resultDatas
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/SignatureUtil.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
common
.
util
;
import
com.alibaba.fastjson.PropertyNamingStrategy
;
import
com.jz.dm.common.exception.SignatureException
;
import
com.jz.dm.model.signtype.Md5
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.StringWriter
;
import
java.security.KeyFactory
;
import
java.security.PrivateKey
;
import
java.security.PublicKey
;
import
java.security.spec.InvalidKeySpecException
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.*
;
/**
* 签名工具
*
*/
@Slf4j
public
class
SignatureUtil
{
public
static
final
String
SIGN_TYPE_RSA
=
"RSA"
;
/**
* sha256WithRsa 算法请求类型
*/
public
static
final
String
SIGN_TYPE_RSA2
=
"RSA2"
;
public
static
final
String
SIGN_ALGORITHMS
=
"SHA1WithRSA"
;
public
static
final
String
SIGN_SHA256RSA_ALGORITHMS
=
"SHA256WithRSA"
;
public
static
final
String
SIGN_REQUEST
=
"SIGN_REQUEST"
;
public
static
final
String
SIGN_CALLBACK
=
"SIGN_CALLBACK"
;
/**
* 获取签名校验内容
*
* @param params
* @return
*/
private
static
String
getVerifyContent
(
Map
<
String
,
Object
>
params
,
String
...
excludeParams
)
{
if
(
params
==
null
)
{
return
null
;
}
if
(
excludeParams
==
null
||
excludeParams
.
length
==
0
)
{
params
.
remove
(
"sign"
);
}
else
{
for
(
String
excludeParam
:
excludeParams
)
{
params
.
remove
(
excludeParam
);
}
}
StringBuffer
content
=
new
StringBuffer
();
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
sort
(
keys
);
for
(
String
key
:
keys
)
{
if
(
params
.
get
(
key
)
!=
null
){
String
value
=
params
.
get
(
key
).
toString
();
if
(!
StringUtils
.
isEmpty
(
value
))
{
content
.
append
(
key
).
append
(
"="
).
append
(
value
);
}
}
}
return
content
.
toString
();
}
/**
* 校验签名
*
* @param params
* @param publicKey
* @param charset
* @return
* @throws
*/
public
static
boolean
verify
(
Map
params
,
String
publicKey
,
String
charset
,
SignType
signType
,
String
...
excludeParams
)
{
String
sign
=
(
String
)
params
.
get
(
"sign"
);
String
content
=
getVerifyContent
(
params
,
excludeParams
);
log
.
info
(
"请求验签: {}"
,
content
);
if
(
signType
==
SignType
.
RSA
)
{
return
rsaVerify
(
content
,
sign
,
publicKey
,
charset
);
}
else
if
(
signType
==
SignType
.
RSA2
)
{
return
rsa256Verify
(
content
,
sign
,
publicKey
,
charset
);
}
else
if
(
signType
==
SignType
.
MD5
)
{
String
calcSign
=
Md5
.
encrypt
(
content
,
publicKey
,
charset
);
return
StringUtils
.
equals
(
calcSign
,
sign
);
}
else
{
throw
new
SignatureException
(
OpenApiResultCode
.
SIGN_TYPE_NOT_SUPPORT
,
"Sign Type is Not Support : signType="
+
signType
);
}
}
public
static
void
main
(
String
[]
args
)
{
//ed123fca54c919bce4d5e16b6ebd0304
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map1
=
new
HashMap
<>();
map1
.
put
(
"tradeNo"
,
"2020041510842580008"
);
map1
.
put
(
"outTradeNo"
,
"XJ1586919520927"
);
map1
.
put
(
"status"
,
"PAYMENT"
);
map
.
put
(
"data"
,
map1
);
String
responseJson
=
JsonUtil
.
toJSONString
(
map
,
PropertyNamingStrategy
.
SnakeCase
);
String
s
=
"app_id=200407008243charset=UTF-8method=trade.submitparams={\"accountType\":\"WBANK\",\"outTradeNo\":\"TS2020041411353338464\",\"remark\":\"test11\",\"items\":[{\"amount\":\"10\",\"idCard\":\"430524199707287172\",\"mobile\":\"15910401066\",\"name\":\"马斌\",\"remark\":\"test22\",\"cardNo\":\"6217995550000488697\"}]}sign_type=MD5timestamp=1586858028000version=1.0.0"
;
SignType
signType
=
SignType
.
MD5
;
String
calcSign
=
Md5
.
encrypt
(
s
,
"pwxw5FaQ4UFvycYfbmRvqPQ1m96aJblURXyVsnMXPe8qJhurmebv1XPnvPkJjjC8"
,
"UTF-8"
);
System
.
out
.
println
(
calcSign
);
}
/**
* rsa校验签名
*
* @param content
* @param sign
* @param publicKey
* @param charset
* @return
* @throws
*/
public
static
boolean
rsaVerify
(
String
content
,
String
sign
,
String
publicKey
,
String
charset
)
{
try
{
PublicKey
pubKey
=
getPublicKeyFromX509
(
"RSA"
,
new
ByteArrayInputStream
(
publicKey
.
getBytes
()));
java
.
security
.
Signature
signature
=
java
.
security
.
Signature
.
getInstance
(
SIGN_ALGORITHMS
);
signature
.
initVerify
(
pubKey
);
if
(
StringUtil
.
isEmpty
(
charset
))
{
signature
.
update
(
content
.
getBytes
());
}
else
{
signature
.
update
(
content
.
getBytes
(
charset
));
}
return
signature
.
verify
(
Base64
.
decodeBase64
(
sign
.
getBytes
()));
}
catch
(
Exception
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
SIGN_VERIFY_ERROR
,
"RSAcontent = "
+
content
+
"; charset = "
+
charset
,
e
);
}
}
/**
* rsa256校验签名
*
* @param content
* @param sign
* @param publicKey
* @param charset
* @return
* @throws
*/
public
static
boolean
rsa256Verify
(
String
content
,
String
sign
,
String
publicKey
,
String
charset
)
{
try
{
PublicKey
pubKey
=
getPublicKeyFromX509
(
"RSA"
,
new
ByteArrayInputStream
(
publicKey
.
getBytes
()));
java
.
security
.
Signature
signature
=
java
.
security
.
Signature
.
getInstance
(
SIGN_SHA256RSA_ALGORITHMS
);
signature
.
initVerify
(
pubKey
);
if
(
StringUtil
.
isEmpty
(
charset
))
{
signature
.
update
(
content
.
getBytes
());
}
else
{
signature
.
update
(
content
.
getBytes
(
charset
));
}
return
signature
.
verify
(
Base64
.
decodeBase64
(
sign
.
getBytes
()));
}
catch
(
Exception
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
SIGN_VERIFY_ERROR
,
"RSAcontent = "
+
content
+
"; charset = "
+
charset
,
e
);
}
}
/**
* 获取公钥
*
* @param algorithm
* @param ins
* @return
* @throws Exception
*/
public
static
PublicKey
getPublicKeyFromX509
(
String
algorithm
,
InputStream
ins
)
throws
Exception
{
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
algorithm
);
StringWriter
writer
=
new
StringWriter
();
StreamUtil
.
io
(
new
InputStreamReader
(
ins
),
writer
);
byte
[]
encodedKey
=
writer
.
toString
().
getBytes
();
encodedKey
=
Base64
.
decodeBase64
(
encodedKey
);
return
keyFactory
.
generatePublic
(
new
X509EncodedKeySpec
(
encodedKey
));
}
/**
* 获取签名内容
*
* @param params
* @return
*/
public
static
String
getSignContent
(
Map
<
String
,
Object
>
params
)
{
StringBuffer
content
=
new
StringBuffer
();
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
sort
(
keys
);
int
index
=
0
;
for
(
int
i
=
0
;
i
<
keys
.
size
();
i
++)
{
String
key
=
keys
.
get
(
i
);
String
value
=
params
.
get
(
key
)
==
null
?
""
:
params
.
get
(
key
).
toString
();
if
(
StringUtil
.
isNotEmpty
(
key
,
value
))
{
content
.
append
(
key
+
"="
+
value
);
index
++;
}
}
return
content
.
toString
();
}
/**
* 内容签名
*
* @param params
* @param publicKey
* @param charset
* @param signType
* @param providePublicKey true : 惠多多提供外部公钥了, false : 没有对外提供公钥,使用外部公钥加密做签名
* @return
*/
public
static
String
sign
(
Map
<
String
,
Object
>
params
,
String
publicKey
,
String
charset
,
SignType
signType
,
String
businessType
,
boolean
providePublicKey
)
{
String
signContent
=
getSignContent
(
params
);
return
sign
(
signContent
,
publicKey
,
charset
,
signType
,
businessType
,
providePublicKey
);
}
/**
* rsa内容签名
*
* @param content
* @param privateKey
* @param charset
* @return
*/
public
static
String
sign
(
String
content
,
String
privateKey
,
String
charset
,
SignType
signType
,
String
type
,
boolean
providePublicKey
)
{
log
.
info
(
"参与加签字符串:{}"
,
content
);
if
(
signType
==
SignType
.
RSA
)
{
if
(
SIGN_CALLBACK
.
equals
(
type
))
{
if
(
providePublicKey
)
{
return
callBackRsaSignByPrivateKey
(
content
,
privateKey
,
charset
);
}
else
{
return
callBackRsaSignByPublicKey
(
content
,
privateKey
,
charset
);
}
}
if
(
providePublicKey
)
{
return
rsaSignByPrivateKey
(
content
,
privateKey
,
charset
);
}
else
{
return
rsaSignByPublicKey
(
content
,
privateKey
,
charset
);
}
}
else
if
(
signType
==
SignType
.
RSA2
)
{
return
rsa256Sign
(
content
,
privateKey
,
charset
);
}
else
if
(
signType
==
SignType
.
MD5
)
{
return
Md5
.
encrypt
(
content
,
privateKey
,
charset
);
}
else
{
throw
new
SignatureException
(
OpenApiResultCode
.
SIGN_TYPE_NOT_SUPPORT
,
"Sign Type is Not Support : signType="
+
signType
);
}
}
public
static
PrivateKey
getPrivateKeyFromPKCS8
(
String
algorithm
,
InputStream
ins
)
throws
Exception
{
if
(
ins
==
null
||
StringUtil
.
isEmpty
(
algorithm
))
{
return
null
;
}
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
algorithm
);
byte
[]
privateKey
=
StreamUtil
.
readText
(
ins
).
getBytes
();
privateKey
=
Base64
.
decodeBase64
(
privateKey
);
return
keyFactory
.
generatePrivate
(
new
PKCS8EncodedKeySpec
(
privateKey
));
}
/**
* sha256WithRsa 加签
*
* @param content
* @param privateKey
* @param charset
* @return
*/
public
static
String
rsa256Sign
(
String
content
,
String
privateKey
,
String
charset
)
{
try
{
PrivateKey
priKey
=
getPrivateKeyFromPKCS8
(
SIGN_TYPE_RSA
,
new
ByteArrayInputStream
(
privateKey
.
getBytes
()));
java
.
security
.
Signature
signature
=
java
.
security
.
Signature
.
getInstance
(
SIGN_SHA256RSA_ALGORITHMS
);
signature
.
initSign
(
priKey
);
if
(
StringUtil
.
isEmpty
(
charset
))
{
signature
.
update
(
content
.
getBytes
());
}
else
{
signature
.
update
(
content
.
getBytes
(
charset
));
}
byte
[]
signed
=
signature
.
sign
();
return
new
String
(
Base64
.
encodeBase64
(
signed
));
}
catch
(
Exception
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
DATA_SIGN_ERROR
,
"RSAcontent = "
+
content
+
"; charset = "
+
charset
,
e
);
}
}
/**
* sha1WithRsa 加签
*
* @param content
* @param publicKey
* @param charset
* @return
*/
public
static
String
rsaSignByPublicKey
(
String
content
,
String
publicKey
,
String
charset
)
{
try
{
byte
[]
signed
=
RSA
.
encryptByPublicKey
(
content
.
getBytes
(
charset
),
publicKey
);
return
new
String
(
Base64
.
encodeBase64
(
signed
));
}
catch
(
InvalidKeySpecException
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
PUBLIC_KEY_FORMAT_ERROR
,
"RSA公钥格式不正确,请检查是否正确配置了PKCS8格式的公钥"
,
e
);
}
catch
(
Exception
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
DATA_SIGN_ERROR
,
"RSAcontent = "
+
content
+
"; charset = "
+
charset
,
e
);
}
}
/**
* sha1WithRsa 加签
*
* @param content
* @param privateKey
* @param charset
* @return
*/
public
static
String
rsaSignByPrivateKey
(
String
content
,
String
privateKey
,
String
charset
)
{
try
{
PrivateKey
priKey
=
getPrivateKeyFromPKCS8
(
SIGN_TYPE_RSA
,
new
ByteArrayInputStream
(
privateKey
.
getBytes
()));
java
.
security
.
Signature
signature
=
java
.
security
.
Signature
.
getInstance
(
SIGN_ALGORITHMS
);
signature
.
initSign
(
priKey
);
if
(
StringUtil
.
isEmpty
(
charset
))
{
signature
.
update
(
content
.
getBytes
());
}
else
{
signature
.
update
(
content
.
getBytes
(
charset
));
}
byte
[]
signed
=
signature
.
sign
();
return
new
String
(
Base64
.
encodeBase64
(
signed
));
}
catch
(
InvalidKeySpecException
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
PRIVATE_KEY_FORMAT_ERROR
,
"RSA私钥格式不正确,请检查是否正确配置了PKCS8格式的私钥"
,
e
);
}
catch
(
Exception
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
DATA_SIGN_ERROR
,
"RSAcontent = "
+
content
+
"; charset = "
+
charset
,
e
);
}
}
/**
* sha1WithRsa 回调内容加签
* @param content
* @param publicKey
* @param charset
* @return
*/
public
static
String
callBackRsaSignByPublicKey
(
String
content
,
String
publicKey
,
String
charset
)
{
try
{
byte
[]
signed
=
RSA
.
encryptByPublicKey
(
Md5
.
encrypt
(
content
,
""
).
getBytes
(
charset
),
publicKey
);
return
new
String
(
Base64
.
encodeBase64
(
signed
));
}
catch
(
InvalidKeySpecException
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
PUBLIC_KEY_FORMAT_ERROR
,
"RSA公钥格式不正确,请检查是否正确配置了PKCS8格式的公钥"
,
e
);
}
catch
(
Exception
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
DATA_SIGN_ERROR
,
"RSAcontent = "
+
content
+
"; charset = "
+
charset
,
e
);
}
}
/**
* sha1WithRsa 回调内容加签
* @param content
* @param privateKey
* @param charset
* @return
*/
public
static
String
callBackRsaSignByPrivateKey
(
String
content
,
String
privateKey
,
String
charset
)
{
try
{
PrivateKey
priKey
=
getPrivateKeyFromPKCS8
(
SIGN_TYPE_RSA
,
new
ByteArrayInputStream
(
privateKey
.
getBytes
()));
java
.
security
.
Signature
signature
=
java
.
security
.
Signature
.
getInstance
(
SIGN_ALGORITHMS
);
signature
.
initSign
(
priKey
);
if
(
StringUtil
.
isEmpty
(
charset
))
{
signature
.
update
(
Md5
.
encrypt
(
content
,
""
).
getBytes
());
}
else
{
signature
.
update
(
Md5
.
encrypt
(
content
,
""
).
getBytes
(
charset
));
}
byte
[]
signed
=
signature
.
sign
();
return
new
String
(
Base64
.
encodeBase64
(
signed
));
}
catch
(
InvalidKeySpecException
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
PRIVATE_KEY_FORMAT_ERROR
,
"RSA私钥格式不正确,请检查是否正确配置了PKCS8格式的私钥"
,
e
);
}
catch
(
Exception
e
)
{
throw
new
SignatureException
(
OpenApiResultCode
.
DATA_SIGN_ERROR
,
"RSAcontent = "
+
content
+
"; charset = "
+
charset
,
e
);
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/TtpayUtils.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
common
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
/**
*
* @author Admin
*/
public
final
class
TtpayUtils
{
/**
* 除去数组中的空值和签名参数
* 为了兼容健康商城签名问题,过滤sign2参数
* @param sArray 签名参数组
* @return 去掉空值与签名参数后的新签名参数组
*/
public
static
Map
<
String
,
String
>
filter
(
Map
<
String
,
String
>
sArray
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
if
(
sArray
==
null
||
sArray
.
size
()
<=
0
)
{
return
result
;
}
for
(
String
key
:
sArray
.
keySet
())
{
String
value
=
sArray
.
get
(
key
);
if
(
StringUtils
.
isEmpty
(
value
)
||
key
.
equalsIgnoreCase
(
"sign"
))
{
continue
;
}
result
.
put
(
key
,
value
);
}
return
result
;
}
/**
* 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* @param params 需要排序并参与字符拼接的参数组
* @return 拼接后字符串
*/
public
static
String
createLinkString
(
Map
<
String
,
String
>
params
)
{
// 第一步:把字典按Key的字母顺序排序,参数使用TreeMap已经完成排序
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
sort
(
keys
);
// 第二步:把所有参数名和参数值串在一起
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
key
:
keys
)
{
String
value
=
params
.
get
(
key
);
if
(!
StringUtils
.
isEmpty
(
value
))
{
sb
.
append
(
key
).
append
(
"="
).
append
(
value
);
}
}
return
sb
.
toString
();
}
/**
* 方法说明:根据运单号返回还有校验位
*
* @param no
* @return
*/
public
static
String
createId
(
String
mobile
,
int
length
)
{
int
count
=
0
;
String
no
=
mobile
.
substring
(
0
,
length
);
//计算前6位校验码
int
len
=
no
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
p
=
(
no
.
charAt
(
len
-
i
-
1
))
*
(
i
*
2
+
1
);
int
q
=
divide
(
p
,
10
);
int
r
=
p
-
q
*
10
;
count
+=
(
q
+
r
);
}
return
((
divide
(
count
,
10
)
+
1
)
*
10
-
count
)
%
10
+
mobile
.
substring
(
mobile
.
length
()
-
length
+
1
);
}
public
static
int
divide
(
int
x
,
int
y
)
{
if
(
y
==
0
)
{
return
0
;
}
BigDecimal
bigX
=
new
BigDecimal
(
x
);
BigDecimal
bigY
=
new
BigDecimal
(
y
);
return
bigX
.
divide
(
bigY
,
0
,
RoundingMode
.
HALF_UP
).
intValue
();
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
TtpayUtils
.
createId
(
"15000000013"
,
7
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/config/MybatisPlusConfig.java
View file @
792757f1
...
...
@@ -9,7 +9,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @ClassName: MybatisPlusConfig
* @Author
Bellamy
* @Author
ZC
* @Date 2020/11/27
* @Version 1.0
*/
...
...
@@ -18,18 +18,15 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@MapperScan
(
"com.jz.dm.mapper"
)
public
class
MybatisPlusConfig
{
@Bean
public
PaginationInterceptor
paginationInterceptor
()
{
public
PaginationInterceptor
paginationInterceptor
()
{
PaginationInterceptor
paginationInterceptor
=
new
PaginationInterceptor
();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
paginationInterceptor
.
setLimit
(
500
);
// 开启 count 的 join 优化,只针对部分 left join
paginationInterceptor
.
setCountSqlParser
(
new
JsqlParserCountOptimize
());
paginationInterceptor
.
setCountSqlParser
(
new
JsqlParserCountOptimize
(
true
));
return
paginationInterceptor
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/config/SwaggerConfiguration.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
config
;
import
com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public
class
SwaggerConfiguration
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.jz.dm.mall.controller"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"APi网关 RESTful APIs"
)
.
description
(
"swagger-bootstrap-ui"
)
.
termsOfServiceUrl
(
"http://localhost:8088/"
)
.
contact
(
"ZC"
)
.
version
(
"1.0"
)
.
build
();
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/AuthController.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
controller
;
import
com.jz.dm.service.AuthService
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.controller
* @PROJECT_NAME: jz-dm-parent
* @NAME: AuthController
* @DATE: 2020-12-23/16:38
* @DAY_NAME_SHORT: 周三
* @Description: 授权controller
**/
@RestController
@RequestMapping
(
"auth"
)
@Api
(
tags
=
"授权认证Controller"
)
public
class
AuthController
{
@Autowired
private
AuthService
authService
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/GatewayController.java
View file @
792757f1
...
...
@@ -5,9 +5,9 @@ import com.alibaba.fastjson.JSONObject;
import
com.alibaba.fastjson.PropertyNamingStrategy
;
import
com.jz.dm.common.util.JsonUtil
;
import
com.jz.dm.gateway.GatewayService
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model.RequestContext
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model
s.enity
.RequestContext
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -21,7 +21,7 @@ import java.util.Map;
/**
* 网关请求
* @author
key
* @author
zc
*/
@RestController
public
class
GatewayController
{
...
...
@@ -48,7 +48,6 @@ public class GatewayController {
RequestContext
requestContext
=
RequestContext
.
getCurrentContext
();
requestContext
.
setRequest
(
httpServletRequest
);
requestContext
.
setResponse
(
httpServletResponse
);
System
.
out
.
println
(
"经过了controller~~~~~~~~~~~~~~~~~~~~"
);
GatewayResponse
gatewayResponse
=
gatewayService
.
invoke
(
gatewayRequest
);
JSONObject
result
=
new
JSONObject
();
convertResponse
(
result
,
gatewayResponse
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/OrganizationManageController.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
controller
;
import
com.jz.dm.service.OrganizationManageService
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.controller
* @PROJECT_NAME: jz-dm-parent
* @NAME: OrganizationManageController
* @DATE: 2020-12-23/22:00
* @DAY_NAME_SHORT: 周三
* @Description: 组织管理controller
**/
@RestController
@RequestMapping
(
"organization"
)
@Api
(
tags
=
"组织管理Controller"
)
public
class
OrganizationManageController
{
@Autowired
private
OrganizationManageService
organizationManageService
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ProducerController.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
controller
;
import
com.jz.dm.service.ProducerService
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.controller
* @PROJECT_NAME: jz-dm-parent
* @NAME: ProducerController
* @DATE: 2020-12-23/16:44
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@RestController
@RequestMapping
(
"producer"
)
@Api
(
tags
=
"Api制作Controller"
)
public
class
ProducerController
{
@Autowired
private
ProducerService
producerService
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AbstractFilter.java
View file @
792757f1
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model.RequestContext
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model
s.enity
.RequestContext
;
import
org.springframework.core.Ordered
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/CheckArgsFilter.java
View file @
792757f1
...
...
@@ -3,11 +3,11 @@ package com.jz.dm.filter;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.SignType
;
import
com.jz.dm.common.util.StringUtil
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model.enums.Format
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
com.jz.dm.co
mmon.co
nstant.Constants
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model
s
.enums.Format
;
import
com.jz.dm.model
s
.enums.GatewayResultCode
;
import
org.springframework.stereotype.Component
;
import
java.nio.charset.Charset
;
...
...
@@ -46,11 +46,13 @@ public class CheckArgsFilter extends AbstractFilter {
if
(
StringUtil
.
isEmpty
(
request
.
getFormat
()))
{
request
.
setFormat
(
Format
.
JSON
.
name
());
}
try
{
Format
.
valueOf
(
request
.
getFormat
());
//格式,目前仅支持JSON
Charset
.
forName
(
request
.
getCharset
());
//请求使用的编码格式,如UTF-8,GBK,GB2312等
SignType
.
valueOf
(
request
.
getSignType
());
//生成签名字符串所使用的签名算法类型
//格式,目前仅支持JSON
Format
.
valueOf
(
request
.
getFormat
());
//请求使用的编码格式,如UTF-8,GBK,GB2312等
Charset
.
forName
(
request
.
getCharset
());
//生成签名字符串所使用的签名算法类型
SignType
.
valueOf
(
request
.
getSignType
());
}
catch
(
Exception
ex
)
{
//无效参数
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/CheckPostSizeFilter.java
View file @
792757f1
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model.RequestContext
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
com.jz.dm.co
mmon.co
nstant.Constants
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model
s.enity
.RequestContext
;
import
com.jz.dm.model
s
.enums.GatewayResultCode
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/CheckTimestampFilter.java
View file @
792757f1
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
com.jz.dm.co
mmon.co
nstant.Constants
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model
s
.enums.GatewayResultCode
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -41,9 +41,9 @@ public class CheckTimestampFilter extends AbstractFilter {
}
catch
(
Exception
ex
)
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
//无效参数
}
//
if (System.currentTimeMillis() - time > max) {
//
throw new GatewayException(GatewayResultCode.ILLEGAL_TIMETEMP);//无效时间戳
//
}
if
(
System
.
currentTimeMillis
()
-
time
>
max
)
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_TIMETEMP
);
//无效时间戳
}
chain
.
doFilter
(
request
,
response
);
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/Filter.java
View file @
792757f1
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
/**
* 过滤器
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/FilterChain.java
View file @
792757f1
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
/**
* 请求过滤链
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/FilterChainImpl.java
View file @
792757f1
...
...
@@ -3,9 +3,9 @@ package com.jz.dm.filter;
import
com.jz.dm.common.exception.OpenApiException
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.common.util.ResultCode
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model
s
.enums.GatewayResultCode
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/InvokeRouteFilter.java
View file @
792757f1
...
...
@@ -4,12 +4,12 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.constant.LoggingConstants
;
import
com.jz.dm.co
mmon.co
nstant.Constants
;
import
com.jz.dm.co
mmon.co
nstant.LoggingConstants
;
import
com.jz.dm.gateway.DefaultOpenApiDispatcher
;
import
com.jz.dm.model
.enums.GatewayResultCode
;
import
com.jz.dm.model
.enums.RouteTyp
e
;
import
com.jz.dm.model
.*
;
import
com.jz.dm.model
s.enity.*
;
import
com.jz.dm.model
s.enums.GatewayResultCod
e
;
import
com.jz.dm.model
s.enums.RouteType
;
import
org.slf4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -19,7 +19,7 @@ import org.springframework.stereotype.Component;
*
* @author key
*/
@Component
@Component
(
"invokeRouteFilter"
)
public
class
InvokeRouteFilter
extends
AbstractFilter
{
/** openapi dispatcher logger */
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/SignatureFilter.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
filter
;
import
com.alibaba.fastjson.JSONException
;
import
com.alibaba.fastjson.PropertyNamingStrategy
;
import
com.jz.dm.common.util.*
;
import
com.jz.dm.common.exception.SignatureException
;
import
com.jz.dm.common.util.StringUtil
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
///**
// * 签名过滤器
// */
//@Component
//public class SignatureFilter extends AbstractFilter {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(SignatureFilter.class);
//
// // @Autowired
// // private IApiWhiteService apiWhiteService;
// // @Value("${secret_private}")
// // private String secretPrivate;
//
// private String encryptData;
//
// @Override
// protected void internalDoFilter(GatewayRequest request, GatewayResponse response,
// FilterChain chain) {
// try {
// chain.doFilter(request, response);
// } finally {
// String responseJson = null;
// String sign = StringUtil.EMPTY_STRING;
// String privatekey = null;
// if (StringUtil.isEmpty(request.getAppKey())) {
// return;
// }
// //ApiWhite apiWhite = apiWhiteService.byMerchantId(request.getAppId());
// //if (apiWhite == null) {
// // return;
// //}
// //是否提供密码
// //boolean providePublicKey = false;
// //if ("0".equals(apiWhite.getProvideSecret())) {
// // privatekey = apiWhite.getSecretKey();
// //} else if ("1".equals(apiWhite.getProvideSecret())) {
// // privatekey = secretPrivate;
// // providePublicKey = true;
// //}
// try {
// responseJson = JsonUtil.toJSONString(response.getResponse(),
// PropertyNamingStrategy.SnakeCase);
// if (StringUtil.isNotEmpty(request.getSignType())) {
// String charset = request.getCharset();
// if (StringUtil.isEmpty(charset)) {
// charset = Constants.CHARSET_UTF8;
// }
//
// //if (providePublicKey) {
// // sign = SignatureUtil.sign(convertResult(response.getResponse(), response, apiWhite), privatekey, charset, SignType.valueOf(request.getSignType()), SignatureUtil.SIGN_REQUEST, providePublicKey);
// //} else {
// // sign = SignatureUtil.sign(convertResult(response.getResponse(), response, apiWhite), privatekey, charset, SignType.valueOf(request.getSignType()), SignatureUtil.SIGN_REQUEST, providePublicKey);
// //}
// }
// } catch (JSONException e) {
// LogUtil.error(LOGGER, e,
// "serializer response to json string error. response=" + response.getResponse());
// response.clearAttributes();
// response.setCode(OpenApiResultCode.RESPONSE_DATA_FORMAT_ERROR.getCode());
// response.setMsg(OpenApiResultCode.RESPONSE_DATA_FORMAT_ERROR.getMsg());
// // sign = signatureException(request, response, privatekey, providePublicKey);
// } catch (SignatureException ex) {
// LogUtil.error(LOGGER, ex,
// "sign response error. response=" + response.getResponse());
// response.clearAttributes();
// response.setCode(ex.getResultCode().getCode());
// response.setMsg(ex.getResultCode().getMsg());
// } catch (Throwable ex) {
// LogUtil.error(LOGGER, ex,
// "signatureFilter doFilter error. response=" + response.getResponse());
// response.clearAttributes();
// response.setCode(GatewayResultCode.UNKNOWN_EXCEPTION.getCode());
// response.setMsg(GatewayResultCode.UNKNOWN_EXCEPTION.getMsg());
// // sign = signatureException(request, response, privatekey, providePublicKey);
// }
// response.setSign(sign);
// //if (apiWhite.getIsEncrypt()) {
// // response.setEncryptData(encryptData);
// //}
// }
// }
//
// private Map<String, Object> convertResult(Map<String, Object> attributes, GatewayResponse response) {
// Map<String, Object> mapResult = new HashMap<>();
// mapResult.put("code", response.getCode());
// mapResult.put("msg", response.getMsg());
// Object code = attributes.get("code");
// Object msg = attributes.get("msg");
// attributes.remove("code");
// attributes.remove("msg");
// if (!CollectionUtils.isEmpty(attributes)) {
// mapResult.put("data", JsonUtil.toJSONString(attributes, PropertyNamingStrategy.SnakeCase));
// //if (apiWhite.getIsEncrypt()) {
// // String string = (String) mapResult.get("data");
// // try {
// // RSAPrivateKey privateKey = RSAUtils.getPrivateKey(secretPrivate);
// // String encrypt = RSAUtils.privateEncrypt(string, privateKey);
// // mapResult.put("data", encrypt);
// // encryptData = encrypt;
// // } catch (Exception e) {
// // e.printStackTrace();
// // }
// //}
// }
// attributes.put("code", code);
// attributes.put("msg", msg);
// return mapResult;
// }
//
// private String signatureException(GatewayRequest request, GatewayResponse response,
// String privateKey, boolean providePublicKey) {
// String responseJson = null;
// String sign = StringUtil.EMPTY_STRING;
// try {
// responseJson = JsonUtil.toJSONString(response.getResponse(),
// PropertyNamingStrategy.SnakeCase);
// } catch (JSONException e1) {
// LogUtil.error(LOGGER, e1,
// "serializer response to json string error. response=" + response.getResponse());
// return sign;
// }
// try {
// sign = SignatureUtil.sign(responseJson, privateKey, request.getCharset(), SignType.valueOf(request.getSignType()), SignatureUtil.SIGN_REQUEST, providePublicKey);
// } catch (SignatureException ex) {
// LogUtil.error(LOGGER, ex, "sign response error. response=" + response.getResponse());
// }
// return sign;
// }
//
// /**
// * @see org.springframework.core.Ordered#getOrder()
// */
// @Override
// public int getOrder() {
// return Constants.FILTER_ORDER_0;
// }
//
// @Override
// public String getFilterName() {
// return "SignatureFilter";
// }
//
//}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
View file @
792757f1
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.common.util.HddHashMap
;
import
com.jz.dm.common.util.RSAUtils
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.model.enums.RouteType
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model.OpenApi
;
import
com.jz.dm.model.RequestContext
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.OpenApi
;
import
com.jz.dm.models.enity.RequestContext
;
import
com.jz.dm.models.enums.RouteType
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
java.security.interfaces.RSAPublicKey
;
/**
* 验签过滤器
* 验签过滤器
(验证签名信息)
*/
@Slf4j
@Component
public
class
VerifySignFilter
extends
AbstractFilter
{
//@Autowired
//private IApiWhiteService apiWhiteService;
private
final
static
String
CHARSET
=
"UTF-8"
;
@Override
public
int
getOrder
()
{
return
Constants
.
FILTER_ORDER_4
;
...
...
@@ -38,8 +31,7 @@ public class VerifySignFilter extends AbstractFilter {
// 后期再扩展
OpenApi
openApi
=
new
OpenApi
();
openApi
.
setApplication
(
"JZ_API_GATEWAY"
);
//应用
openApi
.
setRouteType
(
RouteType
.
SPRINGBOOT
);
//漏油类型
//openApi.setRouteType(RouteType.SRPING);//漏油类型
openApi
.
setRouteType
(
RouteType
.
SRPING
);
//漏油类型
RequestContext
.
getCurrentContext
().
set
(
"openApi"
,
openApi
);
chain
.
doFilter
(
request
,
response
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/DefaultOpenApiDispatcher.java
View file @
792757f1
...
...
@@ -6,7 +6,7 @@ import com.jz.dm.common.util.OpenApiRequest;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.OpenApiResultCode
;
import
com.jz.dm.common.util.StringUtil
;
import
com.jz.dm.model.DispatchContext
;
import
com.jz.dm.model
s.enity
.DispatchContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
...
...
@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* 默认openapi分发器
*
* @author
key
* @author
zc
*/
@Component
(
"defaultOpenApiDispatcher"
)
public
class
DefaultOpenApiDispatcher
implements
OpenApiDispatcher
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/GatewayService.java
View file @
792757f1
package
com
.
jz
.
dm
.
gateway
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
/**
* GatewayService
* @author
key
* @author
zc
*/
public
interface
GatewayService
{
/**
* @param gatewayRequest
* @return
*/
GatewayResponse
invoke
(
GatewayRequest
gatewayRequest
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/OpenApiDispatcher.java
View file @
792757f1
package
com
.
jz
.
dm
.
gateway
;
import
com.jz.dm.model.DispatchContext
;
import
com.jz.dm.model
s.enity
.DispatchContext
;
/**
* openapi分发器
*
* @author
key
* @author
zc
*/
public
interface
OpenApiDispatcher
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/OpenApiService.java
View file @
792757f1
...
...
@@ -6,7 +6,7 @@ import com.jz.dm.common.util.OpenApiResponse;
/**
* openapi服务
* @author
key
* @author
zc
*/
public
interface
OpenApiService
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/impl/GatewayServiceImpl.java
View file @
792757f1
...
...
@@ -5,8 +5,8 @@ package com.jz.dm.gateway.impl;
import
com.jz.dm.filter.FilterChain
;
import
com.jz.dm.filter.FilterChainFactory
;
import
com.jz.dm.gateway.GatewayService
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -24,7 +24,6 @@ public class GatewayServiceImpl implements GatewayService {
@Override
public
GatewayResponse
invoke
(
GatewayRequest
gatewayRequest
)
{
GatewayResponse
gatewayResponse
=
new
GatewayResponse
();
System
.
out
.
println
(
"经过了网关服务~~~~~~~~~~~~~~~~~~~~"
);
FilterChain
filterChain
=
filterChainFactory
.
getFilterChain
();
filterChain
.
doFilter
(
gatewayRequest
,
gatewayResponse
);
return
gatewayResponse
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiAuthMapper.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiAuth
;
/**api授权信息表 mapper
* @author zc
*
*/
public
interface
ApiAuthMapper
extends
BaseMapper
<
ApiAuth
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiInterfaceMapper.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiInterface
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.mapper
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiInterfaceMapper
* @DATE: 2020-12-22/15:05
* @DAY_NAME_SHORT: 周二
* @Description:
**/
public
interface
ApiInterfaceMapper
extends
BaseMapper
<
ApiInterface
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiOpenApiEsFieldsMapper.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiOpenApiEsFields
;
/**apiEs字段信息表 mapper
* @author ybz
*
*/
public
interface
ApiOpenApiEsFieldsMapper
extends
BaseMapper
<
ApiOpenApiEsFields
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiOpenApiEsTagconfigMapper.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiOpenApiEsTagconfig
;
/**apiEs配置信息表 mapper
* @author ZC
*/
public
interface
ApiOpenApiEsTagconfigMapper
extends
BaseMapper
<
ApiOpenApiEsTagconfig
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiOrgMapper.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiOrg
;
/**api组织信息表 mapper
* @author zc
*
*/
public
interface
ApiOrgMapper
extends
BaseMapper
<
ApiOrg
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiReqLogMapper.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
/**api请求日志表 mapper
* @author ybz
*/
public
interface
ApiReqLogMapper
extends
BaseMapper
<
ApiReqLog
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiSyncingDatasourceMapper.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiSyncingDatasource
;
/**api数据源配置信息表 mapper
* @author ybz
*
*/
public
interface
ApiSyncingDatasourceMapper
extends
BaseMapper
<
ApiSyncingDatasource
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiSyncingDatasourceTypeMapper.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiSyncingDatasourceType
;
/**api数据源类型信息表 mapper
* @author ybz
*
*/
public
interface
ApiSyncingDatasourceTypeMapper
extends
BaseMapper
<
ApiSyncingDatasourceType
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/model/signtype/SHA1WithRSA.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
model
.
signtype
;
import
com.jz.dm.constant.Constants
;
import
com.sun.org.apache.xerces.internal.impl.dv.util.Base64
;
import
javax.crypto.Cipher
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
import
java.security.Key
;
import
java.security.KeyFactory
;
import
java.security.PrivateKey
;
import
java.security.PublicKey
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
public
class
SHA1WithRSA
{
public
static
final
String
SIGN_TYPE_RSA
=
"RSA"
;
public
static
final
String
SIGN_ALGORITHMS
=
"SHA1WithRSA"
;
/**
* RSA最大加密明文大小
*/
private
static
final
int
MAX_ENCRYPT_BLOCK
=
117
;
/**
* RSA最大解密密文大小
*/
private
static
final
int
MAX_DECRYPT_BLOCK
=
128
;
/**
* RSA签名
*
* @param content 待签名数据
* @param privateKey 商户私钥
* @param input_charset 编码格式
* @return 签名值
*/
public
static
String
sign
(
String
content
,
String
privateKey
,
String
input_charset
)
{
try
{
PKCS8EncodedKeySpec
priPKCS8
=
new
PKCS8EncodedKeySpec
(
Base64
.
decode
(
privateKey
));
KeyFactory
keyf
=
KeyFactory
.
getInstance
(
SIGN_TYPE_RSA
);
PrivateKey
priKey
=
keyf
.
generatePrivate
(
priPKCS8
);
java
.
security
.
Signature
signature
=
java
.
security
.
Signature
.
getInstance
(
SIGN_ALGORITHMS
);
signature
.
initSign
(
priKey
);
signature
.
update
(
content
.
getBytes
(
input_charset
));
byte
[]
signed
=
signature
.
sign
();
return
Base64
.
encode
(
signed
);
}
catch
(
Exception
e
)
{
}
return
null
;
}
/**
* RSA验签名检查
*
* @param content 待签名数据
* @param sign 签名值
* @param ali_public_key 支付宝公钥
* @param input_charset 编码格式
* @return 布尔值
*/
public
static
boolean
verify
(
String
content
,
String
sign
,
String
ali_public_key
,
String
input_charset
)
{
try
{
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
SIGN_TYPE_RSA
);
byte
[]
encodedKey
=
Base64
.
decode
(
ali_public_key
);
PublicKey
pubKey
=
keyFactory
.
generatePublic
(
new
X509EncodedKeySpec
(
encodedKey
));
java
.
security
.
Signature
signature
=
java
.
security
.
Signature
.
getInstance
(
SIGN_ALGORITHMS
);
signature
.
initVerify
(
pubKey
);
signature
.
update
(
content
.
getBytes
(
input_charset
));
boolean
bverify
=
signature
.
verify
(
Base64
.
decode
(
sign
));
return
bverify
;
}
catch
(
Exception
e
)
{
}
return
false
;
}
public
static
String
encrypt
(
String
content
,
String
publickey
)
{
try
{
byte
[]
data
=
content
.
getBytes
(
"UTF-8"
);
byte
[]
keys
=
Base64
.
decode
(
publickey
);
X509EncodedKeySpec
x509KeySpec
=
new
X509EncodedKeySpec
(
keys
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
SIGN_TYPE_RSA
);
Key
publicK
=
keyFactory
.
generatePublic
(
x509KeySpec
);
// 对数据加密
Cipher
cipher
=
Cipher
.
getInstance
(
keyFactory
.
getAlgorithm
());
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
publicK
);
int
inputLen
=
data
.
length
;
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
int
offSet
=
0
,
i
=
0
;
byte
[]
cache
;
// 对数据分段加密
while
(
inputLen
-
offSet
>
0
)
{
if
(
inputLen
-
offSet
>
MAX_ENCRYPT_BLOCK
)
{
cache
=
cipher
.
doFinal
(
data
,
offSet
,
MAX_ENCRYPT_BLOCK
);
}
else
{
cache
=
cipher
.
doFinal
(
data
,
offSet
,
inputLen
-
offSet
);
}
out
.
write
(
cache
,
0
,
cache
.
length
);
i
++;
offSet
=
i
*
MAX_ENCRYPT_BLOCK
;
}
byte
[]
encryptedData
=
out
.
toByteArray
();
out
.
close
();
return
Base64
.
encode
(
encryptedData
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
public
static
String
decrypt
(
String
content
,
String
privatekey
)
{
try
{
byte
[]
data
=
Base64
.
decode
(
content
);
byte
[]
keyBytes
=
Base64
.
decode
(
privatekey
);
PKCS8EncodedKeySpec
pkcs8KeySpec
=
new
PKCS8EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
SIGN_TYPE_RSA
);
Key
privateK
=
keyFactory
.
generatePrivate
(
pkcs8KeySpec
);
Cipher
cipher
=
Cipher
.
getInstance
(
keyFactory
.
getAlgorithm
());
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
privateK
);
int
inputLen
=
data
.
length
;
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
int
offSet
=
0
,
i
=
0
;
byte
[]
cache
;
// 对数据分段解密
while
(
inputLen
-
offSet
>
0
)
{
if
(
inputLen
-
offSet
>
MAX_DECRYPT_BLOCK
)
{
cache
=
cipher
.
doFinal
(
data
,
offSet
,
MAX_DECRYPT_BLOCK
);
}
else
{
cache
=
cipher
.
doFinal
(
data
,
offSet
,
inputLen
-
offSet
);
}
out
.
write
(
cache
,
0
,
cache
.
length
);
i
++;
offSet
=
i
*
MAX_DECRYPT_BLOCK
;
}
byte
[]
decryptedData
=
out
.
toByteArray
();
out
.
close
();
return
new
String
(
decryptedData
,
"UTF-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
public
static
void
main
(
String
[]
args
)
{
//String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANWCsjJK8va1KQpKqn+A2H98nlt2DJc1krohxOOlr2M6lAZeNacMhMvgAxH6Af+VZBFoOOBIUyaSBlWcXtxdpBKSAe5sLESyhLMK0jRDZJst13Tfimq65X0G2yEFQQAD3wLlrp+EGnJIXTZwLRRPKCfR34bOvvDuVi6GFD3rjFtXAgMBAAECgYAtaiNlNzP+7gHQwpkJjep/E47LfYyoDSkslko+8dsgjDE4OYnIAo2sn/WHOVp7dtdWLIkMi9XD+oOGakBzNyfSt+Xmzc4NBJoBGp1YRjJy8vwwgMD9QLCeXcTLaIMbfoDQ6D410rjPecqdfrfqf8+OEsR13XJ3W7qavvFejT8eAQJBAO/s5sqRg7W0ASTA8nQE18xO+kmJWNpZOAawh1bdh9b5ZIqjtXOk46XenxQBP00PgLlPbTHwj7YqozG8ixnsMZcCQQDj0LzuIbecFuOeQRkyRYSMX/CKqg8g3MvmB+gcKV1Con007y7NthYK/ILEdIhll/5k/F1zz4pQvgv/t5tWetxBAkEAxcQsFUvPGobO7oHRGIspanKrYtRBFnK2eOUoGhUvNKeMFa+OEU4YjBAuZmoEyLt/qsBqzOBzRYBt1sCIlIyZ7wJAHOL88d0IoRwt5IUworU552rK32pM3MfietqJzfhYwPhFlA64CpGKHf6CvlJgcTFiqn9tgh/Q1AglEVnAsqiFgQJAcspCepgN1Ef9We1lLccFdf+7uBp0iFTv232pPoLV4OPwaacgbtRi/rJYuRsAtQ66d2PMPp6VhROzLpVCwQhwpA==";
String
privateKey
=
"MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANWCsjJK8va1KQpKqn+A2H98nlt2DJc1krohxOOlr2M6lAZeNacMhMvgAxH6Af+VZBFoOOBIUyaSBlWcXtxdpBKSAe5sLESyhLMK0jRDZJst13Tfimq65X0G2yEFQQAD3wLlrp+EGnJIXTZwLRRPKCfR34bOvvDuVi6GFD3rjFtXAgMBAAECgYAtaiNlNzP+7gHQwpkJjep/E47LfYyoDSkslko+8dsgjDE4OYnIAo2sn/WHOVp7dtdWLIkMi9XD+oOGakBzNyfSt+Xmzc4NBJoBGp1YRjJy8vwwgMD9QLCeXcTLaIMbfoDQ6D410rjPecqdfrfqf8+OEsR13XJ3W7qavvFejT8eAQJBAO/s5sqRg7W0ASTA8nQE18xO+kmJWNpZOAawh1bdh9b5ZIqjtXOk46XenxQBP00PgLlPbTHwj7YqozG8ixnsMZcCQQDj0LzuIbecFuOeQRkyRYSMX/CKqg8g3MvmB+gcKV1Con007y7NthYK/ILEdIhll/5k/F1zz4pQvgv/t5tWetxBAkEAxcQsFUvPGobO7oHRGIspanKrYtRBFnK2eOUoGhUvNKeMFa+OEU4YjBAuZmoEyLt/qsBqzOBzRYBt1sCIlIyZ7wJAHOL88d0IoRwt5IUworU552rK32pM3MfietqJzfhYwPhFlA64CpGKHf6CvlJgcTFiqn9tgh/Q1AglEVnAsqiFgQJAcspCepgN1Ef9We1lLccFdf+7uBp0iFTv232pPoLV4OPwaacgbtRi/rJYuRsAtQ66d2PMPp6VhROzLpVCwQhwpA=="
;
String
pubKey
=
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVgrIySvL2tSkKSqp/gNh/fJ5bdgyXNZK6IcTjpa9jOpQGXjWnDITL4AMR+gH/lWQRaDjgSFMmkgZVnF7cXaQSkgHubCxEsoSzCtI0Q2SbLdd034pquuV9BtshBUEAA98C5a6fhBpySF02cC0UTygn0d+Gzr7w7lYuhhQ964xbVwIDAQAB"
;
String
ali_pub_key
=
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB"
;
String
content
=
"body=2015-01-11在天上人间消费&buyer_email=215262016@qq.com&buyer_id=2088902962305570&discount=0.00&gmt_create=2015-01-11 09:54:48&gmt_payment=2015-01-11 09:54:49&is_total_fee_adjust=N¬ify_id=8261289e01d29d527d5de6802b90d99156¬ify_time=2015-01-11 09:54:49¬ify_type=trade_status_sync&out_trade_no=2015011100000002&payment_type=1&price=0.01&quantity=1&seller_email=ttl66868@163.com&seller_id=2088711660560521&subject=天上人间消费&total_fee=0.01&trade_no=2015011128211457&trade_status=TRADE_SUCCESS&use_coupon=N"
;
String
sign
=
sign
(
content
,
privateKey
,
Constants
.
CHARSET_UTF8
);
System
.
out
.
println
(
sign
);
boolean
b
=
verify
(
content
,
sign
,
pubKey
,
Constants
.
CHARSET_UTF8
);
System
.
out
.
println
(
b
);
sign
=
"C9guMhDh1MSmE2O7O04oaPbCkKWf0WsokBR97W1BQidL/mQaQpvyHFSGYe+jnWo8iOryZCOirWrSrdfbwWePkCj9PGyPD9GeW0gUoK6VOdDxekUXPQvRmV2KznOhDXIQF+aw+aiMiTKsGEskdLorn9LaEP13TTYQHaiXzSh+G50="
;
boolean
bl
=
verify
(
content
,
sign
,
ali_pub_key
,
Constants
.
CHARSET_UTF8
);
System
.
out
.
println
(
bl
);
}
/**
* 解密
*
* @param content 密文
* @param private_key 商户私钥
* @param input_charset 编码格式
* @return 解密后的字符串
*/
public
static
String
decrypt
(
String
content
,
String
private_key
,
String
input_charset
)
throws
Exception
{
PrivateKey
prikey
=
getPrivateKey
(
private_key
);
Cipher
cipher
=
Cipher
.
getInstance
(
SIGN_TYPE_RSA
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
prikey
);
InputStream
ins
=
new
ByteArrayInputStream
(
Base64
.
decode
(
content
));
ByteArrayOutputStream
writer
=
new
ByteArrayOutputStream
();
// rsa解密的字节大小最多是128,将需要解密的内容,按128位拆开解密
byte
[]
buf
=
new
byte
[
128
];
int
bufl
;
while
((
bufl
=
ins
.
read
(
buf
))
!=
-
1
)
{
byte
[]
block
=
null
;
if
(
buf
.
length
==
bufl
)
{
block
=
buf
;
}
else
{
block
=
new
byte
[
bufl
];
for
(
int
i
=
0
;
i
<
bufl
;
i
++)
{
block
[
i
]
=
buf
[
i
];
}
}
writer
.
write
(
cipher
.
doFinal
(
block
));
}
return
new
String
(
writer
.
toByteArray
(),
input_charset
);
}
/**
* 得到私钥
*
* @param key 密钥字符串(经过base64编码)
* @throws Exception
*/
public
static
PrivateKey
getPrivateKey
(
String
key
)
throws
Exception
{
byte
[]
keyBytes
;
keyBytes
=
Base64
.
decode
(
key
);
PKCS8EncodedKeySpec
keySpec
=
new
PKCS8EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
SIGN_TYPE_RSA
);
PrivateKey
privateKey
=
keyFactory
.
generatePrivate
(
keySpec
);
return
privateKey
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/model/signtype/SHA256WithRSA.java
deleted
100644 → 0
View file @
abb8bc5e
package
com
.
jz
.
dm
.
model
.
signtype
;
import
com.jz.dm.common.util.Base64
;
import
com.jz.dm.common.util.StreamUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.*
;
import
java.security.*
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPublicKey
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
SHA256WithRSA
{
public
static
final
String
SIGN_TYPE_RSA
=
"RSA"
;
public
static
final
String
SIGN_SHA256RSA_ALGORITHMS
=
"SHA256WithRSA"
;
/**
* RSA签名
*
* @param content 待签名数据
* @param privateKey 商户私钥
* @param input_charset 编码格式
* @return 签名值
*/
public
static
String
sign
(
String
content
,
String
privateKey
,
String
input_charset
)
{
try
{
PrivateKey
priKey
=
getPrivateKeyFromPKCS8
(
SIGN_TYPE_RSA
,
new
ByteArrayInputStream
(
privateKey
.
getBytes
()));
Signature
signature
=
Signature
.
getInstance
(
SIGN_SHA256RSA_ALGORITHMS
);
signature
.
initSign
(
priKey
);
signature
.
update
(
content
.
getBytes
(
input_charset
));
return
new
String
(
Base64
.
encodeBase64
(
signature
.
sign
()));
}
catch
(
Exception
e
)
{
}
return
null
;
}
/**
* RSA验签名检查
*
* @param content 待签名数据
* @param sign 签名值
* @param ali_public_key 支付宝公钥
* @param input_charset 编码格式
* @return 布尔值
*/
public
static
boolean
verify
(
String
content
,
String
sign
,
String
publicKey
,
String
input_charset
)
{
try
{
PublicKey
pubKey
=
getPublicKeyFromX509
(
SIGN_TYPE_RSA
,
new
ByteArrayInputStream
(
publicKey
.
getBytes
()));
Signature
signature
=
Signature
.
getInstance
(
SIGN_SHA256RSA_ALGORITHMS
);
signature
.
initVerify
(
pubKey
);
signature
.
update
(
content
.
getBytes
(
input_charset
));
return
signature
.
verify
(
Base64
.
decodeBase64
(
sign
.
getBytes
()));
}
catch
(
Exception
e
)
{
}
return
false
;
}
public
static
PrivateKey
getPrivateKeyFromPKCS8
(
String
algorithm
,
InputStream
ins
)
throws
Exception
{
if
(
ins
==
null
||
StringUtils
.
isEmpty
(
algorithm
))
{
return
null
;
}
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
algorithm
);
byte
[]
encodedKey
=
StreamUtil
.
readText
(
ins
).
getBytes
();
encodedKey
=
Base64
.
decodeBase64
(
encodedKey
);
return
keyFactory
.
generatePrivate
(
new
PKCS8EncodedKeySpec
(
encodedKey
));
}
public
static
PublicKey
getPublicKeyFromX509
(
String
algorithm
,
InputStream
ins
)
throws
Exception
{
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
algorithm
);
StringWriter
writer
=
new
StringWriter
();
StreamUtil
.
io
(
new
InputStreamReader
(
ins
),
writer
);
byte
[]
encodedKey
=
writer
.
toString
().
getBytes
();
encodedKey
=
Base64
.
decodeBase64
(
encodedKey
);
return
keyFactory
.
generatePublic
(
new
X509EncodedKeySpec
(
encodedKey
));
}
private
static
java
.
util
.
Base64
.
Decoder
decoder
=
java
.
util
.
Base64
.
getDecoder
();
private
static
java
.
util
.
Base64
.
Encoder
encoder
=
java
.
util
.
Base64
.
getEncoder
();
public
static
Map
<
String
,
byte
[]>
generateKeyBytes
()
{
try
{
KeyPairGenerator
keyPairGenerator
=
KeyPairGenerator
.
getInstance
(
SIGN_TYPE_RSA
);
keyPairGenerator
.
initialize
(
2048
);
KeyPair
keyPair
=
keyPairGenerator
.
generateKeyPair
();
RSAPublicKey
publicKey
=
(
RSAPublicKey
)
keyPair
.
getPublic
();
RSAPrivateKey
privateKey
=
(
RSAPrivateKey
)
keyPair
.
getPrivate
();
Map
<
String
,
byte
[]>
keyMap
=
new
HashMap
<
String
,
byte
[]>();
keyMap
.
put
(
"PUBLIC_KEY"
,
publicKey
.
getEncoded
());
keyMap
.
put
(
"PRIVATE_KEY"
,
privateKey
.
getEncoded
());
return
keyMap
;
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
{
Map
<
String
,
byte
[]>
a
=
generateKeyBytes
();
String
key
=
encoder
.
encodeToString
(
a
.
get
(
"PRIVATE_KEY"
));
String
pkey
=
encoder
.
encodeToString
(
a
.
get
(
"PUBLIC_KEY"
));
String
content
=
"abc"
;
String
sign
=
SHA1WithRSA
.
sign
(
content
,
key
,
"utf-8"
);
System
.
out
.
println
(
SHA1WithRSA
.
verify
(
content
,
sign
,
pkey
,
"utf-8"
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.jz.dm.models.enity.BaseObject
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_auth"
)
public
class
ApiAuth
extends
BaseObject
implements
Serializable
{
/**
* api信息表id
*/
@TableField
(
"api_interface_id"
)
private
Long
apiInterfaceId
;
/**
* api组织id
*/
@TableField
(
"api_org_id"
)
private
Long
apiOrgId
;
/**
* 授权类型:1.数据银行购买 2.dmp授权
*/
@TableField
(
"auth_type"
)
private
String
authType
;
/**
* 授权码
*/
@TableField
(
"auth_code"
)
private
String
authCode
;
/**
* 盐值
*/
@TableField
(
"salt"
)
private
String
salt
;
/**
* 组织id
*/
@TableField
(
"org_id"
)
private
Long
orgId
;
/**
* 授权方式:1.按次调用 2.按月调用 3.按季调用 4.按年调用
*/
@TableField
(
"auth_mode"
)
private
String
authMode
;
/**
* 开始时间
*/
@ApiModelProperty
(
"开始时间"
)
@TableField
(
"valid_start_time"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
validStartTime
;
/**
* 结束时间
*/
@ApiModelProperty
(
"结束时间"
)
@TableField
(
"valid_end_time"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
validEndTime
;
/**
* 状态(1-正常 2-作废)
*/
@TableField
(
"status"
)
private
String
status
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.jz.dm.models.enity.BaseObject
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_interface"
)
public
class
ApiInterface
extends
BaseObject
implements
Serializable
{
/**
* api唯一标识
*/
@TableField
(
"api_key"
)
private
String
apiKey
;
/**
* api名称
*/
@TableField
(
"api_name"
)
private
String
apiName
;
/**
* api描述
*/
@TableField
(
"api_desc"
)
private
String
apiDesc
;
/**
* api请求协议:http,https
*/
@TableField
(
"api_protocl"
)
private
String
apiProtocl
;
/**
* 目标url
*/
@TableField
(
"target_url"
)
private
String
targetUrl
;
/**
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
*/
@TableField
(
"status"
)
private
String
status
;
/**
* 版本号
*/
@TableField
(
"version"
)
private
String
version
;
/**
* 加密方式: MD5 RSA
*/
@TableField
(
"sign_type"
)
private
String
signType
;
/**
* 超时时间
*/
@TableField
(
"timeout"
)
private
String
timeout
;
/**
* 是否测试数据:0 否,1 是
*/
@TableField
(
"is_test"
)
private
Integer
isTest
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiOpenApiEsFields.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.jz.dm.models.enity.BaseObject
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**apiEs字段信息表
* @author ybz
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_open_api_es_fields"
)
public
class
ApiOpenApiEsFields
extends
BaseObject
implements
Serializable
{
/**
* 源数据库
*/
@TableField
(
"es_database"
)
private
String
esDatabase
;
/**
* 源表
*/
@TableField
(
"es_table"
)
private
String
esTable
;
/**
* 字段名称
*/
@TableField
(
"field_name"
)
private
String
fieldName
;
/**
* 字段类型
*/
@TableField
(
"field_type"
)
private
String
fieldType
;
/**
* 字段描述
*/
@TableField
(
"field_desc"
)
private
String
fieldDesc
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiOpenApiEsTagconfig.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.jz.dm.models.enity.BaseObject
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**apiEs配置信息表
* @author ybz
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_open_api_es_tagconfig"
)
public
class
ApiOpenApiEsTagconfig
extends
BaseObject
implements
Serializable
{
/**
* 工程id
*/
@TableField
(
"project_id"
)
private
Long
projectId
;
/**
* app_id
*/
@TableField
(
"app_id"
)
private
String
appId
;
/**
* api_id
*/
@TableField
(
"api_id"
)
private
String
apiId
;
/**
* api类型
*/
@TableField
(
"api_type"
)
private
String
apiType
;
/**
* api唯一标识
*/
@TableField
(
"api_key"
)
private
String
apiKey
;
/**
* 数据源id
*/
@TableField
(
"es_data_source"
)
private
String
esDataSource
;
/**
* 源数据库名称
*/
@TableField
(
"es_data_base"
)
private
String
esDataBase
;
/**
* 源数据表名称
*/
@TableField
(
"es_table"
)
private
String
esTable
;
/**
* 请求参数集合
*/
@TableField
(
"request_param"
)
private
String
requestParam
;
/**
* 响应参数集合
*/
@TableField
(
"result_param"
)
private
String
resultParam
;
/**
* 是否分页
*/
@TableField
(
"page"
)
private
String
page
;
/**
* 处理类型
*/
@TableField
(
"handle_type"
)
private
String
handleType
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.jz.dm.models.enity.BaseObject
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_org"
)
public
class
ApiOrg
extends
BaseObject
implements
Serializable
{
/**
* 组织编码(组织唯一标识)
*/
@TableField
(
"org_code"
)
private
String
orgCode
;
/**
* 组织名称
*/
@TableField
(
"org_name"
)
private
String
orgName
;
/**
* 组织描述
*/
@TableField
(
"org_desc"
)
private
String
orgDesc
;
/**
* 组织英文名称
*/
@TableField
(
"org_cn_name"
)
private
String
orgCnName
;
/**
* 状态(1-正常 2-冻结 3-下架)
*/
@TableField
(
"status"
)
private
String
status
;
/**
* 组织邮箱
*/
@TableField
(
"org_mail"
)
private
String
orgMail
;
/**
* 组织排序
*/
@TableField
(
"org_sort"
)
private
Integer
orgSort
;
/**
* 父类组织编码
*/
@TableField
(
"parent_id"
)
private
String
parentId
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiReqLog.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.jz.dm.models.enity.BaseObject
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.util.Date
;
/**api请求日志表
* @author ybz
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_req_log"
)
public
class
ApiReqLog
extends
BaseObject
implements
Serializable
{
/**
* 请求ip
*/
@TableField
(
"request_ip"
)
private
String
requestIp
;
/**
* apikey
*/
@TableField
(
"api_key"
)
private
String
apiKey
;
/**
* 请求参数
*/
@TableField
(
"request_params"
)
private
String
requestParams
;
/**
* 返回参数
*/
@TableField
(
"response_params"
)
private
String
responseParams
;
/**
* 请求路径
*/
@TableField
(
"request_url"
)
private
String
requestUrl
;
/**
* 请求方法
*/
@TableField
(
"request_method"
)
private
String
requestMethod
;
/**
* 请求类型(方式)
*/
@TableField
(
"request_type"
)
private
String
requestType
;
/**
* 加密方式:MD5,RSA
*/
@TableField
(
"encry_mode"
)
private
String
encryMode
;
/**
* 传输方式:POST,GET
*/
@TableField
(
"trans_mode"
)
private
String
transMode
;
/**
* 客户请求token
*/
@TableField
(
"request_token"
)
private
String
requestToken
;
/**
* 请求时间
*/
@ApiModelProperty
(
"请求时间"
)
@TableField
(
"request_time"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
requestTime
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiSyncingDatasource.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.jz.dm.models.enity.BaseObject
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**api数据源配置信息表
* @author ybz
*
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_syncing_datasource"
)
public
class
ApiSyncingDatasource
extends
BaseObject
implements
Serializable
{
/**
* 数据源类型ID
*/
@TableField
(
"datasource_type"
)
private
Long
datasourceType
;
/**
* 数据源名称
*/
@TableField
(
"datasource_name"
)
private
String
datasourceName
;
/**
* 数据源描述
*/
@TableField
(
"datasource_desc"
)
private
String
datasourceDesc
;
/**
* 项目编号
*/
@TableField
(
"project_id"
)
private
Long
projectId
;
/**
* JDBC URL
*/
@TableField
(
"jdbc_url"
)
private
String
jdbcUrl
;
/**
* 数据库名
*/
@TableField
(
"db_name"
)
private
String
dbName
;
/**
* 账号
*/
@TableField
(
"user_name"
)
private
String
userName
;
/**
* 密码
*/
@TableField
(
"password"
)
private
String
password
;
/**
* 终端信息
*/
@TableField
(
"endpoint"
)
private
String
endpoint
;
/**
* Bucket信息
*/
@TableField
(
"bucket"
)
private
String
bucket
;
/**
* accessId
*/
@TableField
(
"access_id"
)
private
String
accessId
;
/**
* accessKey
*/
@TableField
(
"access_key"
)
private
String
accessKey
;
/**
* FTP协议
*/
@TableField
(
"protocol"
)
private
String
protocol
;
/**
* IP
*/
@TableField
(
"host"
)
private
String
host
;
/**
* 端口
*/
@TableField
(
"port"
)
private
String
port
;
/**
* NameNode地址
*/
@TableField
(
"default_fs"
)
private
String
defaultFs
;
/**
* 表空间
*/
@TableField
(
"table_schema"
)
private
String
tableSchema
;
/**
* 数据状态
*/
@TableField
(
"data_status"
)
private
String
dataStatus
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiSyncingDatasourceType.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.jz.dm.models.enity.BaseObject
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_syncing_datasource_type"
)
public
class
ApiSyncingDatasourceType
extends
BaseObject
implements
Serializable
{
/**
* 数据源名称
*/
@TableField
(
"datasource"
)
private
String
datasource
;
/**
* 数据源分类编码
*/
@TableField
(
"datasource_catecode"
)
private
String
datasourceCatecode
;
/**
* 数据源分类名称
*/
@TableField
(
"datasource_catename"
)
private
String
datasourceCatename
;
/**
* 数据源类型
*/
@TableField
(
"datasource_type"
)
private
String
datasourceType
;
/**
* 数据源图标
*/
@TableField
(
"img_url"
)
private
String
imgUrl
;
/**
* 状态
*/
@TableField
(
"data_status"
)
private
String
dataStatus
;
/**
* 是否启用
*/
@TableField
(
"is_enabled"
)
private
String
isEnabled
;
/**
*
*/
@TableField
(
"datasource_catetype"
)
private
String
datasourceCatetype
;
/**
*
*/
@TableField
(
"driver_class_name"
)
private
String
driverClassName
;
/**
* 是否启用测试
*/
@TableField
(
"is_enable_test"
)
private
String
isEnableTest
;
/**
*
*/
@TableField
(
"default_source_script"
)
private
String
defaultSourceScript
;
/**
*
*/
@TableField
(
"default_target_script"
)
private
String
defaultTargetScript
;
/**
* 是否启用源
*/
@TableField
(
"is_enable_source"
)
private
String
isEnableSource
;
/**
* 是否启用目标
*/
@TableField
(
"is_enable_target"
)
private
String
isEnableTarget
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/enity/BaseObject.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
enity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.enity
* @PROJECT_NAME: jz-dm-parent
* @NAME: BaseObject
* @DATE: 2020-12-22/14:03
* @DAY_NAME_SHORT: 周二
* @Description: 日期处理公共类
**/
@Data
public
class
BaseObject
implements
Serializable
{
/**
* 主健ID
*/
@ApiModelProperty
(
"主健ID"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
long
id
;
/**
* 创建日期
*/
@ApiModelProperty
(
"创建日期"
)
@TableField
(
"create_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createDate
;
/**
* 创建人
*/
@ApiModelProperty
(
"创建人"
)
@TableField
(
"create_user"
)
private
String
createUser
;
/**
* 更新人
*/
@ApiModelProperty
(
"更新人"
)
@TableField
(
"update_user"
)
private
String
updateUser
;
/**
* 更新日期
*/
@ApiModelProperty
(
"更新日期"
)
@TableField
(
"update_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
updateDate
;
/**
* 是否删除
*/
@TableField
(
"is_deleted"
)
private
Integer
isDeleted
;
/**
* 备注
*/
@TableField
(
"remark"
)
private
String
remark
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/enity/BaseRequest.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
models
.
enity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.enity
* @PROJECT_NAME: jz-dm-parent
* @NAME: BaseRequest
* @DATE: 2020-12-22/15:14
* @DAY_NAME_SHORT: 周二
* @Description:
**/
@Data
public
class
BaseRequest
{
@ApiModelProperty
(
"当前页码"
)
private
long
pageNum
=
1
;
@ApiModelProperty
(
"每页条数"
)
private
long
pageSize
=
20
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/model/DispatchContext.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/model
s/enity
/DispatchContext.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
;
package
com
.
jz
.
dm
.
model
s
.
enity
;
import
java.io.Serializable
;
import
java.util.HashMap
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/model/GatewayRequest.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/model
s/enity
/GatewayRequest.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
;
package
com
.
jz
.
dm
.
model
s
.
enity
;
import
com.jz.dm.web.annotation.ParamName
;
...
...
@@ -10,7 +10,7 @@ import java.util.Map;
/**
* api请求
*
* @author
key
* @author
ZC
*/
public
class
GatewayRequest
implements
Serializable
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/model/GatewayResponse.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/model
s/enity
/GatewayResponse.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
;
package
com
.
jz
.
dm
.
model
s
.
enity
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.alibaba.fastjson.annotation.JSONType
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/model/OpenApi.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/model
s/enity
/OpenApi.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
;
package
com
.
jz
.
dm
.
model
s
.
enity
;
import
com.alibaba.fastjson.JSON
;
import
com.jz.dm.model.enums.RouteType
;
import
com.jz.dm.model
s
.enums.RouteType
;
import
java.util.Date
;
import
java.util.HashMap
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/model/RequestContext.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/model
s/enity
/RequestContext.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
;
package
com
.
jz
.
dm
.
model
s
.
enity
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/model/enums/Format.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/model
s
/enums/Format.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
.
enums
;
package
com
.
jz
.
dm
.
model
s
.
enums
;
/**
* 数据格式
*
* @author zc
*/
public
enum
Format
{
JSON
,
XML
JSON
,
XML
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/model/enums/GatewayResultCode.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/model
s
/enums/GatewayResultCode.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
.
enums
;
package
com
.
jz
.
dm
.
model
s
.
enums
;
...
...
@@ -47,14 +47,9 @@ public enum GatewayResultCode implements ResultCode {
/** ip不允许访问 */
IP_NOT_ALLOW_ACCESS
(
"IP_NOT_ALLOW_ACCESS"
,
"ip不允许访问"
),
/** ip不允许访问 */
IP_NOT_CONFIG
(
"IP_NOT_CONFIG"
,
"未配置白名单"
),
/** 提交数据过大 */
POST_DATA_TOO_LARGE
(
"POST_DATA_TOO_LARGE"
,
"提交数据过大"
),
/** 调用转发异常 */
DISPATCHER_EXCEPTION
(
"DISPATCHER_EXCEPTION"
,
"调用转发异常"
);
POST_DATA_TOO_LARGE
(
"POST_DATA_TOO_LARGE"
,
"提交数据过大"
);
/**
* 初始化保存到map里方便根据code获取
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/model/enums/RouteType.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/model
s
/enums/RouteType.java
View file @
792757f1
package
com
.
jz
.
dm
.
model
.
enums
;
package
com
.
jz
.
dm
.
model
s
.
enums
;
/**
* 路由类型
...
...
@@ -8,9 +8,6 @@ public enum RouteType {
/**
* 漏油类型
*/
SRPING
,
/**
* 路由网关
*/
SPRINGBOOT
;
SRPING
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/AuthService.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
service
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service
* @PROJECT_NAME: jz-dm-parent
* @NAME: AuthService
* @DATE: 2020-12-23/16:46
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
interface
AuthService
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/OrganizationManageService.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
service
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service
* @PROJECT_NAME: jz-dm-parent
* @NAME: OrganizationManageService
* @DATE: 2020-12-23/16:49
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
interface
OrganizationManageService
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ProducerService.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
service
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service
* @PROJECT_NAME: jz-dm-parent
* @NAME: ProducerService
* @DATE: 2020-12-23/16:56
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
interface
ProducerService
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/
AccountAdd
Service.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/service/
apirequest/ApiQuery
Service.java
View file @
792757f1
package
com
.
jz
.
dm
.
service
;
package
com
.
jz
.
dm
.
service
.
apirequest
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiResponse
;
...
...
@@ -6,9 +6,18 @@ import com.jz.dm.gateway.OpenApiService;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
@Service
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.apirequest
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiQueryService
* @DATE: 2020-12-23/18:10
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Service
(
"apiQueryService"
)
@Slf4j
public
class
A
ccountAdd
Service
implements
OpenApiService
{
public
class
A
piQuery
Service
implements
OpenApiService
{
@Override
public
String
getOpenApiMethod
()
{
return
"query"
;
...
...
@@ -16,12 +25,11 @@ public class AccountAddService implements OpenApiService {
@Override
public
String
getOpenApiVersion
()
{
return
"
V
1.0.0"
;
return
"1.0.0"
;
}
@Override
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
System
.
out
.
println
(
"请求过来了。。。。。"
);
System
.
out
.
println
(
request
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.jz.dm.service.AuthService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: AuthServiceImpl
* @DATE: 2020-12-23/16:48
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Service
(
"authService"
)
@Slf4j
public
class
AuthServiceImpl
implements
AuthService
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.jz.dm.service.OrganizationManageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: OrganizationManageImpl
* @DATE: 2020-12-23/16:50
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Service
(
"organizationManageService"
)
@Slf4j
public
class
OrganizationManageImpl
implements
OrganizationManageService
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
0 → 100644
View file @
792757f1
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.jz.dm.service.ProducerService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: ProducerServiceImpl
* @DATE: 2020-12-23/16:57
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Service
(
"producerService"
)
@Slf4j
public
class
ProducerServiceImpl
implements
ProducerService
{
}
jz-dm-apigateway/src/main/resources/application-test.yml
View file @
792757f1
...
...
@@ -4,7 +4,7 @@ spring:
basic
:
enabled
:
false
datasource
:
url
:
jdbc:mysql://
rm-wz9n399q2avsy3k6m4o.mysql.rds.aliyuncs.com:3306/wj-mkt-project
?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
url
:
jdbc:mysql://
119.23.32.151:3306/api_gateway
?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
username
:
root
password
:
I%ou$buy!ok
driver-class-name
:
com.mysql.jdbc.Driver
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiAuthMapper.xml
0 → 100644
View file @
792757f1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.jz.dm.mapper.ApiAuthMapper"
>
<sql
id=
"Base_Column_List"
>
id, api_interface_id, api_org_id, auth_type, auth_code,
salt, org_id, auth_mode, valid_start_time, valid_end_time,
status, remark, create_date, create_user, update_date,
update_user, is_deleted
</sql>
</mapper>
jz-dm-apigateway/src/main/resources/mapper/ApiInterfaceMapper.xml
0 → 100644
View file @
792757f1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.jz.dm.mapper.ApiInterfaceMapper"
>
<sql
id=
"Base_Column_List"
>
id, api_key, api_name, api_desc, api_protocl,
target_url, status, version, sign_type, timeout,
is_test, remark, create_date, create_user, update_date,
update_user, is_deleted
</sql>
</mapper>
\ No newline at end of file
jz-dm-apigateway/src/main/resources/mapper/ApiOpenApiEsFieldsMapper.xml
0 → 100644
View file @
792757f1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.jz.dm.mapper.ApiOpenApiEsFieldsMapper"
>
<sql
id=
"Base_Column_List"
>
id, es_database, es_table, field_name, field_type,
field_desc, remark, create_date, create_user, update_date,
update_user, is_deleted
</sql>
</mapper>
jz-dm-apigateway/src/main/resources/mapper/ApiOpenApiEsTagconfigMapper.xml
0 → 100644
View file @
792757f1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.jz.dm.mapper.ApiOpenApiEsTagconfigMapper"
>
<sql
id=
"Base_Column_List"
>
id, project_id, app_id, api_id, api_type,
api_key, es_data_source, es_data_base, es_table, request_param,
result_param, page, handle_type, remark, create_date,
create_user, update_date, update_user, is_deleted
</sql>
</mapper>
jz-dm-apigateway/src/main/resources/mapper/ApiOrgMapper.xml
0 → 100644
View file @
792757f1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.jz.dm.mapper.ApiOrgMapper"
>
<sql
id=
"Base_Column_List"
>
id, org_code, org_name, org_desc, org_cn_name,
status, org_mail, org_sort, parent_id, remark,
create_date, create_user, update_date, update_user, is_deleted
</sql>
</mapper>
jz-dm-apigateway/src/main/resources/mapper/ApiReqLogMapper.xml
0 → 100644
View file @
792757f1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.jz.dm.mapper.ApiReqLogMapper"
>
<sql
id=
"Base_Column_List"
>
id, request_ip, api_key, request_params, response_params,
request_url, request_method, request_type, encry_mode, trans_mode,
request_token, request_time, remark, create_date, create_user,
update_date, update_user, is_deleted
</sql>
</mapper>
jz-dm-apigateway/src/main/resources/mapper/ApiSyncingDatasourceMapper.xml
0 → 100644
View file @
792757f1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.jz.dm.mapper.ApiSyncingDatasourceMapper"
>
<sql
id=
"Base_Column_List"
>
id, datasource_type, datasource_name, datasource_desc, project_id,
jdbc_url, db_name, user_name, password, endpoint,
bucket, access_id, access_key, protocol, host,
port, default_fs, table_schema, data_status, remark,
create_date, create_user, update_date, update_user, is_deleted
</sql>
</mapper>
jz-dm-apigateway/src/main/resources/mapper/ApiSyncingDatasourceTypeMapper.xml
0 → 100644
View file @
792757f1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.jz.dm.mapper.ApiSyncingDatasourceTypeMapper"
>
<sql
id=
"Base_Column_List"
>
id, datasource, datasource_catecode, datasource_catename, datasource_type,
img_url, data_status, is_enabled, datasource_catetype, driver_class_name,
is_enable_test, default_source_script, default_target_script, is_enable_source, is_enable_target,
remark, create_date, create_user, update_date, update_user,
is_deleted
</sql>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment