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
Show 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 @@
...
@@ -31,15 +31,19 @@
<dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.1.1
</version>
</dependency>
</dependency>
<!-- 引入Druid依赖,阿里巴巴所提供的数据源 -->
<!-- 引入Druid依赖,阿里巴巴所提供的数据源 -->
<dependency>
<!--
<dependency>
<groupId>com.alibaba</groupId>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<artifactId>druid</artifactId>
</dependency>
</dependency>
-->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid-spring-boot-starter
</artifactId>
<version>
1.1.20
</version>
</dependency>
<!-- 提供mysql驱动 -->
<!-- 提供mysql驱动 -->
<dependency>
<dependency>
<groupId>
mysql
</groupId>
<groupId>
mysql
</groupId>
...
@@ -74,6 +78,15 @@
...
@@ -74,6 +78,15 @@
<version>
1.18.16
</version>
<version>
1.18.16
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
</dependency>
</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>
</dependencies>
</project>
</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
;
package
com
.
jz
.
dm
;
import
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
@@ -11,12 +12,11 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
...
@@ -11,12 +12,11 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* @PACKAGE_NAME: com.jz.dm
* @PACKAGE_NAME: com.jz.dm
* @PROJECT_NAME: jz-dm-parent
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiGatewayApplication
* @NAME: ApiGatewayApplication
* @USER: key
* @DATE: 2020-12-2/16:03
* @DATE: 2020-12-2/16:03
* @DAY_NAME_SHORT: 周三
* @DAY_NAME_SHORT: 周三
* @Description:
* @Description:
**/
**/
@SpringBootApplication
@SpringBootApplication
(
exclude
=
DruidDataSourceAutoConfigure
.
class
)
@ComponentScan
(
basePackages
=
{
"com.jz"
})
@ComponentScan
(
basePackages
=
{
"com.jz"
})
@MapperScan
(
"com.jz.dm.mapper"
)
@MapperScan
(
"com.jz.dm.mapper"
)
@EnableTransactionManagement
@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 {
...
@@ -13,9 +13,6 @@ public class Constants {
*/
*/
public
static
final
String
SIGN_TYPE_RSA2
=
"RSA2"
;
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"
;
public
static
final
String
ENCRYPT_TYPE_AES
=
"AES"
;
...
@@ -35,10 +32,6 @@ public class Constants {
...
@@ -35,10 +32,6 @@ public class Constants {
public
static
final
String
CHARSET
=
"charset"
;
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
ENCRYPT_TYPE
=
"encrypt_type"
;
public
static
final
String
PARAMS
=
"params"
;
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.Logger
;
import
org.slf4j.LoggerFactory
;
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.*;
...
@@ -15,6 +15,15 @@ import java.util.*;
public
class
JSONWriter
{
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
StringBuffer
buf
=
new
StringBuffer
();
private
Stack
<
Object
>
calls
=
new
Stack
<
Object
>();
private
Stack
<
Object
>
calls
=
new
Stack
<
Object
>();
private
boolean
emitClassName
=
true
;
private
boolean
emitClassName
=
true
;
...
@@ -159,8 +168,8 @@ public class JSONWriter {
...
@@ -159,8 +168,8 @@ public class JSONWriter {
private
void
date
(
Date
date
)
{
private
void
date
(
Date
date
)
{
if
(
this
.
format
==
null
)
{
if
(
this
.
format
==
null
)
{
this
.
format
=
new
SimpleDateFormat
(
Constants
.
DATE_TIME_FORMAT
);
this
.
format
=
new
SimpleDateFormat
(
DATE_TIME_FORMAT
);
this
.
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
Constants
.
DATE_TIMEZONE
));
this
.
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
DATE_TIMEZONE
));
}
}
add
(
"\""
);
add
(
"\""
);
add
(
format
.
format
(
date
));
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.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
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;
...
@@ -16,7 +16,7 @@ import java.util.Map;
*/
*/
public
class
OpenApiRequest
{
public
class
OpenApiRequest
{
private
String
appKey
;
private
String
appKey
;
//apiKey
private
String
openApiParams
;
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;
...
@@ -9,7 +9,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
/**
* @ClassName: MybatisPlusConfig
* @ClassName: MybatisPlusConfig
* @Author
Bellamy
* @Author
ZC
* @Date 2020/11/27
* @Date 2020/11/27
* @Version 1.0
* @Version 1.0
*/
*/
...
@@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
...
@@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@MapperScan
(
"com.jz.dm.mapper"
)
@MapperScan
(
"com.jz.dm.mapper"
)
public
class
MybatisPlusConfig
{
public
class
MybatisPlusConfig
{
@Bean
@Bean
public
PaginationInterceptor
paginationInterceptor
()
{
public
PaginationInterceptor
paginationInterceptor
()
{
PaginationInterceptor
paginationInterceptor
=
new
PaginationInterceptor
();
PaginationInterceptor
paginationInterceptor
=
new
PaginationInterceptor
();
...
@@ -27,9 +26,7 @@ public class MybatisPlusConfig {
...
@@ -27,9 +26,7 @@ public class MybatisPlusConfig {
// 设置最大单页限制数量,默认 500 条,-1 不受限制
// 设置最大单页限制数量,默认 500 条,-1 不受限制
paginationInterceptor
.
setLimit
(
500
);
paginationInterceptor
.
setLimit
(
500
);
// 开启 count 的 join 优化,只针对部分 left join
// 开启 count 的 join 优化,只针对部分 left join
paginationInterceptor
.
setCountSqlParser
(
new
JsqlParserCountOptimize
());
paginationInterceptor
.
setCountSqlParser
(
new
JsqlParserCountOptimize
(
true
));
return
paginationInterceptor
;
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;
...
@@ -5,9 +5,9 @@ import com.alibaba.fastjson.JSONObject;
import
com.alibaba.fastjson.PropertyNamingStrategy
;
import
com.alibaba.fastjson.PropertyNamingStrategy
;
import
com.jz.dm.common.util.JsonUtil
;
import
com.jz.dm.common.util.JsonUtil
;
import
com.jz.dm.gateway.GatewayService
;
import
com.jz.dm.gateway.GatewayService
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model.RequestContext
;
import
com.jz.dm.model
s.enity
.RequestContext
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -21,7 +21,7 @@ import java.util.Map;
...
@@ -21,7 +21,7 @@ import java.util.Map;
/**
/**
* 网关请求
* 网关请求
* @author
key
* @author
zc
*/
*/
@RestController
@RestController
public
class
GatewayController
{
public
class
GatewayController
{
...
@@ -48,7 +48,6 @@ public class GatewayController {
...
@@ -48,7 +48,6 @@ public class GatewayController {
RequestContext
requestContext
=
RequestContext
.
getCurrentContext
();
RequestContext
requestContext
=
RequestContext
.
getCurrentContext
();
requestContext
.
setRequest
(
httpServletRequest
);
requestContext
.
setRequest
(
httpServletRequest
);
requestContext
.
setResponse
(
httpServletResponse
);
requestContext
.
setResponse
(
httpServletResponse
);
System
.
out
.
println
(
"经过了controller~~~~~~~~~~~~~~~~~~~~"
);
GatewayResponse
gatewayResponse
=
gatewayService
.
invoke
(
gatewayRequest
);
GatewayResponse
gatewayResponse
=
gatewayService
.
invoke
(
gatewayRequest
);
JSONObject
result
=
new
JSONObject
();
JSONObject
result
=
new
JSONObject
();
convertResponse
(
result
,
gatewayResponse
);
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
;
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model.RequestContext
;
import
com.jz.dm.model
s.enity
.RequestContext
;
import
org.springframework.core.Ordered
;
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;
...
@@ -3,11 +3,11 @@ package com.jz.dm.filter;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.SignType
;
import
com.jz.dm.common.util.SignType
;
import
com.jz.dm.common.util.StringUtil
;
import
com.jz.dm.common.util.StringUtil
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.co
mmon.co
nstant.Constants
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model.enums.Format
;
import
com.jz.dm.model
s
.enums.Format
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
com.jz.dm.model
s
.enums.GatewayResultCode
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
...
@@ -46,11 +46,13 @@ public class CheckArgsFilter extends AbstractFilter {
...
@@ -46,11 +46,13 @@ public class CheckArgsFilter extends AbstractFilter {
if
(
StringUtil
.
isEmpty
(
request
.
getFormat
()))
{
if
(
StringUtil
.
isEmpty
(
request
.
getFormat
()))
{
request
.
setFormat
(
Format
.
JSON
.
name
());
request
.
setFormat
(
Format
.
JSON
.
name
());
}
}
try
{
try
{
Format
.
valueOf
(
request
.
getFormat
());
//格式,目前仅支持JSON
//格式,目前仅支持JSON
Charset
.
forName
(
request
.
getCharset
());
//请求使用的编码格式,如UTF-8,GBK,GB2312等
Format
.
valueOf
(
request
.
getFormat
());
SignType
.
valueOf
(
request
.
getSignType
());
//生成签名字符串所使用的签名算法类型
//请求使用的编码格式,如UTF-8,GBK,GB2312等
Charset
.
forName
(
request
.
getCharset
());
//生成签名字符串所使用的签名算法类型
SignType
.
valueOf
(
request
.
getSignType
());
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
//无效参数
//无效参数
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
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
;
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.co
mmon.co
nstant.Constants
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model.RequestContext
;
import
com.jz.dm.model
s.enity
.RequestContext
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
com.jz.dm.model
s
.enums.GatewayResultCode
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
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
;
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.co
mmon.co
nstant.Constants
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
com.jz.dm.model
s
.enums.GatewayResultCode
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
/**
...
@@ -41,9 +41,9 @@ public class CheckTimestampFilter extends AbstractFilter {
...
@@ -41,9 +41,9 @@ public class CheckTimestampFilter extends AbstractFilter {
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
//无效参数
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
//无效参数
}
}
//
if (System.currentTimeMillis() - time > max) {
if
(
System
.
currentTimeMillis
()
-
time
>
max
)
{
//
throw new GatewayException(GatewayResultCode.ILLEGAL_TIMETEMP);//无效时间戳
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_TIMETEMP
);
//无效时间戳
//
}
}
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/Filter.java
View file @
792757f1
package
com
.
jz
.
dm
.
filter
;
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
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
;
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
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;
...
@@ -3,9 +3,9 @@ package com.jz.dm.filter;
import
com.jz.dm.common.exception.OpenApiException
;
import
com.jz.dm.common.exception.OpenApiException
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.common.util.ResultCode
;
import
com.jz.dm.common.util.ResultCode
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
com.jz.dm.model.enums.GatewayResultCode
;
import
com.jz.dm.model
s
.enums.GatewayResultCode
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
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;
...
@@ -4,12 +4,12 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.co
mmon.co
nstant.Constants
;
import
com.jz.dm.constant.LoggingConstants
;
import
com.jz.dm.co
mmon.co
nstant.LoggingConstants
;
import
com.jz.dm.gateway.DefaultOpenApiDispatcher
;
import
com.jz.dm.gateway.DefaultOpenApiDispatcher
;
import
com.jz.dm.model
.enums.GatewayResultCode
;
import
com.jz.dm.model
s.enity.*
;
import
com.jz.dm.model
.enums.RouteTyp
e
;
import
com.jz.dm.model
s.enums.GatewayResultCod
e
;
import
com.jz.dm.model
.*
;
import
com.jz.dm.model
s.enums.RouteType
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -19,7 +19,7 @@ import org.springframework.stereotype.Component;
...
@@ -19,7 +19,7 @@ import org.springframework.stereotype.Component;
*
*
* @author key
* @author key
*/
*/
@Component
@Component
(
"invokeRouteFilter"
)
public
class
InvokeRouteFilter
extends
AbstractFilter
{
public
class
InvokeRouteFilter
extends
AbstractFilter
{
/** openapi dispatcher logger */
/** 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
;
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.common.util.HddHashMap
;
import
com.jz.dm.common.util.RSAUtils
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.constant.Constants
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.model.enums.RouteType
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.models.enity.OpenApi
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.models.enity.RequestContext
;
import
com.jz.dm.model.OpenApi
;
import
com.jz.dm.models.enums.RouteType
;
import
com.jz.dm.model.RequestContext
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.security.interfaces.RSAPublicKey
;
/**
/**
* 验签过滤器
* 验签过滤器
(验证签名信息)
*/
*/
@Slf4j
@Slf4j
@Component
@Component
public
class
VerifySignFilter
extends
AbstractFilter
{
public
class
VerifySignFilter
extends
AbstractFilter
{
//@Autowired
//private IApiWhiteService apiWhiteService;
private
final
static
String
CHARSET
=
"UTF-8"
;
@Override
@Override
public
int
getOrder
()
{
public
int
getOrder
()
{
return
Constants
.
FILTER_ORDER_4
;
return
Constants
.
FILTER_ORDER_4
;
...
@@ -38,8 +31,7 @@ public class VerifySignFilter extends AbstractFilter {
...
@@ -38,8 +31,7 @@ public class VerifySignFilter extends AbstractFilter {
// 后期再扩展
// 后期再扩展
OpenApi
openApi
=
new
OpenApi
();
OpenApi
openApi
=
new
OpenApi
();
openApi
.
setApplication
(
"JZ_API_GATEWAY"
);
//应用
openApi
.
setApplication
(
"JZ_API_GATEWAY"
);
//应用
openApi
.
setRouteType
(
RouteType
.
SPRINGBOOT
);
//漏油类型
openApi
.
setRouteType
(
RouteType
.
SRPING
);
//漏油类型
//openApi.setRouteType(RouteType.SRPING);//漏油类型
RequestContext
.
getCurrentContext
().
set
(
"openApi"
,
openApi
);
RequestContext
.
getCurrentContext
().
set
(
"openApi"
,
openApi
);
chain
.
doFilter
(
request
,
response
);
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;
...
@@ -6,7 +6,7 @@ import com.jz.dm.common.util.OpenApiRequest;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.OpenApiResultCode
;
import
com.jz.dm.common.util.OpenApiResultCode
;
import
com.jz.dm.common.util.StringUtil
;
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.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
/**
* 默认openapi分发器
* 默认openapi分发器
*
*
* @author
key
* @author
zc
*/
*/
@Component
(
"defaultOpenApiDispatcher"
)
@Component
(
"defaultOpenApiDispatcher"
)
public
class
DefaultOpenApiDispatcher
implements
OpenApiDispatcher
{
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
;
package
com
.
jz
.
dm
.
gateway
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
/**
/**
* GatewayService
* GatewayService
* @author
key
* @author
zc
*/
*/
public
interface
GatewayService
{
public
interface
GatewayService
{
/**
* @param gatewayRequest
* @return
*/
GatewayResponse
invoke
(
GatewayRequest
gatewayRequest
);
GatewayResponse
invoke
(
GatewayRequest
gatewayRequest
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/gateway/OpenApiDispatcher.java
View file @
792757f1
package
com
.
jz
.
dm
.
gateway
;
package
com
.
jz
.
dm
.
gateway
;
import
com.jz.dm.model.DispatchContext
;
import
com.jz.dm.model
s.enity
.DispatchContext
;
/**
/**
* openapi分发器
* openapi分发器
*
*
* @author
key
* @author
zc
*/
*/
public
interface
OpenApiDispatcher
{
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;
...
@@ -6,7 +6,7 @@ import com.jz.dm.common.util.OpenApiResponse;
/**
/**
* openapi服务
* openapi服务
* @author
key
* @author
zc
*/
*/
public
interface
OpenApiService
{
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;
...
@@ -5,8 +5,8 @@ package com.jz.dm.gateway.impl;
import
com.jz.dm.filter.FilterChain
;
import
com.jz.dm.filter.FilterChain
;
import
com.jz.dm.filter.FilterChainFactory
;
import
com.jz.dm.filter.FilterChainFactory
;
import
com.jz.dm.gateway.GatewayService
;
import
com.jz.dm.gateway.GatewayService
;
import
com.jz.dm.model.GatewayRequest
;
import
com.jz.dm.model
s.enity
.GatewayRequest
;
import
com.jz.dm.model.GatewayResponse
;
import
com.jz.dm.model
s.enity
.GatewayResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -24,7 +24,6 @@ public class GatewayServiceImpl implements GatewayService {
...
@@ -24,7 +24,6 @@ public class GatewayServiceImpl implements GatewayService {
@Override
@Override
public
GatewayResponse
invoke
(
GatewayRequest
gatewayRequest
)
{
public
GatewayResponse
invoke
(
GatewayRequest
gatewayRequest
)
{
GatewayResponse
gatewayResponse
=
new
GatewayResponse
();
GatewayResponse
gatewayResponse
=
new
GatewayResponse
();
System
.
out
.
println
(
"经过了网关服务~~~~~~~~~~~~~~~~~~~~"
);
FilterChain
filterChain
=
filterChainFactory
.
getFilterChain
();
FilterChain
filterChain
=
filterChainFactory
.
getFilterChain
();
filterChain
.
doFilter
(
gatewayRequest
,
gatewayResponse
);
filterChain
.
doFilter
(
gatewayRequest
,
gatewayResponse
);
return
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
;