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
d7b311c3
Commit
d7b311c3
authored
Jan 04, 2021
by
ysongq
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dm_dev' of
http://gitlab.ioubuy.cn/yaobenzhang/dm_project
into dm_dev
parents
2eca6b14
ec3266f6
Changes
72
Show whitespace changes
Inline
Side-by-side
Showing
72 changed files
with
2042 additions
and
1607 deletions
+2042
-1607
.gitignore
.gitignore
+0
-1
api_gateway.sql
database/zc/api_gateway.sql
+24
-5
pom.xml
jz-dm-apigateway/pom.xml
+63
-0
BaseCurrentUserObject.java
...ain/java/com/jz/dm/common/base/BaseCurrentUserObject.java
+12
-13
LoggingConstants.java
...main/java/com/jz/dm/common/constant/LoggingConstants.java
+4
-0
GatewayResultCode.java
...c/main/java/com/jz/dm/common/enums/GatewayResultCode.java
+22
-5
SignType.java
...ateway/src/main/java/com/jz/dm/common/enums/SignType.java
+1
-1
ApiStatusEnum.java
...va/com/jz/dm/common/enums/apiInterface/ApiStatusEnum.java
+8
-0
AuthModeEnum.java
...c/main/java/com/jz/dm/common/enums/auth/AuthModeEnum.java
+9
-0
AuthTypeEnum.java
...c/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
+9
-0
DirectionTypeEnum.java
...a/com/jz/dm/common/enums/direction/DirectionTypeEnum.java
+26
-0
OrgStatusEnum.java
...c/main/java/com/jz/dm/common/enums/org/OrgStatusEnum.java
+36
-0
ProducerStatusTypeEnum.java
...om/jz/dm/common/enums/produce/ProducerStatusTypeEnum.java
+37
-0
SignatureException.java
...n/java/com/jz/dm/common/exception/SignatureException.java
+0
-51
DateUtil.java
...gateway/src/main/java/com/jz/dm/common/util/DateUtil.java
+33
-0
JSONWriter.java
...teway/src/main/java/com/jz/dm/common/util/JSONWriter.java
+0
-219
MapUtil.java
...igateway/src/main/java/com/jz/dm/common/util/MapUtil.java
+93
-0
RandomUtil.java
...teway/src/main/java/com/jz/dm/common/util/RandomUtil.java
+34
-5
StreamUtil.java
...teway/src/main/java/com/jz/dm/common/util/StreamUtil.java
+0
-125
WebUtils.java
...gateway/src/main/java/com/jz/dm/common/util/WebUtils.java
+0
-434
ApiDirectionController.java
...ain/java/com/jz/dm/controller/ApiDirectionController.java
+54
-0
ApiLogController.java
.../src/main/java/com/jz/dm/controller/ApiLogController.java
+1
-1
AuthController.java
...ay/src/main/java/com/jz/dm/controller/AuthController.java
+4
-4
OrganizationManageController.java
...va/com/jz/dm/controller/OrganizationManageController.java
+0
-3
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+9
-9
AuthFilter.java
...apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
+115
-3
CheckArgsFilter.java
...teway/src/main/java/com/jz/dm/filter/CheckArgsFilter.java
+11
-16
InvokeRouteFilter.java
...way/src/main/java/com/jz/dm/filter/InvokeRouteFilter.java
+12
-15
VerifySignFilter.java
...eway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
+44
-8
DefaultOpenApiDispatcher.java
...main/java/com/jz/dm/gateway/DefaultOpenApiDispatcher.java
+1
-1
ApiAuthMapper.java
...gateway/src/main/java/com/jz/dm/mapper/ApiAuthMapper.java
+1
-1
ApiDirectionMapper.java
...ay/src/main/java/com/jz/dm/mapper/ApiDirectionMapper.java
+13
-0
ApiDirection.java
...y/src/main/java/com/jz/dm/models/domian/ApiDirection.java
+102
-0
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+10
-0
ApiInterfaceFile.java
...c/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
+3
-3
ApiOrg.java
...gateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
+1
-1
ApiReqLog.java
...eway/src/main/java/com/jz/dm/models/domian/ApiReqLog.java
+64
-2
DispatchContext.java
...src/main/java/com/jz/dm/models/enity/DispatchContext.java
+5
-96
GatewayRequest.java
.../src/main/java/com/jz/dm/models/enity/GatewayRequest.java
+25
-237
AuthDmpUserApiReq.java
...ain/java/com/jz/dm/models/req/auth/AuthDmpUserApiReq.java
+5
-7
AuthUserApiReq.java
...c/main/java/com/jz/dm/models/req/auth/AuthUserApiReq.java
+9
-11
ApiInterfaceReq.java
.../main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
+15
-6
MakeCustomApiReq.java
...main/java/com/jz/dm/models/req/make/MakeCustomApiReq.java
+0
-63
MakeDataBankApiReq.java
...in/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
+15
-11
OrganizationManageAddReq.java
...dels/req/organizationManage/OrganizationManageAddReq.java
+3
-7
OrganizationManageUpdateReq.java
...s/req/organizationManage/OrganizationManageUpdateReq.java
+9
-2
ApiDirectionService.java
.../src/main/java/com/jz/dm/service/ApiDirectionService.java
+32
-0
ApiInterfaceService.java
.../src/main/java/com/jz/dm/service/ApiInterfaceService.java
+31
-0
AuthService.java
...igateway/src/main/java/com/jz/dm/service/AuthService.java
+10
-2
OrganizationManageService.java
...ain/java/com/jz/dm/service/OrganizationManageService.java
+7
-0
ProducerService.java
...eway/src/main/java/com/jz/dm/service/ProducerService.java
+1
-1
ApiDirectionServiceImpl.java
.../java/com/jz/dm/service/impl/ApiDirectionServiceImpl.java
+55
-0
ApiInterfaceServiceImpl.java
.../java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
+67
-0
ApiLogServiceImpl.java
...c/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
+2
-7
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+92
-69
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+42
-19
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+97
-84
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+75
-0
SystemLogAspect.java
...y/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
+5
-2
application-test.yml
jz-dm-apigateway/src/main/resources/application-test.yml
+4
-3
application.yml
jz-dm-apigateway/src/main/resources/application.yml
+4
-2
ApiAuthMapper.xml
jz-dm-apigateway/src/main/resources/mapper/ApiAuthMapper.xml
+10
-10
ApiDirectionlMapper.xml
...gateway/src/main/resources/mapper/ApiDirectionlMapper.xml
+6
-0
TestOrganizationManage.java
...st/java/com/jz/dm/gateway/org/TestOrganizationManage.java
+0
-1
TestHttpReq.java
...y/src/test/java/com/jz/dm/gateway/orther/TestHttpReq.java
+44
-0
TestMakeApi.java
...y/src/test/java/com/jz/dm/gateway/orther/TestMakeApi.java
+44
-0
TestRedisUserSave.java
...test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
+35
-0
HttpClientPool.java
...mon/src/main/java/com/jz/common/utils/HttpClientPool.java
+123
-0
HttpsUtils.java
...-common/src/main/java/com/jz/common/utils/HttpsUtils.java
+241
-0
RedisUtils.java
...-common/src/main/java/com/jz/common/utils/RedisUtils.java
+19
-0
UrlUtil.java
jz-dm-common/src/main/java/com/jz/common/utils/UrlUtil.java
+1
-1
pom.xml
pom.xml
+53
-40
No files found.
.gitignore
View file @
d7b311c3
*.iml
*.iml
*.jar
*.idea
*.idea
*.class
*.class
*.target
*.target
database/zc/api_gateway.sql
View file @
d7b311c3
...
@@ -9,6 +9,8 @@ CREATE TABLE `t_api_interface` (
...
@@ -9,6 +9,8 @@ CREATE TABLE `t_api_interface` (
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`test_example`
varchar
(
255
)
NULL
DEFAULT
NULL
COMMENT
'测试实例'
;
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`version`
varchar
(
20
)
DEFAULT
'1.0'
COMMENT
'版本号'
,
`version`
varchar
(
20
)
DEFAULT
'1.0'
COMMENT
'版本号'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
...
@@ -52,10 +54,10 @@ CREATE TABLE `t_api_interface_file` (
...
@@ -52,10 +54,10 @@ CREATE TABLE `t_api_interface_file` (
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api文件表自增ID'
,
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api文件表自增ID'
,
`project_id`
bigint
(
20
)
NOT
NULL
COMMENT
'项目编号'
,
`project_id`
bigint
(
20
)
NOT
NULL
COMMENT
'项目编号'
,
`file_source`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件来源:,1 dmp, 2 数据银行'
,
`file_source`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件来源:,1 dmp, 2 数据银行'
,
`file_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件类型
'
,
`file_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'文件类型:1 文件夹 ,2 文件
'
,
`file_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件名称'
,
`file_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件名称'
,
`file_en_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件英文名称'
,
`file_en_name`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'文件英文名称'
,
`parent_id`
bigint
(
20
)
NO
T
NULL
COMMENT
'父类id'
,
`parent_id`
bigint
(
20
)
DEFAUL
T
NULL
COMMENT
'父类id'
,
`status`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'VALID 有效,UNVALID 无效'
,
`status`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'VALID 有效,UNVALID 无效'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
...
@@ -76,7 +78,7 @@ CREATE TABLE `t_api_org` (
...
@@ -76,7 +78,7 @@ CREATE TABLE `t_api_org` (
`org_cn_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织英文名称'
,
`org_cn_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织英文名称'
,
`org_phone`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织电话'
,
`org_phone`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织电话'
,
`org_type`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织类型:OUT 外部组织, IN 内部组织'
,
`org_type`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织类型:OUT 外部组织, IN 内部组织'
,
`status`
varchar
(
100
)
NOT
NULL
COMMENT
'状态(1-正常 2-冻结 3-下架
)'
,
`status`
varchar
(
100
)
NOT
NULL
COMMENT
'状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销
)'
,
`org_mail`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织邮箱'
,
`org_mail`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织邮箱'
,
`org_sort`
int
(
10
)
DEFAULT
'999'
COMMENT
'组织排序'
,
`org_sort`
int
(
10
)
DEFAULT
'999'
COMMENT
'组织排序'
,
`parent_id`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'父类组织编码'
,
`parent_id`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'父类组织编码'
,
...
@@ -103,7 +105,7 @@ CREATE TABLE `t_api_auth` (
...
@@ -103,7 +105,7 @@ CREATE TABLE `t_api_auth` (
`auth_mode`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效'
,
`auth_mode`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效'
,
`valid_start_time`
datetime
DEFAULT
NULL
COMMENT
'开始时间'
,
`valid_start_time`
datetime
DEFAULT
NULL
COMMENT
'开始时间'
,
`valid_end_time`
datetime
DEFAULT
NULL
COMMENT
'结束时间'
,
`valid_end_time`
datetime
DEFAULT
NULL
COMMENT
'结束时间'
,
`status`
varchar
(
100
)
NOT
NULL
COMMENT
'状态(1-正常 2-作废
)'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(VALID-正常 UN_VALID-无效
)'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
...
@@ -245,3 +247,20 @@ CREATE TABLE `t_api_syncing_datasource_type` (
...
@@ -245,3 +247,20 @@ CREATE TABLE `t_api_syncing_datasource_type` (
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api数据源类型信息表'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api数据源类型信息表'
;
#
字典表
DROP
TABLE
IF
EXISTS
`t_api_direction`
;
CREATE
TABLE
`t_api_direction`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'自增ID'
,
`key`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'字典key'
,
`value`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'字典value'
,
`code`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'字典编码'
,
`parent`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'父节点'
,
`direction_type`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'字典类型'
,
`level`
int
(
10
)
DEFAULT
NULL
COMMENT
'等级'
,
`is_enabled`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'是否启用:UNABLE 停用,ENABLE 启用'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_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 @
d7b311c3
...
@@ -109,4 +109,67 @@
...
@@ -109,4 +109,67 @@
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<finalName>
${project.artifactId}
</finalName>
<resources>
<resource>
<directory>
src/main/resources
</directory>
<filtering>
true
</filtering>
<excludes>
<exclude>
static/**
</exclude>
<exclude>
xls/**
</exclude>
<exclude>
conf/**
</exclude>
<exclude>
emails/**
</exclude>
</excludes>
</resource>
<resource>
<directory>
src/main/resources
</directory>
<filtering>
false
</filtering>
<includes>
<include>
static/**
</include>
<include>
xls/**
</include>
<include>
conf/**
</include>
<include>
emails/**
</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<dependencies>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
springloaded
</artifactId>
<version>
1.2.8.RELEASE
</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>
true
</includeSystemScope>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-resources-plugin
</artifactId>
<configuration>
<encoding>
UTF-8
</encoding>
<!-- 过滤后缀为pem、pfx的证书文件 -->
<nonFilteredFileExtensions>
<nonFilteredFileExtension>
p12
</nonFilteredFileExtension>
<nonFilteredFileExtension>
pem
</nonFilteredFileExtension>
<nonFilteredFileExtension>
pfx
</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>
\ No newline at end of file
jz-dm-apigateway/src/main/java/com/jz/dm/common/base/BaseCurrentUserObject.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
common
.
base
;
package
com
.
jz
.
dm
.
common
.
base
;
import
com.jz.common.bean.SysUserDto
;
import
com.jz.common.bean.SysUserDto
;
import
com.jz.common.constant.RedisMessageConstant
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
/**
/**
* @author ZC
* @author ZC
...
@@ -13,28 +14,26 @@ import org.springframework.data.redis.core.RedisTemplate;
...
@@ -13,28 +14,26 @@ import org.springframework.data.redis.core.RedisTemplate;
* @DAY_NAME_SHORT: 周三
* @DAY_NAME_SHORT: 周三
* @Description: 获取当前登录用户
* @Description: 获取当前登录用户
**/
**/
@Component
public
class
BaseCurrentUserObject
{
public
class
BaseCurrentUserObject
{
private
static
RedisTemplate
<
String
,
Object
>
REDIS
=
new
RedisTemplate
();
@Autowired
private
volatile
static
SysUserDto
sysUserDto
;
private
RedisTemplate
redisTemplate
;
private
BaseCurrentUserObject
()
{
}
/**
/**
* 获取登录用户
* 获取登录用户
*
*
* @return
* @return
*/
*/
public
static
SysUserDto
getUserInfo
()
{
public
SysUserDto
getUserInfo
()
{
if
(
sysUserDto
==
null
)
{
SysUserDto
sysUserDto
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"USER"
+
"004"
);
//RedisMessageConstant.SENDTYPE_LOGIN_SYS);
synchronized
(
SysUserDto
.
class
)
{
if
(
sysUserDto
==
null
)
{
sysUserDto
=
(
SysUserDto
)
REDIS
.
opsForValue
().
get
(
"USER"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
}
}
}
return
sysUserDto
;
return
sysUserDto
;
}
}
//SysUserDto currentUser = (SysUserDto)
// redisTemplate.opsForValue().get("user" + RedisMessageConstant.SENDTYPE_LOGIN_SYS);
/*public static void main(String[] args) {
System.out.println(new BaseCurrentUserObject().getUserInfo());
}*/
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/constant/LoggingConstants.java
View file @
d7b311c3
...
@@ -44,4 +44,8 @@ public class LoggingConstants {
...
@@ -44,4 +44,8 @@ public class LoggingConstants {
/** "@" 符号*/
/** "@" 符号*/
public
static
final
String
MONKEYS_AT
=
"@"
;
public
static
final
String
MONKEYS_AT
=
"@"
;
/** "&" 符号*/
public
static
final
String
AND_SPILT
=
"&"
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/GatewayResultCode.java
View file @
d7b311c3
...
@@ -27,7 +27,8 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -27,7 +27,8 @@ public enum GatewayResultCode implements ResultCode {
/** 无效参数 */
/** 无效参数 */
ILLEGAL_ARGUMENT
(
"ILLEGAL_ARGUMENT"
,
"无效参数"
),
ILLEGAL_ARGUMENT
(
"ILLEGAL_ARGUMENT"
,
"无效参数"
),
/** 参数列表为空 */
REQUEST_PARAM_EMPTY
(
"REQUEST_PARAM_EMPTY"
,
"请求参数为空"
),
/** 无效请求 */
/** 无效请求 */
ILLEGAL_REQUEST
(
"ILLEGAL_REQUEST"
,
"无效请求"
),
ILLEGAL_REQUEST
(
"ILLEGAL_REQUEST"
,
"无效请求"
),
...
@@ -35,8 +36,11 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -35,8 +36,11 @@ public enum GatewayResultCode implements ResultCode {
/** 无效请求 */
/** 无效请求 */
ILLEGAL_TIMETEMP
(
"ILLEGAL_TIMETEMP"
,
"无效时间戳"
),
ILLEGAL_TIMETEMP
(
"ILLEGAL_TIMETEMP"
,
"无效时间戳"
),
/** 接口未授权 */
//INTERFACE_NO_AUTHORITY("INTERFACE_NO_AUTHORITY", "接口未授权"),
/** 请求次数受限 */
REQUEST_LIMIT_EXCEPTION
(
"REQUEST_LIMIT_EXCEPTION"
,
"请求次数受限"
),
/** 请求超过限制 */
/** 请求超过限制 */
RATE_LIMIT_EXCEEDED
(
"RATE_LIMIT_EXCEEDED"
,
"请求超过限制"
),
RATE_LIMIT_EXCEEDED
(
"RATE_LIMIT_EXCEEDED"
,
"请求超过限制"
),
...
@@ -47,9 +51,22 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -47,9 +51,22 @@ public enum GatewayResultCode implements ResultCode {
/** ip不允许访问 */
/** ip不允许访问 */
IP_NOT_ALLOW_ACCESS
(
"IP_NOT_ALLOW_ACCESS"
,
"ip不允许访问"
),
IP_NOT_ALLOW_ACCESS
(
"IP_NOT_ALLOW_ACCESS"
,
"ip不允许访问"
),
/** 提交数据过大 */
/** 提交数据过大 */
POST_DATA_TOO_LARGE
(
"POST_DATA_TOO_LARGE"
,
"提交数据过大"
);
POST_DATA_TOO_LARGE
(
"POST_DATA_TOO_LARGE"
,
"提交数据过大"
),
/** 签名错误 */
SIGN_ERROR
(
"SIGN_EMPTY"
,
"签名错误"
),
/** 请求未授权 */
REQUEST_NOT_AUTH
(
"REQUEST_NOT_AUTH"
,
"请求未授权"
),
/** 请求组织不存在 */
ORG_NOT_EXIST
(
"ORG_NOT_EXIST"
,
"请求组织不存在"
),
/** API状态异常 */
API_STATUS_EXCEPTION
(
"API_STATUS_EXCEPTION"
,
"API状态异常"
),
/** 请求组织状态异常 */
ORG_STATE_EXCEPTION
(
"ORG_STATE_EXCEPTION"
,
"请求组织状态异常"
);
/**
/**
* 初始化保存到map里方便根据code获取
* 初始化保存到map里方便根据code获取
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/
util
/SignType.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/common/
enums
/SignType.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
common
.
util
;
package
com
.
jz
.
dm
.
common
.
enums
;
/**
/**
* 签名类型
* 签名类型
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/apiInterface/ApiStatusEnum.java
View file @
d7b311c3
...
@@ -42,4 +42,12 @@ public enum ApiStatusEnum {
...
@@ -42,4 +42,12 @@ public enum ApiStatusEnum {
return
text
;
return
text
;
}
}
public
static
ApiStatusEnum
fromApiStatusName
(
String
typeName
)
{
for
(
ApiStatusEnum
type
:
ApiStatusEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthModeEnum.java
View file @
d7b311c3
...
@@ -34,4 +34,13 @@ public enum AuthModeEnum {
...
@@ -34,4 +34,13 @@ public enum AuthModeEnum {
public
String
getText
()
{
public
String
getText
()
{
return
text
;
return
text
;
}
}
public
static
AuthModeEnum
fromTypeModeName
(
String
typeName
)
{
for
(
AuthModeEnum
type
:
AuthModeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
View file @
d7b311c3
...
@@ -29,4 +29,13 @@ public enum AuthTypeEnum {
...
@@ -29,4 +29,13 @@ public enum AuthTypeEnum {
public
String
getText
()
{
public
String
getText
()
{
return
text
;
return
text
;
}
}
public
static
AuthTypeEnum
fromTypeName
(
String
typeName
)
{
for
(
AuthTypeEnum
type
:
AuthTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/direction/DirectionTypeEnum.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
common
.
enums
.
direction
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums
* @PROJECT_NAME: jz-dm-parent
* @NAME: DirectionTypeEnum
* @DATE: 2020-12-31/18:39
* @DAY_NAME_SHORT: 周四
* @Description:
**/
public
enum
DirectionTypeEnum
{
/**
* API类型
*/
API_TYPE
;
public
static
DirectionTypeEnum
fromTypeName
(
String
typeName
)
{
for
(
DirectionTypeEnum
type
:
DirectionTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/org/OrgStatusEnum.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
common
.
enums
.
org
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums.org
* @PROJECT_NAME: jz-dm-parent
* @NAME: OrgStatusEnum
* @DATE: 2021-1-1/11:17
* @DAY_NAME_SHORT: 周五
* @Description:
**/
public
enum
OrgStatusEnum
{
NORMAL
(
"正常"
),
FREEZE
(
"冻结"
),
CANCEL
(
"注销"
);
private
String
text
;
OrgStatusEnum
(
String
text
)
{
this
.
text
=
text
;
}
public
String
getText
()
{
return
text
;
}
public
static
OrgStatusEnum
fromTypeName
(
String
typeName
)
{
for
(
OrgStatusEnum
type
:
OrgStatusEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/produce/ProducerStatusTypeEnum.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
common
.
enums
.
produce
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums.produce
* @PROJECT_NAME: jz-dm-parent
* @NAME: ProducerStatusTypeEnum
* @DATE: 2021-1-1/18:04
* @DAY_NAME_SHORT: 周五
* @Description:
**/
public
enum
ProducerStatusTypeEnum
{
DRAFT
(
"草稿"
),
ISSUE
(
"发布"
),
OUTMODED
(
"过时"
),
FREEZE
(
"冻结"
),
EXPIRY
(
"失效"
);
private
String
text
;
ProducerStatusTypeEnum
(
String
text
)
{
this
.
text
=
text
;
}
public
String
getText
()
{
return
text
;
}
public
static
ProducerStatusTypeEnum
fromTypeName
(
String
typeName
)
{
for
(
ProducerStatusTypeEnum
type
:
ProducerStatusTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/exception/SignatureException.java
deleted
100644 → 0
View file @
2eca6b14
package
com
.
jz
.
dm
.
common
.
exception
;
import
com.jz.dm.common.util.ResultCode
;
/**
* 签名异常
*
*/
public
class
SignatureException
extends
OpenApiException
{
private
static
final
long
serialVersionUID
=
6551962245794846748L
;
/**
* 构造函数
*
* @param resultCode
*/
public
SignatureException
(
ResultCode
resultCode
)
{
super
(
resultCode
);
}
/**
* 构造函数
* @param resultCode
* @param detailMessage
*/
public
SignatureException
(
ResultCode
resultCode
,
String
detailMessage
)
{
super
(
resultCode
,
detailMessage
);
}
/**
* 构造函数
* @param resultCode
* @param cause
*/
public
SignatureException
(
ResultCode
resultCode
,
Throwable
cause
)
{
super
(
resultCode
,
cause
);
}
/**
* 构造函数
* @param resultCode
* @param detailMessage
* @param cause
*/
public
SignatureException
(
ResultCode
resultCode
,
String
detailMessage
,
Throwable
cause
)
{
super
(
resultCode
,
detailMessage
,
cause
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/DateUtil.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
common
.
util
;
import
java.util.Calendar
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.util
* @PROJECT_NAME: jz-dm-parent
* @NAME: DateUtil
* @DATE: 2021-1-2/21:55
* @DAY_NAME_SHORT: 周六
* @Description: 时间工具类处理时间
**/
public
class
DateUtil
{
/**
* 计算当前距离23:59:59剩余时间
* @return
*/
public
static
long
calculateNowResidueTime
(){
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
(
cal
.
getTimeInMillis
()
-
System
.
currentTimeMillis
())
/
1000
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
calculateNowResidueTime
());
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/JSONWriter.java
deleted
100644 → 0
View file @
2eca6b14
package
com
.
jz
.
dm
.
common
.
util
;
import
java.beans.BeanInfo
;
import
java.beans.IntrospectionException
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.text.CharacterIterator
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.text.StringCharacterIterator
;
import
java.util.*
;
public
class
JSONWriter
{
/**
* 默认时间格式
**/
public
static
final
String
DATE_TIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* Date默认时区
**/
public
static
final
String
DATE_TIMEZONE
=
"GMT+8"
;
private
StringBuffer
buf
=
new
StringBuffer
();
private
Stack
<
Object
>
calls
=
new
Stack
<
Object
>();
private
boolean
emitClassName
=
true
;
private
DateFormat
format
;
public
JSONWriter
(
boolean
emitClassName
)
{
this
.
emitClassName
=
emitClassName
;
}
public
JSONWriter
()
{
this
(
false
);
}
public
JSONWriter
(
DateFormat
format
)
{
this
(
false
);
this
.
format
=
format
;
}
public
String
write
(
Object
object
)
{
buf
.
setLength
(
0
);
value
(
object
);
return
buf
.
toString
();
}
public
String
write
(
long
n
)
{
return
String
.
valueOf
(
n
);
}
public
String
write
(
double
d
)
{
return
String
.
valueOf
(
d
);
}
public
String
write
(
char
c
)
{
return
"\""
+
c
+
"\""
;
}
public
String
write
(
boolean
b
)
{
return
String
.
valueOf
(
b
);
}
private
void
value
(
Object
object
)
{
if
(
object
==
null
||
cyclic
(
object
))
{
add
(
null
);
}
else
{
calls
.
push
(
object
);
if
(
object
instanceof
Class
<?>)
string
(
object
);
else
if
(
object
instanceof
Boolean
)
bool
(((
Boolean
)
object
).
booleanValue
());
else
if
(
object
instanceof
Number
)
add
(
object
);
else
if
(
object
instanceof
String
)
string
(
object
);
else
if
(
object
instanceof
Character
)
string
(
object
);
else
if
(
object
instanceof
Map
<?,
?>)
map
((
Map
<?,
?>)
object
);
else
if
(
object
.
getClass
().
isArray
())
array
(
object
);
else
if
(
object
instanceof
Iterator
<?>)
array
((
Iterator
<?>)
object
);
else
if
(
object
instanceof
Collection
<?>)
array
(((
Collection
<?>)
object
).
iterator
());
else
if
(
object
instanceof
Date
)
date
((
Date
)
object
);
else
bean
(
object
);
calls
.
pop
();
}
}
private
boolean
cyclic
(
Object
object
)
{
Iterator
<
Object
>
it
=
calls
.
iterator
();
while
(
it
.
hasNext
())
{
Object
called
=
it
.
next
();
if
(
object
==
called
)
return
true
;
}
return
false
;
}
private
void
bean
(
Object
object
)
{
add
(
"{"
);
BeanInfo
info
;
boolean
addedSomething
=
false
;
try
{
info
=
Introspector
.
getBeanInfo
(
object
.
getClass
());
PropertyDescriptor
[]
props
=
info
.
getPropertyDescriptors
();
for
(
int
i
=
0
;
i
<
props
.
length
;
++
i
)
{
PropertyDescriptor
prop
=
props
[
i
];
String
name
=
prop
.
getName
();
Method
accessor
=
prop
.
getReadMethod
();
if
((
emitClassName
||
!
"class"
.
equals
(
name
))
&&
accessor
!=
null
)
{
if
(!
accessor
.
isAccessible
())
accessor
.
setAccessible
(
true
);
Object
value
=
accessor
.
invoke
(
object
,
(
Object
[])
null
);
if
(
value
==
null
)
continue
;
if
(
addedSomething
)
add
(
','
);
add
(
name
,
value
);
addedSomething
=
true
;
}
}
}
catch
(
IllegalAccessException
iae
)
{
}
catch
(
InvocationTargetException
ite
)
{
}
catch
(
IntrospectionException
ie
)
{
}
add
(
"}"
);
}
private
void
add
(
String
name
,
Object
value
)
{
add
(
'"'
);
add
(
name
);
add
(
"\":"
);
value
(
value
);
}
private
void
map
(
Map
<?,
?>
map
)
{
add
(
"{"
);
Iterator
<?>
it
=
map
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
<?,
?>
e
=
(
Map
.
Entry
<?,
?>)
it
.
next
();
value
(
e
.
getKey
());
add
(
":"
);
value
(
e
.
getValue
());
if
(
it
.
hasNext
())
add
(
','
);
}
add
(
"}"
);
}
private
void
array
(
Iterator
<?>
it
)
{
add
(
"["
);
while
(
it
.
hasNext
())
{
value
(
it
.
next
());
if
(
it
.
hasNext
())
add
(
","
);
}
add
(
"]"
);
}
private
void
array
(
Object
object
)
{
add
(
"["
);
int
length
=
Array
.
getLength
(
object
);
for
(
int
i
=
0
;
i
<
length
;
++
i
)
{
value
(
Array
.
get
(
object
,
i
));
if
(
i
<
length
-
1
)
add
(
','
);
}
add
(
"]"
);
}
private
void
bool
(
boolean
b
)
{
add
(
b
?
"true"
:
"false"
);
}
private
void
date
(
Date
date
)
{
if
(
this
.
format
==
null
)
{
this
.
format
=
new
SimpleDateFormat
(
DATE_TIME_FORMAT
);
this
.
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
DATE_TIMEZONE
));
}
add
(
"\""
);
add
(
format
.
format
(
date
));
add
(
"\""
);
}
private
void
string
(
Object
obj
)
{
add
(
'"'
);
CharacterIterator
it
=
new
StringCharacterIterator
(
obj
.
toString
());
for
(
char
c
=
it
.
first
();
c
!=
CharacterIterator
.
DONE
;
c
=
it
.
next
())
{
if
(
c
==
'"'
)
add
(
"\\\""
);
else
if
(
c
==
'\\'
)
add
(
"\\\\"
);
else
if
(
c
==
'/'
)
add
(
"\\/"
);
else
if
(
c
==
'\b'
)
add
(
"\\b"
);
else
if
(
c
==
'\f'
)
add
(
"\\f"
);
else
if
(
c
==
'\n'
)
add
(
"\\n"
);
else
if
(
c
==
'\r'
)
add
(
"\\r"
);
else
if
(
c
==
'\t'
)
add
(
"\\t"
);
else
if
(
Character
.
isISOControl
(
c
))
{
unicode
(
c
);
}
else
{
add
(
c
);
}
}
add
(
'"'
);
}
private
void
add
(
Object
obj
)
{
buf
.
append
(
obj
);
}
private
void
add
(
char
c
)
{
buf
.
append
(
c
);
}
static
char
[]
hex
=
"0123456789ABCDEF"
.
toCharArray
();
private
void
unicode
(
char
c
)
{
add
(
"\\u"
);
int
n
=
c
;
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
int
digit
=
(
n
&
0xf000
)
>>
12
;
add
(
hex
[
digit
]);
n
<<=
4
;
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/MapUtil.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
common
.
util
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.commons.lang3.StringUtils
;
import
java.lang.reflect.Field
;
import
java.util.*
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.util
* @PROJECT_NAME: jz-dm-parent
* @NAME: MapUtil
* @DATE: 2021-1-2/14:02
* @DAY_NAME_SHORT: 周六
* @Description:
**/
public
class
MapUtil
{
/**
* 对参数进行字典排序
* @param map
* @return
*/
public
static
List
directSort
(
Map
map
){
List
list
=
new
ArrayList
();
Iterator
iter
=
map
.
entrySet
().
iterator
();
//获得map的Iterator
while
(
iter
.
hasNext
())
{
Map
.
Entry
entry
=
(
Map
.
Entry
)
iter
.
next
();
list
.
add
(
entry
.
getKey
());
}
Collections
.
sort
(
list
);
return
list
;
}
/**
* 将对象转成TreeMap,属性名为key,属性值为value
* @param object 对象
* @return
* @throws IllegalAccessException
*/
public
static
TreeMap
<
String
,
Object
>
objToMap
(
Object
object
)
throws
IllegalAccessException
{
Class
clazz
=
object
.
getClass
();
TreeMap
<
String
,
Object
>
treeMap
=
new
TreeMap
<
String
,
Object
>();
while
(
null
!=
clazz
.
getSuperclass
()
)
{
Field
[]
declaredFields1
=
clazz
.
getDeclaredFields
();
for
(
Field
field
:
declaredFields1
)
{
String
name
=
field
.
getName
();
// 获取原来的访问控制权限
boolean
accessFlag
=
field
.
isAccessible
();
// 修改访问控制权限
field
.
setAccessible
(
true
);
Object
value
=
field
.
get
(
object
);
// 恢复访问控制权限
field
.
setAccessible
(
accessFlag
);
if
(
null
!=
value
&&
StringUtils
.
isNotBlank
(
value
.
toString
()))
{
//如果是List,将List转换为json字符串
if
(
value
instanceof
List
)
{
value
=
JSON
.
toJSONString
(
value
);
}
treeMap
.
put
(
name
,
value
);
}
}
clazz
=
clazz
.
getSuperclass
();
}
return
treeMap
;
}
/**
* 按照指定的分割符将list转换为String
* @param list
* @param separator
* @return
*/
public
static
String
listToString
(
List
list
,
String
separator
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
if
(
i
==
list
.
size
()
-
1
)
{
sb
.
append
(
list
.
get
(
i
));
}
else
{
sb
.
append
(
list
.
get
(
i
));
sb
.
append
(
separator
);
}
}
return
sb
.
toString
();
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/RandomUtil.java
View file @
d7b311c3
...
@@ -65,11 +65,11 @@ public class RandomUtil {
...
@@ -65,11 +65,11 @@ public class RandomUtil {
log
.
info
(
"----------生成组织编码内容或类型不存在--------------"
);
log
.
info
(
"----------生成组织编码内容或类型不存在--------------"
);
return
""
;
return
""
;
}
}
boolean
chineseWord
=
isChineseWord
(
content
);
/*
boolean chineseWord = isChineseWord(content);
if (!chineseWord) {
if (!chineseWord) {
log.info("----------编码中不能出现英文或者字母--------------");
log.info("----------编码中不能出现英文或者字母--------------");
return "";
return "";
}
}
*/
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
();
if
(
Constants
.
AUTH_INT
.
equalsIgnoreCase
(
type
))
{
if
(
Constants
.
AUTH_INT
.
equalsIgnoreCase
(
type
))
{
builder
.
append
(
"NEI"
);
builder
.
append
(
"NEI"
);
...
@@ -126,12 +126,12 @@ public class RandomUtil {
...
@@ -126,12 +126,12 @@ public class RandomUtil {
}
}
coding
=
getCodeInfo
(
userId
,
coding
,
builder
,
month
,
day
,
hour
,
minute
,
second
);
coding
=
getCodeInfo
(
userId
,
coding
,
builder
,
month
,
day
,
hour
,
minute
,
second
);
}
}
return
coding
;
return
coding
;
}
}
/**
/**
* 拼接内部/外部授权码
* 拼接内部/外部授权码
*
* @param orgCode
* @param orgCode
* @param coding
* @param coding
* @param builder
* @param builder
...
@@ -262,6 +262,34 @@ public class RandomUtil {
...
@@ -262,6 +262,34 @@ public class RandomUtil {
return
str
;
return
str
;
}
}
/**
* 生成指定版本号
* @param version 旧版本号
* @return
*/
public
static
String
generateVersion
(
String
version
)
{
StringBuilder
builder
=
new
StringBuilder
();
if
(
StringUtils
.
isNotBlank
(
version
))
{
String
[]
split
=
version
.
substring
(
1
).
split
(
"\\."
);
Integer
one
=
Integer
.
parseInt
(
split
[
0
]);
Integer
two
=
Integer
.
parseInt
(
split
[
1
]);
if
(
two
+
1
==
100
)
{
one
=
one
+
1
;
two
=
0
;
}
else
if
(
two
<
100
)
{
two
=
two
+
1
;
}
builder
.
append
(
"v"
);
builder
.
append
(
one
.
toString
());
builder
.
append
(
"."
);
builder
.
append
(
two
.
toString
());
}
else
{
return
""
;
}
return
builder
.
toString
();
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
//System.out.println(getStringRandom(8));
//System.out.println(getStringRandom(8));
// System.out.println("获取拼音首字母:"+getAllFirstLetter("大中国南昌中大china"));
// System.out.println("获取拼音首字母:"+getAllFirstLetter("大中国南昌中大china"));
...
@@ -269,7 +297,8 @@ public class RandomUtil {
...
@@ -269,7 +297,8 @@ public class RandomUtil {
//System.out.println(generateOrgCoding("九章数据","INT"));
//System.out.println(generateOrgCoding("九章数据","INT"));
// System.out.println(generateTokenCode("", ""));
// System.out.println(generateTokenCode("", ""));
//System.out.println(addZeroForNum("1", 8));
//System.out.println(addZeroForNum("1", 8));
System
.
out
.
println
(
"内部授权码:"
+
generateTokenCode
(
"INT"
,
"NEIJZSJ900hx"
,
""
));
//内部授权码
//System.out.println("内部授权码:" + generateTokenCode("INT", "NEIJZSJ900hx", ""));//内部授权码
System
.
out
.
println
(
"外部授权码:"
+
generateTokenCode
(
"OUT"
,
""
,
"199"
));
//内部授权码
//System.out.println("外部授权码:" + generateTokenCode("OUT", "", "199"));//内部授权码
System
.
out
.
println
(
generateVersion
(
"v1.99"
));
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/StreamUtil.java
deleted
100644 → 0
View file @
2eca6b14
package
com
.
jz
.
dm
.
common
.
util
;
import
java.io.*
;
/**
* 流处理工具
*
*/
public
class
StreamUtil
{
private
static
final
int
DEFAULT_BUFFER_SIZE
=
8192
;
public
static
void
io
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
io
(
in
,
out
,
-
1
);
}
public
static
void
io
(
InputStream
in
,
OutputStream
out
,
int
bufferSize
)
throws
IOException
{
if
(
bufferSize
==
-
1
)
{
bufferSize
=
DEFAULT_BUFFER_SIZE
;
}
byte
[]
buffer
=
new
byte
[
bufferSize
];
int
amount
;
while
((
amount
=
in
.
read
(
buffer
))
>=
0
)
{
out
.
write
(
buffer
,
0
,
amount
);
}
}
public
static
void
io
(
Reader
in
,
Writer
out
)
throws
IOException
{
io
(
in
,
out
,
-
1
);
}
public
static
void
io
(
Reader
in
,
Writer
out
,
int
bufferSize
)
throws
IOException
{
if
(
bufferSize
==
-
1
)
{
bufferSize
=
DEFAULT_BUFFER_SIZE
>>
1
;
}
char
[]
buffer
=
new
char
[
bufferSize
];
int
amount
;
while
((
amount
=
in
.
read
(
buffer
))
>=
0
)
{
out
.
write
(
buffer
,
0
,
amount
);
}
}
public
static
OutputStream
synchronizedOutputStream
(
OutputStream
out
)
{
return
new
SynchronizedOutputStream
(
out
);
}
public
static
OutputStream
synchronizedOutputStream
(
OutputStream
out
,
Object
lock
)
{
return
new
SynchronizedOutputStream
(
out
,
lock
);
}
public
static
String
readText
(
InputStream
in
)
throws
IOException
{
return
readText
(
in
,
null
,
-
1
);
}
public
static
String
readText
(
InputStream
in
,
String
encoding
)
throws
IOException
{
return
readText
(
in
,
encoding
,
-
1
);
}
public
static
String
readText
(
InputStream
in
,
String
encoding
,
int
bufferSize
)
throws
IOException
{
Reader
reader
=
(
encoding
==
null
)
?
new
InputStreamReader
(
in
)
:
new
InputStreamReader
(
in
,
encoding
);
return
readText
(
reader
,
bufferSize
);
}
public
static
String
readText
(
Reader
reader
)
throws
IOException
{
return
readText
(
reader
,
-
1
);
}
public
static
String
readText
(
Reader
reader
,
int
bufferSize
)
throws
IOException
{
StringWriter
writer
=
new
StringWriter
();
io
(
reader
,
writer
,
bufferSize
);
return
writer
.
toString
();
}
private
static
class
SynchronizedOutputStream
extends
OutputStream
{
private
OutputStream
out
;
private
Object
lock
;
SynchronizedOutputStream
(
OutputStream
out
)
{
this
(
out
,
out
);
}
SynchronizedOutputStream
(
OutputStream
out
,
Object
lock
)
{
this
.
out
=
out
;
this
.
lock
=
lock
;
}
public
void
write
(
int
datum
)
throws
IOException
{
synchronized
(
lock
)
{
out
.
write
(
datum
);
}
}
public
void
write
(
byte
[]
data
)
throws
IOException
{
synchronized
(
lock
)
{
out
.
write
(
data
);
}
}
public
void
write
(
byte
[]
data
,
int
offset
,
int
length
)
throws
IOException
{
synchronized
(
lock
)
{
out
.
write
(
data
,
offset
,
length
);
}
}
public
void
flush
()
throws
IOException
{
synchronized
(
lock
)
{
out
.
flush
();
}
}
public
void
close
()
throws
IOException
{
synchronized
(
lock
)
{
out
.
close
();
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/WebUtils.java
deleted
100644 → 0
View file @
2eca6b14
package
com
.
jz
.
dm
.
common
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.*
;
import
org.apache.http.client.HttpRequestRetryHandler
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.protocol.HttpClientContext
;
import
org.apache.http.config.Registry
;
import
org.apache.http.config.RegistryBuilder
;
import
org.apache.http.conn.ConnectTimeoutException
;
import
org.apache.http.conn.routing.HttpRoute
;
import
org.apache.http.conn.socket.ConnectionSocketFactory
;
import
org.apache.http.conn.socket.LayeredConnectionSocketFactory
;
import
org.apache.http.conn.socket.PlainConnectionSocketFactory
;
import
org.apache.http.conn.ssl.SSLConnectionSocketFactory
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.protocol.HttpContext
;
import
org.apache.http.util.EntityUtils
;
import
javax.net.ssl.SSLException
;
import
javax.net.ssl.SSLHandshakeException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InterruptedIOException
;
import
java.net.UnknownHostException
;
import
java.nio.charset.Charset
;
import
java.util.*
;
import
java.util.Map.Entry
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
@Slf4j
public
final
class
WebUtils
{
private
static
final
int
CONNECT_TIMEOUT
=
Config
.
getHttpConnectTimeout
();
// 设置连接建立的超时时间为10s
private
static
final
int
SOCKET_TIMEOUT
=
Config
.
getHttpSocketTimeout
();
private
static
final
int
MAX_CONN
=
Config
.
getHttpMaxPoolSize
();
// 最大连接数
private
static
final
int
MAX_PRE_ROUTE
=
Config
.
getHttpMaxPoolSize
();
private
static
final
int
MAX_ROUTE
=
Config
.
getHttpMaxPoolSize
();
private
static
CloseableHttpClient
httpClient
;
// 发送请求的客户端单例
private
static
PoolingHttpClientConnectionManager
manager
;
// 连接池管理类
private
static
ScheduledExecutorService
monitorExecutor
;
private
final
static
Object
syncLock
=
new
Object
();
// 相当于线程锁,用于线程安全
/**
* http 请求
*
* @param url
* @param params
* @return
* @throws Exception
*/
public
static
String
post
(
String
url
,
Map
<
String
,
String
>
params
)
throws
Exception
{
CloseableHttpClient
client
=
getHttpClient
(
url
);
String
responseText
=
""
;
CloseableHttpResponse
response
=
null
;
try
{
HttpPost
method
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectionRequestTimeout
(
CONNECT_TIMEOUT
)
.
setConnectTimeout
(
CONNECT_TIMEOUT
).
setSocketTimeout
(
SOCKET_TIMEOUT
).
build
();
method
.
setConfig
(
requestConfig
);
if
(
params
!=
null
)
{
List
<
NameValuePair
>
paramList
=
new
ArrayList
<
NameValuePair
>();
for
(
Entry
<
String
,
String
>
param
:
params
.
entrySet
())
{
NameValuePair
pair
=
new
BasicNameValuePair
(
param
.
getKey
(),
param
.
getValue
());
paramList
.
add
(
pair
);
}
method
.
setEntity
(
new
UrlEncodedFormEntity
(
paramList
,
"UTF-8"
));
}
response
=
client
.
execute
(
method
,
HttpClientContext
.
create
());
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
responseText
=
EntityUtils
.
toString
(
entity
);
}
}
catch
(
Exception
e
)
{
throw
e
;
}
finally
{
try
{
if
(
null
!=
response
)
{
response
.
close
();
}
}
catch
(
Exception
e
)
{
throw
e
;
}
}
return
responseText
;
}
public
static
String
post
(
String
url
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
params
)
throws
Exception
{
CloseableHttpClient
client
=
getHttpClient
(
url
);
String
responseText
=
""
;
CloseableHttpResponse
response
=
null
;
try
{
HttpPost
method
=
new
HttpPost
(
url
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectionRequestTimeout
(
CONNECT_TIMEOUT
)
.
setConnectTimeout
(
CONNECT_TIMEOUT
).
setSocketTimeout
(
SOCKET_TIMEOUT
).
build
();
method
.
setConfig
(
requestConfig
);
if
(
null
!=
headers
&&
!
headers
.
isEmpty
())
{
for
(
Entry
<
String
,
String
>
entry
:
headers
.
entrySet
())
{
method
.
setHeader
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
if
(
params
!=
null
)
{
List
<
NameValuePair
>
paramList
=
new
ArrayList
<
NameValuePair
>();
for
(
Entry
<
String
,
String
>
param
:
params
.
entrySet
())
{
NameValuePair
pair
=
new
BasicNameValuePair
(
param
.
getKey
(),
param
.
getValue
());
paramList
.
add
(
pair
);
}
method
.
setEntity
(
new
UrlEncodedFormEntity
(
paramList
,
"UTF-8"
));
}
response
=
client
.
execute
(
method
,
HttpClientContext
.
create
());
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
responseText
=
EntityUtils
.
toString
(
entity
);
}
}
catch
(
Exception
e
)
{
throw
e
;
}
finally
{
try
{
if
(
null
!=
response
)
{
response
.
close
();
}
}
catch
(
Exception
e
)
{
throw
e
;
}
}
return
responseText
;
}
/**
* 通过流方式传数据
*
* @param uri
* @param data
* @return
*/
public
static
String
post
(
String
uri
,
String
data
)
{
CloseableHttpClient
httpClient
=
getHttpClient
(
uri
);
HttpPost
method
=
new
HttpPost
(
uri
);
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectionRequestTimeout
(
CONNECT_TIMEOUT
)
.
setConnectTimeout
(
CONNECT_TIMEOUT
).
setSocketTimeout
(
SOCKET_TIMEOUT
).
build
();
method
.
setConfig
(
requestConfig
);
String
readContent
=
null
;
try
{
method
.
addHeader
(
"Content-type"
,
"application/xml; charset=ISO-8859-1"
);
method
.
setHeader
(
"Accept"
,
"application/xml"
);
method
.
setEntity
(
new
StringEntity
(
data
,
Charset
.
forName
(
"utf-8"
)));
HttpResponse
response
=
httpClient
.
execute
(
method
,
HttpClientContext
.
create
());
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
if
(
statusCode
!=
200
)
{
return
"failed"
;
}
HttpEntity
entity
=
response
.
getEntity
();
InputStream
in
=
entity
.
getContent
();
int
count
=
0
;
while
(
count
==
0
)
{
count
=
Integer
.
parseInt
(
""
+
entity
.
getContentLength
());
// in.available();
}
if
(
count
<=
0
)
{
return
EntityUtils
.
toString
(
entity
);
}
byte
[]
bytes
=
new
byte
[
count
];
int
readCount
=
0
;
// 已经成功读取的字节的个数
while
(
readCount
<=
count
)
{
if
(
readCount
==
count
)
{
break
;
}
readCount
+=
in
.
read
(
bytes
,
readCount
,
count
-
readCount
);
}
readContent
=
new
String
(
bytes
,
0
,
readCount
,
"UTF-8"
);
log
.
info
(
"Get Response Content():\n {}"
,
readContent
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
httpClient
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
readContent
;
}
/**
* 验证码实时校验
* 无需cookie和referer时请求接口
*
* @param headers 请求头
* @param baseUrl 发送请求的URL
* @return URL 所代表远程资源的响应结果
*/
public
static
String
doGet
(
String
baseUrl
,
Map
<
String
,
String
>
headers
)
{
CloseableHttpClient
httpClient
=
getHttpClient
(
baseUrl
);
CloseableHttpResponse
response
=
null
;
String
body
=
null
;
try
{
log
.
info
(
"接口请求路径:"
+
baseUrl
);
HttpGet
httpGet
=
new
HttpGet
(
baseUrl
);
if
(
headers
!=
null
&&
headers
.
size
()
>
0
)
{
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
httpGet
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
}
response
=
httpClient
.
execute
(
httpGet
);
body
=
getBody
(
response
.
getEntity
());
log
.
info
(
"获取请求结果为:"
+
body
);
}
catch
(
Exception
e
)
{
log
.
warn
(
"请求接口时-->"
+
baseUrl
+
"发生异常:"
,
e
);
}
finally
{
try
{
response
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
body
;
}
/**
* 关闭连接池
*/
public
static
void
closeConnectionPool
()
{
try
{
httpClient
.
close
();
manager
.
close
();
monitorExecutor
.
shutdown
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
/**
* 把map转为xml
*
* @param parameters
* @return
*/
public
static
String
parseXML
(
Map
<
String
,
String
>
parameters
)
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"<xml>"
);
Iterator
<
Entry
<
String
,
String
>>
itor
=
parameters
.
entrySet
().
iterator
();
while
(
itor
.
hasNext
())
{
Entry
<
String
,
String
>
entry
=
itor
.
next
();
String
k
=
entry
.
getKey
();
String
v
=
entry
.
getValue
();
if
(
null
!=
v
&&
!
""
.
equals
(
v
)
&&
!
"appkey"
.
equals
(
k
))
{
sb
.
append
(
"<"
+
k
+
">"
+
parameters
.
get
(
k
)
+
"</"
+
k
+
">\n"
);
}
}
sb
.
append
(
"</xml>"
);
return
sb
.
toString
();
}
/**
* 把map转为xml
*
* @param parameters
* @return
*/
public
static
String
parseJSON
(
Map
<
String
,
String
>
parameters
)
{
return
new
JSONWriter
().
write
(
parameters
);
}
/**
* 从URL中提取所有的参数。
*
* @param query URL地址
* @return 参数映射
*/
public
static
Map
<
String
,
String
>
splitUrlQuery
(
String
query
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
String
[]
pairs
=
query
.
split
(
"&"
);
if
(
pairs
!=
null
&&
pairs
.
length
>
0
)
{
for
(
String
pair
:
pairs
)
{
String
[]
param
=
pair
.
split
(
"="
,
2
);
if
(
param
!=
null
&&
param
.
length
==
2
)
{
result
.
put
(
param
[
0
],
param
[
1
]);
}
}
}
return
result
;
}
public
static
CloseableHttpClient
getHttpClient
(
String
url
)
{
int
port
=
80
;
String
hostName
=
url
.
split
(
"/"
)[
2
];
if
(
hostName
.
contains
(
":"
))
{
String
[]
args
=
hostName
.
split
(
":"
);
hostName
=
args
[
0
];
port
=
Integer
.
parseInt
(
args
[
1
]);
}
if
(
httpClient
==
null
)
{
// 多线程下多个线程同时调用getHttpClient容易导致重复创建httpClient对象的问题,所以加上了同步锁
synchronized
(
syncLock
)
{
if
(
httpClient
==
null
)
{
httpClient
=
createHttpClient
(
hostName
,
port
);
// 开启监控线程,对异常和空闲线程进行关闭
monitorExecutor
=
Executors
.
newScheduledThreadPool
(
1
);
monitorExecutor
.
scheduleAtFixedRate
(
new
TimerTask
()
{
@Override
public
void
run
()
{
// 关闭异常连接
manager
.
closeExpiredConnections
();
// 关闭5s空闲的连接
manager
.
closeIdleConnections
(
Config
.
getHttpIdelTimeout
(),
TimeUnit
.
MILLISECONDS
);
}
},
Config
.
getHttpMonitorInterval
(),
Config
.
getHttpMonitorInterval
(),
TimeUnit
.
MILLISECONDS
);
}
}
}
return
httpClient
;
}
public
static
String
getBody
(
HttpEntity
entity
)
throws
ParseException
,
IOException
{
String
body
=
""
;
if
(
entity
!=
null
)
{
// 按指定编码转换结果实体为String类型
body
=
EntityUtils
.
toString
(
entity
,
Consts
.
UTF_8
);
}
EntityUtils
.
consume
(
entity
);
return
body
;
}
/**
* 根据host和port构建httpclient实例
*
* @param host 要访问的域名
* @param port 要访问的端口
* @return
*/
public
static
CloseableHttpClient
createHttpClient
(
String
host
,
int
port
)
{
ConnectionSocketFactory
plainSocketFactory
=
PlainConnectionSocketFactory
.
getSocketFactory
();
LayeredConnectionSocketFactory
sslSocketFactory
=
SSLConnectionSocketFactory
.
getSocketFactory
();
Registry
<
ConnectionSocketFactory
>
registry
=
RegistryBuilder
.<
ConnectionSocketFactory
>
create
()
.
register
(
"http"
,
plainSocketFactory
).
register
(
"https"
,
sslSocketFactory
).
build
();
manager
=
new
PoolingHttpClientConnectionManager
(
registry
);
// 设置连接参数
manager
.
setMaxTotal
(
MAX_CONN
);
// 最大连接数
manager
.
setDefaultMaxPerRoute
(
MAX_PRE_ROUTE
);
// 路由最大连接数
HttpHost
httpHost
=
new
HttpHost
(
host
,
port
);
manager
.
setMaxPerRoute
(
new
HttpRoute
(
httpHost
),
MAX_ROUTE
);
// 请求失败时,进行请求重试
HttpRequestRetryHandler
handler
=
new
HttpRequestRetryHandler
()
{
@Override
public
boolean
retryRequest
(
IOException
e
,
int
i
,
HttpContext
httpContext
)
{
if
(
i
>
3
)
{
// 重试超过3次,放弃请求
log
.
error
(
"retry has more than 3 time, give up request"
);
return
false
;
}
if
(
e
instanceof
NoHttpResponseException
)
{
// 服务器没有响应,可能是服务器断开了连接,应该重试
log
.
error
(
"receive no response from server, retry"
);
return
true
;
}
if
(
e
instanceof
SSLHandshakeException
)
{
// SSL握手异常
log
.
error
(
"SSL hand shake exception"
);
return
false
;
}
if
(
e
instanceof
InterruptedIOException
)
{
// 超时
log
.
error
(
"InterruptedIOException"
);
return
false
;
}
if
(
e
instanceof
UnknownHostException
)
{
// 服务器不可达
log
.
error
(
"server host unknown"
);
return
false
;
}
if
(
e
instanceof
ConnectTimeoutException
)
{
// 连接超时
log
.
error
(
"Connection Time out"
);
return
false
;
}
if
(
e
instanceof
SSLException
)
{
log
.
error
(
"SSLException"
);
return
false
;
}
HttpClientContext
context
=
HttpClientContext
.
adapt
(
httpContext
);
HttpRequest
request
=
context
.
getRequest
();
if
(!(
request
instanceof
HttpEntityEnclosingRequest
))
{
// 如果请求不是关闭连接的请求
return
true
;
}
return
false
;
}
};
return
HttpClients
.
custom
().
setConnectionManager
(
manager
).
setRetryHandler
(
handler
).
build
();
}
}
class
Config
{
static
int
httpConnectTimeout
=
3000
;
static
int
httpSocketTimeout
=
60000
;
static
int
httpMaxPoolSize
=
2000
;
static
int
httpMonitorInterval
=
3000
;
static
int
httpIdelTimeout
=
2000
;
public
static
int
getHttpIdelTimeout
()
{
return
httpIdelTimeout
;
}
public
static
int
getHttpSocketTimeout
()
{
return
httpSocketTimeout
;
}
public
static
int
getHttpMaxPoolSize
()
{
return
httpMaxPoolSize
;
}
public
static
int
getHttpMonitorInterval
()
{
return
httpMonitorInterval
;
}
public
static
int
getHttpConnectTimeout
()
{
return
httpConnectTimeout
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiDirectionController.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
controller
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.service.ApiDirectionService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
reactor.core.publisher.Mono
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.controller
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiLogController
* @DATE: 2020-12-25/14:25
* @DAY_NAME_SHORT: 周五
* @Description:
**/
@RestController
@RequestMapping
(
"api/direction"
)
@Api
(
tags
=
"API字典信息Controller"
)
public
class
ApiDirectionController
{
@Autowired
private
ApiDirectionService
apiDirectionService
;
/**
* @Description:api类型列表
* @return: api类型列表
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"api类型列表"
)
@PostMapping
(
value
=
"/getApiTypeList"
)
public
Mono
<
Result
>
getApiTypeList
(
@RequestParam
(
name
=
"parentCode"
)
String
parentCode
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiDirectionService
.
getApiType
(
parentCode
)));
}
/**
* @Description:查询某个类型的字典值
* @return: 查询某个类型的字典值
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"查询某个类型的字典值"
)
@PostMapping
(
value
=
"/getDirectionVal"
)
public
Mono
<
Result
>
getDirectionVal
(
@RequestParam
(
name
=
"code"
,
required
=
false
)
String
code
,
@RequestParam
(
name
=
"key"
,
required
=
false
)
String
key
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
apiDirectionService
.
getDirectionVal
(
key
,
code
)));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ApiLogController.java
View file @
d7b311c3
...
@@ -26,7 +26,7 @@ import javax.validation.Valid;
...
@@ -26,7 +26,7 @@ import javax.validation.Valid;
**/
**/
@RestController
@RestController
@RequestMapping
(
"api/logging"
)
@RequestMapping
(
"api/logging"
)
@Api
(
tags
=
"
授权认证
Controller"
)
@Api
(
tags
=
"
日志信息
Controller"
)
public
class
ApiLogController
{
public
class
ApiLogController
{
@Autowired
@Autowired
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/AuthController.java
View file @
d7b311c3
...
@@ -39,7 +39,7 @@ public class AuthController {
...
@@ -39,7 +39,7 @@ public class AuthController {
*/
*/
@ApiOperation
(
"商城用户API认证"
)
@ApiOperation
(
"商城用户API认证"
)
@PostMapping
(
value
=
"/mall-user-auth-api"
)
@PostMapping
(
value
=
"/mall-user-auth-api"
)
public
Mono
<
Result
>
authMallUserApi
(
@RequestBody
@Valid
Auth
Mall
UserApiReq
req
)
{
public
Mono
<
Result
>
authMallUserApi
(
@RequestBody
@Valid
AuthUserApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
addMallUserApiAuth
(
req
));
return
Mono
.
fromSupplier
(()
->
authService
.
addMallUserApiAuth
(
req
));
}
}
/**
/**
...
@@ -50,7 +50,7 @@ public class AuthController {
...
@@ -50,7 +50,7 @@ public class AuthController {
*/
*/
@ApiOperation
(
"DMP用户API认证"
)
@ApiOperation
(
"DMP用户API认证"
)
@PostMapping
(
value
=
"dmp-auth-api"
)
@PostMapping
(
value
=
"dmp-auth-api"
)
public
Mono
<
Result
>
authDmpUserApi
(
@RequestBody
@Valid
Auth
Dmp
UserApiReq
req
)
{
public
Mono
<
Result
>
authDmpUserApi
(
@RequestBody
@Valid
AuthUserApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
addDmpUserApiAuth
(
req
));
return
Mono
.
fromSupplier
(()
->
authService
.
addDmpUserApiAuth
(
req
));
}
}
/**
/**
...
@@ -81,8 +81,8 @@ public class AuthController {
...
@@ -81,8 +81,8 @@ public class AuthController {
* @Author: Mr.zhang
* @Author: Mr.zhang
* @Date: 2020-12-26
* @Date: 2020-12-26
*/
*/
@ApiOperation
(
"认证信息修改"
)
//
@ApiOperation("认证信息修改")
@PostMapping
(
value
=
"/update-auth-info"
)
//
@PostMapping(value = "/update-auth-info")
public
Mono
<
Result
>
updateAuthListInfo
(
@RequestBody
@Valid
AuthInfoUpdateReq
req
)
{
public
Mono
<
Result
>
updateAuthListInfo
(
@RequestBody
@Valid
AuthInfoUpdateReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
updateAuthInfo
(
req
));
return
Mono
.
fromSupplier
(()
->
authService
.
updateAuthInfo
(
req
));
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/OrganizationManageController.java
View file @
d7b311c3
...
@@ -6,7 +6,6 @@ import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
...
@@ -6,7 +6,6 @@ import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
import
com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq
;
import
com.jz.dm.service.OrganizationManageService
;
import
com.jz.dm.service.OrganizationManageService
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -51,8 +50,6 @@ public class OrganizationManageController {
...
@@ -51,8 +50,6 @@ public class OrganizationManageController {
*/
*/
@ApiOperation
(
"组织详情查询"
)
@ApiOperation
(
"组织详情查询"
)
@PostMapping
(
value
=
"/getOrgDetail"
)
@PostMapping
(
value
=
"/getOrgDetail"
)
@AccessLimit
(
limit
=
1000
,
sec
=
1
)
//@ApiLogAspect
public
Mono
<
Result
>
getOrganizationDetail
(
@RequestBody
@Valid
OrganizationManageDetailQueryReq
req
)
{
public
Mono
<
Result
>
getOrganizationDetail
(
@RequestBody
@Valid
OrganizationManageDetailQueryReq
req
)
{
return
Mono
.
fromSupplier
(()
->
organizationManageService
.
getOrganizationDetail
(
req
));
return
Mono
.
fromSupplier
(()
->
organizationManageService
.
getOrganizationDetail
(
req
));
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ProducerController.java
View file @
d7b311c3
...
@@ -47,7 +47,7 @@ public class ProducerController {
...
@@ -47,7 +47,7 @@ public class ProducerController {
*/
*/
@ApiOperation
(
"Api制作(自定义)"
)
@ApiOperation
(
"Api制作(自定义)"
)
@PostMapping
(
value
=
"/addCustomApi"
)
@PostMapping
(
value
=
"/addCustomApi"
)
public
Mono
<
Result
>
makeCustomApi
(
@RequestBody
@Valid
MakeCustomApi
Req
req
)
{
public
Mono
<
Result
>
makeCustomApi
(
@RequestBody
@Valid
ApiInterface
Req
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addCustomApi
(
req
)));
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addCustomApi
(
req
)));
}
}
...
@@ -59,7 +59,7 @@ public class ProducerController {
...
@@ -59,7 +59,7 @@ public class ProducerController {
@ApiOperation
(
"Api制作(数据银行)"
)
@ApiOperation
(
"Api制作(数据银行)"
)
@PostMapping
(
value
=
"/addDataBankApiInfo"
)
@PostMapping
(
value
=
"/addDataBankApiInfo"
)
public
Mono
<
Result
>
addDataBankApiInfo
(
@RequestBody
@Valid
MakeDataBankApiReq
req
)
{
public
Mono
<
Result
>
addDataBankApiInfo
(
@RequestBody
@Valid
MakeDataBankApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addDataBankApiInfo
(
req
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
addDataBankApiInfo
(
req
));
}
}
/**
/**
...
@@ -81,7 +81,7 @@ public class ProducerController {
...
@@ -81,7 +81,7 @@ public class ProducerController {
@ApiOperation
(
"Api制作(大数据查询/标签查询)"
)
@ApiOperation
(
"Api制作(大数据查询/标签查询)"
)
@PostMapping
(
value
=
"/makeBigDataApi"
)
@PostMapping
(
value
=
"/makeBigDataApi"
)
public
Mono
<
Result
>
bigDataMakeApi
(
@RequestBody
@Valid
MakeBigDataApiReq
req
)
{
public
Mono
<
Result
>
bigDataMakeApi
(
@RequestBody
@Valid
MakeBigDataApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addBigDataMakeApi
(
req
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
addBigDataMakeApi
(
req
));
}
}
/**
/**
...
@@ -93,7 +93,7 @@ public class ProducerController {
...
@@ -93,7 +93,7 @@ public class ProducerController {
@ApiOperation
(
"保存API基本信息"
)
@ApiOperation
(
"保存API基本信息"
)
@PostMapping
(
value
=
"/saveInterface"
)
@PostMapping
(
value
=
"/saveInterface"
)
public
Mono
<
Result
>
saveInsetInterface
(
@RequestBody
@Valid
ApiInterfaceReq
req
)
{
public
Mono
<
Result
>
saveInsetInterface
(
@RequestBody
@Valid
ApiInterfaceReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
saveInterfaceAPi
(
req
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
saveInterfaceAPi
(
req
));
}
}
/**
/**
* @Description:Api制作(大数据查询/标签查询)保存修改的api信息
* @Description:Api制作(大数据查询/标签查询)保存修改的api信息
...
@@ -104,7 +104,7 @@ public class ProducerController {
...
@@ -104,7 +104,7 @@ public class ProducerController {
@ApiOperation
(
"保存修改的api信息"
)
@ApiOperation
(
"保存修改的api信息"
)
@PostMapping
(
value
=
"/保存修改的api信息"
)
@PostMapping
(
value
=
"/保存修改的api信息"
)
public
Mono
<
Result
>
saveUpdateAPiInfo
(
@RequestBody
@Valid
MakeApiSaveInfoReq
req
)
{
public
Mono
<
Result
>
saveUpdateAPiInfo
(
@RequestBody
@Valid
MakeApiSaveInfoReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
saveUpdateAPiInfo
(
req
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
saveUpdateAPiInfo
(
req
));
}
}
...
@@ -116,7 +116,7 @@ public class ProducerController {
...
@@ -116,7 +116,7 @@ public class ProducerController {
@ApiOperation
(
"获取数据源配置"
)
@ApiOperation
(
"获取数据源配置"
)
@PostMapping
(
value
=
"/getSourceConfig"
)
@PostMapping
(
value
=
"/getSourceConfig"
)
public
Mono
<
Result
>
getSourceConfig
(
@RequestBody
@Valid
SourceConfigReq
req
)
{
public
Mono
<
Result
>
getSourceConfig
(
@RequestBody
@Valid
SourceConfigReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getSourceConfig
(
req
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
getSourceConfig
(
req
));
}
}
/**
/**
* @Description:获取索引
* @Description:获取索引
...
@@ -126,7 +126,7 @@ public class ProducerController {
...
@@ -126,7 +126,7 @@ public class ProducerController {
@ApiOperation
(
"获取索引"
)
@ApiOperation
(
"获取索引"
)
@GetMapping
(
value
=
"/getIndicess"
)
@GetMapping
(
value
=
"/getIndicess"
)
public
Mono
<
Result
>
getSourceWarehouseList
(
@RequestParam
(
name
=
"id"
)
Long
id
)
{
public
Mono
<
Result
>
getSourceWarehouseList
(
@RequestParam
(
name
=
"id"
)
Long
id
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getSourceWarehouseList
(
id
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
getSourceWarehouseList
(
id
));
}
}
/**
/**
* @Description:获取某个索引下的type
* @Description:获取某个索引下的type
...
@@ -137,7 +137,7 @@ public class ProducerController {
...
@@ -137,7 +137,7 @@ public class ProducerController {
@GetMapping
(
value
=
"/getIndicesTypes"
)
@GetMapping
(
value
=
"/getIndicesTypes"
)
public
Mono
<
Result
>
getIndicesTypes
(
@RequestParam
(
name
=
"indices"
)
String
indices
,
public
Mono
<
Result
>
getIndicesTypes
(
@RequestParam
(
name
=
"indices"
)
String
indices
,
@RequestParam
(
name
=
"id"
)
Long
id
)
{
@RequestParam
(
name
=
"id"
)
Long
id
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getIndicesTypes
(
indices
,
id
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
getIndicesTypes
(
indices
,
id
));
}
}
/**
/**
* @Description:获取某个索引 type的fields
* @Description:获取某个索引 type的fields
...
@@ -149,6 +149,6 @@ public class ProducerController {
...
@@ -149,6 +149,6 @@ public class ProducerController {
public
Mono
<
Result
>
getIndicesTypesFields
(
@RequestParam
(
name
=
"indices"
)
String
indices
,
public
Mono
<
Result
>
getIndicesTypesFields
(
@RequestParam
(
name
=
"indices"
)
String
indices
,
@RequestParam
(
name
=
"type"
)
String
type
,
@RequestParam
(
name
=
"type"
)
String
type
,
@RequestParam
(
name
=
"id"
)
Long
id
)
{
@RequestParam
(
name
=
"id"
)
Long
id
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getIndicesTypesFields
(
indices
,
type
,
id
)
));
return
Mono
.
fromSupplier
(()
->
producerService
.
getIndicesTypesFields
(
indices
,
type
,
id
));
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
filter
;
package
com
.
jz
.
dm
.
filter
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.LoggingConstants
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.org.OrgStatusEnum
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.DateUtil
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiOrg
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.service.OrganizationManageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.filter
* @PACKAGE_NAME: com.jz.dm.filter
...
@@ -15,8 +36,20 @@ import org.springframework.stereotype.Component;
...
@@ -15,8 +36,20 @@ import org.springframework.stereotype.Component;
* @Description: 认证过滤器
* @Description: 认证过滤器
**/
**/
@Component
(
"authFilter"
)
@Component
(
"authFilter"
)
@Slf4j
public
class
AuthFilter
extends
AbstractFilter
{
public
class
AuthFilter
extends
AbstractFilter
{
@Autowired
private
AuthService
authService
;
@Autowired
private
OrganizationManageService
organizationManageService
;
@Autowired
private
ApiInterfaceService
apiInterfaceService
;
@Autowired
private
RedisUtils
redisUtils
;
@Value
(
"${request.limit.max}"
)
private
Long
limit
;
@Override
@Override
public
String
getFilterName
()
{
public
String
getFilterName
()
{
...
@@ -27,10 +60,89 @@ public class AuthFilter extends AbstractFilter {
...
@@ -27,10 +60,89 @@ public class AuthFilter extends AbstractFilter {
public
int
getOrder
()
{
public
int
getOrder
()
{
return
Constants
.
FILTER_ORDER_5
;
return
Constants
.
FILTER_ORDER_5
;
}
}
@Override
protected
void
internalDoFilter
(
GatewayRequest
request
,
GatewayResponse
response
,
FilterChain
chain
)
{
//TODO 主要做计费计次验证
@Override
protected
void
internalDoFilter
(
GatewayRequest
request
,
GatewayResponse
response
,
FilterChain
chain
)
{
try
{
ApiInterface
apiInterface
=
apiInterfaceService
.
getApiInfo
(
request
.
getAppKey
());
if
(
null
==
apiInterface
)
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
if
(!
ApiStatusEnum
.
ISSUE
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
throw
new
GatewayException
(
GatewayResultCode
.
API_STATUS_EXCEPTION
);
}
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getParams
());
if
(
null
!=
parameter
)
{
String
authCode
=
parameter
.
getString
(
"authCode"
);
ApiAuth
authAuth
=
authService
.
getAuthUser
(
authCode
);
if
(
null
==
authAuth
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_NOT_AUTH
);
}
//查询认证组织信息
ApiOrg
apiOrg
=
organizationManageService
.
getAuthOrganization
(
authAuth
.
getApiOrgId
());
if
(
null
==
apiOrg
)
{
throw
new
GatewayException
(
GatewayResultCode
.
ORG_NOT_EXIST
);
}
checkBill
(
request
,
authCode
,
authAuth
,
apiOrg
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"~~~~~~~~~~~~~~~~认证过滤异常~~~~~~~~~~~~~~~~~"
);
log
.
error
(
"异常信息:{}"
,
e
.
getMessage
());
}
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
}
/**
* 校验计费信息
* @param request
* @param authCode
* @param authAuth
* @param apiOrg
* @throws ParseException
*/
private
void
checkBill
(
GatewayRequest
request
,
String
authCode
,
ApiAuth
authAuth
,
ApiOrg
apiOrg
)
throws
ParseException
{
switch
(
authAuth
.
getAuthMode
())
{
case
"POWER_CALL_MODE"
:
//按次调用
//状态检查(只限制按次请求$$ 不限制按时间请求)
if
(!
OrgStatusEnum
.
NORMAL
.
name
().
equals
(
apiOrg
.
getStatus
()))
{
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
}
//查询数据银行银行余额是否充足
try
{
//记录请求次数(每天限制请求次数)
String
limitKey
=
request
.
getAppKey
()
+
LoggingConstants
.
AND_SPILT
+
authCode
;
String
reqKey
=
redisUtils
.
get
(
limitKey
);
long
timeOut
=
DateUtil
.
calculateNowResidueTime
();
if
(
null
!=
reqKey
)
{
Integer
value
=
Integer
.
valueOf
(
reqKey
);
if
(
value
>
limit
)
{
//超出最大请求次数
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_LIMIT_EXCEPTION
);
}
else
if
(
value
<=
limit
)
{
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
value
+
1
,
timeOut
);
}
}
else
{
redisUtils
.
set
(
limitKey
,
1
,
timeOut
);
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"~~~~~~~~~~~~~~~~~~~~~~过滤计次信息异常~~~~~~~~~~~~~~~~~~~"
);
log
.
error
(
"异常信息:{}"
,
ex
.
getMessage
());
}
break
;
case
"RECORD_TIME_MODE"
:
//按时间调用
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
Constants
.
DATE_TIME_FORMAT
);
String
formatDate
=
dateFormat
.
format
(
new
Date
());
Date
currentDate
=
dateFormat
.
parse
(
formatDate
);
Date
validEndTime
=
authAuth
.
getValidEndTime
();
//如果 date1 在 date2 之前,before 返回 true,否则返回 false
if
(
currentDate
.
before
(
validEndTime
))
{
//超出时间
throw
new
GatewayException
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
);
}
break
;
case
"PERMANENT_TIME_MODE"
:
//永久有效(直接跳出)
break
;
default
:
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/CheckArgsFilter.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
filter
;
package
com
.
jz
.
dm
.
filter
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.enums.Format
;
import
com.jz.dm.common.enums.GatewayResultCode
;
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.
enums
.SignType
;
import
com.jz.dm.common.util.StringUtil
;
import
com.jz.dm.common.util.StringUtil
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.common.enums.Format
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.nio.charset.Charset
;
/**
/**
* 参数检查过滤器
* 参数检查过滤器
*
*
...
@@ -22,7 +20,7 @@ public class CheckArgsFilter extends AbstractFilter {
...
@@ -22,7 +20,7 @@ public class CheckArgsFilter extends AbstractFilter {
@Override
@Override
public
int
getOrder
()
{
public
int
getOrder
()
{
return
Constants
.
FILTER_ORDER_
3
;
return
Constants
.
FILTER_ORDER_
2
;
}
}
@Override
@Override
...
@@ -34,23 +32,20 @@ public class CheckArgsFilter extends AbstractFilter {
...
@@ -34,23 +32,20 @@ public class CheckArgsFilter extends AbstractFilter {
FilterChain
chain
)
{
FilterChain
chain
)
{
// 校验参数非空
// 校验参数非空
if
(
StringUtil
.
isEmpty
(
request
.
getAppKey
())
||
StringUtil
.
isEmpty
(
request
.
getMethod
())
if
(
StringUtil
.
isEmpty
(
request
.
getAppKey
())
||
StringUtil
.
isEmpty
(
request
.
getMethod
())
||
StringUtil
.
isEmpty
(
request
.
getCharset
())
||
StringUtil
.
isEmpty
(
request
.
getSignType
())
||
StringUtil
.
isEmpty
(
request
.
getSignType
())||
StringUtil
.
isEmpty
(
request
.
getSign
())
||
StringUtil
.
isEmpty
(
request
.
getSign
())
||
StringUtil
.
isEmpty
(
request
.
getTimestamp
())
||
StringUtil
.
isEmpty
(
request
.
getTimestamp
())||
StringUtil
.
isEmpty
(
request
.
getParams
()))
{
||
StringUtil
.
isEmpty
(
request
.
getVersion
())
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
//无效参数
||
StringUtil
.
isEmpty
(
request
.
getParams
()))
{
//无效参数
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
}
}
// 设置默认值
// 设置默认值
if
(
StringUtil
.
isEmpty
(
request
.
getFormat
()))
{
if
(
StringUtil
.
isEmpty
(
request
.
getFormat
()))
{
request
.
setFormat
(
Format
.
JSON
.
name
());
request
.
setFormat
(
Format
.
JSON
.
name
());
}
}
try
{
try
{
request
.
setVersion
(
"v1.0.0"
);
//格式,目前仅支持JSON
//格式,目前仅支持JSON
Format
.
valueOf
(
request
.
getFormat
());
Format
.
valueOf
(
request
.
getFormat
());
//请求使用的编码格式,如UTF-8,GBK,GB2312等
//请求使用的编码格式,如UTF-8,GBK,GB2312等
Charset
.
forName
(
request
.
getCharset
());
//
Charset.forName(request.getCharset());
//生成签名字符串所使用的签名算法类型
//生成签名字符串所使用的签名算法类型
SignType
.
valueOf
(
request
.
getSignType
());
SignType
.
valueOf
(
request
.
getSignType
());
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/InvokeRouteFilter.java
View file @
d7b311c3
...
@@ -2,14 +2,13 @@ package com.jz.dm.filter;
...
@@ -2,14 +2,13 @@ package com.jz.dm.filter;
import
com.alibaba.fastjson.JSON
;
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.util.LogUtil
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.LoggingConstants
;
import
com.jz.dm.common.constant.LoggingConstants
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.gateway.DefaultOpenApiDispatcher
;
import
com.jz.dm.gateway.DefaultOpenApiDispatcher
;
import
com.jz.dm.models.enity.
*
;
import
com.jz.dm.models.enity.
DispatchContext
;
import
com.jz.dm.
common.enums.GatewayResultCode
;
import
com.jz.dm.
models.enity.GatewayRequest
;
import
com.jz.dm.
common.enums.RouteTyp
e
;
import
com.jz.dm.
models.enity.GatewayRespons
e
;
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
;
...
@@ -45,19 +44,17 @@ public class InvokeRouteFilter extends AbstractFilter {
...
@@ -45,19 +44,17 @@ public class InvokeRouteFilter extends AbstractFilter {
//当前系统时间戳
//当前系统时间戳
long
startTime
=
System
.
currentTimeMillis
();
long
startTime
=
System
.
currentTimeMillis
();
try
{
try
{
OpenApi
openApi
=
(
OpenApi
)
RequestContext
.
getCurrentContext
().
get
(
"openApi"
);
//
OpenApi openApi = (OpenApi) RequestContext.getCurrentContext().get("openApi");
if
(
openApi
.
getRouteType
()
==
null
)
{
//
if (openApi.getRouteType() == null) {
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ROUTE_TYPE
);
//
throw new GatewayException(GatewayResultCode.ILLEGAL_ROUTE_TYPE);
}
//
}
if
(
openApi
.
getRouteType
()
!=
RouteType
.
SRPING
)
{
//
if (openApi.getRouteType() != RouteType.SRPING) {
chain
.
doFilter
(
request
,
response
);
//
chain.doFilter(request, response);
return
;
//
return;
}
//
}
DispatchContext
context
=
new
DispatchContext
();
DispatchContext
context
=
new
DispatchContext
();
context
.
setAppKey
(
request
.
getAppKey
());
//apiKey
context
.
setAppKey
(
request
.
getAppKey
());
//apiKey
context
.
setApplication
(
openApi
.
getApplication
());
//应用
//context.setApplication(openApi.getApplication());//应用
context
.
setOpenApiMethod
(
request
.
getMethod
());
//方法 例如:tradd.add
context
.
setOpenApiMethod
(
request
.
getMethod
());
//方法 例如:tradd.add
context
.
setOpenApiParams
(
request
.
getParams
());
//入参
context
.
setOpenApiParams
(
request
.
getParams
());
//入参
context
.
setOpenApiVersion
(
request
.
getVersion
());
//版本号
context
.
setOpenApiVersion
(
request
.
getVersion
());
//版本号
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
filter
;
package
com
.
jz
.
dm
.
filter
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.LoggingConstants
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.MapUtil
;
import
com.jz.dm.common.util.Md5
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.GatewayResponse
;
import
com.jz.dm.models.enity.OpenApi
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.models.enity.RequestContext
;
import
com.jz.dm.common.enums.RouteType
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.TreeMap
;
/**
/**
* 验签过滤器(验证签名信息)
* 验签过滤器(验证签名信息)
*/
*/
...
@@ -16,9 +26,11 @@ import org.springframework.stereotype.Component;
...
@@ -16,9 +26,11 @@ import org.springframework.stereotype.Component;
@Component
@Component
public
class
VerifySignFilter
extends
AbstractFilter
{
public
class
VerifySignFilter
extends
AbstractFilter
{
@Autowired
private
ApiInterfaceService
apiInterfaceService
;
@Override
@Override
public
int
getOrder
()
{
public
int
getOrder
()
{
return
Constants
.
FILTER_ORDER_
2
;
return
Constants
.
FILTER_ORDER_
3
;
}
}
@Override
@Override
...
@@ -28,11 +40,35 @@ public class VerifySignFilter extends AbstractFilter {
...
@@ -28,11 +40,35 @@ public class VerifySignFilter extends AbstractFilter {
@Override
@Override
protected
void
internalDoFilter
(
GatewayRequest
request
,
GatewayResponse
response
,
protected
void
internalDoFilter
(
GatewayRequest
request
,
GatewayResponse
response
,
FilterChain
chain
)
{
FilterChain
chain
)
{
try
{
TreeMap
<
String
,
Object
>
map
=
MapUtil
.
objToMap
(
request
);
if
(
null
==
map
){
log
.
info
(
"~~~~~~~~~~~~~~~签名数据转换map异常~~~~~~~~~~~~~~~~~~"
);
throw
new
GatewayException
(
GatewayResultCode
.
UNKNOWN_EXCEPTION
);
}
List
signParams
=
MapUtil
.
directSort
(
map
);
if
(
CollectionUtils
.
isNotEmpty
(
signParams
)){
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
//需要传入授权码
ApiAuth
apiAuthInfo
=
apiInterfaceService
.
getApiAuthInfo
(
request
.
getAppKey
(),
jsonObject
.
getString
(
"authCode"
));
if
(
null
==
apiAuthInfo
){
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
String
paramStr
=
MapUtil
.
listToString
(
signParams
,
LoggingConstants
.
AND_SPILT
);
String
salt
=
Md5
.
encrypt
(
paramStr
,
apiAuthInfo
.
getSalt
());
if
(!
request
.
getSign
().
equals
(
salt
)){
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"~~~~~~~~~~~~~~签名过滤异常~~~~~~~~~~~~~~~~~~"
);
log
.
error
(
"异常信息:{}"
,
e
.
getMessage
());
}
// 后期再扩展
// 后期再扩展
OpenApi
openApi
=
new
OpenApi
();
//
OpenApi openApi = new OpenApi();
openApi
.
setApplication
(
"JZ_API_GATEWAY"
);
//应用
//
openApi.setApplication("JZ_API_GATEWAY");//应用
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 @
d7b311c3
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiAuthMapper.java
View file @
d7b311c3
...
@@ -19,7 +19,7 @@ public interface ApiAuthMapper extends BaseMapper<ApiAuth> {
...
@@ -19,7 +19,7 @@ public interface ApiAuthMapper extends BaseMapper<ApiAuth> {
* @param req
* @param req
* @return
* @return
*/
*/
AuthInfoDto
selectAuthDetail
(
@Param
(
"req"
)
AuthDetailInfoReq
req
);
AuthInfoDto
selectAuthDetail
(
AuthDetailInfoReq
req
);
/**
/**
* 分页查询认证列表
* 分页查询认证列表
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiDirectionMapper.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiDirection
;
/**api授权信息表 mapper
* @author zc
*
*/
public
interface
ApiDirectionMapper
extends
BaseMapper
<
ApiDirection
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiDirection.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_direction"
)
public
class
ApiDirection
implements
Serializable
{
/**
* 主健ID
*/
@ApiModelProperty
(
"主健ID"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 字典key
*/
@TableField
(
"`key`"
)
private
String
key
;
/**
* 字典value
*/
@TableField
(
"`value`"
)
private
String
value
;
/**
* 字典编码
*/
@TableField
(
"`code`"
)
private
String
code
;
/**
* 父节点
*/
@TableField
(
"parent"
)
private
String
parent
;
/**
* 字典类型
*/
@TableField
(
"direction_type"
)
private
String
directionType
;
/**
* is_enabled
*/
@TableField
(
"`level`"
)
private
Integer
level
;
/**
* 是否启用:UNABLE 停用,ENABLE 启用
*/
@TableField
(
"is_enabled"
)
private
String
isEnabled
;
/**
* 创建日期
*/
@ApiModelProperty
(
"创建日期"
)
@TableField
(
"create_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createDate
;
/**
* 创建人
*/
@ApiModelProperty
(
"创建人"
)
@TableField
(
"create_user"
)
private
String
createUser
;
/**
* 是否删除
*/
@TableField
(
"is_deleted"
)
private
Integer
isDeleted
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
d7b311c3
...
@@ -58,6 +58,16 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -58,6 +58,16 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
*/
@TableField
(
"target_url"
)
@TableField
(
"target_url"
)
private
String
targetUrl
;
private
String
targetUrl
;
/**
* 接入类型:对应字典表key
*/
@TableField
(
"join_type"
)
private
String
joinType
;
/**
* 测试实例
*/
@TableField
(
"test_example"
)
private
String
testExample
;
/**
/**
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
* 状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
View file @
d7b311c3
...
@@ -28,7 +28,7 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
...
@@ -28,7 +28,7 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
* 项目编号
* 项目编号
*/
*/
@TableField
(
"project_id"
)
@TableField
(
"project_id"
)
private
Stri
ng
projectId
;
private
Lo
ng
projectId
;
/**
/**
* 文件来源:1 DMP 2 数据银行
* 文件来源:1 DMP 2 数据银行
...
@@ -37,10 +37,10 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
...
@@ -37,10 +37,10 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
private
String
fileSource
;
private
String
fileSource
;
/**
/**
* 文件类型
* 文件类型
:1 文件夹 ,2 文件
*/
*/
@TableField
(
"file_type"
)
@TableField
(
"file_type"
)
private
String
api
Type
;
private
String
file
Type
;
/**
/**
* 文件名称
* 文件名称
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
View file @
d7b311c3
...
@@ -57,7 +57,7 @@ public class ApiOrg extends BaseObject implements Serializable {
...
@@ -57,7 +57,7 @@ public class ApiOrg extends BaseObject implements Serializable {
private
String
orgType
;
private
String
orgType
;
/**
/**
* 状态(
1-正常 2-冻结 3-下架
)
* 状态(
NORMAL-正常 FREEZE-冻结 CANCEL-注销
)
*/
*/
@TableField
(
"status"
)
@TableField
(
"status"
)
private
String
status
;
private
String
status
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiReqLog.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
models
.
domian
;
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.
jz.dm.common.base.BaseObject
;
import
com.
fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
...
@@ -23,7 +25,15 @@ import java.util.Date;
...
@@ -23,7 +25,15 @@ import java.util.Date;
@NoArgsConstructor
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_req_log"
)
@TableName
(
"t_api_req_log"
)
public
class
ApiReqLog
extends
BaseObject
implements
Serializable
{
public
class
ApiReqLog
implements
Serializable
{
/**
* 主健ID
*/
@ApiModelProperty
(
"主健ID"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
/**
* 请求ip
* 请求ip
...
@@ -93,4 +103,56 @@ public class ApiReqLog extends BaseObject implements Serializable {
...
@@ -93,4 +103,56 @@ public class ApiReqLog extends BaseObject implements Serializable {
*/
*/
@TableField
(
"status"
)
@TableField
(
"status"
)
private
String
status
;
private
String
status
;
/**
* 创建日期
*/
@ApiModelProperty
(
"创建日期"
)
@TableField
(
"create_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createDate
;
/**
* 创建人
*/
@ApiModelProperty
(
"创建人"
)
@TableField
(
"create_user"
)
private
String
createUser
;
/**
* 更新人
*/
@ApiModelProperty
(
"更新人"
)
@TableField
(
"update_user"
)
@JsonIgnore
private
String
updateUser
;
/**
* 更新日期
*/
@ApiModelProperty
(
"更新日期"
)
@TableField
(
"update_date"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@JsonIgnore
private
Date
updateDate
;
/**
* 是否删除
*/
@TableField
(
"is_deleted"
)
@JsonIgnore
private
Integer
isDeleted
;
/**
* 备注
*/
@TableField
(
"remark"
)
@JsonIgnore
private
String
remark
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/enity/DispatchContext.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
models
.
enity
;
package
com
.
jz
.
dm
.
models
.
enity
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -7,6 +9,7 @@ import java.util.Map;
...
@@ -7,6 +9,7 @@ import java.util.Map;
/**
/**
* Dispatch Context
* Dispatch Context
*/
*/
@Data
public
class
DispatchContext
implements
Serializable
{
public
class
DispatchContext
implements
Serializable
{
/**
/**
...
@@ -15,15 +18,10 @@ public class DispatchContext implements Serializable {
...
@@ -15,15 +18,10 @@ public class DispatchContext implements Serializable {
private
static
final
long
serialVersionUID
=
-
3448256355423553719L
;
private
static
final
long
serialVersionUID
=
-
3448256355423553719L
;
/**
/**
*
商户应用id
*
api唯一标识
*/
*/
private
String
appKey
;
private
String
appKey
;
/**
* 应用
*/
private
String
application
;
/**
/**
* openapi接口
* openapi接口
*/
*/
...
@@ -44,95 +42,6 @@ public class DispatchContext implements Serializable {
...
@@ -44,95 +42,6 @@ public class DispatchContext implements Serializable {
*/
*/
private
final
Map
<
String
,
Object
>
extAttributes
=
new
HashMap
<
String
,
Object
>();
private
final
Map
<
String
,
Object
>
extAttributes
=
new
HashMap
<
String
,
Object
>();
/**
* Getter method for property <tt>appId</tt>.
*
* @return property value of appId
*/
public
String
getAppKey
()
{
return
appKey
;
}
/**
* Setter method for property <tt>appId</tt>.
*
* @param appKey value to be assigned to property appId
*/
public
void
setAppKey
(
String
appKey
)
{
this
.
appKey
=
appKey
;
}
/**
* Getter method for property <tt>application</tt>.
*
* @return property value of application
*/
public
String
getApplication
()
{
return
application
;
}
/**
* Setter method for property <tt>application</tt>.
*
* @param application value to be assigned to property application
*/
public
void
setApplication
(
String
application
)
{
this
.
application
=
application
;
}
/**
* Getter method for property <tt>openApiMethod</tt>.
*
* @return property value of openApiMethod
*/
public
String
getOpenApiMethod
()
{
return
openApiMethod
;
}
/**
* Setter method for property <tt>openApiMethod</tt>.
*
* @param openApiMethod value to be assigned to property openApiMethod
*/
public
void
setOpenApiMethod
(
String
openApiMethod
)
{
this
.
openApiMethod
=
openApiMethod
;
}
/**
* Getter method for property <tt>openApiParams</tt>.
*
* @return property value of openApiParams
*/
public
String
getOpenApiParams
()
{
return
openApiParams
;
}
/**
* Setter method for property <tt>openApiParams</tt>.
*
* @param openApiParams value to be assigned to property openApiParams
*/
public
void
setOpenApiParams
(
String
openApiParams
)
{
this
.
openApiParams
=
openApiParams
;
}
/**
* Getter method for property <tt>openApiVersion</tt>.
*
* @return property value of openApiVersion
*/
public
String
getOpenApiVersion
()
{
return
openApiVersion
;
}
/**
* Setter method for property <tt>openApiVersion</tt>.
*
* @param openApiVersion value to be assigned to property openApiVersion
*/
public
void
setOpenApiVersion
(
String
openApiVersion
)
{
this
.
openApiVersion
=
openApiVersion
;
}
/**
/**
* 获取扩展属性
* 获取扩展属性
...
@@ -169,7 +78,7 @@ public class DispatchContext implements Serializable {
...
@@ -169,7 +78,7 @@ public class DispatchContext implements Serializable {
*/
*/
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"DispatchContext [
application="
+
application
+
",
openApiMethod="
+
openApiMethod
return
"DispatchContext [openApiMethod="
+
openApiMethod
+
", openApiParams="
+
openApiParams
+
", openApiVersion="
+
openApiVersion
+
"]"
;
+
", openApiParams="
+
openApiParams
+
", openApiVersion="
+
openApiVersion
+
"]"
;
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/enity/GatewayRequest.java
View file @
d7b311c3
...
@@ -2,6 +2,9 @@ package com.jz.dm.models.enity;
...
@@ -2,6 +2,9 @@ package com.jz.dm.models.enity;
import
com.jz.dm.web.annotation.ParamName
;
import
com.jz.dm.web.annotation.ParamName
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -9,261 +12,46 @@ import java.util.Map;
...
@@ -9,261 +12,46 @@ import java.util.Map;
/**
/**
* api请求
* api请求
*
* @author zc
* @author ZC
*/
*/
@ApiModel
(
"api请求实体类"
)
@Data
public
class
GatewayRequest
implements
Serializable
{
public
class
GatewayRequest
implements
Serializable
{
/**
* 分配的ID
*/
@ParamName
(
"app_key"
)
@ParamName
(
"app_key"
)
@ApiModelProperty
(
value
=
"appKey API唯一标识"
)
private
String
appKey
;
private
String
appKey
;
/**
@ApiModelProperty
(
value
=
"接口名称"
)
* 接口名称
*/
private
String
method
;
private
String
method
;
/**
@ApiModelProperty
(
value
=
"格式,目前仅支持JSON"
)
* 格式,目前仅支持JSON
*/
private
String
format
;
private
String
format
;
/**
/**
* 请求使用的编码格式,如UTF-8,GBK,GB2312等
* 请求使用的编码格式,如UTF-8,GBK,GB2312等
*/
*/
private
String
charset
;
//private String
charset;
/**
* 生成签名字符串所使用的签名算法类型
*/
@ParamName
(
"sign_type"
)
@ParamName
(
"sign_type"
)
@ApiModelProperty
(
value
=
"生成签名字符串所使用的签名算法类型"
)
private
String
signType
;
private
String
signType
;
/**
@ApiModelProperty
(
value
=
"请求参数的签名串"
)
* 请求参数的签名串
*/
private
String
sign
;
private
String
sign
;
/**
@ApiModelProperty
(
value
=
"发送请求的时间,格式yyyy-MM-dd HH:mm:ss"
)
* 发送请求的时间,格式"yyyy-MM-dd HH:mm:ss"
*/
private
String
timestamp
;
private
String
timestamp
;
/**
@ApiModelProperty
(
value
=
"调用的接口版本,固定为:1.0"
)
* 调用的接口版本,固定为:1.0
*/
private
String
version
;
private
String
version
;
/**
@ApiModelProperty
(
value
=
"请求参数,JSON格式"
)
* 请求参数,JSON格式
*/
private
String
params
;
private
String
params
;
/**
@ApiModelProperty
(
value
=
"扩展属性"
)
* 扩展属性
*/
private
final
Map
<
String
,
Attribute
>
extAttributes
=
new
HashMap
<
String
,
Attribute
>();
private
final
Map
<
String
,
Attribute
>
extAttributes
=
new
HashMap
<
String
,
Attribute
>();
/**
* Getter method for property <tt>appId</tt>.
*
* @return property value of appId
*/
public
String
getAppKey
()
{
return
appKey
;
}
/**
* Setter method for property <tt>appId</tt>.
*
* @param appKey value to be assigned to property appId
*/
public
void
setAppKey
(
String
appKey
)
{
this
.
appKey
=
appKey
;
}
/**
* Getter method for property <tt>method</tt>.
*
* @return property value of method
*/
public
String
getMethod
()
{
return
method
;
}
/**
* Setter method for property <tt>method</tt>.
*
* @param method value to be assigned to property method
*/
public
void
setMethod
(
String
method
)
{
this
.
method
=
method
;
}
/**
* Getter method for property <tt>format</tt>.
*
* @return property value of format
*/
public
String
getFormat
()
{
return
format
;
}
/**
* Setter method for property <tt>format</tt>.
*
* @param format value to be assigned to property format
*/
public
void
setFormat
(
String
format
)
{
this
.
format
=
format
;
}
/**
* Getter method for property <tt>charset</tt>.
*
* @return property value of charset
*/
public
String
getCharset
()
{
return
charset
;
}
/**
* Setter method for property <tt>charset</tt>.
*
* @param charset value to be assigned to property charset
*/
public
void
setCharset
(
String
charset
)
{
this
.
charset
=
charset
;
}
/**
* Getter method for property <tt>signType</tt>.
*
* @return property value of signType
*/
public
String
getSignType
()
{
return
signType
;
}
/**
* Setter method for property <tt>signType</tt>.
*
* @param signType value to be assigned to property signType
*/
public
void
setSignType
(
String
signType
)
{
this
.
signType
=
signType
;
}
/**
* Getter method for property <tt>sign</tt>.
*
* @return property value of sign
*/
public
String
getSign
()
{
return
sign
;
}
/**
* Setter method for property <tt>sign</tt>.
*
* @param sign value to be assigned to property sign
*/
public
void
setSign
(
String
sign
)
{
this
.
sign
=
sign
;
}
/**
* Getter method for property <tt>timestamp</tt>.
*
* @return property value of timestamp
*/
public
String
getTimestamp
()
{
return
timestamp
;
}
/**
* Setter method for property <tt>timestamp</tt>.
*
* @param timestamp value to be assigned to property timestamp
*/
public
void
setTimestamp
(
String
timestamp
)
{
this
.
timestamp
=
timestamp
;
}
/**
* Getter method for property <tt>version</tt>.
*
* @return property value of version
*/
public
String
getVersion
()
{
return
version
;
}
/**
* Setter method for property <tt>version</tt>.
*
* @param version value to be assigned to property version
*/
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
/**
* Getter method for property <tt>notifyUrl</tt>.
*
* @return property value of notifyUrl
*/
// public String getNotifyUrl() {
// return notifyUrl;
//}
/**
* Setter method for property <tt>notifyUrl</tt>.
*
* @param notifyUrl value to be assigned to property notifyUrl
*/
//public void setNotifyUrl(String notifyUrl) {
// this.notifyUrl = notifyUrl;
//}
/**
* Getter method for property <tt>returnUrl</tt>.
*
* @return property value of returnUrl
*/
//public String getReturnUrl() {
// return returnUrl;
//}
/**
* Setter method for property <tt>returnUrl</tt>.
*
* @param returnUrl value to be assigned to property returnUrl
*/
// public void setReturnUrl(String returnUrl) {
// this.returnUrl = returnUrl;
// }
/**
* Getter method for property <tt>params</tt>.
*
* @return property value of params
*/
public
String
getParams
()
{
return
params
;
}
/**
* Setter method for property <tt>params</tt>.
*
* @param params value to be assigned to property params
*/
public
void
setParams
(
String
params
)
{
this
.
params
=
params
;
}
/**
/**
* 获取扩展属性
* 获取扩展属性
*
*
...
@@ -301,7 +89,7 @@ public class GatewayRequest implements Serializable {
...
@@ -301,7 +89,7 @@ public class GatewayRequest implements Serializable {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"GatewayRequest [appKey="
+
appKey
+
", method="
+
method
+
", format="
+
format
return
"GatewayRequest [appKey="
+
appKey
+
", method="
+
method
+
", format="
+
format
+
",
charset="
+
charset
+
",
signType="
+
signType
+
", sign="
+
sign
+
", signType="
+
signType
+
", sign="
+
sign
+
", timestamp="
+
timestamp
+
", version="
+
version
+
", timestamp="
+
timestamp
+
", version="
+
version
+
", params="
+
params
+
", extAttributes="
+
", params="
+
params
+
", extAttributes="
+
extAttributes
+
"]"
;
+
extAttributes
+
"]"
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthDmpUserApiReq.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.enums.auth.AuthTypeEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -16,7 +14,7 @@ import java.util.Date;
...
@@ -16,7 +14,7 @@ import java.util.Date;
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @PROJECT_NAME: jz-dm-parent
* @NAME: Auth
Mall
UserApiReq
* @NAME: AuthUserApiReq
* @DATE: 2020-12-26/15:52
* @DATE: 2020-12-26/15:52
* @DAY_NAME_SHORT: 周六
* @DAY_NAME_SHORT: 周六
* @Description:
* @Description:
...
@@ -33,17 +31,17 @@ public class AuthDmpUserApiReq implements Serializable {
...
@@ -33,17 +31,17 @@ public class AuthDmpUserApiReq implements Serializable {
@NotNull
(
message
=
"组织编码不能为空"
)
@NotNull
(
message
=
"组织编码不能为空"
)
private
String
orgCode
;
private
String
orgCode
;
@ApiModelProperty
(
value
=
"组织类型: INT 内部, OUT 外部"
,
required
=
true
)
/*
@ApiModelProperty(value = "组织类型: INT 内部, OUT 外部",required = true)
@NotNull(message = "组织类型不能为空")
@NotNull(message = "组织类型不能为空")
private
String
orgType
;
private String orgType;
*/
@ApiModelProperty
(
value
=
"授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH dmp授权"
,
required
=
true
)
@ApiModelProperty
(
value
=
"授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH dmp授权"
,
required
=
true
)
@NotNull
(
message
=
"授权类型不能为空"
)
@NotNull
(
message
=
"授权类型不能为空"
)
private
AuthTypeEnum
authType
;
private
String
authType
;
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@NotNull
(
message
=
"授权方式不能为空"
)
@NotNull
(
message
=
"授权方式不能为空"
)
private
AuthModeEnum
authMode
;
private
String
authMode
;
@ApiModelProperty
(
value
=
"开始时间"
,
required
=
false
)
@ApiModelProperty
(
value
=
"开始时间"
,
required
=
false
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/Auth
Mall
UserApiReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthUserApiReq.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.enums.auth.AuthTypeEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -16,37 +14,37 @@ import java.util.Date;
...
@@ -16,37 +14,37 @@ import java.util.Date;
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @PROJECT_NAME: jz-dm-parent
* @NAME: Auth
Mall
UserApiReq
* @NAME: AuthUserApiReq
* @DATE: 2020-12-26/15:52
* @DATE: 2020-12-26/15:52
* @DAY_NAME_SHORT: 周六
* @DAY_NAME_SHORT: 周六
* @Description:
* @Description:
**/
**/
@Data
@Data
@ApiModel
(
"商城用户API认证"
)
@ApiModel
(
"商城用户API认证"
)
public
class
Auth
Mall
UserApiReq
implements
Serializable
{
public
class
AuthUserApiReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"apiKey唯一标识"
,
required
=
true
)
@ApiModelProperty
(
value
=
"apiKey唯一标识"
,
required
=
true
)
@NotNull
(
message
=
"apiKey唯一标识不能为空"
)
@NotNull
(
message
=
"apiKey唯一标识不能为空"
)
private
String
apiKey
;
private
String
apiKey
;
@ApiModelProperty
(
value
=
"组织类型: INT 内部, OUT 外部"
,
required
=
true
)
//
@ApiModelProperty(value = "组织类型: INT 内部, OUT 外部",required = true)
@NotNull
(
message
=
"组织类型不能为空"
)
//
@NotNull(message = "组织类型不能为空")
private
String
orgType
;
//
private String orgType;
@ApiModelProperty
(
value
=
"用户id"
,
required
=
false
)
@ApiModelProperty
(
value
=
"用户id
-- 数据银行认证时必传
"
,
required
=
false
)
private
String
userId
;
private
String
userId
;
@ApiModelProperty
(
value
=
"组织编码"
,
required
=
true
)
@ApiModelProperty
(
value
=
"组织编码"
,
required
=
true
)
@NotNull
(
message
=
"组织编码不能为空"
)
@NotNull
(
message
=
"组织编码不能为空"
)
private
String
orgCode
;
private
String
orgCode
;
@ApiModelProperty
(
value
=
"授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH
dmp
授权"
,
required
=
true
)
@ApiModelProperty
(
value
=
"授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH 授权"
,
required
=
true
)
@NotNull
(
message
=
"授权类型不能为空"
)
@NotNull
(
message
=
"授权类型不能为空"
)
private
AuthTypeEnum
authType
;
private
String
authType
;
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@NotNull
(
message
=
"授权方式不能为空"
)
@NotNull
(
message
=
"授权方式不能为空"
)
private
AuthModeEnum
authMode
;
private
String
authMode
;
@ApiModelProperty
(
value
=
"开始时间"
,
required
=
false
)
@ApiModelProperty
(
value
=
"开始时间"
,
required
=
false
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
View file @
d7b311c3
...
@@ -28,9 +28,7 @@ public class ApiInterfaceReq {
...
@@ -28,9 +28,7 @@ public class ApiInterfaceReq {
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
public
String
apiDesc
;
/*
@ApiModelProperty(value = "api版本",required = false)
public String version;*/
@ApiModelProperty
(
value
=
"传输方式"
,
required
=
true
)
@ApiModelProperty
(
value
=
"传输方式"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
@NotNull
(
message
=
"传输方式不能为空"
)
...
@@ -38,7 +36,11 @@ public class ApiInterfaceReq {
...
@@ -38,7 +36,11 @@ public class ApiInterfaceReq {
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@NotNull
(
message
=
"加密方式不能为空"
)
@NotNull
(
message
=
"加密方式不能为空"
)
public
String
type
;
public
String
signType
;
@ApiModelProperty
(
value
=
"接入类型:对应字典表key"
,
required
=
true
)
@NotNull
(
message
=
"接入类型不能为空"
)
public
String
joinType
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
true
)
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
true
)
@NotNull
(
message
=
"目标地址不能为空"
)
@NotNull
(
message
=
"目标地址不能为空"
)
...
@@ -51,8 +53,15 @@ public class ApiInterfaceReq {
...
@@ -51,8 +53,15 @@ public class ApiInterfaceReq {
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"列"
,
required
=
false
)
@ApiModelProperty
(
value
=
"文件Id"
,
required
=
true
)
public
String
columnCode
;
@NotNull
(
message
=
"文件id不能为空"
)
public
Long
fileId
;
@ApiModelProperty
(
value
=
"项目id"
,
required
=
true
)
@NotNull
(
message
=
"项目id不能为空"
)
public
Long
projectId
;
/*@ApiModelProperty(value = "api名称",required = false)
/*@ApiModelProperty(value = "api名称",required = false)
public String apiName;
public String apiName;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeCustomApiReq.java
deleted
100644 → 0
View file @
2eca6b14
package
com
.
jz
.
dm
.
models
.
req
.
make
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeCustomApiReq
* @DATE: 2020-12-26/13:01
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"制作自定义Api"
)
public
class
MakeCustomApiReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"api类型"
,
required
=
true
)
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
/* @ApiModelProperty(value = "apiId 等价于apiKey",required = true)
@NotNull(message = "apiId不能为空")
public String apiId;*/
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
/* @ApiModelProperty(value = "api版本",required = false)
public String version;*/
@ApiModelProperty
(
value
=
"传输方式"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
public
String
transMode
;
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@NotNull
(
message
=
"加密方式不能为空"
)
public
String
type
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
true
)
@NotNull
(
message
=
"目标地址不能为空"
)
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@NotNull
(
message
=
"超时时间不能为空"
)
public
String
timeout
;
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"列"
,
required
=
false
)
public
String
columnCode
;
/* @ApiModelProperty(value = "状态",required = false)
public String status;*/
@ApiModelProperty
(
value
=
"更新时传入api自增id"
,
required
=
false
)
public
Long
id
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
View file @
d7b311c3
...
@@ -24,23 +24,20 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -24,23 +24,20 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"api类型不能为空"
)
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
public
String
apiType
;
//@ApiModelProperty(value = "apiKey 等价于apiId",required = true)
//@NotNull(message = "apiKey不能为空")
//public String apiKey;
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
//@ApiModelProperty(value = "api版本",required = false)
//public String version;
@ApiModelProperty
(
value
=
"传输方式(1为HTTPS,2为HTTP)"
,
required
=
true
)
@ApiModelProperty
(
value
=
"传输方式(1为HTTPS,2为HTTP)"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
@NotNull
(
message
=
"传输方式不能为空"
)
public
String
apiProtocl
;
public
String
apiProtocl
;
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@NotNull
(
message
=
"加密方式不能为空"
)
@NotNull
(
message
=
"加密方式不能为空"
)
public
String
type
;
public
String
signType
;
@ApiModelProperty
(
value
=
"接入类型:对应字典表key"
,
required
=
true
)
@NotNull
(
message
=
"接入类型不能为空"
)
public
String
joinType
;
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
false
)
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
false
)
public
String
targetUrl
;
public
String
targetUrl
;
...
@@ -70,4 +67,11 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -70,4 +67,11 @@ public class MakeDataBankApiReq implements Serializable {
//@NotNull(message = "文件id不能为空")
//@NotNull(message = "文件id不能为空")
public
Long
fileId
;
public
Long
fileId
;
//-------------------------前端无效传参----------------------
//@ApiModelProperty(value = "状态",hidden = true)
//public String status;
//
//@ApiModelProperty(value = "创建用户",hidden = true)
//public String createUser;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageAddReq.java
View file @
d7b311c3
...
@@ -20,9 +20,9 @@ import java.io.Serializable;
...
@@ -20,9 +20,9 @@ import java.io.Serializable;
@ApiModel
(
"组织管理详情请求体"
)
@ApiModel
(
"组织管理详情请求体"
)
public
class
OrganizationManageAddReq
implements
Serializable
{
public
class
OrganizationManageAddReq
implements
Serializable
{
//@ApiModelProperty(value = "组织编码(组织唯一标识)
",required = true)
@ApiModelProperty
(
value
=
"组织类型:INT 内部组织 OUT 外部组织
"
,
required
=
true
)
//@NotNull(message = "组织编码不能为空
")
@NotNull
(
message
=
"组织类型不能为空!
"
)
//private String orgCod
e;
private
String
orgTyp
e
;
@ApiModelProperty
(
value
=
"组织名称"
,
required
=
true
)
@ApiModelProperty
(
value
=
"组织名称"
,
required
=
true
)
@NotNull
(
message
=
"组织名称不能为空"
)
@NotNull
(
message
=
"组织名称不能为空"
)
...
@@ -40,10 +40,6 @@ public class OrganizationManageAddReq implements Serializable {
...
@@ -40,10 +40,6 @@ public class OrganizationManageAddReq implements Serializable {
@ApiModelProperty
(
value
=
"组织电话"
,
required
=
false
)
@ApiModelProperty
(
value
=
"组织电话"
,
required
=
false
)
private
String
orgPhone
;
private
String
orgPhone
;
@ApiModelProperty
(
value
=
"组织类型"
,
required
=
true
)
@NotNull
(
message
=
"组织类型不能为空!"
)
private
String
orgType
;
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
private
String
remark
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageUpdateReq.java
View file @
d7b311c3
...
@@ -19,23 +19,30 @@ import java.io.Serializable;
...
@@ -19,23 +19,30 @@ import java.io.Serializable;
@Data
@Data
@ApiModel
(
"更新组织请求体"
)
@ApiModel
(
"更新组织请求体"
)
public
class
OrganizationManageUpdateReq
implements
Serializable
{
public
class
OrganizationManageUpdateReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
,
required
=
true
)
@ApiModelProperty
(
value
=
"id"
,
required
=
true
)
@NotNull
(
message
=
"id不能为空"
)
@NotNull
(
message
=
"id不能为空"
)
private
Long
id
;
private
Long
id
;
@ApiModelProperty
(
value
=
"组织名称"
,
required
=
true
)
/*
@ApiModelProperty(value = "组织名称",required = true)
@NotNull(message = "组织名称不能为空")
@NotNull(message = "组织名称不能为空")
private
String
orgName
;
private String orgName;
*/
@ApiModelProperty
(
value
=
"组织描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"组织描述"
,
required
=
false
)
private
String
orgDesc
;
private
String
orgDesc
;
@ApiModelProperty
(
value
=
"状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)"
,
required
=
false
)
private
String
status
;
@ApiModelProperty
(
value
=
"组织英文名称"
,
required
=
false
)
@ApiModelProperty
(
value
=
"组织英文名称"
,
required
=
false
)
private
String
orgCnName
;
private
String
orgCnName
;
@ApiModelProperty
(
value
=
"组织邮箱"
,
required
=
false
)
@ApiModelProperty
(
value
=
"组织邮箱"
,
required
=
false
)
private
String
orgMail
;
private
String
orgMail
;
@ApiModelProperty
(
value
=
"组织电话"
,
required
=
false
)
private
String
orgPhone
;
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
private
String
remark
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiDirectionService.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
service
;
import
com.jz.dm.models.domian.ApiDirection
;
import
java.util.List
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiDirectionService
* @DATE: 2020-12-31/18:00
* @DAY_NAME_SHORT: 周四
* @Description:
**/
public
interface
ApiDirectionService
{
/**
* 根据类型获取API类型信息
* @param parentCode
* @return
*/
List
<
ApiDirection
>
getApiType
(
String
parentCode
);
/**
* 查询code值信息
* @param code
* @param key
* @return
*/
List
<
ApiDirection
>
getDirectionVal
(
String
key
,
String
code
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ApiInterfaceService.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
service
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiInterfaceService
* @DATE: 2021-1-2/14:26
* @DAY_NAME_SHORT: 周六
* @Description:
**/
public
interface
ApiInterfaceService
{
/**
* 根据Api授权码获取用户授权信息
* @param apiKey
* @param authCode
* @return
*/
ApiAuth
getApiAuthInfo
(
String
apiKey
,
String
authCode
);
/**
* 获取api信息
* @param appKey
* @return
*/
ApiInterface
getApiInfo
(
String
appKey
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/AuthService.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
service
;
package
com
.
jz
.
dm
.
service
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.req.auth.*
;
import
com.jz.dm.models.req.auth.*
;
/**
/**
...
@@ -32,14 +33,14 @@ public interface AuthService {
...
@@ -32,14 +33,14 @@ public interface AuthService {
* @param req
* @param req
* @return
* @return
*/
*/
Result
addDmpUserApiAuth
(
Auth
Dmp
UserApiReq
req
);
Result
addDmpUserApiAuth
(
AuthUserApiReq
req
);
/**
/**
* 添加商城用户api认证
* 添加商城用户api认证
* @param req
* @param req
* @return
* @return
*/
*/
Result
addMallUserApiAuth
(
Auth
Mall
UserApiReq
req
);
Result
addMallUserApiAuth
(
AuthUserApiReq
req
);
/**
/**
* 修改认证信息
* 修改认证信息
...
@@ -54,4 +55,11 @@ public interface AuthService {
...
@@ -54,4 +55,11 @@ public interface AuthService {
* @return
* @return
*/
*/
Result
updateSaltInfo
(
SaltResetReq
req
);
Result
updateSaltInfo
(
SaltResetReq
req
);
/**
* 获取API授权信息
* @param authCode
* @return
*/
ApiAuth
getAuthUser
(
String
authCode
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/OrganizationManageService.java
View file @
d7b311c3
...
@@ -52,4 +52,11 @@ public interface OrganizationManageService {
...
@@ -52,4 +52,11 @@ public interface OrganizationManageService {
* @return
* @return
*/
*/
Result
delete
(
Long
id
);
Result
delete
(
Long
id
);
/**
* 获取认证组织信息
* @param apiOrgId
* @return
*/
ApiOrg
getAuthOrganization
(
Long
apiOrgId
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/ProducerService.java
View file @
d7b311c3
...
@@ -20,7 +20,7 @@ public interface ProducerService {
...
@@ -20,7 +20,7 @@ public interface ProducerService {
* @param req
* @param req
* @return
* @return
*/
*/
Result
addCustomApi
(
MakeCustomApi
Req
req
);
Result
addCustomApi
(
ApiInterface
Req
req
);
/**
/**
* Api制作(实时接入)
* Api制作(实时接入)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiDirectionServiceImpl.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.jz.dm.common.enums.GeneralStatusTypeEnum
;
import
com.jz.dm.mapper.ApiDirectionMapper
;
import
com.jz.dm.models.domian.ApiDirection
;
import
com.jz.dm.service.ApiDirectionService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiDirectionServiceImpl
* @DATE: 2020-12-31/18:01
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Service
(
"apiDirectionService"
)
@Slf4j
public
class
ApiDirectionServiceImpl
implements
ApiDirectionService
{
@Resource
private
ApiDirectionMapper
apiDirectionMapper
;
@Override
public
List
<
ApiDirection
>
getApiType
(
String
parentCode
)
{
QueryWrapper
<
ApiDirection
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"parent"
,
parentCode
);
//父类下的所有子类
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
return
apiDirectionMapper
.
selectList
(
query
);
}
@Override
public
List
<
ApiDirection
>
getDirectionVal
(
String
key
,
String
code
)
{
QueryWrapper
<
ApiDirection
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
key
)
&&
StringUtils
.
isNotBlank
(
code
)){
query
.
eq
(
"key"
,
key
);
query
.
eq
(
"code"
,
code
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
}
else
if
(
StringUtils
.
isNotBlank
(
code
)){
query
.
eq
(
"key"
,
key
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
}
else
{
query
.
eq
(
"code"
,
code
);
query
.
eq
(
"is_enabled"
,
GeneralStatusTypeEnum
.
ENABLE
);
}
return
apiDirectionMapper
.
selectList
(
query
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.service.ApiInterfaceService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiInterfaceServiceImpl
* @DATE: 2021-1-2/14:27
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Service
(
"apiInterfaceService"
)
@Slf4j
public
class
ApiInterfaceServiceImpl
implements
ApiInterfaceService
{
@Resource
private
ApiInterfaceMapper
apiInterfaceMapper
;
@Resource
private
ApiAuthMapper
apiAuthMapper
;
/**
* 获取用户授权信息
* @param apiKey
* @param authCode
* @return
*/
@Override
public
ApiAuth
getApiAuthInfo
(
String
apiKey
,
String
authCode
)
{
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"api_key"
,
apiKey
);
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectOne
(
query
);
if
(
null
!=
apiInterface
){
QueryWrapper
<
ApiAuth
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"is_deleted"
,
0
);
queryWrapper
.
eq
(
"auth_code"
,
authCode
);
ApiAuth
apiAuth
=
apiAuthMapper
.
selectOne
(
queryWrapper
);
if
(
null
!=
apiAuth
){
return
apiAuth
;
}
}
return
null
;
}
/**
* 获取API信息
* @param appKey
* @return
*/
@Override
public
ApiInterface
getApiInfo
(
String
appKey
)
{
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"api_key"
,
appKey
);
return
apiInterfaceMapper
.
selectOne
(
query
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
View file @
d7b311c3
...
@@ -45,6 +45,7 @@ public class ApiLogServiceImpl implements ApiLogService {
...
@@ -45,6 +45,7 @@ public class ApiLogServiceImpl implements ApiLogService {
public
IPage
<
ApiReqLog
>
listApiLog
(
LogInfoListReq
req
)
{
public
IPage
<
ApiReqLog
>
listApiLog
(
LogInfoListReq
req
)
{
IPage
<
ApiReqLog
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
IPage
<
ApiReqLog
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiReqLog
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiReqLog
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"is_deleted"
,
0
);
query
.
orderByDesc
(
"create_date"
);
query
.
orderByDesc
(
"create_date"
);
return
apiReqLogMapper
.
selectPage
(
page
,
query
);
return
apiReqLogMapper
.
selectPage
(
page
,
query
);
}
}
...
@@ -76,14 +77,12 @@ public class ApiLogServiceImpl implements ApiLogService {
...
@@ -76,14 +77,12 @@ public class ApiLogServiceImpl implements ApiLogService {
*/
*/
@Override
@Override
public
void
updateLog
(
Long
id
,
JSONObject
jsonObject
)
{
public
void
updateLog
(
Long
id
,
JSONObject
jsonObject
)
{
//if (!lock.tryLock("apiLog")){
// return;
//}
try
{
try
{
ApiReqLog
apiReqLog
=
apiReqLogMapper
.
maxId
(
id
);
ApiReqLog
apiReqLog
=
apiReqLogMapper
.
maxId
(
id
);
if
(
null
!=
apiReqLog
){
if
(
null
!=
apiReqLog
){
ApiReqLog
reqLog
=
new
ApiReqLog
();
ApiReqLog
reqLog
=
new
ApiReqLog
();
reqLog
.
setId
(
apiReqLog
.
getId
());
reqLog
.
setId
(
apiReqLog
.
getId
());
reqLog
.
setStatus
(
apiReqLog
.
getStatus
());
reqLog
.
setResponseParams
(
jsonObject
.
toString
());
reqLog
.
setResponseParams
(
jsonObject
.
toString
());
reqLog
.
setUpdateDate
(
new
Date
());
reqLog
.
setUpdateDate
(
new
Date
());
apiReqLogMapper
.
updateById
(
reqLog
);
apiReqLogMapper
.
updateById
(
reqLog
);
...
@@ -93,9 +92,5 @@ public class ApiLogServiceImpl implements ApiLogService {
...
@@ -93,9 +92,5 @@ public class ApiLogServiceImpl implements ApiLogService {
}
catch
(
Exception
ex
){
}
catch
(
Exception
ex
){
log
.
error
(
"更新日志返回信息异常:{}"
,
ex
.
getMessage
());
log
.
error
(
"更新日志返回信息异常:{}"
,
ex
.
getMessage
());
}
}
//finally {
// lock.unlock("apiLog");
//}
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
d7b311c3
...
@@ -7,8 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -7,8 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.enums.GeneralStatusTypeEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.enums.auth.AuthTypeEnum
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
...
@@ -30,6 +30,9 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -30,6 +30,9 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.Date
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthModeEnum
.
fromTypeModeName
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthTypeEnum
.
fromTypeName
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PACKAGE_NAME: com.jz.dm.service.impl
...
@@ -61,6 +64,7 @@ public class AuthServiceImpl implements AuthService {
...
@@ -61,6 +64,7 @@ public class AuthServiceImpl implements AuthService {
public
Result
getAuthListInfo
(
AuthListInfoReq
req
)
{
public
Result
getAuthListInfo
(
AuthListInfoReq
req
)
{
IPage
<
AuthInfoDto
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
IPage
<
AuthInfoDto
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
AuthInfoDto
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
AuthInfoDto
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"au.is_deleted"
,
0
);
query
.
orderByDesc
(
"au.create_date"
);
query
.
orderByDesc
(
"au.create_date"
);
IPage
<
AuthInfoDto
>
listSelectApiAuth
=
apiAuthMapper
.
listSelectApiAuth
(
page
,
query
);
IPage
<
AuthInfoDto
>
listSelectApiAuth
=
apiAuthMapper
.
listSelectApiAuth
(
page
,
query
);
return
Result
.
of_success
(
listSelectApiAuth
);
return
Result
.
of_success
(
listSelectApiAuth
);
...
@@ -85,8 +89,7 @@ public class AuthServiceImpl implements AuthService {
...
@@ -85,8 +89,7 @@ public class AuthServiceImpl implements AuthService {
*/
*/
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
addDmpUserApiAuth
(
AuthDmpUserApiReq
req
)
{
public
Result
addDmpUserApiAuth
(
AuthUserApiReq
req
)
{
AuthUserResponse
response
=
new
AuthUserResponse
();
ApiInterface
apiInterface
=
getInterface
(
req
.
getApiKey
());
ApiInterface
apiInterface
=
getInterface
(
req
.
getApiKey
());
if
(
null
==
apiInterface
)
{
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
"api授权信息不存在!"
);
return
Result
.
of_error
(
"api授权信息不存在!"
);
...
@@ -96,44 +99,26 @@ public class AuthServiceImpl implements AuthService {
...
@@ -96,44 +99,26 @@ public class AuthServiceImpl implements AuthService {
return
Result
.
of_error
(
"组织信息不存在!"
);
return
Result
.
of_error
(
"组织信息不存在!"
);
}
}
//授权验证
//授权验证
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
()
.
name
())
&&
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
()
)){
!
AuthTypeEnum
.
DMP_AUTH
.
name
().
equals
(
req
.
getAuthType
().
name
()))
{
if
(
null
==
fromTypeName
(
req
.
getAuthType
()))
{
return
Result
.
of_error
(
"授权类型错误
!"
);
return
Result
.
of_error
(
"授权类型不存在
!"
);
}
}
//认证类型
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
().
name
())
&&
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
().
name
()))
{
if
(
null
==
req
.
getValidStartTime
()
||
null
==
req
.
getValidEndTime
())
{
return
Result
.
of_error
(
"开始或结束时间不能为空!"
);
}
}
//验证授权方式
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
())){
if
(
null
==
fromTypeModeName
(
req
.
getAuthMode
())){
return
Result
.
of_error
(
"授权方式不存在!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
().
name
())
&&
AuthModeEnum
.
POWER_CALL_MODE
.
name
().
equals
(
req
.
getAuthMode
()))
{
return
Result
.
of_error
(
"授权类型错误!"
);
}
}
String
authCode
=
""
;
//认证类型为永久授权
ApiAuth
apiAuth
=
new
ApiAuth
();
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
())
&&
apiAuth
.
setAuthType
(
req
.
getAuthType
().
name
());
!
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
()))
{
apiAuth
.
setAuthMode
(
req
.
getAuthMode
().
name
());
return
Result
.
of_error
(
"授权类型错误!"
);
apiAuth
.
setApiInterfaceId
(
apiInterface
.
getId
());
apiAuth
.
setApiOrgId
(
apiOrg
.
getId
());
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
apiAuth
.
setApiInterfaceId
(
apiInterface
.
getId
());
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
())
//内部组织
&&
Constants
.
AUTH_INT
.
equalsIgnoreCase
(
req
.
getOrgType
()))
{
authCode
=
getAuthCode
(
apiOrg
.
getOrgCode
(),
""
,
Constants
.
AUTH_INT
);
}
}
apiAuth
.
setAuthCode
(
authCode
);
//授权码
if
(
StringUtils
.
isBlank
(
apiOrg
.
getOrgCode
())){
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
return
Result
.
of_error
(
"内部授权组织编码不能为空!!"
);
apiAuth
.
setSalt
(
salt
);
//盐值
apiAuth
.
setStatus
(
"1"
);
//授权状态
apiAuth
.
setCreateUser
(
""
);
apiAuth
.
setRemark
(
req
.
getRemark
());
response
.
setAuthCode
(
authCode
);
response
.
setSalt
(
salt
);
if
(
apiAuthMapper
.
insert
(
apiAuth
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
,
response
);
}
}
return
Result
.
of_success
(
ResultMsg
.
FAILURE
);
return
saveAuthInfo
(
apiInterface
,
apiOrg
,
req
,
Constants
.
AUTH_INT
);
}
}
/**
/**
...
@@ -144,8 +129,7 @@ public class AuthServiceImpl implements AuthService {
...
@@ -144,8 +129,7 @@ public class AuthServiceImpl implements AuthService {
*/
*/
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
addMallUserApiAuth
(
AuthMallUserApiReq
req
)
{
public
Result
addMallUserApiAuth
(
AuthUserApiReq
req
)
{
AuthUserResponse
response
=
new
AuthUserResponse
();
ApiInterface
apiInterface
=
getInterface
(
req
.
getApiKey
());
ApiInterface
apiInterface
=
getInterface
(
req
.
getApiKey
());
if
(
null
==
apiInterface
)
{
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
"api授权信息不存在!"
);
return
Result
.
of_error
(
"api授权信息不存在!"
);
...
@@ -155,48 +139,74 @@ public class AuthServiceImpl implements AuthService {
...
@@ -155,48 +139,74 @@ public class AuthServiceImpl implements AuthService {
return
Result
.
of_error
(
"组织信息不存在!"
);
return
Result
.
of_error
(
"组织信息不存在!"
);
}
}
//授权验证
//授权验证
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
().
name
())
&&
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
())){
!
AuthTypeEnum
.
DATA_BANK_AUTH
.
name
().
equals
(
req
.
getAuthType
().
name
()))
{
if
(
null
==
fromTypeName
(
req
.
getAuthType
())){
return
Result
.
of_error
(
"授权类型不存在!"
);
}
}
//验证授权方式
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
())){
if
(
null
==
fromTypeModeName
(
req
.
getAuthMode
())){
return
Result
.
of_error
(
"授权方式不存在!"
);
}
}
//认证类型为永久授权
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
())
&&
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
()))
{
return
Result
.
of_error
(
"授权类型错误!"
);
return
Result
.
of_error
(
"授权类型错误!"
);
}
}
//认证类型
//认证类型
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
().
name
())
&&
AuthModeEnum
.
RECORD_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
().
name
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
())
&&
AuthModeEnum
.
RECORD_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
())){
if
(
null
==
req
.
getValidStartTime
()
||
null
==
req
.
getValidEndTime
())
{
if
(
null
==
req
.
getValidStartTime
()
||
null
==
req
.
getValidEndTime
())
{
return
Result
.
of_error
(
"开始或结束时间不能为空!"
);
return
Result
.
of_error
(
"开始或结束时间不能为空!"
);
}
}
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
().
name
())
&&
//验证用户id
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
().
name
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getUserId
()))
{
return
Result
.
of_error
(
"授权类型错误!
"
);
return
Result
.
of_error
(
"外部授权用户Id不能为空
"
);
}
}
String
authCode
=
""
;
return
saveAuthInfo
(
apiInterface
,
apiOrg
,
req
,
Constants
.
AUTH_OUT
);
}
/**
* 保存授权信息
* @param apiInterface
* @param apiOrg
* @param req
* @param orgType
* @return
*/
private
Result
saveAuthInfo
(
ApiInterface
apiInterface
,
ApiOrg
apiOrg
,
AuthUserApiReq
req
,
String
orgType
){
AuthUserResponse
response
=
new
AuthUserResponse
();
ApiAuth
apiAuth
=
new
ApiAuth
();
ApiAuth
apiAuth
=
new
ApiAuth
();
apiAuth
.
setAuthType
(
req
.
getAuthType
().
name
());
apiAuth
.
setAuthMode
(
req
.
getAuthMode
().
name
());
apiAuth
.
setApiInterfaceId
(
apiInterface
.
getId
());
apiAuth
.
setApiInterfaceId
(
apiInterface
.
getId
());
apiAuth
.
setApiOrgId
(
apiOrg
.
getId
());
apiAuth
.
setApiOrgId
(
apiOrg
.
getId
());
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
())
//内部组织
//商城只有外部授权
&&
Constants
.
AUTH_INT
.
equalsIgnoreCase
(
req
.
getOrgType
()))
{
String
authCode
=
""
;
//内部组织
if
(
StringUtils
.
isNotBlank
(
orgType
)
&&
Constants
.
AUTH_INT
.
equalsIgnoreCase
(
orgType
))
{
authCode
=
getAuthCode
(
apiOrg
.
getOrgCode
(),
""
,
Constants
.
AUTH_INT
);
authCode
=
getAuthCode
(
apiOrg
.
getOrgCode
(),
""
,
Constants
.
AUTH_INT
);
}
else
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
())
//外部组织
//外部组织
&&
Constants
.
AUTH_OUT
.
equalsIgnoreCase
(
req
.
getOrgType
()))
{
}
else
if
(
StringUtils
.
isNotBlank
(
orgType
)
&&
Constants
.
AUTH_OUT
.
equalsIgnoreCase
(
orgType
))
{
authCode
=
getAuthCode
(
""
,
req
.
getUserId
(),
Constants
.
AUTH_OUT
);
authCode
=
getAuthCode
(
""
,
req
.
getUserId
(),
Constants
.
AUTH_OUT
);
}
}
apiAuth
.
setAuthCode
(
authCode
);
//授权码
//生成盐值
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
apiAuth
.
setAuthCode
(
authCode
);
//授权码
apiAuth
.
setSalt
(
salt
);
//盐值
apiAuth
.
setSalt
(
salt
);
//盐值
apiAuth
.
setStatus
(
"1"
);
//授权状态
apiAuth
.
setStatus
(
GeneralStatusTypeEnum
.
VALID
.
name
()
);
//授权状态
apiAuth
.
setCreateUser
(
""
);
apiAuth
.
setCreateUser
(
""
);
apiAuth
.
setRemark
(
req
.
getRemark
());
response
.
setAuthCode
(
authCode
);
response
.
setAuthCode
(
authCode
);
response
.
setSalt
(
salt
);
response
.
setSalt
(
salt
);
if
(
apiAuthMapper
.
insert
(
apiAuth
)
>
0
)
{
if
(
apiAuthMapper
.
insert
(
apiAuth
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
,
response
);
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
,
response
);
}
}
return
Result
.
of_success
(
ResultMsg
.
FAILURE
,
response
);
return
Result
.
of_error
(
ResultMsg
.
INSERT_FAIL
);
}
}
/**
/**
* 获取授权码
* 获取授权码
* @param type
* @param type
...
@@ -244,7 +254,7 @@ public class AuthServiceImpl implements AuthService {
...
@@ -244,7 +254,7 @@ public class AuthServiceImpl implements AuthService {
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
UpdateWrapper
<
ApiAuth
>
update
=
new
UpdateWrapper
<>();
UpdateWrapper
<
ApiAuth
>
update
=
new
UpdateWrapper
<>();
update
.
set
(
"salt"
,
salt
);
update
.
set
(
"salt"
,
salt
);
update
.
set
(
"create_
tim
e"
,
new
Date
());
update
.
set
(
"create_
dat
e"
,
new
Date
());
update
.
set
(
"create_user"
,
""
);
update
.
set
(
"create_user"
,
""
);
update
.
eq
(
"id"
,
req
.
getId
());
update
.
eq
(
"id"
,
req
.
getId
());
if
(
apiAuthMapper
.
update
(
null
,
update
)
>
0
)
{
if
(
apiAuthMapper
.
update
(
null
,
update
)
>
0
)
{
...
@@ -254,6 +264,19 @@ public class AuthServiceImpl implements AuthService {
...
@@ -254,6 +264,19 @@ public class AuthServiceImpl implements AuthService {
return
Result
.
of_success
(
ResultMsg
.
UPDATE_FAIL
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_FAIL
);
}
}
/**
* 获取API授权信息
* @param authCode
* @return
*/
@Override
public
ApiAuth
getAuthUser
(
String
authCode
)
{
QueryWrapper
<
ApiAuth
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"auth_code"
,
authCode
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiAuthMapper
.
selectOne
(
query
);
}
private
ApiInterface
getInterface
(
String
apiKey
)
{
private
ApiInterface
getInterface
(
String
apiKey
)
{
QueryWrapper
<
ApiInterface
>
queryInface
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterface
>
queryInface
=
new
QueryWrapper
<>();
queryInface
.
last
(
"where is_deleted=0 and api_key ='"
+
apiKey
+
"'"
);
queryInface
.
last
(
"where is_deleted=0 and api_key ='"
+
apiKey
+
"'"
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
service
.
impl
;
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.bean.SysUserDto
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.enums.org.OrgStatusEnum
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.mapper.ApiOrgMapper
;
import
com.jz.dm.mapper.ApiOrgMapper
;
import
com.jz.dm.models.domian.ApiOrg
;
import
com.jz.dm.models.domian.ApiOrg
;
...
@@ -25,6 +25,8 @@ import org.springframework.stereotype.Service;
...
@@ -25,6 +25,8 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.Date
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
org
.
OrgStatusEnum
.
fromTypeName
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PACKAGE_NAME: com.jz.dm.service.impl
...
@@ -53,6 +55,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -53,6 +55,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
public
IPage
<
ApiOrg
>
listOrganization
(
OrganizationManageListQueryReq
req
)
{
public
IPage
<
ApiOrg
>
listOrganization
(
OrganizationManageListQueryReq
req
)
{
IPage
<
ApiOrg
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
IPage
<
ApiOrg
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"is_deleted"
,
0
);
query
.
orderByDesc
(
"create_date"
);
query
.
orderByDesc
(
"create_date"
);
return
apiOrgMapper
.
selectPage
(
page
,
query
);
return
apiOrgMapper
.
selectPage
(
page
,
query
);
}
}
...
@@ -65,7 +68,10 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -65,7 +68,10 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/
*/
@Override
@Override
public
Result
getOrganizationDetail
(
OrganizationManageDetailQueryReq
req
)
{
public
Result
getOrganizationDetail
(
OrganizationManageDetailQueryReq
req
)
{
return
Result
.
of_success
(
apiOrgMapper
.
selectById
(
req
.
getId
()));
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"id"
,
req
.
getId
());
return
Result
.
of_success
(
apiOrgMapper
.
selectOne
(
query
));
}
}
/**
/**
...
@@ -76,14 +82,14 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -76,14 +82,14 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/
*/
@Override
@Override
public
Result
add
(
OrganizationManageAddReq
req
)
{
public
Result
add
(
OrganizationManageAddReq
req
)
{
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"user"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
/*
SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS);
if (null == currentUser){
if (null == currentUser){
return Result.of_error(ResultMsg.USER_NOT_EXIST);
return Result.of_error(ResultMsg.USER_NOT_EXIST);
}
}
*/
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
ApiOrg
orgNameInfo
=
getOrgNameInfo
(
req
.
getOrgName
());
ApiOrg
orgNameInfo
=
getOrgNameInfo
(
req
.
getOrgName
());
if
(
null
!=
orgNameInfo
)
{
if
(
null
!=
orgNameInfo
)
{
return
Result
.
of_error
(
"组织名称已存在"
);
return
Result
.
of_error
(
"组织名称已存在
!
"
);
}
}
}
}
String
coding
=
""
;
String
coding
=
""
;
...
@@ -98,9 +104,9 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -98,9 +104,9 @@ public class OrganizationManageImpl implements OrganizationManageService {
if
(
StringUtils
.
isBlank
(
coding
))
{
if
(
StringUtils
.
isBlank
(
coding
))
{
return
Result
.
of_error
(
"生成组织编码异常!"
);
return
Result
.
of_error
(
"生成组织编码异常!"
);
}
}
apiOrg
.
setOrgCode
(
coding
);
//组织编码
需要生成
apiOrg
.
setOrgCode
(
coding
);
//组织编码
apiOrg
.
setStatus
(
"1"
);
//正常
apiOrg
.
setStatus
(
OrgStatusEnum
.
NORMAL
.
name
()
);
//正常
apiOrg
.
setCreateUser
(
currentUser
.
getUserName
());
//
apiOrg.setCreateUser(currentUser.getUserName());
if
(
apiOrgMapper
.
insert
(
apiOrg
)
>
0
)
{
if
(
apiOrgMapper
.
insert
(
apiOrg
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
}
...
@@ -109,6 +115,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -109,6 +115,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
/**
/**
* 获取组织编码(去重)
* 获取组织编码(去重)
*
* @param orgName 组织名称
* @param orgName 组织名称
* @param type 生成类型
* @param type 生成类型
* @return
* @return
...
@@ -127,30 +134,29 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -127,30 +134,29 @@ public class OrganizationManageImpl implements OrganizationManageService {
/**
/**
* 更新组织
* 更新组织
*
* @param req
* @param req
* @return
* @return
*/
*/
@Override
@Override
public
Result
update
(
OrganizationManageUpdateReq
req
)
{
public
Result
update
(
OrganizationManageUpdateReq
req
)
{
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"user"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
/* SysUserDto currentUser = (SysUserDto) redisTemplate.opsForValue().get("user"
+ RedisMessageConstant.SENDTYPE_LOGIN_SYS);
if
(
null
==
currentUser
){
if (null == currentUser)
{
return Result.of_error(ResultMsg.USER_NOT_EXIST);
return Result.of_error(ResultMsg.USER_NOT_EXIST);
}
}
*/
ApiOrg
apiOrg
=
apiOrgMapper
.
selectById
(
req
.
getId
());
ApiOrg
apiOrg
=
apiOrgMapper
.
selectById
(
req
.
getId
());
if
(
null
==
apiOrg
)
{
if
(
null
==
apiOrg
)
{
return
Result
.
of_error
(
"组织信息不存在!"
);
return
Result
.
of_error
(
"组织信息不存在!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
()))
{
ApiOrg
orgNameInfo
=
getOrgNameInfo
(
req
.
getOrgName
());
if
(
null
==
fromTypeName
(
req
.
getStatus
())){
if
(
null
!=
orgNameInfo
)
{
return
Result
.
of_error
(
"更新组织状态不存在!"
);
return
Result
.
of_error
(
"组织名称已存在"
);
}
}
}
}
ApiOrg
apiOrgUpdate
=
new
ApiOrg
();
ApiOrg
apiOrgUpdate
=
new
ApiOrg
();
apiOrgUpdate
.
setId
(
apiOrg
.
getId
());
BeanUtils
.
copyProperties
(
req
,
apiOrgUpdate
);
BeanUtils
.
copyProperties
(
req
,
apiOrgUpdate
);
apiOrgUpdate
.
setUpdateDate
(
new
Date
());
apiOrgUpdate
.
setUpdateDate
(
new
Date
());
apiOrgUpdate
.
setUpdateUser
(
currentUser
.
getUserName
());
//
apiOrgUpdate.setUpdateUser(currentUser.getUserName());
if
(
apiOrgMapper
.
updateById
(
apiOrgUpdate
)
>
0
)
{
if
(
apiOrgMapper
.
updateById
(
apiOrgUpdate
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
}
...
@@ -159,6 +165,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -159,6 +165,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
/**
/**
* 删除组织
* 删除组织
*
* @param id
* @param id
* @return
* @return
*/
*/
...
@@ -168,12 +175,28 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -168,12 +175,28 @@ public class OrganizationManageImpl implements OrganizationManageService {
if
(
null
==
apiOrg
)
{
if
(
null
==
apiOrg
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
}
}
if
(
apiOrgMapper
.
deleteById
(
id
)
>
0
)
{
UpdateWrapper
<
ApiOrg
>
delete
=
new
UpdateWrapper
<>();
delete
.
set
(
"is_deleted"
,
1
);
delete
.
eq
(
"id"
,
id
);
if
(
apiOrgMapper
.
update
(
null
,
delete
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
DELETE_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
DELETE_SUCCESS
);
}
}
return
Result
.
of_success
(
ResultMsg
.
DELETE_FAIL
);
return
Result
.
of_success
(
ResultMsg
.
DELETE_FAIL
);
}
}
/**
* 获取认证组织信息
* @param apiOrgId
* @return
*/
@Override
public
ApiOrg
getAuthOrganization
(
Long
apiOrgId
)
{
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"id"
,
apiOrgId
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiOrgMapper
.
selectOne
(
query
);
}
/**
/**
* 根据名称获取组织信息
* 根据名称获取组织信息
*
*
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
d7b311c3
...
@@ -9,12 +9,14 @@ import com.jz.common.bean.SysUserDto;
...
@@ -9,12 +9,14 @@ import com.jz.common.bean.SysUserDto;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.exception.ResponseException
;
import
com.jz.common.exception.ResponseException
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.constant.TagConstants
;
import
com.jz.dm.common.constant.TagConstants
;
import
com.jz.dm.common.enums.GeneralStatusTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.produce.ProducerStatusTypeEnum
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.common.util.RandomUtil
;
import
com.jz.dm.common.util.WebUtils
;
import
com.jz.dm.mapper.*
;
import
com.jz.dm.mapper.*
;
import
com.jz.dm.models.domian.*
;
import
com.jz.dm.models.domian.*
;
import
com.jz.dm.models.req.make.*
;
import
com.jz.dm.models.req.make.*
;
...
@@ -33,7 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -33,7 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.*
;
import
static
com
.
jz
.
dm
.
common
.
base
.
BaseCurrentUserObject
.
getUserInfo
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
apiInterface
.
ApiStatusEnum
.
fromApiStatusName
;
/**
/**
* @author ZC
* @author ZC
...
@@ -64,6 +66,8 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -64,6 +66,8 @@ public class ProducerServiceImpl implements ProducerService {
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@Autowired
@Autowired
private
RedisUtils
redisUtils
;
private
RedisUtils
redisUtils
;
@Autowired
private
HttpsUtils
httpsUtils
;
@Value
(
"${dmp.openapi.timeout.max}"
)
@Value
(
"${dmp.openapi.timeout.max}"
)
private
int
maxTimeout
;
private
int
maxTimeout
;
...
@@ -76,17 +80,19 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -76,17 +80,19 @@ public class ProducerServiceImpl implements ProducerService {
/**
/**
* 获取文件列表
* 获取文件列表
*
* @param pageSize
* @param pageSize
* @param pageNum
* @param pageNum
* @return
* @return
*/
*/
@Override
@Override
public
IPage
<
ApiInterfaceFile
>
getFileCatalog
(
String
pageNum
,
String
pageSize
)
{
public
IPage
<
ApiInterfaceFile
>
getFileCatalog
(
String
pageNum
,
String
pageSize
)
{
Integer
pageN
=
Integer
.
valueOf
(
pageNum
);
Integer
pageN
=
Integer
.
valueOf
(
pageNum
);
Integer
pageS
=
Integer
.
valueOf
(
pageSize
);
Integer
pageS
=
Integer
.
valueOf
(
pageSize
);
IPage
<
ApiInterfaceFile
>
page
=
new
Page
<>(
pageN
,
pageS
);
IPage
<
ApiInterfaceFile
>
page
=
new
Page
<>(
pageN
,
pageS
);
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
query
.
orderByDesc
(
"create_time"
);
query
.
eq
(
"is_deleted"
,
0
);
query
.
orderByDesc
(
"create_date"
);
return
apiInterfaceFileMapper
.
selectPage
(
page
,
query
);
return
apiInterfaceFileMapper
.
selectPage
(
page
,
query
);
}
}
...
@@ -97,66 +103,55 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -97,66 +103,55 @@ public class ProducerServiceImpl implements ProducerService {
* @return
* @return
*/
*/
@Override
@Override
public
Result
addCustomApi
(
MakeCustomApiReq
req
)
{
public
Result
addCustomApi
(
ApiInterfaceReq
req
)
{
ApiInterfaceReq
makeBigDataApiReq
=
new
ApiInterfaceReq
();
return
saveInterfaceAPi
(
req
);
makeBigDataApiReq
.
setApiType
(
req
.
getApiType
());
makeBigDataApiReq
.
setApiDesc
(
req
.
getApiDesc
());
makeBigDataApiReq
.
setTransMode
(
req
.
getTransMode
());
makeBigDataApiReq
.
setType
(
req
.
getType
());
makeBigDataApiReq
.
setTargetUrl
(
req
.
getTargetUrl
());
makeBigDataApiReq
.
setTimeout
(
req
.
getTimeout
());
makeBigDataApiReq
.
setApiFunction
(
req
.
getApiFunction
());
makeBigDataApiReq
.
setColumnCode
(
req
.
getColumnCode
());
return
saveInterfaceAPi
(
makeBigDataApiReq
);
}
}
/**
/**
* 数据银行制作API/数据包
* 数据银行制作API/数据包
*
* @param req
* @param req
* @return
* @return
*/
*/
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
)
{
public
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
)
{
List
<
ApiInterfaceFile
>
fileSource
=
apiInterfaceFileMapper
.
selectList
(
new
QueryWrapper
<
ApiInterfaceFile
>().
eq
(
"file_source"
,
"2"
));
List
<
ApiInterfaceFile
>
fileSource
=
apiInterfaceFileMapper
.
selectList
(
new
QueryWrapper
<
ApiInterfaceFile
>().
eq
(
"file_source"
,
"2"
));
if
(
fileSource
.
size
()
==
0
||
fileSource
.
size
()
>=
2
){
if
(
fileSource
.
size
()
==
0
||
fileSource
.
size
()
>=
2
)
{
return
Result
.
of_error
(
"文件夹信息异常!"
);
return
Result
.
of_error
(
"文件夹信息异常!"
);
}
}
String
apiKey
=
""
;
if
(
StringUtils
.
isNotBlank
(
req
.
getApiType
())
if
(
StringUtils
.
isNotBlank
(
req
.
getApiType
())
&&
"2"
.
equals
(
req
.
getApiType
())){
//数据银行制作API
&&
"2"
.
equals
(
req
.
getApiType
()))
{
//数据银行制作API
apiKey
=
RandomUtil
.
getStringRandom
(
16
);
ApiInterface
anInterface
=
new
ApiInterface
();
ApiInterface
anInterface
=
new
ApiInterface
();
anInterface
.
setCreateUser
(
""
);
anInterface
.
setCreateUser
(
""
);
anInterface
.
setStatus
(
"2"
);
//发布
anInterface
.
setStatus
(
ProducerStatusTypeEnum
.
ISSUE
.
name
());
//发布
anInterface
.
setSignType
(
req
.
getType
());
//加密类型
anInterface
.
setApiKey
(
apiKey
);
//apiKey
anInterface
.
setVersion
(
"1.0"
);
anInterface
.
setFileId
(
req
.
getFileId
());
anInterface
.
setApiKey
(
RandomUtil
.
getStringRandom
(
16
));
//apiKey
BeanUtils
.
copyProperties
(
req
,
anInterface
);
anInterface
.
setFileId
(
fileSource
.
get
(
0
).
getId
());
BeanUtils
.
copyProperties
(
req
,
anInterface
);
int
resIn
=
apiInterfaceMapper
.
insert
(
anInterface
);
int
resIn
=
apiInterfaceMapper
.
insert
(
anInterface
);
ApiInterfaceCustom
interfaceCustom
=
new
ApiInterfaceCustom
();
ApiInterfaceCustom
interfaceCustom
=
new
ApiInterfaceCustom
();
interfaceCustom
.
setCreateUser
(
""
);
interfaceCustom
.
setCreateUser
(
""
);
interfaceCustom
.
setApiKey
(
apiKey
);
interfaceCustom
.
setApiInterfaceId
(
anInterface
.
getId
());
interfaceCustom
.
setApiInterfaceId
(
anInterface
.
getId
());
BeanUtils
.
copyProperties
(
req
,
interfaceCustom
);
BeanUtils
.
copyProperties
(
req
,
interfaceCustom
);
int
resOut
=
apiInterfaceCustomMapper
.
insert
(
interfaceCustom
);
int
resOut
=
apiInterfaceCustomMapper
.
insert
(
interfaceCustom
);
if
(
resOut
==
0
||
resIn
==
0
){
if
(
resOut
==
0
||
resIn
==
0
)
{
throw
ResponseException
.
of_error
(
"保存信息失败!"
);
throw
ResponseException
.
of_error
(
"保存信息失败!"
);
}
}
}
else
if
(
StringUtils
.
isNotBlank
(
req
.
getApiType
())
}
else
if
(
StringUtils
.
isNotBlank
(
req
.
getApiType
())
&&
"3"
.
equals
(
req
.
getApiType
())){
//数据银行制作数据包
&&
"3"
.
equals
(
req
.
getApiType
()))
{
//数据银行制作数据包
if
(
StringUtils
.
isBlank
(
req
.
getTargetUrl
())){
//目标地址
if
(
StringUtils
.
isBlank
(
req
.
getTargetUrl
()))
{
//目标地址
return
Result
.
of_error
(
"目标地址为空!"
);
return
Result
.
of_error
(
"目标地址为空!"
);
}
}
ApiInterfaceReq
makeBigDataApiReq
=
new
ApiInterfaceReq
();
ApiInterfaceReq
apiInterfaceReq
=
new
ApiInterfaceReq
();
makeBigDataApiReq
.
setApiType
(
req
.
getApiType
());
apiInterfaceReq
.
setTransMode
(
req
.
getApiProtocl
());
makeBigDataApiReq
.
setApiDesc
(
req
.
getApiDesc
());
BeanUtils
.
copyProperties
(
req
,
apiInterfaceReq
);
makeBigDataApiReq
.
setTransMode
(
req
.
getApiProtocl
());
Result
result
=
saveInterfaceAPi
(
apiInterfaceReq
);
makeBigDataApiReq
.
setType
(
req
.
getType
());
apiKey
=(
String
)
result
.
getData
();
makeBigDataApiReq
.
setTargetUrl
(
req
.
getTargetUrl
());
makeBigDataApiReq
.
setTimeout
(
req
.
getTimeout
());
makeBigDataApiReq
.
setApiFunction
(
req
.
getApiFunction
());
saveInterfaceAPi
(
makeBigDataApiReq
);
}
}
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
,
apiKey
);
}
}
/**
/**
...
@@ -180,9 +175,8 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -180,9 +175,8 @@ public class ProducerServiceImpl implements ProducerService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
addBigDataMakeApi
(
MakeBigDataApiReq
req
)
{
public
Result
addBigDataMakeApi
(
MakeBigDataApiReq
req
)
{
//SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS);
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"USER"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
SysUserDto
currentUser
=
getUserInfo
();
if
(
null
==
currentUser
)
{
if
(
null
==
currentUser
){
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_EXIST
);
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_EXIST
);
}
}
QueryWrapper
<
ApiOpenApiEsFields
>
queryOpenApi
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOpenApiEsFields
>
queryOpenApi
=
new
QueryWrapper
<>();
...
@@ -224,17 +218,16 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -224,17 +218,16 @@ public class ProducerServiceImpl implements ProducerService {
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_ESTAG_JDBC_INFO_NAMESPACE
+
redisValueOfKey
,
dataSource
.
getJdbcUrl
());
redisTemplate
.
opsForValue
().
set
(
TagConstants
.
OPEN_API_ESTAG_JDBC_INFO_NAMESPACE
+
redisValueOfKey
,
dataSource
.
getJdbcUrl
());
}
}
int
result
=
0
;
int
result
=
0
;
ApiOpenApiEsTagconfig
apiEsTagconfig
=
new
ApiOpenApiEsTagconfig
();
if
(
null
!=
req
.
getId
()
&&
""
.
equals
(
req
.
getId
()))
{
//更新
if
(
null
!=
req
.
getId
()
&&
""
.
equals
(
req
.
getId
()))
{
//更新
ApiOpenApiEsTagconfig
update
=
new
ApiOpenApiEsTagconfig
();
apiEsTagconfig
.
setUpdateDate
(
new
Date
());
update
.
setUpdateDate
(
new
Date
());
apiEsTagconfig
.
setUpdateUser
(
currentUser
.
getUserName
());
update
.
setUpdateUser
(
currentUser
.
getUserName
());
BeanUtils
.
copyProperties
(
req
,
apiEsTagconfig
);
BeanUtils
.
copyProperties
(
req
,
update
);
result
=
apiOpenApiEsTagconfigMapper
.
updateById
(
apiEsTagconfig
);
result
=
apiOpenApiEsTagconfigMapper
.
updateById
(
update
);
}
else
{
//保存
}
else
{
//保存
ApiOpenApiEsTagconfig
inset
=
new
ApiOpenApiEsTagconfig
();
apiEsTagconfig
.
setCreateUser
(
currentUser
.
getUserName
());
inset
.
setCreateUser
(
currentUser
.
getUserName
());
BeanUtils
.
copyProperties
(
req
,
apiEsTagconfig
);
BeanUtils
.
copyProperties
(
req
,
inset
);
result
=
apiOpenApiEsTagconfigMapper
.
insert
(
apiEsTagconfig
);
result
=
apiOpenApiEsTagconfigMapper
.
insert
(
inset
);
}
}
if
(
result
<=
0
)
{
if
(
result
<=
0
)
{
return
Result
.
of_error
(
ResultMsg
.
FAILURE
);
return
Result
.
of_error
(
ResultMsg
.
FAILURE
);
...
@@ -244,20 +237,37 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -244,20 +237,37 @@ public class ProducerServiceImpl implements ProducerService {
/**
/**
* 保存api基本信息
* 保存api基本信息
*
* @param req
* @param req
* @return
* @return
*/
*/
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
public
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
)
{
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
//query.eq("project_id", req.getProjectId());
query
.
eq
(
"id"
,
req
.
getFileId
());
ApiInterfaceFile
file
=
apiInterfaceFileMapper
.
selectOne
(
query
);
if
(
null
==
file
)
{
file
=
new
ApiInterfaceFile
();
file
.
setProjectId
(
req
.
getProjectId
());
file
.
setFileSource
(
"1"
);
//dmp
file
.
setFileType
(
"1"
);
//文件夹
file
.
setStatus
(
GeneralStatusTypeEnum
.
VALID
.
name
());
file
.
setCreateUser
(
""
);
file
.
setRemark
(
"创建文件夹"
);
if
(
apiInterfaceFileMapper
.
insert
(
file
)
==
0
){
throw
ResponseException
.
of_error
(
"创建文件夹失败!"
);
}
}
//生成ApiKey
String
apiKey
=
RandomUtil
.
getStringRandom
(
16
);
ApiInterface
apiInterface
=
new
ApiInterface
();
ApiInterface
apiInterface
=
new
ApiInterface
();
apiInterface
.
setApiKey
(
RandomUtil
.
getStringRandom
(
16
));
apiInterface
.
setApiKey
(
apiKey
);
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
apiInterface
.
setTargetUrl
(
req
.
getTargetUrl
());
apiInterface
.
setStatus
(
ApiStatusEnum
.
ISSUE
.
name
());
//发布
apiInterface
.
setStatus
(
"2"
);
//发布
apiInterface
.
setFileId
(
file
.
getId
());
apiInterface
.
setApiFunction
(
req
.
getApiFunction
());
BeanUtils
.
copyProperties
(
req
,
apiInterface
);
apiInterface
.
setSignType
(
req
.
getType
());
//加密方式
apiInterface
.
setApiType
(
req
.
getApiType
());
//api类型
// apiInterface.setCreateUser(currentUser.getUserName());
// apiInterface.setCreateUser(currentUser.getUserName());
Long
timeout
=
Long
.
parseLong
(
req
.
getTimeout
());
Long
timeout
=
Long
.
parseLong
(
req
.
getTimeout
());
if
(
timeout
==
null
||
timeout
==
0
)
{
if
(
timeout
==
null
||
timeout
==
0
)
{
...
@@ -267,12 +277,10 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -267,12 +277,10 @@ public class ProducerServiceImpl implements ProducerService {
}
else
if
(
timeout
>
maxTimeout
)
{
}
else
if
(
timeout
>
maxTimeout
)
{
return
Result
.
of_success
(
"接口超时时间最大5000ms"
);
return
Result
.
of_success
(
"接口超时时间最大5000ms"
);
}
}
apiInterface
.
setTimeout
(
req
.
getTimeout
());
if
(
apiInterfaceMapper
.
insert
(
apiInterface
)
==
0
)
{
int
res
=
apiInterfaceMapper
.
insert
(
apiInterface
);
if
(
res
==
0
){
throw
ResponseException
.
of_error
(
"保存Api信息失败!"
);
throw
ResponseException
.
of_error
(
"保存Api信息失败!"
);
}
}
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
,
apiKey
);
}
}
/**
/**
...
@@ -283,8 +291,8 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -283,8 +291,8 @@ public class ProducerServiceImpl implements ProducerService {
*/
*/
@Override
@Override
public
Result
saveUpdateAPiInfo
(
MakeApiSaveInfoReq
req
)
{
public
Result
saveUpdateAPiInfo
(
MakeApiSaveInfoReq
req
)
{
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"user"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
SysUserDto
currentUser
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"USER"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
if
(
null
==
currentUser
){
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_EXIST
);
return
Result
.
of_error
(
ResultMsg
.
USER_NOT_EXIST
);
}
}
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getId
());
...
@@ -296,7 +304,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -296,7 +304,7 @@ public class ProducerServiceImpl implements ProducerService {
}
}
apiInterface
.
setApiType
(
req
.
getApiType
());
apiInterface
.
setApiType
(
req
.
getApiType
());
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setVersion
(
req
.
getVersion
());
apiInterface
.
setVersion
(
RandomUtil
.
generateVersion
(
apiInterface
.
getVersion
()));
//版本自动累加
apiInterface
.
setSignType
(
req
.
getType
());
apiInterface
.
setSignType
(
req
.
getType
());
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
if
(
StringUtils
.
isNotBlank
(
req
.
getTargetUrl
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getTargetUrl
()))
{
...
@@ -305,6 +313,11 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -305,6 +313,11 @@ public class ProducerServiceImpl implements ProducerService {
apiInterface
.
setTimeout
(
req
.
getTimeout
());
apiInterface
.
setTimeout
(
req
.
getTimeout
());
}
}
apiInterface
.
setApiFunction
(
req
.
getApiFunction
());
apiInterface
.
setApiFunction
(
req
.
getApiFunction
());
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
())){
if
(
null
==
fromApiStatusName
(
req
.
getStatus
())){
return
Result
.
of_error
(
"更新状态不存在!"
);
}
}
apiInterface
.
setStatus
(
req
.
getStatus
());
apiInterface
.
setStatus
(
req
.
getStatus
());
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
()))
{
boolean
b
=
canChange
(
apiInterface
.
getStatus
(),
req
.
getStatus
());
boolean
b
=
canChange
(
apiInterface
.
getStatus
(),
req
.
getStatus
());
...
@@ -324,7 +337,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -324,7 +337,7 @@ public class ProducerServiceImpl implements ProducerService {
}
}
apiInterface
.
setUpdateDate
(
new
Date
());
apiInterface
.
setUpdateDate
(
new
Date
());
apiInterface
.
setTimeout
(
req
.
getTimeout
());
apiInterface
.
setTimeout
(
req
.
getTimeout
());
//apiInterface.setUpdateUser(currentUser.getUserName()
);
apiInterface
.
setUpdateUser
(
""
);
int
result
=
apiInterfaceMapper
.
updateById
(
apiInterface
);
int
result
=
apiInterfaceMapper
.
updateById
(
apiInterface
);
if
(
result
>
0
)
{
if
(
result
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
...
@@ -335,6 +348,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -335,6 +348,7 @@ public class ProducerServiceImpl implements ProducerService {
/**
/**
* 判断状态是否改变
* 判断状态是否改变
*
* @param currentStatus
* @param currentStatus
* @param toStatus
* @param toStatus
* @return
* @return
...
@@ -359,7 +373,6 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -359,7 +373,6 @@ public class ProducerServiceImpl implements ProducerService {
}
}
/**
/**
* 获取数据源配置
* 获取数据源配置
*
*
...
@@ -377,14 +390,14 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -377,14 +390,14 @@ public class ProducerServiceImpl implements ProducerService {
return
Result
.
of_error
(
"存在重复的Apikey"
);
return
Result
.
of_error
(
"存在重复的Apikey"
);
}
}
}
else
{
}
else
{
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectById
(
req
.
getApiKey
());
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
if
(
apiInterface
.
getApiKey
().
equals
(
req
.
getApiKey
()))
{
query
.
eq
(
"api_key"
,
req
.
getApiKey
());
ApiInterface
anInterface
=
apiInterfaceMapper
.
selectOne
(
new
QueryWrapper
<
ApiInterface
>().
eq
(
"api_key"
,
req
.
getApiKey
()));
query
.
eq
(
"is_deleted"
,
0
);
if
(
null
!=
anInterface
)
{
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectOne
(
query
);
if
(
null
!=
apiInterface
)
{
return
Result
.
of_error
(
"存在重复的Apikey"
);
return
Result
.
of_error
(
"存在重复的Apikey"
);
}
}
}
}
}
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
}
}
...
@@ -402,7 +415,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -402,7 +415,7 @@ public class ProducerServiceImpl implements ProducerService {
}
}
JSONArray
result
=
new
JSONArray
();
JSONArray
result
=
new
JSONArray
();
log
.
info
(
"查询es标签类下的索引地址信息:"
+
datasource
.
getJdbcUrl
()
+
"/es/get/indicess"
);
log
.
info
(
"查询es标签类下的索引地址信息:"
+
datasource
.
getJdbcUrl
()
+
"/es/get/indicess"
);
String
resp
=
Web
Utils
.
doGet
(
datasource
.
getJdbcUrl
()
+
"/es/get/indicess"
,
null
);
String
resp
=
https
Utils
.
doGet
(
datasource
.
getJdbcUrl
()
+
"/es/get/indicess"
,
null
);
if
(
resp
!=
null
)
{
if
(
resp
!=
null
)
{
log
.
info
(
"返回索引信息集合:"
+
resp
);
log
.
info
(
"返回索引信息集合:"
+
resp
);
JSONArray
json
=
JSONArray
.
parseArray
(
resp
);
JSONArray
json
=
JSONArray
.
parseArray
(
resp
);
...
@@ -439,7 +452,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -439,7 +452,7 @@ public class ProducerServiceImpl implements ProducerService {
JSONObject
param
=
new
JSONObject
();
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"indices"
,
indices
);
param
.
put
(
"indices"
,
indices
);
log
.
info
(
"参数集合:"
+
param
.
toString
());
log
.
info
(
"参数集合:"
+
param
.
toString
());
String
resp
=
WebUtils
.
p
ost
(
datasource
.
getJdbcUrl
()
+
"/es/get/indices/types"
,
param
.
toString
());
String
resp
=
httpsUtils
.
submitP
ost
(
datasource
.
getJdbcUrl
()
+
"/es/get/indices/types"
,
param
.
toString
());
log
.
info
(
"索引下type的信息集合:"
+
resp
);
log
.
info
(
"索引下type的信息集合:"
+
resp
);
return
Result
.
of_success
(
resp
);
return
Result
.
of_success
(
resp
);
}
}
...
@@ -462,12 +475,12 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -462,12 +475,12 @@ public class ProducerServiceImpl implements ProducerService {
HashMap
<
String
,
String
>
herders
=
new
HashMap
<>();
HashMap
<
String
,
String
>
herders
=
new
HashMap
<>();
herders
.
put
(
"Content-Encoding"
,
"UTF-8"
);
herders
.
put
(
"Content-Encoding"
,
"UTF-8"
);
herders
.
put
(
"Content-Type"
,
"application/json"
);
herders
.
put
(
"Content-Type"
,
"application/json"
);
HashMap
<
String
,
String
>
dataMap
=
new
HashMap
<>
();
JSONObject
param
=
new
JSONObject
();
dataMap
.
put
(
"indices"
,
indices
);
param
.
put
(
"indices"
,
indices
);
dataMap
.
put
(
"type"
,
type
);
param
.
put
(
"type"
,
type
);
String
resp
=
null
;
String
resp
=
null
;
try
{
try
{
resp
=
WebUtils
.
post
(
datasource
.
getJdbcUrl
()
+
"/es/get/type/fields"
,
herders
,
dataMap
);
resp
=
httpsUtils
.
submitPost
(
datasource
.
getJdbcUrl
()
+
"/es/get/type/fields"
,
param
,
herders
);
log
.
info
(
"索引下type的fields信息集合:"
+
resp
);
log
.
info
(
"索引下type的fields信息集合:"
+
resp
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/
api
request/ApiQueryService.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
d7b311c3
package
com
.
jz
.
dm
.
service
.
api
request
;
package
com
.
jz
.
dm
.
service
.
request
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.gateway.OpenApiService
;
import
com.jz.dm.gateway.OpenApiService
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.
api
request
* @PACKAGE_NAME: com.jz.dm.service.request
* @PROJECT_NAME: jz-dm-parent
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiQueryService
* @NAME: ApiQueryService
* @DATE: 2020-12-23/18:10
* @DATE: 2020-12-23/18:10
...
@@ -29,14 +34,42 @@ public class ApiQueryService implements OpenApiService {
...
@@ -29,14 +34,42 @@ public class ApiQueryService implements OpenApiService {
@Override
@Override
public
String
getOpenApiVersion
()
{
public
String
getOpenApiVersion
()
{
return
"1.0.0"
;
return
"
v
1.0.0"
;
}
}
@Autowired
private
ApiInterfaceService
apiInterfaceService
;
@Override
@Override
@ApiLogAspect
@ApiLogAspect
(
description
=
"API请求日志"
)
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getOpenApiParams
());
String
apiType
=
parameter
.
getString
(
"apiType"
);
if
(
StringUtils
.
isNotBlank
(
apiType
)){
try
{
switch
(
apiType
){
case
"QUERY_TAG"
:
//标签查询
//String reqParam = parameter.getString("request_param");
//apiInterfaceService.getTagReqData();
break
;
case
"BIG_DATA_QUERY"
:
//大数据查询
break
;
case
"CUSTOM_QUERY"
:
//自定义查询(三方查询)
break
;
case
"DATA_BAG_QUERY"
:
//数据包查询
break
;
default
:
response
.
setCode
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getMsg
());
break
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"~~~~~~~~~~~~~~~请求api信息异常~~~~~~~~~~~~~"
);
log
.
error
(
"异常信息:{}"
,
e
.
getMessage
());
response
.
setCode
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getMsg
());
}
}
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
View file @
d7b311c3
...
@@ -4,7 +4,8 @@ package com.jz.dm.web.aspect;
...
@@ -4,7 +4,8 @@ package com.jz.dm.web.aspect;
import
com.jz.common.utils.IpUtils
;
import
com.jz.common.utils.IpUtils
;
import
com.jz.common.utils.JsonUtils
;
import
com.jz.common.utils.JsonUtils
;
import
com.jz.common.utils.UrlUtil
;
import
com.jz.common.utils.UrlUtil
;
import
com.jz.dm.common.util.SignType
;
import
com.jz.dm.common.enums.SignType
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
...
@@ -46,6 +47,8 @@ public class SystemLogAspect {
...
@@ -46,6 +47,8 @@ public class SystemLogAspect {
@Resource
@Resource
private
ApiLogService
apiLogService
;
private
ApiLogService
apiLogService
;
@Resource
private
ApiReqLogMapper
apiReqLogMapper
;
/* //前置通知切入点
/* //前置通知切入点
@Pointcut("@annotation(com.jz.dm.web.annotation.ApiLogAspect)")
@Pointcut("@annotation(com.jz.dm.web.annotation.ApiLogAspect)")
...
@@ -98,7 +101,7 @@ public class SystemLogAspect {
...
@@ -98,7 +101,7 @@ public class SystemLogAspect {
reqLog
.
setRemark
(
getServiceMethodDescription
(
joinPoint
));
reqLog
.
setRemark
(
getServiceMethodDescription
(
joinPoint
));
System
.
out
.
println
(
reqLog
);
System
.
out
.
println
(
reqLog
);
if
(
null
!=
reqLog
)
{
if
(
null
!=
reqLog
)
{
api
LogService
.
insetLogInfo
(
reqLog
);
api
ReqLogMapper
.
insert
(
reqLog
);
}
}
Object
result
=
joinPoint
.
proceed
(
joinPoint
.
getArgs
());
Object
result
=
joinPoint
.
proceed
(
joinPoint
.
getArgs
());
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
result
);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
result
);
...
...
jz-dm-apigateway/src/main/resources/application-test.yml
View file @
d7b311c3
...
@@ -74,12 +74,13 @@ spring:
...
@@ -74,12 +74,13 @@ spring:
proxy-target-class
:
true
proxy-target-class
:
true
auto
:
true
auto
:
true
#rePrefix redis存储的前缀
#ignoreRedis true存入 false不存 api.timeout.default
#ignoreRedis true存入 false不存 api.timeout.default
dmp
:
dmp
:
ignoreRedis
:
true
ignoreRedis
:
true
rePrefix
:
test
openapi
:
openapi
:
timeout
:
timeout
:
default
:
5000
default
:
5000
max
:
5000
max
:
5000
request
:
#api请求次数
limit
:
max
:
10
jz-dm-apigateway/src/main/resources/application.yml
View file @
d7b311c3
...
@@ -13,8 +13,10 @@ logging:
...
@@ -13,8 +13,10 @@ logging:
spring
:
spring
:
application
:
application
:
name
:
九章数据平台
name
:
九章数据平台
aop
:
servlet
:
proxy-target-class
:
true
multipart
:
max-file-size
:
10MB
max-request-size
:
50MB
profiles
:
profiles
:
active
:
test
#默认使用的配置文件
active
:
test
#默认使用的配置文件
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiAuthMapper.xml
View file @
d7b311c3
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
DATE_FORMAT(au.valid_start_time,'%Y-%m-%d %H:%i:%s') AS validStartTime,
DATE_FORMAT(au.valid_start_time,'%Y-%m-%d %H:%i:%s') AS validStartTime,
DATE_FORMAT(au.valid_end_time,'%Y-%m-%d %H:%i:%s') AS validEndTime,
DATE_FORMAT(au.valid_end_time,'%Y-%m-%d %H:%i:%s') AS validEndTime,
(CASE au.status
(CASE au.status
WHEN '
1
' THEN '正常'
WHEN '
VALID
' THEN '正常'
WHEN '
2
' THEN '作废'
WHEN '
UN_VALID
' THEN '作废'
END) AS status,
END) AS status,
au.remark AS remark,
au.remark AS remark,
DATE_FORMAT(au.create_date,'%Y-%m-%d %H:%i:%s') AS createDate,
DATE_FORMAT(au.create_date,'%Y-%m-%d %H:%i:%s') AS createDate,
...
@@ -29,10 +29,10 @@
...
@@ -29,10 +29,10 @@
ao.org_name AS orgName,
ao.org_name AS orgName,
ai.api_key AS apiKey
ai.api_key AS apiKey
FROM t_api_auth AS au
FROM t_api_auth AS au
JOIN t_api_interface AS ai ON au.api_interface_id = ai.id AND ai.is_deleted =0 AND ai.`status` ='
2
'
JOIN t_api_interface AS ai ON au.api_interface_id = ai.id AND ai.is_deleted =0 AND ai.`status` ='
ISSUE
'
JOIN t_api_org AS ao ON au.api_org_id = ao.id AND ao.`status` ='
1
' AND ao.is_deleted =0
JOIN t_api_org AS ao ON au.api_org_id = ao.id AND ao.`status` ='
NORMAL
' AND ao.is_deleted =0
WHERE au.is_deleted =0
WHERE au.is_deleted =0
AND au.id =#{
req.
id}
AND au.id =#{id}
</select>
</select>
<select
id=
"listSelectApiAuth"
resultType=
"com.jz.dm.models.dto.AuthInfoDto"
>
<select
id=
"listSelectApiAuth"
resultType=
"com.jz.dm.models.dto.AuthInfoDto"
>
...
@@ -48,8 +48,8 @@
...
@@ -48,8 +48,8 @@
DATE_FORMAT(au.valid_start_time,'%Y-%m-%d %H:%i:%s') AS validStartTime,
DATE_FORMAT(au.valid_start_time,'%Y-%m-%d %H:%i:%s') AS validStartTime,
DATE_FORMAT(au.valid_end_time,'%Y-%m-%d %H:%i:%s') AS validEndTime,
DATE_FORMAT(au.valid_end_time,'%Y-%m-%d %H:%i:%s') AS validEndTime,
(CASE au.status
(CASE au.status
WHEN '
1
' THEN '正常'
WHEN '
VALID
' THEN '正常'
WHEN '
2
' THEN '作废'
WHEN '
UN_VALID
' THEN '作废'
END) AS status,
END) AS status,
au.remark AS remark,
au.remark AS remark,
DATE_FORMAT(au.create_date,'%Y-%m-%d %H:%i:%s') AS createDate,
DATE_FORMAT(au.create_date,'%Y-%m-%d %H:%i:%s') AS createDate,
...
@@ -57,8 +57,8 @@
...
@@ -57,8 +57,8 @@
ao.org_name AS orgName,
ao.org_name AS orgName,
ai.api_key AS apiKey
ai.api_key AS apiKey
FROM t_api_auth AS au
FROM t_api_auth AS au
JOIN t_api_interface AS ai ON au.api_interface_id = ai.id AND ai.is_deleted =0 AND ai.`status` ='
2
'
JOIN t_api_interface AS ai ON au.api_interface_id = ai.id AND ai.is_deleted =0 AND ai.`status` ='
ISSUE
'
JOIN t_api_org AS ao ON au.api_org_id = ao.id AND ao.`status` ='
1
' AND ao.is_deleted =0
JOIN t_api_org AS ao ON au.api_org_id = ao.id AND ao.`status` ='
NORMAL
' AND ao.is_deleted =0
${ew.customSqlSegment}
${ew.customSqlSegment}
</select>
</select>
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiDirectionlMapper.xml
0 → 100644
View file @
d7b311c3
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.jz.dm.mapper.ApiDirectionMapper"
>
</mapper>
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/org/TestOrganizationManage.java
View file @
d7b311c3
...
@@ -73,7 +73,6 @@ public class TestOrganizationManage extends SpringTestCase {
...
@@ -73,7 +73,6 @@ public class TestOrganizationManage extends SpringTestCase {
public
void
updateOrg
(){
public
void
updateOrg
(){
OrganizationManageUpdateReq
req
=
new
OrganizationManageUpdateReq
();
OrganizationManageUpdateReq
req
=
new
OrganizationManageUpdateReq
();
req
.
setId
(
8L
);
req
.
setId
(
8L
);
req
.
setOrgName
(
"ABCOssO"
);
req
.
setOrgDesc
(
"粗这次002"
);
req
.
setOrgDesc
(
"粗这次002"
);
req
.
setOrgCnName
(
"AOKK33"
);
req
.
setOrgCnName
(
"AOKK33"
);
req
.
setOrgMail
(
"727322JA@QQ.COM"
);
req
.
setOrgMail
(
"727322JA@QQ.COM"
);
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestHttpReq.java
0 → 100644
View file @
d7b311c3
package
com
.
jz
.
dm
.
gateway
.
orther
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.dm.gateway.SpringTestCase
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.HashMap
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.gateway.orther
* @PROJECT_NAME: jz-dm-parent
* @NAME: TestHttpReq
* @DATE: 2021-1-3/10:15
* @DAY_NAME_SHORT: 周日
* @Description:
**/
public
class
TestHttpReq
extends
SpringTestCase
{
private
static
final
String
baseUrl
=
"http://localhost:8081/logInfo/getMallLogDetail/1"
;
private
static
final
String
baseUrlPost
=
"http://localhost:8081/logInfo/getMallLogInfo"
;
@Autowired
private
HttpsUtils
httpsUtils
;
@Test
public
void
getReqTest
(){
String
response
=
httpsUtils
.
doGet
(
baseUrl
,
new
HashMap
<>());