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
3c1a67a6
Commit
3c1a67a6
authored
Dec 30, 2020
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
1d53c633
77c6b4d9
Changes
63
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
63 changed files
with
3338 additions
and
539 deletions
+3338
-539
api_gateway.sql
database/zc/api_gateway.sql
+27
-3
pom.xml
jz-dm-apigateway/pom.xml
+5
-0
BaseCurrentUserObject.java
...ain/java/com/jz/dm/common/base/BaseCurrentUserObject.java
+40
-0
Constants.java
...ay/src/main/java/com/jz/dm/common/constant/Constants.java
+4
-0
TagConstants.java
...src/main/java/com/jz/dm/common/constant/TagConstants.java
+30
-0
ApiStatusEnum.java
...va/com/jz/dm/common/enums/apiInterface/ApiStatusEnum.java
+45
-0
AuthModeEnum.java
...c/main/java/com/jz/dm/common/enums/auth/AuthModeEnum.java
+37
-0
AuthTypeEnum.java
...c/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
+32
-0
MessageDigestException.java
...va/com/jz/dm/common/exception/MessageDigestException.java
+0
-49
RandomUtil.java
...teway/src/main/java/com/jz/dm/common/util/RandomUtil.java
+275
-0
WebUtils.java
...gateway/src/main/java/com/jz/dm/common/util/WebUtils.java
+361
-318
ReentrantRedisLock.java
...ay/src/main/java/com/jz/dm/config/ReentrantRedisLock.java
+49
-0
WebAppConfigurer.java
...eway/src/main/java/com/jz/dm/config/WebAppConfigurer.java
+37
-0
AuthController.java
...ay/src/main/java/com/jz/dm/controller/AuthController.java
+75
-0
OrganizationManageController.java
...va/com/jz/dm/controller/OrganizationManageController.java
+8
-4
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+119
-2
ApiAuthMapper.java
...gateway/src/main/java/com/jz/dm/mapper/ApiAuthMapper.java
+19
-0
ApiInterfaceCustomMapper.java
.../main/java/com/jz/dm/mapper/ApiInterfaceCustomMapper.java
+16
-0
ApiOpenApiEsFieldsMapper.java
.../main/java/com/jz/dm/mapper/ApiOpenApiEsFieldsMapper.java
+9
-1
ApiReqLogMapper.java
...teway/src/main/java/com/jz/dm/mapper/ApiReqLogMapper.java
+9
-1
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+10
-0
ApiInterfaceCustom.java
...main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
+73
-0
ApiOrg.java
...gateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
+10
-0
AuthInfoDto.java
...teway/src/main/java/com/jz/dm/models/dto/AuthInfoDto.java
+57
-0
AuthDetailInfoReq.java
...ain/java/com/jz/dm/models/req/auth/AuthDetailInfoReq.java
+26
-0
AuthDmpUserApiReq.java
...ain/java/com/jz/dm/models/req/auth/AuthDmpUserApiReq.java
+48
-0
AuthInfoUpdateReq.java
...ain/java/com/jz/dm/models/req/auth/AuthInfoUpdateReq.java
+26
-0
AuthListInfoReq.java
.../main/java/com/jz/dm/models/req/auth/AuthListInfoReq.java
+21
-0
AuthMallUserApiReq.java
...in/java/com/jz/dm/models/req/auth/AuthMallUserApiReq.java
+48
-0
SaltResetReq.java
...src/main/java/com/jz/dm/models/req/auth/SaltResetReq.java
+30
-0
ApiInterfaceReq.java
.../main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
+66
-0
MakeApiSaveInfoReq.java
...in/java/com/jz/dm/models/req/make/MakeApiSaveInfoReq.java
+71
-0
MakeBigDataApiReq.java
...ain/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
+67
-0
MakeCustomApiReq.java
...main/java/com/jz/dm/models/req/make/MakeCustomApiReq.java
+63
-0
MakeDataBankApiReq.java
...in/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
+69
-0
MakeRealCustomApiReq.java
.../java/com/jz/dm/models/req/make/MakeRealCustomApiReq.java
+20
-0
SourceConfigReq.java
.../main/java/com/jz/dm/models/req/make/SourceConfigReq.java
+28
-0
OrganizationManageAddReq.java
...dels/req/organizationManage/OrganizationManageAddReq.java
+8
-1
OrganizationManageDetailQueryReq.java
.../organizationManage/OrganizationManageDetailQueryReq.java
+1
-1
OrganizationManageListQueryReq.java
...eq/organizationManage/OrganizationManageListQueryReq.java
+1
-1
OrganizationManageUpdateReq.java
...s/req/organizationManage/OrganizationManageUpdateReq.java
+1
-1
AuthService.java
...igateway/src/main/java/com/jz/dm/service/AuthService.java
+44
-0
OrganizationManageService.java
...ain/java/com/jz/dm/service/OrganizationManageService.java
+4
-4
ProducerService.java
...eway/src/main/java/com/jz/dm/service/ProducerService.java
+76
-0
ApiQueryService.java
...in/java/com/jz/dm/service/apirequest/ApiQueryService.java
+7
-0
ApiLogServiceImpl.java
...c/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
+25
-10
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+187
-0
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+61
-30
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+433
-0
AccessLimit.java
...y/src/main/java/com/jz/dm/web/annotation/AccessLimit.java
+23
-0
ApiLogAspect.java
.../src/main/java/com/jz/dm/web/annotation/ApiLogAspect.java
+2
-2
ApiReturnLog.java
.../src/main/java/com/jz/dm/web/annotation/ApiReturnLog.java
+0
-19
SystemLogAspect.java
...y/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
+109
-80
AccessLimitInterceptor.java
...ava/com/jz/dm/web/interceptor/AccessLimitInterceptor.java
+84
-0
application-test.yml
jz-dm-apigateway/src/main/resources/application-test.yml
+14
-4
ApiAuthMapper.xml
jz-dm-apigateway/src/main/resources/mapper/ApiAuthMapper.xml
+38
-0
ApiInterfaceCustomMapper.xml
...ay/src/main/resources/mapper/ApiInterfaceCustomMapper.xml
+7
-0
ApiOpenApiEsFieldsMapper.xml
...ay/src/main/resources/mapper/ApiOpenApiEsFieldsMapper.xml
+13
-1
TestApplicationContextInitializer.java
.../com/jz/dm/gateway/TestApplicationContextInitializer.java
+1
-1
TestAuth.java
...gateway/src/test/java/com/jz/dm/gateway/org/TestAuth.java
+22
-0
TestOrganizationManage.java
...st/java/com/jz/dm/gateway/org/TestOrganizationManage.java
+5
-5
pom.xml
jz-dm-common/pom.xml
+1
-1
RedisUtils.java
...-common/src/main/java/com/jz/common/utils/RedisUtils.java
+241
-0
No files found.
database/zc/api_gateway.sql
View file @
3c1a67a6
...
@@ -7,7 +7,9 @@ CREATE TABLE `t_api_interface` (
...
@@ -7,7 +7,9 @@ CREATE TABLE `t_api_interface` (
`api_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api描述'
,
`api_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api描述'
,
`api_protocl`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'api请求协议:http,https'
,
`api_protocl`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'api请求协议:http,https'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`status`
varchar
(
20
)
NOT
NULL
COMMENT
'状态(1-草稿 2-发布 3-过时 4-冻结 5-失效)'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`version`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'版本号'
,
`version`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'版本号'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
...
@@ -22,6 +24,26 @@ CREATE TABLE `t_api_interface` (
...
@@ -22,6 +24,26 @@ CREATE TABLE `t_api_interface` (
UNIQUE
KEY
`api_key_unique`
(
`api_key`
)
USING
BTREE
UNIQUE
KEY
`api_key_unique`
(
`api_key`
)
USING
BTREE
)
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信息表'
;
#
api
api
自定义信息表
DROP
TABLE
IF
EXISTS
`t_api_interface_custom`
;
CREATE
TABLE
`t_api_interface_custom`
(
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api 信息表自增ID'
,
`api_key`
varchar
(
200
)
NOT
NULL
COMMENT
'api唯一标识'
,
`api_interface_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api表自增id'
,
`api_type`
varchar
(
50
)
DEFAULT
''
COMMENT
'api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义'
,
`request_param`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求参数'
,
`response_param`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应参数'
,
`req_headers`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求头'
,
`resp_code`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应状态码'
,
`api_example`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api返回样例'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`update_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
`update_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'更新人'
,
`is_deleted`
tinyint
(
2
)
unsigned
NOT
NULL
DEFAULT
'0'
COMMENT
'是否删除'
,
PRIMARY
KEY
(
`id`
),
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
ROW_FORMAT
=
DYNAMIC
COMMENT
=
'api自定义信息表'
;
#
api
组织信息表
#
api
组织信息表
...
@@ -32,6 +54,8 @@ CREATE TABLE `t_api_org` (
...
@@ -32,6 +54,8 @@ CREATE TABLE `t_api_org` (
`org_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织名称'
,
`org_name`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'组织名称'
,
`org_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'组织描述'
,
`org_desc`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'组织描述'
,
`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_type`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'组织类型:OUT 外部组织, IN 内部组织'
,
`status`
varchar
(
100
)
NOT
NULL
COMMENT
'状态(1-正常 2-冻结 3-下架)'
,
`status`
varchar
(
100
)
NOT
NULL
COMMENT
'状态(1-正常 2-冻结 3-下架)'
,
`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
'组织排序'
,
...
@@ -53,10 +77,10 @@ CREATE TABLE `t_api_auth` (
...
@@ -53,10 +77,10 @@ CREATE TABLE `t_api_auth` (
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api授权信息表自增ID'
,
`id`
bigint
(
20
)
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'api授权信息表自增ID'
,
`api_interface_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api信息表id'
,
`api_interface_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api信息表id'
,
`api_org_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api组织id'
,
`api_org_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api组织id'
,
`auth_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'授权类型:
1.数据银行购买 2.
dmp授权'
,
`auth_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'授权类型:
DATA_BANK_AUTH 数据银行购买 DMP_AUTH
dmp授权'
,
`auth_code`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'授权码'
,
`auth_code`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'授权码'
,
`salt`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'盐值'
,
`salt`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'盐值'
,
`auth_mode`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'授权方式:1.按次调用 2.按月调用 3.按季调用 4.按年调用
'
,
`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
(
100
)
NOT
NULL
COMMENT
'状态(1-正常 2-作废)'
,
...
...
jz-dm-apigateway/pom.xml
View file @
3c1a67a6
...
@@ -100,6 +100,11 @@
...
@@ -100,6 +100,11 @@
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-aop
</artifactId>
<artifactId>
spring-boot-starter-aop
</artifactId>
</dependency>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>-->
<dependency>
<dependency>
<groupId>
net.sf.json-lib
</groupId>
<groupId>
net.sf.json-lib
</groupId>
<artifactId>
json-lib
</artifactId>
<artifactId>
json-lib
</artifactId>
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/base/BaseCurrentUserObject.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
common
.
base
;
import
com.jz.common.bean.SysUserDto
;
import
com.jz.common.constant.RedisMessageConstant
;
import
org.springframework.data.redis.core.RedisTemplate
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.base
* @PROJECT_NAME: jz-dm-parent
* @NAME: BaseCurrentUserObject
* @DATE: 2020-12-30/16:05
* @DAY_NAME_SHORT: 周三
* @Description: 获取当前登录用户
**/
public
class
BaseCurrentUserObject
{
private
static
RedisTemplate
<
String
,
Object
>
REDIS
=
new
RedisTemplate
();
private
volatile
static
SysUserDto
sysUserDto
;
private
BaseCurrentUserObject
()
{
}
/**
* 获取登录用户
*
* @return
*/
public
static
SysUserDto
getUserInfo
()
{
if
(
sysUserDto
==
null
)
{
synchronized
(
SysUserDto
.
class
)
{
if
(
sysUserDto
==
null
)
{
sysUserDto
=
(
SysUserDto
)
REDIS
.
opsForValue
().
get
(
"USER"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_SYS
);
}
}
}
return
sysUserDto
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/constant/Constants.java
View file @
3c1a67a6
...
@@ -54,6 +54,10 @@ public class Constants {
...
@@ -54,6 +54,10 @@ public class Constants {
/** JSON 应格式 */
/** JSON 应格式 */
public
static
final
String
FORMAT_JSON
=
"JSON"
;
public
static
final
String
FORMAT_JSON
=
"JSON"
;
/** 生成内部授权码格式 */
public
static
final
String
AUTH_INT
=
"INT"
;
/** 生成外部授权码格式 */
public
static
final
String
AUTH_OUT
=
"OUT"
;
/** XML 应格式 */
/** XML 应格式 */
public
static
final
String
FORMAT_XML
=
"XML"
;
public
static
final
String
FORMAT_XML
=
"XML"
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/constant/TagConstants.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
common
.
constant
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.constant
* @PROJECT_NAME: jz-dm-parent
* @NAME: TagConstants
* @DATE: 2020-12-28/18:40
* @DAY_NAME_SHORT: 周一
* @Description:
**/
public
class
TagConstants
{
//远程shell脚本存放路径
public
static
final
String
remoteShellFilePath
=
"/opt/shell"
;
//远程sql脚本存放路径
public
static
final
String
remoteSqlFilePath
=
"/opt/sql"
;
//kafka handler 相关
public
static
final
String
OPEN_API_HANDLER_LIST_INFO_NAMESPACE
=
"jz:openapi:handler:list"
;
public
static
final
String
OPEN_API_HANDLER_INFO_NAMESPACE
=
"jz:openapi:handler:"
;
public
static
final
String
OPEN_API_SCHEMA_INFO_NAMESPACE
=
"jz:openapi:schema:"
;
public
static
final
String
OPEN_API_SERVERS_INFO_NAMESPACE
=
"jz:openapi:kafka:servers:"
;
// es handler 相关
public
static
final
String
OPEN_API_ESTAG_INFO_NAMESPACE
=
"jz:openapi:handler:estag:"
;
public
static
final
String
OPEN_API_ESTAG_JDBC_INFO_NAMESPACE
=
"jz:openapi:handler:estag:jdbc:"
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/apiInterface/ApiStatusEnum.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
common
.
enums
.
apiInterface
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.constant
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiStatusEnum
* @DATE: 2020-12-29/14:28
* @DAY_NAME_SHORT: 周二
* @Description:
**/
public
enum
ApiStatusEnum
{
/**
* 草稿
*/
DRAFT
(
"草稿"
),
/**
* 发布'
*/
ISSUE
(
"发布"
),
/**
* 过时
*/
OUTMODED
(
"过时"
),
/**
* 冻结
*/
FREEZE
(
"冻结"
),
/**
* 失效'
*/
EXPIRY
(
"失效"
);
private
String
text
;
ApiStatusEnum
(
String
text
)
{
this
.
text
=
text
;
}
public
String
getText
()
{
return
text
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthModeEnum.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
common
.
enums
.
auth
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums.auth
* @PROJECT_NAME: jz-dm-parent
* @NAME: AuthModeEnum
* @DATE: 2020-12-26/23:53
* @DAY_NAME_SHORT: 周六
* @Description: 认证方式枚举
**/
public
enum
AuthModeEnum
{
/**
* 按次调用
*/
POWER_CALL_MODE
(
"按次调用"
),
/**
* 按时间调用'
*/
RECORD_TIME_MODE
(
"按时间调用"
),
/**
* 永久有效'
*/
PERMANENT_TIME_MODE
(
"永久有效"
);
private
String
text
;
AuthModeEnum
(
String
text
)
{
this
.
text
=
text
;
}
public
String
getText
()
{
return
text
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthTypeEnum.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
common
.
enums
.
auth
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums.auth
* @PROJECT_NAME: jz-dm-parent
* @NAME: AuthTypeEnum
* @DATE: 2020-12-26/23:47
* @DAY_NAME_SHORT: 周六
* @Description: 授权认证枚举类
**/
public
enum
AuthTypeEnum
{
/**
* 数据银行
*/
DATA_BANK_AUTH
(
"数据银行授权"
),
/**
* dmp授权'
*/
DMP_AUTH
(
"DMP授权"
);
private
String
text
;
AuthTypeEnum
(
String
text
)
{
this
.
text
=
text
;
}
public
String
getText
()
{
return
text
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/exception/MessageDigestException.java
deleted
100644 → 0
View file @
1d53c633
package
com
.
jz
.
dm
.
common
.
exception
;
import
com.jz.dm.common.util.ResultCode
;
/**
* 信息摘要异常
*
*/
public
class
MessageDigestException
extends
OpenApiException
{
private
static
final
long
serialVersionUID
=
477249046784548217L
;
/**
* 构造函数
* @param resultCode
*/
public
MessageDigestException
(
ResultCode
resultCode
)
{
super
(
resultCode
);
}
/**
* 构造函数
* @param resultCode
* @param detailMessage
*/
public
MessageDigestException
(
ResultCode
resultCode
,
String
detailMessage
)
{
super
(
resultCode
,
detailMessage
);
}
/**
* 构造函数
* @param resultCode
* @param cause
*/
public
MessageDigestException
(
ResultCode
resultCode
,
Throwable
cause
)
{
super
(
resultCode
,
cause
);
}
/**
* 构造函数
* @param resultCode
* @param detailMessage
* @param cause
*/
public
MessageDigestException
(
ResultCode
resultCode
,
String
detailMessage
,
Throwable
cause
)
{
super
(
resultCode
,
detailMessage
,
cause
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/RandomUtil.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
common
.
util
;
import
com.jz.dm.common.constant.Constants
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Calendar
;
import
java.util.Random
;
import
java.util.regex.Pattern
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.util
* @PROJECT_NAME: jz-dm-parent
* @NAME: RandomUtil
* @DATE: 2020-12-30/9:50
* @DAY_NAME_SHORT: 周三
* @Description: 生成随机编码工具类
**/
@Slf4j
public
class
RandomUtil
{
private
final
static
int
[]
li_SecPosValue
=
{
1601
,
1637
,
1833
,
2078
,
2274
,
2302
,
2433
,
2594
,
2787
,
3106
,
3212
,
3472
,
3635
,
3722
,
3730
,
3858
,
4027
,
4086
,
4390
,
4558
,
4684
,
4925
,
5249
,
5590
};
private
final
static
String
[]
lc_FirstLetter
=
{
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"j"
,
"k"
,
"l"
,
"m"
,
"n"
,
"o"
,
"p"
,
"q"
,
"r"
,
"s"
,
"t"
,
"w"
,
"x"
,
"y"
,
"z"
};
/**
* 生成指定长度字母+数字的随机数
*
* @param length 长度
* @return
*/
public
static
String
getStringRandom
(
int
length
)
{
String
val
=
""
;
Random
random
=
new
Random
();
//参数length,表示生成几位随机数
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
String
charOrNum
=
random
.
nextInt
(
2
)
%
2
==
0
?
"char"
:
"num"
;
//输出字母还是数字
if
(
"char"
.
equalsIgnoreCase
(
charOrNum
))
{
//输出是大写字母还是小写字母
int
temp
=
random
.
nextInt
(
2
)
%
2
==
0
?
65
:
97
;
val
+=
(
char
)
(
random
.
nextInt
(
26
)
+
temp
);
}
else
if
(
"num"
.
equalsIgnoreCase
(
charOrNum
))
{
val
+=
String
.
valueOf
(
random
.
nextInt
(
10
));
}
}
log
.
info
(
"生成指定长度字母+数字的随机数为:{}"
,
val
);
return
val
;
}
/**
* 生成组织(内/外)部编码
*
* @param type 类型
* @param content
* @return
*/
public
static
String
generateOrgCoding
(
String
content
,
String
type
)
{
String
coding
=
""
;
if
(
null
==
content
||
null
==
type
)
{
log
.
info
(
"----------生成组织编码内容或类型不存在--------------"
);
return
""
;
}
boolean
chineseWord
=
isChineseWord
(
content
);
if
(!
chineseWord
)
{
log
.
info
(
"----------编码中不能出现英文或者字母--------------"
);
return
""
;
}
StringBuilder
builder
=
new
StringBuilder
();
if
(
Constants
.
AUTH_INT
.
equalsIgnoreCase
(
type
))
{
builder
.
append
(
"NEI"
);
}
else
{
builder
.
append
(
"WAI"
);
}
String
orgContent
=
getAllFirstLetter
(
content
);
orgContent
=
orgContent
.
toUpperCase
();
builder
.
append
(
orgContent
);
if
(
builder
.
length
()
>
12
)
{
coding
=
builder
.
toString
().
substring
(
0
,
13
);
}
else
if
(
builder
.
length
()
==
12
)
{
coding
=
builder
.
toString
();
}
else
if
(
builder
.
length
()
<
12
)
{
String
random
=
getStringRandom
(
12
-
builder
.
length
());
builder
.
append
(
random
);
coding
=
builder
.
toString
();
log
.
info
(
"-----------生成的组织编码为:{}"
,
coding
);
}
return
coding
;
}
/**
* 生成内/外部授权码
*
* @param orgCode
* @param userId
* @param type
* @return
*/
public
static
String
generateTokenCode
(
String
type
,
String
orgCode
,
String
userId
)
{
String
coding
=
""
;
StringBuilder
builder
=
new
StringBuilder
();
Calendar
cal
=
Calendar
.
getInstance
();
int
year
=
cal
.
get
(
Calendar
.
YEAR
);
int
month
=
cal
.
get
(
Calendar
.
MONTH
)
+
1
;
int
day
=
cal
.
get
(
Calendar
.
DAY_OF_MONTH
);
int
hour
=
cal
.
get
(
Calendar
.
HOUR_OF_DAY
);
int
minute
=
cal
.
get
(
Calendar
.
MINUTE
);
int
second
=
cal
.
get
(
Calendar
.
SECOND
);
builder
.
append
(
year
);
//年
if
(
StringUtils
.
isNotBlank
(
type
)
&&
Constants
.
AUTH_INT
.
equalsIgnoreCase
(
type
))
{
//内部授权码
if
(
StringUtils
.
isBlank
(
orgCode
))
{
return
""
;
}
coding
=
getCodeInfo
(
orgCode
,
coding
,
builder
,
month
,
day
,
hour
,
minute
,
second
);
}
else
if
(
StringUtils
.
isNotBlank
(
type
)
&&
Constants
.
AUTH_OUT
.
equalsIgnoreCase
(
type
))
{
//外部组织
if
(
StringUtils
.
isBlank
(
userId
))
{
return
""
;
}
if
(
userId
.
length
()
<
8
)
{
//补全用户id
String
userNum
=
addZeroForNum
(
userId
,
8
);
builder
.
append
(
userNum
);
}
coding
=
getCodeInfo
(
orgCode
,
coding
,
builder
,
month
,
day
,
hour
,
minute
,
second
);
}
return
coding
;
}
/**
* 拼接内部/外部授权码
* @param orgCode
* @param coding
* @param builder
* @param month
* @param day
* @param hour
* @param minute
* @param second
* @return
*/
private
static
String
getCodeInfo
(
String
orgCode
,
String
coding
,
StringBuilder
builder
,
int
month
,
int
day
,
int
hour
,
int
minute
,
int
second
)
{
builder
.
append
(
orgCode
);
//组织编码
builder
.
append
(
month
);
//月
builder
.
append
(
day
);
//日
builder
.
append
(
hour
);
//时
builder
.
append
(
minute
);
//分
builder
.
append
(
second
);
//秒
if
(
builder
.
length
()
>
32
)
{
coding
=
builder
.
toString
().
substring
(
0
,
33
);
}
else
if
(
builder
.
length
()
==
32
)
{
coding
=
builder
.
toString
();
}
else
if
(
builder
.
length
()
<
32
)
{
String
random
=
getStringRandom
(
32
-
builder
.
length
());
builder
.
append
(
random
);
coding
=
builder
.
toString
();
log
.
info
(
"-----------生成的内部授权码为:{}"
,
coding
);
}
return
coding
;
}
/**
* 取得给定汉字串的首字母串,即声母串
*
* @param str 给定汉字串
* @return 声母串
*/
public
static
String
getAllFirstLetter
(
String
str
)
{
if
(
str
==
null
||
str
.
trim
().
length
()
==
0
)
{
return
""
;
}
String
_str
=
""
;
for
(
int
i
=
0
;
i
<
str
.
length
();
i
++)
{
_str
=
_str
+
getFirstLetter
(
str
.
substring
(
i
,
i
+
1
));
}
return
_str
;
}
/**
* 取得给定汉字的首字母,即声母
*
* @param chinese 给定的汉字
* @return 给定汉字的声母
*/
public
static
String
getFirstLetter
(
String
chinese
)
{
if
(
chinese
==
null
||
chinese
.
trim
().
length
()
==
0
)
{
return
""
;
}
chinese
=
conversionStr
(
chinese
,
"GB2312"
,
"ISO8859-1"
);
if
(
chinese
.
length
()
>
1
)
{
// 判断是不是汉字
int
li_SectorCode
=
(
int
)
chinese
.
charAt
(
0
);
// 汉字区码
int
li_PositionCode
=
(
int
)
chinese
.
charAt
(
1
);
// 汉字位码
li_SectorCode
=
li_SectorCode
-
160
;
li_PositionCode
=
li_PositionCode
-
160
;
int
li_SecPosCode
=
li_SectorCode
*
100
+
li_PositionCode
;
// 汉字区位码
if
(
li_SecPosCode
>
1600
&&
li_SecPosCode
<
5590
)
{
for
(
int
i
=
0
;
i
<
23
;
i
++)
{
if
(
li_SecPosCode
>=
li_SecPosValue
[
i
]
&&
li_SecPosCode
<
li_SecPosValue
[
i
+
1
])
{
chinese
=
lc_FirstLetter
[
i
];
break
;
}
}
}
else
// 非汉字字符,如图形符号或ASCII码
{
chinese
=
conversionStr
(
chinese
,
"ISO8859-1"
,
"GB2312"
);
chinese
=
chinese
.
substring
(
0
,
1
);
}
}
return
chinese
;
}
/**
* 字符串编码转换
*
* @param str 要转换编码的字符串
* @param charsetName 原来的编码
* @param toCharsetName 转换后的编码
* @return 经过编码转换后的字符串
*/
private
static
String
conversionStr
(
String
str
,
String
charsetName
,
String
toCharsetName
)
{
try
{
str
=
new
String
(
str
.
getBytes
(
charsetName
),
toCharsetName
);
}
catch
(
UnsupportedEncodingException
ex
)
{
System
.
out
.
println
(
"字符串编码转换异常:"
+
ex
.
getMessage
());
}
return
str
;
}
/**
* 限制只能输入中文
*/
public
static
boolean
isChineseWord
(
String
str
)
{
String
pattern
=
"[\u4e00-\u9fa5]+"
;
boolean
isMatch
=
Pattern
.
matches
(
pattern
,
str
);
return
isMatch
;
}
/**
* 生成8位用户id,不够的前面用0补全
*
* @param str
* @param strLength
* @return
*/
public
static
String
addZeroForNum
(
String
str
,
int
strLength
)
{
int
strLen
=
str
.
length
();
if
(
strLen
<
strLength
)
{
while
(
strLen
<
strLength
)
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"0"
).
append
(
str
);
// 左补0
// sb.append(str).append("0");//右补0
str
=
sb
.
toString
();
strLen
=
str
.
length
();
}
}
return
str
;
}
public
static
void
main
(
String
[]
args
)
{
//System.out.println(getStringRandom(8));
// System.out.println("获取拼音首字母:"+getAllFirstLetter("大中国南昌中大china"));
//System.out.println(isChineseWord("大中国南昌中大"));
//System.out.println(generateOrgCoding("九章数据","INT"));
// System.out.println(generateTokenCode("", ""));
//System.out.println(addZeroForNum("1", 8));
System
.
out
.
println
(
"内部授权码:"
+
generateTokenCode
(
"INT"
,
"NEIJZSJ900hx"
,
""
));
//内部授权码
System
.
out
.
println
(
"外部授权码:"
+
generateTokenCode
(
"OUT"
,
""
,
"199"
));
//内部授权码
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/WebUtils.java
View file @
3c1a67a6
This diff is collapsed.
Click to expand it.
jz-dm-apigateway/src/main/java/com/jz/dm/config/ReentrantRedisLock.java
0 → 100644
View file @
3c1a67a6
/**
* Copyright (c) 2011-2019 All Rights Reserved.
*/
package
com
.
jz
.
dm
.
config
;
import
com.jz.common.utils.RedisUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* @author Admin
* @version $Id: MapLock.java 2019年10月26日 下午5:27:52 $
*/
@Component
public
class
ReentrantRedisLock
{
//获取尝试时间
private
final
String
LOCK
=
"lock:"
;
@Resource
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
@Value
(
"${server.port}"
)
private
String
port
;
@Autowired
private
RedisUtils
redisUtils
;
/**
* 判断是否存在
*
* @return
*/
public
synchronized
boolean
tryLock
(
String
value
)
{
return
redisUtils
.
setIfAbsent
(
LOCK
+
value
,
value
,
2
);
}
public
synchronized
boolean
tryLock
(
String
value
,
long
minutes
)
{
return
redisUtils
.
setIfAbsent
(
LOCK
+
value
,
value
,
minutes
);
}
/**
* 处理完成清除
*/
public
void
unlock
(
String
value
)
{
redisTemplate
.
delete
(
LOCK
+
value
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/config/WebAppConfigurer.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
config
;
import
com.jz.dm.web.interceptor.AccessLimitInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.config
* @PROJECT_NAME: jz-dm-parent
* @NAME: WebAppConfigurer
* @DATE: 2020-12-26/18:53
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Configuration
public
class
WebAppConfigurer
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
// 可添加多个,这里选择拦截所有请求地址,进入后判断是否有加注解即可
registry
.
addInterceptor
(
getAccessLimitInterceptor
())
.
addPathPatterns
(
"/api/organization/**"
)
.
excludePathPatterns
(
"/**/*.html"
,
//html静态资源
"/**/*.js"
,
//js静态资源
"/**/*.css"
//css静态资源
);
}
@Bean
public
AccessLimitInterceptor
getAccessLimitInterceptor
()
{
return
new
AccessLimitInterceptor
();
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/AuthController.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
controller
;
package
com
.
jz
.
dm
.
controller
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.req.auth.*
;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.service.AuthService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
reactor.core.publisher.Mono
;
import
javax.validation.Valid
;
/**
/**
* @author ZC
* @author ZC
...
@@ -22,4 +30,71 @@ public class AuthController {
...
@@ -22,4 +30,71 @@ public class AuthController {
@Autowired
@Autowired
private
AuthService
authService
;
private
AuthService
authService
;
/**
* @Description:商城用户API认证
* @return: 商城用户API认证
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"商城用户API认证"
)
@PostMapping
(
value
=
"/mall-user-auth-api"
)
public
Mono
<
Result
>
authMallUserApi
(
@RequestBody
@Valid
AuthMallUserApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
addMallUserApiAuth
(
req
));
}
/**
* @Description:DMP用户API认证
* @return: DMP用户API认证
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"商城用户API认证"
)
@PostMapping
(
value
=
"dmp-auth-api"
)
public
Mono
<
Result
>
authDmpUserApi
(
@RequestBody
@Valid
AuthDmpUserApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
addDmpUserApiAuth
(
req
));
}
/**
* @Description: 认证详情查询
* @return: 认证详情查询
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"认证详情查询"
)
@PostMapping
(
value
=
"/auth-detail-info"
)
public
Mono
<
Result
>
selectAuthDetailInfo
(
@RequestBody
@Valid
AuthDetailInfoReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
getAuthDetailInfo
(
req
));
}
/**
* @Description: 认证列表查询
* @return: 认证列表查询
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"认证列表查询"
)
@PostMapping
(
value
=
"/auth-list"
)
public
Mono
<
Result
>
selectAuthListInfo
(
@RequestBody
@Valid
AuthListInfoReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
getAuthListInfo
(
req
));
}
/**
* @Description: 认证信息修改
* @return: 认证信息修改
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"认证信息修改"
)
@PostMapping
(
value
=
"/update-auth-info"
)
public
Mono
<
Result
>
updateAuthListInfo
(
@RequestBody
@Valid
AuthInfoUpdateReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
updateAuthInfo
(
req
));
}
/**
* @Description: 盐值重置接口
* @return: 盐值重置接口
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"盐值重置接口"
)
@PostMapping
(
value
=
"/reset-salt"
)
public
Mono
<
Result
>
resetSalt
(
@RequestBody
@Valid
SaltResetReq
req
)
{
return
Mono
.
fromSupplier
(()
->
authService
.
updateSaltInfo
(
req
));
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/OrganizationManageController.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
controller
;
package
com
.
jz
.
dm
.
controller
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.req.OrganizationManageAddReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageAddReq
;
import
com.jz.dm.models.req.OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.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
com.jz.dm.web.annotation.ApiLogAspect
;
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
;
...
@@ -50,6 +52,8 @@ public class OrganizationManageController {
...
@@ -50,6 +52,8 @@ 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 @
3c1a67a6
package
com
.
jz
.
dm
.
controller
;
package
com
.
jz
.
dm
.
controller
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.req.make.*
;
import
com.jz.dm.service.ProducerService
;
import
com.jz.dm.service.ProducerService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RestController
;
import
reactor.core.publisher.Mono
;
import
javax.validation.Valid
;
/**
/**
* @author ZC
* @author ZC
...
@@ -22,4 +27,116 @@ public class ProducerController {
...
@@ -22,4 +27,116 @@ public class ProducerController {
@Autowired
@Autowired
private
ProducerService
producerService
;
private
ProducerService
producerService
;
/**
* @Description:Api制作(自定义)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"Api制作(自定义)"
)
@PostMapping
(
value
=
"/addCustomApi"
)
public
Mono
<
Result
>
makeCustomApi
(
@RequestBody
@Valid
MakeCustomApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addCustomApi
(
req
)));
}
/**
* @Description:Api制作(数据银行)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"Api制作(数据银行)"
)
@PostMapping
(
value
=
"/addDataBankApiInfo"
)
public
Mono
<
Result
>
addDataBankApiInfo
(
@RequestBody
@Valid
MakeDataBankApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addDataBankApiInfo
(
req
)));
}
/**
* @Description:Api制作(实时接入)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"Api制作(实时接入)"
)
@PostMapping
(
value
=
"/realMakeApi"
)
public
Mono
<
Result
>
realCustomApi
(
@RequestBody
@Valid
MakeRealCustomApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addRealCustomApi
(
req
)));
}
/**
* @Description:Api制作(大数据查询/标签查询)
* @return:
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"Api制作(大数据查询/标签查询)"
)
@PostMapping
(
value
=
"/makeBigDataApi"
)
public
Mono
<
Result
>
bigDataMakeApi
(
@RequestBody
@Valid
MakeBigDataApiReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addBigDataMakeApi
(
req
)));
}
/**
* @Description:保存API基本信息
* @return: (保存API基本信息)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"保存API基本信息"
)
@PostMapping
(
value
=
"/saveInterface"
)
public
Mono
<
Result
>
saveInsetInterface
(
@RequestBody
@Valid
ApiInterfaceReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
saveInterfaceAPi
(
req
)));
}
/**
* @Description:Api制作(大数据查询/标签查询)保存修改的api信息
* @return: (自定义更新同时使用)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"保存修改的api信息"
)
@PostMapping
(
value
=
"/保存修改的api信息"
)
public
Mono
<
Result
>
saveUpdateAPiInfo
(
@RequestBody
@Valid
MakeApiSaveInfoReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
saveUpdateAPiInfo
(
req
)));
}
/**
* @Description:获取数据源配置
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"获取数据源配置"
)
@PostMapping
(
value
=
"/getSourceConfig"
)
public
Mono
<
Result
>
getSourceConfig
(
@RequestBody
@Valid
SourceConfigReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getSourceConfig
(
req
)));
}
/**
* @Description:获取索引
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"获取索引"
)
@GetMapping
(
value
=
"/getIndicess"
)
public
Mono
<
Result
>
getSourceWarehouseList
(
@RequestParam
(
name
=
"id"
)
Long
id
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getSourceWarehouseList
(
id
)));
}
/**
* @Description:获取某个索引下的type
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"获取某个索引下的type"
)
@GetMapping
(
value
=
"/getIndicesTypes"
)
public
Mono
<
Result
>
getIndicesTypes
(
@RequestParam
(
name
=
"indices"
)
String
indices
,
@RequestParam
(
name
=
"id"
)
Long
id
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getIndicesTypes
(
indices
,
id
)));
}
/**
* @Description:获取某个索引 type的fields
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"获取某个索引 type的fields"
)
@GetMapping
(
value
=
"/getIndicesTypesFields"
)
public
Mono
<
Result
>
getIndicesTypesFields
(
@RequestParam
(
name
=
"indices"
)
String
indices
,
@RequestParam
(
name
=
"type"
)
String
type
,
@RequestParam
(
name
=
"id"
)
Long
id
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getIndicesTypesFields
(
indices
,
type
,
id
)));
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiAuthMapper.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
mapper
;
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.dto.AuthInfoDto
;
import
com.jz.dm.models.req.auth.AuthDetailInfoReq
;
import
org.apache.ibatis.annotations.Param
;
/**api授权信息表 mapper
/**api授权信息表 mapper
* @author zc
* @author zc
...
@@ -9,4 +14,18 @@ import com.jz.dm.models.domian.ApiAuth;
...
@@ -9,4 +14,18 @@ import com.jz.dm.models.domian.ApiAuth;
*/
*/
public
interface
ApiAuthMapper
extends
BaseMapper
<
ApiAuth
>
{
public
interface
ApiAuthMapper
extends
BaseMapper
<
ApiAuth
>
{
/**
* 查询认证详情信息
* @param req
* @return
*/
AuthInfoDto
selectAuthDetail
(
AuthDetailInfoReq
req
);
/**
* 分页查询认证列表
* @param page
* @param query
* @return
*/
IPage
<
AuthInfoDto
>
listSelectApiAuth
(
IPage
<
AuthInfoDto
>
page
,
@Param
(
"ew"
)
Wrapper
<
AuthInfoDto
>
query
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiInterfaceCustomMapper.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.mapper
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiInterfaceCustomMapper
* @DATE: 2020-12-30/18:00
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
interface
ApiInterfaceCustomMapper
extends
BaseMapper
<
ApiInterfaceCustom
>
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiOpenApiEsFieldsMapper.java
View file @
3c1a67a6
...
@@ -2,11 +2,19 @@ package com.jz.dm.mapper;
...
@@ -2,11 +2,19 @@ package com.jz.dm.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiOpenApiEsFields
;
import
com.jz.dm.models.domian.ApiOpenApiEsFields
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.ArrayList
;
/**apiEs字段信息表 mapper
/**apiEs字段信息表 mapper
* @author ybz
* @author ybz
*
*
*/
*/
public
interface
ApiOpenApiEsFieldsMapper
extends
BaseMapper
<
ApiOpenApiEsFields
>
{
public
interface
ApiOpenApiEsFieldsMapper
extends
BaseMapper
<
ApiOpenApiEsFields
>
{
/**
* 批量插入字段信息
* @param lists
*/
void
insetBatch
(
@Param
(
"lists"
)
ArrayList
<
ApiOpenApiEsFields
>
lists
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiReqLogMapper.java
View file @
3c1a67a6
...
@@ -2,10 +2,18 @@ package com.jz.dm.mapper;
...
@@ -2,10 +2,18 @@ package com.jz.dm.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
org.apache.ibatis.annotations.Select
;
/**api请求日志表 mapper
/**api请求日志表 mapper
* @author ybz
* @author ybz
*/
*/
public
interface
ApiReqLogMapper
extends
BaseMapper
<
ApiReqLog
>
{
public
interface
ApiReqLogMapper
extends
BaseMapper
<
ApiReqLog
>
{
/**
* 查询出最大id数据
* @param id
* @return
*/
@Select
(
"SELECT * FROM t_api_req_log WHERE id =(SELECT MAX(id) FROM t_api_req_log)"
)
ApiReqLog
maxId
(
Long
id
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
3c1a67a6
...
@@ -48,6 +48,11 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -48,6 +48,11 @@ public class ApiInterface extends BaseObject implements Serializable {
@TableField
(
"api_protocl"
)
@TableField
(
"api_protocl"
)
private
String
apiProtocl
;
private
String
apiProtocl
;
/**
* api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义'
*/
@TableField
(
"api_type"
)
private
String
apiType
;
/**
/**
* 目标url
* 目标url
*/
*/
...
@@ -59,6 +64,11 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -59,6 +64,11 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
*/
@TableField
(
"status"
)
@TableField
(
"status"
)
private
String
status
;
private
String
status
;
/**
* 接口功能
*/
@TableField
(
"api_function"
)
private
String
apiFunction
;
/**
/**
* 版本号
* 版本号
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
domian
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.jz.dm.common.base.BaseObject
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* @Description:
* @Author: Mr.zhang
* @Date: 2020-12-23
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@TableName
(
"t_api_interface_custom"
)
public
class
ApiInterfaceCustom
extends
BaseObject
implements
Serializable
{
/**
* api唯一标识
*/
@TableField
(
"api_key"
)
private
String
apiKey
;
/**
* apiInterfaceId
*/
@TableField
(
"api_interface_id"
)
private
Long
apiInterfaceId
;
/**
* api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义'
*/
@TableField
(
"api_type"
)
private
String
apiType
;
/**
* api请求参数
*/
@TableField
(
"request_param"
)
private
String
requestParam
;
/**
* api响应参数
*/
@TableField
(
"response_param"
)
private
String
responseParam
;
/**
* 请求头
*/
@TableField
(
"req_headers"
)
private
String
reqHeaders
;
/**
* 响应状态码
*/
@TableField
(
"resp_code"
)
private
String
respCode
;
/**
* api返回样例
*/
@TableField
(
"api_example"
)
private
String
apiExample
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiOrg.java
View file @
3c1a67a6
...
@@ -45,6 +45,16 @@ public class ApiOrg extends BaseObject implements Serializable {
...
@@ -45,6 +45,16 @@ public class ApiOrg extends BaseObject implements Serializable {
*/
*/
@TableField
(
"org_cn_name"
)
@TableField
(
"org_cn_name"
)
private
String
orgCnName
;
private
String
orgCnName
;
/**
* 组织电话
*/
@TableField
(
"org_phone"
)
private
String
orgPhone
;
/**
* 组织类型 OUT 外部组织 IN 内部组织
*/
@TableField
(
"org_type"
)
private
String
orgType
;
/**
/**
* 状态(1-正常 2-冻结 3-下架)
* 状态(1-正常 2-冻结 3-下架)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/dto/AuthInfoDto.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.dto
* @PROJECT_NAME: jz-dm-parent
* @NAME: AuthInfoDto
* @DATE: 2020-12-27/0:31
* @DAY_NAME_SHORT: 周日
* @Description:
**/
@Data
@ApiModel
(
"授权信息返回体"
)
public
class
AuthInfoDto
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"授权组织id"
)
private
Long
apiOrgId
;
@ApiModelProperty
(
value
=
"api应用id"
)
private
Long
apiInterfaceId
;
@ApiModelProperty
(
value
=
"授权组织名称"
)
private
String
orgName
;
@ApiModelProperty
(
value
=
"apiKey"
)
private
String
apiKey
;
@ApiModelProperty
(
value
=
"授权方式:1.按次调用 2.按时间调用,3永久有效"
)
private
String
authMode
;
@ApiModelProperty
(
value
=
"开始时间"
)
private
Date
validStartTime
;
@ApiModelProperty
(
value
=
"结束时间"
)
private
Date
validEndTime
;
@ApiModelProperty
(
value
=
"状态(1-正常 2-作废"
)
private
String
status
;
@ApiModelProperty
(
value
=
"备注"
)
private
String
remark
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"创建用户"
)
private
String
createUser
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthDetailInfoReq.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
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: AuthDetailInfoReq
* @DATE: 2020-12-26/15:56
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"认证详情信息查询"
)
public
class
AuthDetailInfoReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
,
required
=
true
)
@NotNull
(
message
=
"id不能为空"
)
private
Long
id
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthDmpUserApiReq.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
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.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: AuthMallUserApiReq
* @DATE: 2020-12-26/15:52
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"DMP用户API认证"
)
public
class
AuthDmpUserApiReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"apiKey唯一标识"
,
required
=
true
)
@NotNull
(
message
=
"apiKey唯一标识不能为空"
)
private
String
apiKey
;
@ApiModelProperty
(
value
=
"组织id"
,
required
=
true
)
@NotNull
(
message
=
"组织id不能为空"
)
private
Long
orgId
;
@ApiModelProperty
(
value
=
"授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTH dmp授权"
,
required
=
true
)
@NotNull
(
message
=
"授权类型不能为空"
)
private
AuthTypeEnum
authType
;
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@NotNull
(
message
=
"授权方式不能为空"
)
private
AuthModeEnum
authMode
;
@ApiModelProperty
(
value
=
"开始时间"
,
required
=
false
)
private
String
validStartTime
;
@ApiModelProperty
(
value
=
"结束时间"
,
required
=
false
)
private
String
validEndTime
;
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthInfoUpdateReq.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
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: AuthDetailInfoReq
* @DATE: 2020-12-26/15:56
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"认证信息修改"
)
public
class
AuthInfoUpdateReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
,
required
=
true
)
@NotNull
(
message
=
"id不能为空"
)
private
Long
id
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthListInfoReq.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: AuthListInfoReq
* @DATE: 2020-12-27/0:22
* @DAY_NAME_SHORT: 周日
* @Description:
**/
@Data
@ApiModel
(
"认证信息列表请求体"
)
public
class
AuthListInfoReq
extends
BasePageBean
implements
Serializable
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/AuthMallUserApiReq.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
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.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: AuthMallUserApiReq
* @DATE: 2020-12-26/15:52
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"商城用户API认证"
)
public
class
AuthMallUserApiReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"apiKey唯一标识"
,
required
=
true
)
@NotNull
(
message
=
"apiKey唯一标识不能为空"
)
private
String
apiKey
;
@ApiModelProperty
(
value
=
"组织id"
,
required
=
true
)
@NotNull
(
message
=
"组织id不能为空"
)
private
Long
orgId
;
@ApiModelProperty
(
value
=
"授权类型:DATA_BANK_AUTH 数据银行 , DMP_AUTHdmp 授权"
,
required
=
true
)
@NotNull
(
message
=
"授权类型不能为空"
)
private
AuthTypeEnum
authType
;
@ApiModelProperty
(
value
=
"授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效"
,
required
=
true
)
@NotNull
(
message
=
"授权方式不能为空"
)
private
AuthModeEnum
authMode
;
@ApiModelProperty
(
value
=
"开始时间"
,
required
=
false
)
private
String
validStartTime
;
@ApiModelProperty
(
value
=
"结束时间"
,
required
=
false
)
private
String
validEndTime
;
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/auth/SaltResetReq.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
.
auth
;
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: SaltResetReq
* @DATE: 2020-12-26/19:16
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"盐值重置请求体"
)
public
class
SaltResetReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
,
required
=
true
)
@NotNull
(
message
=
"id不能为空"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"盐值"
,
required
=
true
)
@NotNull
(
message
=
"盐值不能为空"
)
private
String
salt
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
0 → 100644
View file @
3c1a67a6
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
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req.make
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiInterfaceReq
* @DATE: 2020-12-29/10:48
* @DAY_NAME_SHORT: 周二
* @Description:
**/
@Data
@ApiModel
(
value
=
"api基本信息"
)
public
class
ApiInterfaceReq
{
@ApiModelProperty
(
value
=
"api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义"
,
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
=
"api名称"
,
required
=
false
)
public
String
apiName
;
@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/MakeApiSaveInfoReq.java
0 → 100644
View file @
3c1a67a6
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.make
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeApiSaveInfoReq
* @DATE: 2020-12-29/10:00
* @DAY_NAME_SHORT: 周二
* @Description:
**/
@Data
@ApiModel
(
"保存API基本信息请求体"
)
public
class
MakeApiSaveInfoReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
,
required
=
true
)
@NotNull
(
message
=
"id不能为空"
)
public
Long
id
;
@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
=
"传输方式"
,
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
=
true
)
@NotNull
(
message
=
"项目编号不能为空"
)
public
String
projectId
;
@ApiModelProperty
(
value
=
"列"
,
required
=
false
)
public
String
columnCode
;
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
public
String
status
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
.
make
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeBigDataApiReq
* @DATE: 2020-12-26/13:08
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"Api制作大数据查询/标签查询请求体"
)
public
class
MakeBigDataApiReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id--更新时id不能为空"
,
required
=
false
)
private
Long
id
;
@ApiModelProperty
(
value
=
"数据类型:api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 8 查询hive数据源 9自定义"
,
required
=
true
)
@NotNull
(
message
=
"apiType不能为空"
)
private
String
apiType
;
@ApiModelProperty
(
value
=
"apiId 等价于apiKey"
,
required
=
true
)
@NotNull
(
message
=
"apiId不能为空"
)
public
String
apiId
;
@ApiModelProperty
(
value
=
"数据源Id"
,
required
=
true
)
@NotNull
(
message
=
"数据源Id不能为空"
)
private
String
esDataSource
;
@ApiModelProperty
(
value
=
"源库名称"
,
required
=
true
)
@NotNull
(
message
=
"源库名称不能为空"
)
private
String
esDatabase
;
@ApiModelProperty
(
value
=
"源表名称"
,
required
=
true
)
@NotNull
(
message
=
"源表名称不能为空"
)
private
String
esTable
;
@ApiModelProperty
(
value
=
"处理类型"
,
required
=
true
)
@NotNull
(
message
=
"处理类型不能为空"
)
private
String
handleType
;
@ApiModelProperty
(
value
=
"是否分页"
,
required
=
false
)
private
long
page
;
@ApiModelProperty
(
value
=
"请求参数"
,
required
=
true
)
@NotNull
(
message
=
"请求参数不能为空"
)
private
String
requestParam
;
@ApiModelProperty
(
value
=
"返回参数"
,
required
=
true
)
@NotNull
(
message
=
"返回参数不能为空"
)
private
String
resultParam
;
@ApiModelProperty
(
value
=
"段列表"
,
required
=
true
)
@NotNull
(
message
=
"字段列表不能为空"
)
private
String
tableFields
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeCustomApiReq.java
0 → 100644
View file @
3c1a67a6
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
0 → 100644
View file @
3c1a67a6
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.make
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeDataBankApiReq
* @DATE: 2020-12-30/15:32
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Data
@ApiModel
(
"数据银行api制作"
)
public
class
MakeDataBankApiReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义"
,
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
=
"传输方式(1为HTTPS,2为HTTP)"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
public
String
transMode
;
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@NotNull
(
message
=
"加密方式不能为空"
)
public
String
type
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
false
)
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
false
)
public
String
timeout
;
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"请求头"
,
required
=
false
)
public
String
reqHeaders
;
@ApiModelProperty
(
value
=
"请求参数"
,
required
=
false
)
public
String
requestParam
;
@ApiModelProperty
(
value
=
"响应参数"
,
required
=
false
)
public
String
responseParam
;
@ApiModelProperty
(
value
=
"响应状态码"
,
required
=
false
)
public
String
respCode
;
@ApiModelProperty
(
value
=
"api样例"
,
required
=
false
)
public
String
apiExample
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeRealCustomApiReq.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
.
make
;
import
io.swagger.annotations.ApiModel
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: MakeRealCustomApiReq
* @DATE: 2020-12-26/13:06
* @DAY_NAME_SHORT: 周六
* @Description:
**/
@Data
@ApiModel
(
"API制作(实时接入)"
)
public
class
MakeRealCustomApiReq
implements
Serializable
{
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/SourceConfigReq.java
0 → 100644
View file @
3c1a67a6
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.make
* @PROJECT_NAME: jz-dm-parent
* @NAME: SourceConfigReq
* @DATE: 2020-12-27/1:44
* @DAY_NAME_SHORT: 周日
* @Description:
**/
@Data
@ApiModel
(
"数据源配置请求体"
)
public
class
SourceConfigReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"发布id"
,
required
=
false
)
private
String
releaseId
;
@ApiModelProperty
(
value
=
"apiKey"
,
required
=
true
)
@NotNull
(
message
=
"apiKey不能为空"
)
private
String
apiKey
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/OrganizationManageAddReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
organizationManage/
OrganizationManageAddReq.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
;
package
com
.
jz
.
dm
.
models
.
req
.
organizationManage
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -37,6 +37,13 @@ public class OrganizationManageAddReq implements Serializable {
...
@@ -37,6 +37,13 @@ public class OrganizationManageAddReq implements Serializable {
@ApiModelProperty
(
value
=
"组织邮箱"
,
required
=
false
)
@ApiModelProperty
(
value
=
"组织邮箱"
,
required
=
false
)
private
String
orgMail
;
private
String
orgMail
;
@ApiModelProperty
(
value
=
"组织电话"
,
required
=
false
)
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/OrganizationManageDetailQueryReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
organizationManage/
OrganizationManageDetailQueryReq.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
;
package
com
.
jz
.
dm
.
models
.
req
.
organizationManage
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/OrganizationManageListQueryReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
organizationManage/
OrganizationManageListQueryReq.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
;
package
com
.
jz
.
dm
.
models
.
req
.
organizationManage
;
import
com.jz.common.bean.BasePageBean
;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/OrganizationManageUpdateReq.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/
organizationManage/
OrganizationManageUpdateReq.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
models
.
req
;
package
com
.
jz
.
dm
.
models
.
req
.
organizationManage
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/AuthService.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
service
;
package
com
.
jz
.
dm
.
service
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.req.auth.*
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service
* @PACKAGE_NAME: com.jz.dm.service
...
@@ -10,4 +13,45 @@ package com.jz.dm.service;
...
@@ -10,4 +13,45 @@ package com.jz.dm.service;
* @Description:
* @Description:
**/
**/
public
interface
AuthService
{
public
interface
AuthService
{
/**
* 认证列表
* @param req
* @return
*/
Result
getAuthListInfo
(
AuthListInfoReq
req
);
/**
* 获取认证详情信息
* @param req
* @return
*/
Result
getAuthDetailInfo
(
AuthDetailInfoReq
req
);
/**
* 添加Dmp用户认证
* @param req
* @return
*/
Result
addDmpUserApiAuth
(
AuthDmpUserApiReq
req
);
/**
* 添加商城用户api认证
* @param req
* @return
*/
Result
addMallUserApiAuth
(
AuthMallUserApiReq
req
);
/**
* 修改认证信息
* @param req
* @return
*/
Result
updateAuthInfo
(
AuthInfoUpdateReq
req
);
/**
* 盐值重置
* @param req
* @return
*/
Result
updateSaltInfo
(
SaltResetReq
req
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/OrganizationManageService.java
View file @
3c1a67a6
...
@@ -3,10 +3,10 @@ package com.jz.dm.service;
...
@@ -3,10 +3,10 @@ package com.jz.dm.service;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.domian.ApiOrg
;
import
com.jz.dm.models.domian.ApiOrg
;
import
com.jz.dm.models.req.OrganizationManageAddReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageAddReq
;
import
com.jz.dm.models.req.OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.OrganizationManageUpdateReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageUpdateReq
;
/**
/**
* @author ZC
* @author ZC
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/ProducerService.java
View file @
3c1a67a6
package
com
.
jz
.
dm
.
service
;
package
com
.
jz
.
dm
.
service
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.models.req.make.*
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service
* @PACKAGE_NAME: com.jz.dm.service
...
@@ -10,4 +13,77 @@ package com.jz.dm.service;
...
@@ -10,4 +13,77 @@ package com.jz.dm.service;
* @Description:
* @Description:
**/
**/
public
interface
ProducerService
{
public
interface
ProducerService
{
/**
* 制作自定义APi
* @param req
* @return
*/
Result
addCustomApi
(
MakeCustomApiReq
req
);
/**
* Api制作(实时接入)
* @param req
* @return
*/
Result
addRealCustomApi
(
MakeRealCustomApiReq
req
);
/**
* Api制作(大数据查询/标签查询)
* @param req
* @return
*/
Result
addBigDataMakeApi
(
MakeBigDataApiReq
req
);
/**
* 获取数据源配置
* @param req
* @return
*/
Result
getSourceConfig
(
SourceConfigReq
req
);
/**
* 获取数据库列表
* @param id
* @return
*/
Result
getSourceWarehouseList
(
Long
id
);
/**
* 获取某个索引下的type
* @param indices
* @param id
* @return
*/
Result
getIndicesTypes
(
String
indices
,
Long
id
);
/**
* 获取某个索引 type的fields
* @param indices
* @param type
* @param id
* @return
*/
Result
getIndicesTypesFields
(
String
indices
,
String
type
,
Long
id
);
/**
* 保存修改的api信息
* @param req
* @return
*/
Result
saveUpdateAPiInfo
(
MakeApiSaveInfoReq
req
);
/**
* 数据银行制作API/数据包
* @param req
* @return
*/
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
);
/**
* 保存 API基本信息
* @param req
* @return
*/
Result
saveInterfaceAPi
(
ApiInterfaceReq
req
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/apirequest/ApiQueryService.java
View file @
3c1a67a6
...
@@ -3,8 +3,12 @@ package com.jz.dm.service.apirequest;
...
@@ -3,8 +3,12 @@ package com.jz.dm.service.apirequest;
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.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
/**
/**
* @author ZC
* @author ZC
...
@@ -29,6 +33,9 @@ public class ApiQueryService implements OpenApiService {
...
@@ -29,6 +33,9 @@ public class ApiQueryService implements OpenApiService {
}
}
@Override
@Override
@ApiLogAspect
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
View file @
3c1a67a6
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.config.ReentrantRedisLock
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.models.req.LogInfoDetailReq
;
import
com.jz.dm.models.req.LogInfoDetailReq
;
...
@@ -11,6 +12,7 @@ import com.jz.dm.models.req.LogInfoListReq;
...
@@ -11,6 +12,7 @@ import com.jz.dm.models.req.LogInfoListReq;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.service.ApiLogService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -31,7 +33,9 @@ public class ApiLogServiceImpl implements ApiLogService {
...
@@ -31,7 +33,9 @@ public class ApiLogServiceImpl implements ApiLogService {
@Resource
@Resource
private
ApiReqLogMapper
apiReqLogMapper
;
private
ApiReqLogMapper
apiReqLogMapper
;
// 加锁
@Autowired
private
ReentrantRedisLock
lock
;
/**
/**
* 日志信息列表
* 日志信息列表
* @param req
* @param req
...
@@ -72,15 +76,26 @@ public class ApiLogServiceImpl implements ApiLogService {
...
@@ -72,15 +76,26 @@ public class ApiLogServiceImpl implements ApiLogService {
*/
*/
@Override
@Override
public
void
updateLog
(
Long
id
,
JSONObject
jsonObject
)
{
public
void
updateLog
(
Long
id
,
JSONObject
jsonObject
)
{
ApiReqLog
apiReqLog
=
apiReqLogMapper
.
selectById
(
id
);
//if (!lock.tryLock("apiLog")){
if
(
null
!=
apiReqLog
){
// return;
ApiReqLog
reqLog
=
new
ApiReqLog
();
//}
reqLog
.
setId
(
id
);
try
{
reqLog
.
setResponseParams
(
jsonObject
.
toString
());
ApiReqLog
apiReqLog
=
apiReqLogMapper
.
maxId
(
id
);
reqLog
.
setUpdateDate
(
new
Date
());
if
(
null
!=
apiReqLog
){
apiReqLogMapper
.
updateById
(
reqLog
);
ApiReqLog
reqLog
=
new
ApiReqLog
();
}
else
{
reqLog
.
setId
(
apiReqLog
.
getId
());
log
.
info
(
"id为:{}"
,
id
+
"-----------------日志信息不存在"
);
reqLog
.
setResponseParams
(
jsonObject
.
toString
());
reqLog
.
setUpdateDate
(
new
Date
());
apiReqLogMapper
.
updateById
(
reqLog
);
}
else
{
log
.
info
(
"id为:{}"
,
id
+
"-----------------日志信息不存在"
);
}
}
catch
(
Exception
ex
){
log
.
error
(
"更新日志返回信息异常:{}"
,
ex
.
getMessage
());
}
}
//finally {
// lock.unlock("apiLog");
//}
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
3c1a67a6
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.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.enums.auth.AuthTypeEnum
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.mapper.ApiOrgMapper
;
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.dto.AuthInfoDto
;
import
com.jz.dm.models.req.auth.*
;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.service.AuthService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Date
;
/**
/**
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.impl
* @PACKAGE_NAME: com.jz.dm.service.impl
...
@@ -16,4 +37,170 @@ import org.springframework.stereotype.Service;
...
@@ -16,4 +37,170 @@ import org.springframework.stereotype.Service;
@Service
(
"authService"
)
@Service
(
"authService"
)
@Slf4j
@Slf4j
public
class
AuthServiceImpl
implements
AuthService
{
public
class
AuthServiceImpl
implements
AuthService
{
@Resource
private
ApiAuthMapper
apiAuthMapper
;
@Resource
private
ApiInterfaceMapper
apiInterfaceMapper
;
@Resource
private
ApiOrgMapper
apiOrgMapper
;
/**
* 认证信息列表
*
* @param req
* @return
*/
@Override
public
Result
getAuthListInfo
(
AuthListInfoReq
req
)
{
IPage
<
AuthInfoDto
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
AuthInfoDto
>
query
=
new
QueryWrapper
<>();
query
.
orderByDesc
(
"create_date"
);
IPage
<
AuthInfoDto
>
listSelectApiAuth
=
apiAuthMapper
.
listSelectApiAuth
(
page
,
query
);
return
Result
.
of_success
(
listSelectApiAuth
);
}
/**
* 认证信息详情
*
* @param req
* @return
*/
@Override
public
Result
getAuthDetailInfo
(
AuthDetailInfoReq
req
)
{
return
Result
.
of_success
(
apiAuthMapper
.
selectAuthDetail
(
req
));
}
/**
* 添加dmp认证信息
*
* @param req
* @return
*/
@Override
public
Result
addDmpUserApiAuth
(
AuthDmpUserApiReq
req
)
{
ApiInterface
apiInterface
=
getInterface
(
req
.
getApiKey
());
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
"api授权信息不存在!"
);
}
ApiOrg
apiOrg
=
apiOrgMapper
.
selectById
(
req
.
getOrgId
());
if
(
null
==
apiOrg
)
{
return
Result
.
of_error
(
"组织信息不存在!"
);
}
//授权验证
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
().
name
())
&&
!
AuthTypeEnum
.
DMP_AUTH
.
name
().
equals
(
req
.
getAuthType
()))
{
return
Result
.
of_error
(
"授权类型错误!"
);
}
//认证类型
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
().
name
())
&&
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getValidStartTime
())
||
StringUtils
.
isBlank
(
req
.
getValidEndTime
()))
{
return
Result
.
of_error
(
"开始或结束时间不能为空!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
().
name
())
&&
AuthModeEnum
.
POWER_CALL_MODE
.
name
().
equals
(
req
.
getAuthMode
()))
{
return
Result
.
of_error
(
"授权类型错误!"
);
}
ApiAuth
apiAuth
=
new
ApiAuth
();
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
apiAuth
.
setApiInterfaceId
(
apiInterface
.
getId
());
apiAuth
.
setAuthCode
(
""
);
//授权码
apiAuth
.
setSalt
(
""
);
//盐值
apiAuth
.
setStatus
(
"1"
);
//授权状态
if
(
apiAuthMapper
.
insert
(
apiAuth
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
}
return
Result
.
of_success
(
ResultMsg
.
FAILURE
);
}
/**
* 添加商城用户认证信息
*
* @param req
* @return
*/
@Override
public
Result
addMallUserApiAuth
(
AuthMallUserApiReq
req
)
{
ApiInterface
apiInterface
=
getInterface
(
req
.
getApiKey
());
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
"api授权信息不存在!"
);
}
ApiOrg
apiOrg
=
apiOrgMapper
.
selectById
(
req
.
getOrgId
());
if
(
null
==
apiOrg
)
{
return
Result
.
of_error
(
"组织信息不存在!"
);
}
//授权验证
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthType
().
name
())
&&
!
AuthTypeEnum
.
DATA_BANK_AUTH
.
name
().
equals
(
req
.
getAuthType
()))
{
return
Result
.
of_error
(
"授权类型错误!"
);
}
//认证类型
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
().
name
())
&&
AuthModeEnum
.
RECORD_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getValidStartTime
())
||
StringUtils
.
isBlank
(
req
.
getValidEndTime
()))
{
return
Result
.
of_error
(
"开始或结束时间不能为空!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getAuthMode
().
name
())
&&
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
().
equals
(
req
.
getAuthMode
()))
{
return
Result
.
of_error
(
"授权类型错误!"
);
}
ApiAuth
apiAuth
=
new
ApiAuth
();
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
apiAuth
.
setApiInterfaceId
(
apiInterface
.
getId
());
apiAuth
.
setAuthCode
(
""
);
//授权码
apiAuth
.
setSalt
(
""
);
//盐值
apiAuth
.
setStatus
(
"1"
);
//授权状态
if
(
apiAuthMapper
.
insert
(
apiAuth
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
}
return
Result
.
of_success
(
ResultMsg
.
FAILURE
);
}
/**
* 修改用户认证信息
*
* @param req
* @return
*/
@Override
public
Result
updateAuthInfo
(
AuthInfoUpdateReq
req
)
{
//TODO 认证后是否可以修改
return
null
;
}
/**
* 盐值重置
*
* @param req
* @return
*/
@Override
public
Result
updateSaltInfo
(
SaltResetReq
req
)
{
ApiAuth
apiAuth
=
apiAuthMapper
.
selectById
(
req
.
getId
());
if
(
null
==
apiAuth
)
{
return
Result
.
of_error
(
"认证用户不存在"
);
}
if
(
StringUtils
.
isNotBlank
(
req
.
getSalt
()))
{
UpdateWrapper
<
ApiAuth
>
update
=
new
UpdateWrapper
<>();
update
.
set
(
"salt"
,
req
.
getSalt
());
update
.
set
(
"create_time"
,
new
Date
());
update
.
set
(
"create_user"
,
""
);
update
.
eq
(
"id"
,
req
.
getId
());
if
(
apiAuthMapper
.
update
(
null
,
update
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
}
return
Result
.
of_success
(
ResultMsg
.
UPDATE_FAIL
);
}
private
ApiInterface
getInterface
(
String
apiKey
){
QueryWrapper
<
ApiInterface
>
queryInface
=
new
QueryWrapper
<>();
queryInface
.
last
(
"where is_deleted=0 and api_key ="
+
apiKey
+
""
);
ApiInterface
apiInterface
=
apiInterfaceMapper
.
selectOne
(
queryInface
);
if
(
null
!=
apiInterface
){
return
apiInterface
;
}
return
null
;
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
View file @
3c1a67a6
...
@@ -5,15 +5,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
...
@@ -5,15 +5,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.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
;
import
com.jz.dm.models.req.OrganizationManageAddReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageAddReq
;
import
com.jz.dm.models.req.OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.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.ApiBeforeLog
;
import
com.jz.dm.web.annotation.ApiReturnLog
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
...
@@ -36,12 +36,14 @@ import java.util.Date;
...
@@ -36,12 +36,14 @@ import java.util.Date;
@Slf4j
@Slf4j
public
class
OrganizationManageImpl
implements
OrganizationManageService
{
public
class
OrganizationManageImpl
implements
OrganizationManageService
{
@Resource
@Resource
private
ApiOrgMapper
apiOrgMapper
;
private
ApiOrgMapper
apiOrgMapper
;
@Resource
@Resource
private
RedisTemplate
redisTemplate
;
private
RedisTemplate
redisTemplate
;
/**
/**
* 组织列表信息查询
* 组织列表信息查询
*
* @param req
* @param req
* @return
* @return
*/
*/
...
@@ -50,23 +52,23 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -50,23 +52,23 @@ public class OrganizationManageImpl implements OrganizationManageService {
IPage
<
ApiOrg
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
IPage
<
ApiOrg
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
orderByDesc
(
"create_date"
);
query
.
orderByDesc
(
"create_date"
);
return
apiOrgMapper
.
selectPage
(
page
,
query
);
return
apiOrgMapper
.
selectPage
(
page
,
query
);
}
}
/**
/**
* 获取组织详情
* 获取组织详情
*
* @param req
* @param req
* @return
* @return
*/
*/
@Override
@Override
@ApiBeforeLog
@ApiReturnLog
public
Result
getOrganizationDetail
(
OrganizationManageDetailQueryReq
req
)
{
public
Result
getOrganizationDetail
(
OrganizationManageDetailQueryReq
req
)
{
return
Result
.
of_success
(
apiOrgMapper
.
selectById
(
req
.
getId
()));
return
Result
.
of_success
(
apiOrgMapper
.
selectById
(
req
.
getId
()));
}
}
/**
/**
* 添加组织
* 添加组织
*
* @param req
* @param req
* @return
* @return
*/
*/
...
@@ -76,23 +78,51 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -76,23 +78,51 @@ public class OrganizationManageImpl implements OrganizationManageService {
//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
=
""
;
ApiOrg
apiOrg
=
new
ApiOrg
();
ApiOrg
apiOrg
=
new
ApiOrg
();
BeanUtils
.
copyProperties
(
req
,
apiOrg
);
BeanUtils
.
copyProperties
(
req
,
apiOrg
);
apiOrg
.
setOrgCode
(
"111eef33"
);
//组织编码需要生成
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
())
//内部组织
&&
Constants
.
AUTH_INT
.
equals
(
req
.
getOrgType
()))
{
coding
=
generateCode
(
req
.
getOrgName
(),
Constants
.
AUTH_INT
);
}
else
{
coding
=
generateCode
(
req
.
getOrgName
(),
Constants
.
AUTH_OUT
);
}
if
(
StringUtils
.
isBlank
(
coding
))
{
return
Result
.
of_error
(
"生成组织编码异常!"
);
}
apiOrg
.
setOrgCode
(
coding
);
//组织编码需要生成
apiOrg
.
setStatus
(
"1"
);
//正常
apiOrg
.
setStatus
(
"1"
);
//正常
//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
);
}
}
return
Result
.
of_error
(
ResultMsg
.
INSERT_FAIL
);
return
Result
.
of_error
(
ResultMsg
.
INSERT_FAIL
);
}
}
/**
* 获取组织编码(去重)
* @param orgName 组织名称
* @param type 生成类型
* @return
*/
private
String
generateCode
(
String
orgName
,
String
type
)
{
String
coding
=
""
;
coding
=
RandomUtil
.
generateOrgCoding
(
orgName
,
type
);
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"org_code"
,
coding
);
ApiOrg
org
=
apiOrgMapper
.
selectOne
(
query
);
if
(
null
!=
org
)
{
coding
=
RandomUtil
.
generateOrgCoding
(
orgName
,
type
);
}
return
coding
;
}
/**
/**
* 更新组织
* 更新组织
* @param req
* @param req
...
@@ -105,21 +135,21 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -105,21 +135,21 @@ public class OrganizationManageImpl implements OrganizationManageService {
// 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
.
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
(
"组织名称已存在"
);
}
}
}
}
ApiOrg
apiOrgUpdate
=
new
ApiOrg
();
ApiOrg
apiOrgUpdate
=
new
ApiOrg
();
apiOrgUpdate
.
setId
(
apiOrg
.
getId
());
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
);
}
}
return
Result
.
of_success
(
ResultMsg
.
UPDATE_FAIL
);
return
Result
.
of_success
(
ResultMsg
.
UPDATE_FAIL
);
...
@@ -133,10 +163,10 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -133,10 +163,10 @@ public class OrganizationManageImpl implements OrganizationManageService {
@Override
@Override
public
Result
delete
(
Long
id
)
{
public
Result
delete
(
Long
id
)
{
ApiOrg
apiOrg
=
apiOrgMapper
.
selectById
(
id
);
ApiOrg
apiOrg
=
apiOrgMapper
.
selectById
(
id
);
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
)
{
if
(
apiOrgMapper
.
deleteById
(
id
)
>
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
);
...
@@ -144,16 +174,17 @@ public class OrganizationManageImpl implements OrganizationManageService {
...
@@ -144,16 +174,17 @@ public class OrganizationManageImpl implements OrganizationManageService {
/**
/**
* 根据名称获取组织信息
* 根据名称获取组织信息
*
* @param orgName 组织名称
* @param orgName 组织名称
* @return
* @return
*/
*/
private
ApiOrg
getOrgNameInfo
(
String
orgName
)
{
private
ApiOrg
getOrgNameInfo
(
String
orgName
)
{
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"org_name"
,
orgName
);
query
.
eq
(
"org_name"
,
orgName
);
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"status"
,
"3"
);
query
.
eq
(
"status"
,
"3"
);
ApiOrg
apiOrg
=
apiOrgMapper
.
selectOne
(
query
);
ApiOrg
apiOrg
=
apiOrgMapper
.
selectOne
(
query
);
if
(
null
!=
apiOrg
){
if
(
null
!=
apiOrg
)
{
return
apiOrg
;
return
apiOrg
;
}
}
return
null
;
return
null
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
3c1a67a6
This diff is collapsed.
Click to expand it.
jz-dm-apigateway/src/main/java/com/jz/dm/web/annotation/AccessLimit.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
web
.
annotation
;
import
java.lang.annotation.*
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.web.annotation
* @PROJECT_NAME: jz-dm-parent
* @NAME: AccessLimit
* @DATE: 2020-12-26/17:38
* @DAY_NAME_SHORT: 周六
* @Description: 限流拦截器
**/
@Inherited
@Documented
@Target
({
ElementType
.
FIELD
,
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
AccessLimit
{
//标识 指定sec时间段内的访问次数限制
int
limit
()
default
5
;
//标识 时间段(秒)
int
sec
()
default
5
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/web/annotation/Api
BeforeLog
.java
→
jz-dm-apigateway/src/main/java/com/jz/dm/web/annotation/Api
LogAspect
.java
View file @
3c1a67a6
...
@@ -6,7 +6,7 @@ import java.lang.annotation.*;
...
@@ -6,7 +6,7 @@ import java.lang.annotation.*;
* @author ZC
* @author ZC
* @PACKAGE_NAME: com.jz.dm.web.annotation
* @PACKAGE_NAME: com.jz.dm.web.annotation
* @PROJECT_NAME: jz-dm-parent
* @PROJECT_NAME: jz-dm-parent
* @NAME: Api
BeforeLog
* @NAME: Api
LogAspect
* @DATE: 2020-12-25/15:50
* @DATE: 2020-12-25/15:50
* @DAY_NAME_SHORT: 周五
* @DAY_NAME_SHORT: 周五
* @Description: api全局切面日志
* @Description: api全局切面日志
...
@@ -14,6 +14,6 @@ import java.lang.annotation.*;
...
@@ -14,6 +14,6 @@ import java.lang.annotation.*;
@Target
({
ElementType
.
PARAMETER
,
ElementType
.
METHOD
})
//作用在参数和方法上
@Target
({
ElementType
.
PARAMETER
,
ElementType
.
METHOD
})
//作用在参数和方法上
@Retention
(
RetentionPolicy
.
RUNTIME
)
//运行时注解
@Retention
(
RetentionPolicy
.
RUNTIME
)
//运行时注解
@Documented
//表明这个注解应该被 javadoc工具记录
@Documented
//表明这个注解应该被 javadoc工具记录
public
@interface
Api
BeforeLog
{
public
@interface
Api
LogAspect
{
String
description
()
default
""
;
String
description
()
default
""
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/web/annotation/ApiReturnLog.java
deleted
100644 → 0
View file @
1d53c633
package
com
.
jz
.
dm
.
web
.
annotation
;
import
java.lang.annotation.*
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.web.annotation
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiReturnLog
* @DATE: 2020-12-25/17:43
* @DAY_NAME_SHORT: 周五
* @Description:
**/
@Target
({
ElementType
.
PARAMETER
,
ElementType
.
METHOD
})
//作用在参数和方法上
@Retention
(
RetentionPolicy
.
RUNTIME
)
//运行时注解
@Documented
//表明这个注解应该被 javadoc工具记录
public
@interface
ApiReturnLog
{
String
description
()
default
""
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
View file @
3c1a67a6
This diff is collapsed.
Click to expand it.
jz-dm-apigateway/src/main/java/com/jz/dm/web/interceptor/AccessLimitInterceptor.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
web
.
interceptor
;
import
com.jz.common.utils.IpUtils
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.web.aspect
* @PROJECT_NAME: jz-dm-parent
* @NAME: AccessLimitInterceptor
* @DATE: 2020-12-26/17:39
* @DAY_NAME_SHORT: 周六
* @Description:
**/
public
class
AccessLimitInterceptor
implements
HandlerInterceptor
{
//使用RedisTemplate操作redis
/* @Autowired
private RedisTemplate<String, Integer> redisTemplate;*/
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
if
(
handler
instanceof
HandlerMethod
)
{
HandlerMethod
handlerMethod
=
(
HandlerMethod
)
handler
;
Method
method
=
handlerMethod
.
getMethod
();
if
(!
method
.
isAnnotationPresent
(
AccessLimit
.
class
))
{
return
true
;
}
AccessLimit
accessLimit
=
method
.
getAnnotation
(
AccessLimit
.
class
);
if
(
accessLimit
==
null
)
{
return
true
;
}
int
limit
=
accessLimit
.
limit
();
int
sec
=
accessLimit
.
sec
();
String
key
=
IpUtils
.
getIpAddr
(
request
)
+
request
.
getRequestURI
();
/*Integer maxLimit = redisTemplate.opsForValue().get(key);
if (maxLimit == null) {
//set时一定要加过期时间
redisTemplate.opsForValue().set(key, 1, sec, TimeUnit.SECONDS);
} else if (maxLimit < limit) {
redisTemplate.opsForValue().set(key, maxLimit + 1, sec, TimeUnit.SECONDS);
} else {
output(response, "请求太频繁~!");
return false;
}*/
}
return
true
;
}
public
void
output
(
HttpServletResponse
response
,
String
msg
)
throws
IOException
{
response
.
setContentType
(
"application/json;charset=UTF-8"
);
ServletOutputStream
outputStream
=
null
;
try
{
outputStream
=
response
.
getOutputStream
();
outputStream
.
write
(
msg
.
getBytes
(
"UTF-8"
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
outputStream
.
flush
();
outputStream
.
close
();
}
}
@Override
public
void
postHandle
(
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
,
Object
o
,
ModelAndView
modelAndView
)
throws
Exception
{
}
@Override
public
void
afterCompletion
(
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
,
Object
o
,
Exception
e
)
throws
Exception
{
}
}
jz-dm-apigateway/src/main/resources/application-test.yml
View file @
3c1a67a6
...
@@ -54,9 +54,9 @@ spring:
...
@@ -54,9 +54,9 @@ spring:
public-key
:
rajZdV0xpCox+2vEHFLsKq2o2XVdMaQq
public-key
:
rajZdV0xpCox+2vEHFLsKq2o2XVdMaQq
redis
:
redis
:
#database: 0
#database: 0
host
:
47.115.53.1
host
:
47.115.53.1
port
:
6379
port
:
6379
password
:
123456
password
:
123456
#timeout: 5000
#timeout: 5000
# cluster:
# cluster:
# nodes:
# nodes:
...
@@ -72,4 +72,14 @@ spring:
...
@@ -72,4 +72,14 @@ spring:
#切面启用
#切面启用
aop
:
aop
:
proxy-target-class
:
true
proxy-target-class
:
true
auto
:
true
auto
:
true
\ No newline at end of file
#rePrefix redis存储的前缀
#ignoreRedis true存入 false不存 api.timeout.default
dmp
:
ignoreRedis
:
true
rePrefix
:
test
openapi
:
timeout
:
default
:
5000
max
:
5000
jz-dm-apigateway/src/main/resources/mapper/ApiAuthMapper.xml
View file @
3c1a67a6
...
@@ -7,5 +7,43 @@
...
@@ -7,5 +7,43 @@
status, remark, create_date, create_user, update_date,
status, remark, create_date, create_user, update_date,
update_user, is_deleted
update_user, is_deleted
</sql>
</sql>
<select
id=
"selectAuthDetail"
resultType=
"com.jz.dm.models.dto.AuthInfoDto"
>
SELECT au.id AS id,
au.api_org_id AS apiOrgId,
au.api_interface_id AS apiInterFace,
au.auth_mode AS authMode,
au.valid_start_time AS validStartTime,
au.valid_end_time AS validEndTime,
au.status AS status,
au.remark AS remark,
au.create_time AS createDate,
au.create_user AS createUser,
ao.org_name AS orgName,
ai.api_key AS apiKey
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_org AS ao ON au.api_org_id = ao.id AND ao.`status` ='1' AND ao.is_deleted =0
WHERE au.is_deleted =0
AND au.id =#{req.getId}
</select>
<select
id=
"listSelectApiAuth"
resultType=
"com.jz.dm.models.dto.AuthInfoDto"
>
SELECT au.id AS id,
au.api_org_id AS apiOrgId,
au.api_interface_id AS apiInterFace,
au.auth_mode AS authMode,
au.valid_start_time AS validStartTime,
au.valid_end_time AS validEndTime,
au.status AS status,
au.remark AS remark,
au.create_time AS createDate,
au.create_user AS createUser,
ao.org_name AS orgName,
ai.api_key AS apiKey
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_org AS ao ON au.api_org_id = ao.id AND ao.`status` ='1' AND ao.is_deleted =0
${ew.customSqlSegment}
</select>
</mapper>
</mapper>
jz-dm-apigateway/src/main/resources/mapper/ApiInterfaceCustomMapper.xml
0 → 100644
View file @
3c1a67a6
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.jz.dm.mapper.ApiInterfaceMapper"
>
</mapper>
\ No newline at end of file
jz-dm-apigateway/src/main/resources/mapper/ApiOpenApiEsFieldsMapper.xml
View file @
3c1a67a6
...
@@ -7,5 +7,17 @@
...
@@ -7,5 +7,17 @@
field_desc, remark, create_date, create_user, update_date,
field_desc, remark, create_date, create_user, update_date,
update_user, is_deleted
update_user, is_deleted
</sql>
</sql>
<insert
id=
"insetBatch"
>
INSERT INTO `t_api_open_api_es_fields`
(`es_database`, `es_table`, `field_name`, `field_type`, `field_desc`, `create_user`)
VALUES
<if
test=
"lists != null and lists.size >0"
>
<foreach
collection=
"lists"
item=
"item"
separator=
","
>
( #{item.esDatabase}, #{item.esTable}, #{item.fieldName},#{item.fieldType},
#{item.fieldDesc},#{item.createUser})
</foreach>
</if>
</insert>
</mapper>
</mapper>
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/TestApplicationContextInitializer.java
View file @
3c1a67a6
...
@@ -36,7 +36,7 @@ public class TestApplicationContextInitializer implements ApplicationContextInit
...
@@ -36,7 +36,7 @@ public class TestApplicationContextInitializer implements ApplicationContextInit
ResourcePatternResolver
resolver
=
new
PathMatchingResourcePatternResolver
();
ResourcePatternResolver
resolver
=
new
PathMatchingResourcePatternResolver
();
Resource
[]
resources
=
null
;
Resource
[]
resources
=
null
;
try
{
try
{
resources
=
resolver
.
getResources
(
"classpath
:properties/*.properties
"
);
resources
=
resolver
.
getResources
(
"classpath
*:/**/*.yml
"
);
for
(
Resource
res
:
resources
)
{
for
(
Resource
res
:
resources
)
{
Properties
properties
=
PropertiesLoaderUtils
.
loadProperties
(
res
);
Properties
properties
=
PropertiesLoaderUtils
.
loadProperties
(
res
);
CollectionUtils
.
mergePropertiesIntoMap
(
properties
,
props
);
CollectionUtils
.
mergePropertiesIntoMap
(
properties
,
props
);
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/org/TestAuth.java
0 → 100644
View file @
3c1a67a6
package
com
.
jz
.
dm
.
gateway
.
org
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.service.AuthService
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.gateway.org
* @PROJECT_NAME: jz-dm-parent
* @NAME: TestAuth
* @DATE: 2020-12-30/15:16
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
class
TestAuth
extends
SpringTestCase
{
@Autowired
private
AuthService
authService
;
}
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/org/TestOrganizationManage.java
View file @
3c1a67a6
...
@@ -4,10 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
...
@@ -4,10 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.models.domian.ApiOrg
;
import
com.jz.dm.models.domian.ApiOrg
;
import
com.jz.dm.models.req.OrganizationManageAddReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageAddReq
;
import
com.jz.dm.models.req.OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageDetailQueryReq
;
import
com.jz.dm.models.req.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.OrganizationManageUpdateReq
;
import
com.jz.dm.models.req.
organizationManage.
OrganizationManageUpdateReq
;
import
com.jz.dm.service.OrganizationManageService
;
import
com.jz.dm.service.OrganizationManageService
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -43,7 +43,7 @@ public class TestOrganizationManage extends SpringTestCase {
...
@@ -43,7 +43,7 @@ public class TestOrganizationManage extends SpringTestCase {
@Test
@Test
public
void
getOrgDetail
(){
public
void
getOrgDetail
(){
OrganizationManageDetailQueryReq
req
=
new
OrganizationManageDetailQueryReq
();
OrganizationManageDetailQueryReq
req
=
new
OrganizationManageDetailQueryReq
();
req
.
setId
(
5
L
);
req
.
setId
(
1
L
);
Result
detail
=
organizationManageService
.
getOrganizationDetail
(
req
);
Result
detail
=
organizationManageService
.
getOrganizationDetail
(
req
);
ApiOrg
apiOrg
=
(
ApiOrg
)
detail
.
getData
();
ApiOrg
apiOrg
=
(
ApiOrg
)
detail
.
getData
();
System
.
out
.
println
(
apiOrg
);
System
.
out
.
println
(
apiOrg
);
...
...
jz-dm-common/pom.xml
View file @
3c1a67a6
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
...
@@ -62,6 +61,7 @@
...
@@ -62,6 +61,7 @@
<dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependency>
<!-- swagger2接口文档 -->
<!-- swagger2接口文档 -->
<dependency>
<dependency>
...
...
jz-dm-common/src/main/java/com/jz/common/utils/RedisUtils.java
0 → 100644
View file @
3c1a67a6
/**
* Copyright (c) 2011-2019 All Rights Reserved.
*/
package
com
.
jz
.
common
.
utils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.script.RedisScript
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
/**
*
*
* @author Admin
* @version $Id: RedisUtils.java 2019年11月2日 上午8:36:41 $
*/
@Component
(
"redisUtils"
)
public
class
RedisUtils
{
@Autowired
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
/**
* 实现命令:TTL key,以秒为单位,返回给定 key的剩余生存时间(TTL, time to live)。
*
* @param key
* @return
*/
public
long
ttl
(
String
key
)
{
return
redisTemplate
.
getExpire
(
key
);
}
/**
* 实现命令:expire 设置过期时间,单位秒
*
* @param key
* @return
*/
public
void
expire
(
String
key
,
long
timeout
)
{
redisTemplate
.
expire
(
key
,
timeout
,
TimeUnit
.
SECONDS
);
}
/**
* 实现命令:INCR key,增加key一次
*
* @param key
* @return
*/
public
long
incr
(
String
key
,
long
delta
)
{
return
redisTemplate
.
opsForValue
().
increment
(
key
,
delta
);
}
/**
* 实现命令: key,减少key一次
*
* @param key
* @return
*/
public
long
decr
(
String
key
,
long
delta
)
{
if
(
delta
<
0
)
{
del
(
key
);
return
0
;
}
return
redisTemplate
.
opsForValue
().
increment
(
key
,
-
delta
);
}
/**
* 实现命令:KEYS pattern,查找所有符合给定模式 pattern的 key
*/
public
Set
<
String
>
keys
(
String
pattern
)
{
return
redisTemplate
.
keys
(
pattern
);
}
/**
* 实现命令:DEL key,删除一个key
*
* @param key
*/
public
void
del
(
String
key
)
{
redisTemplate
.
delete
(
key
);
}
/**
* 实现命令:SET key value,设置一个key-value(将字符串值 value关联到 key)
*
* @param key
* @param value
*/
public
void
set
(
String
key
,
Object
value
)
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
);
}
/**
* 实现命令:SET key value EX seconds,设置key-value和超时时间(秒)
*
* @param key
* @param value
* @param timeout (以秒为单位)
*/
public
void
set
(
String
key
,
Object
value
,
long
timeout
)
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
,
timeout
,
TimeUnit
.
SECONDS
);
}
/**
* 实现命令:SET key value EX seconds,设置key-value和超时时间(分钟)
*
* @param key
* @param value
* @param timeout (以分钟为单位)
*/
public
Boolean
setIfAbsent
(
String
key
,
String
value
,
long
timeout
)
{
try
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
,
timeout
,
TimeUnit
.
MINUTES
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
return
true
;
}
/**
* 实现命令:GET key,返回 key所关联的字符串值。
*
* @param key
* @return value
*/
public
String
get
(
String
key
)
{
return
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
}
/**
* Hash(哈希表)
* 实现命令:HSET key field value,将哈希表 key中的域 field的值设为 value
*
* @param key
* @param field
* @param value
*/
public
void
hset
(
String
key
,
String
field
,
Object
value
)
{
redisTemplate
.
opsForHash
().
put
(
key
,
field
,
value
);
}
/**
* Hash(哈希表)
* 实现命令:HMSET key map 批量插入
*
* @param key
* @param m
*/
public
void
hmset
(
String
key
,
Map
<
Object
,
Object
>
m
)
{
redisTemplate
.
opsForHash
().
putAll
(
key
,
m
);
}
/**
* 实现命令:HGET key field,返回哈希表 key中给定域 field的值
*
* @param key
* @param field
* @return
*/
public
String
hget
(
String
key
,
String
field
)
{
return
(
String
)
redisTemplate
.
opsForHash
().
get
(
key
,
field
);
}
/**
* 实现命令:HDEL key field [field ...],删除哈希表 key 中的一个或多个指定域,不存在的域将被忽略。
*
* @param key
* @param fields
*/
public
void
hdel
(
String
key
,
Object
...
fields
)
{
redisTemplate
.
opsForHash
().
delete
(
key
,
fields
);
}
/**
* 实现命令:HGETALL key,返回哈希表 key中,所有的域和值。
*
* @param key
* @return
*/
public
Map
<
Object
,
Object
>
hgetall
(
String
key
)
{
return
redisTemplate
.
opsForHash
().
entries
(
key
);
}
/**
* List(列表)
* 实现命令:LPUSH key value,将一个值 value插入到列表 key的表头
*
* @param key
* @param value
* @return 执行 LPUSH命令后,列表的长度。
*/
public
long
lpush
(
String
key
,
Object
value
)
{
return
redisTemplate
.
opsForList
().
leftPush
(
key
,
value
);
}
/**
* 实现命令:LPOP key,移除并返回列表 key的头元素。
*
* @param key
* @return 列表key的头元素。
*/
public
String
lpop
(
String
key
)
{
return
(
String
)
redisTemplate
.
opsForList
().
leftPop
(
key
);
}
/**
* 实现命令:RPUSH key value,将一个值 value插入到列表 key的表尾(最右边)。
*
* @param key
* @param value
* @return 执行 LPUSH命令后,列表的长度。
*/
public
long
rpush
(
String
key
,
Object
value
)
{
return
redisTemplate
.
opsForList
().
rightPush
(
key
,
value
);
}
/**
*
*
* @param <T>
* @param script
* @param keys
* @param args
* @return
*/
public
<
T
>
T
execute
(
RedisScript
<
T
>
script
,
List
<
String
>
keys
,
Object
...
args
)
{
return
redisTemplate
.
execute
(
script
,
keys
,
args
);
}
/**
*
* @param
*/
public
List
<
Object
>
range
(
String
key
)
{
return
redisTemplate
.
opsForList
().
range
(
key
,
0
,
500
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment