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
0a7b743c
Commit
0a7b743c
authored
Jan 13, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化gateway部分代码
parent
78e8094b
Changes
35
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
721 additions
and
474 deletions
+721
-474
api_gateway.sql
database/zc/api_gateway.sql
+9
-5
ApiGatewayApplication.java
...ateway/src/main/java/com/jz/dm/ApiGatewayApplication.java
+1
-0
BaseCurrentUserObject.java
...ain/java/com/jz/dm/common/base/BaseCurrentUserObject.java
+0
-39
GeneralStatusTypeEnum.java
...in/java/com/jz/dm/common/enums/GeneralStatusTypeEnum.java
+9
-0
MapUtil.java
...igateway/src/main/java/com/jz/dm/common/util/MapUtil.java
+2
-4
Md5.java
...m-apigateway/src/main/java/com/jz/dm/common/util/Md5.java
+0
-159
RedisSerializableUtil.java
...ain/java/com/jz/dm/common/util/RedisSerializableUtil.java
+54
-0
GatewayController.java
...src/main/java/com/jz/dm/controller/GatewayController.java
+0
-1
OrganizationManageController.java
...va/com/jz/dm/controller/OrganizationManageController.java
+4
-4
ProducerController.java
...rc/main/java/com/jz/dm/controller/ProducerController.java
+30
-5
AuthFilter.java
...apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
+31
-22
VerifySignFilter.java
...eway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
+2
-3
ApiAuth.java
...ateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
+1
-1
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+2
-2
ApiInterfaceCustom.java
...main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
+24
-0
ApiInterfaceFile.java
...c/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
+1
-1
LogInfoListReq.java
...ay/src/main/java/com/jz/dm/models/req/LogInfoListReq.java
+6
-0
ApiInterfaceReq.java
.../main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
+16
-8
MakeBigDataApiReq.java
...ain/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
+19
-7
MakeDataBankApiReq.java
...in/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
+17
-11
OrganizationManageAddReq.java
...dels/req/organizationManage/OrganizationManageAddReq.java
+3
-0
OrganizationManageListQueryReq.java
...eq/organizationManage/OrganizationManageListQueryReq.java
+8
-0
OrganizationManageUpdateReq.java
...s/req/organizationManage/OrganizationManageUpdateReq.java
+5
-0
OrganizationManageService.java
...ain/java/com/jz/dm/service/OrganizationManageService.java
+2
-2
ProducerService.java
...eway/src/main/java/com/jz/dm/service/ProducerService.java
+14
-0
ApiLogServiceImpl.java
...c/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
+7
-0
OrganizationManageImpl.java
...n/java/com/jz/dm/service/impl/OrganizationManageImpl.java
+27
-20
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+358
-158
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+6
-3
SystemLogAspect.java
...y/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
+1
-1
application-test.yml
jz-dm-apigateway/src/main/resources/application-test.yml
+4
-3
ApiReqTest.java
...teway/src/test/java/com/jz/dm/gateway/api/ApiReqTest.java
+6
-7
TestRedisUserSave.java
...test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
+42
-8
pom.xml
jz-dm-common/pom.xml
+1
-0
RedisUtils.java
...-common/src/main/java/com/jz/common/utils/RedisUtils.java
+9
-0
No files found.
database/zc/api_gateway.sql
View file @
0a7b743c
...
...
@@ -8,18 +8,18 @@ CREATE TABLE `t_api_interface` (
`api_protocl`
varchar
(
32
)
DEFAULT
NULL
COMMENT
'api请求协议:http,https'
,
`api_path`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'请求地址'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 数据银行制作
API 2 数据银行制作数据包, 3
API实时接入 6 标签查询 9自定义'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 数据银行制作
大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4
API实时接入 6 标签查询 9自定义'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`test_example`
varchar
(
255
)
NULL
DEFAULT
NULL
COMMENT
'测试实例'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`output_type`
varchar
(
50
)
NULL
DEFAULT
'JSON'
COMMENT
'输出类型:flow 流形式输出, json格式输出'
,
`page`
tinyint
(
2
)
NULL
DEFAULT
'0'
COMMENT
'是否分页:0 false ,1 true'
,
`version`
varchar
(
20
)
DEFAULT
'1.0'
COMMENT
'版本号'
,
`version`
varchar
(
20
)
DEFAULT
'
v
1.0'
COMMENT
'版本号'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`file_id`
bigint
(
20
)
NOT
NULL
COMMENT
'文件夹id'
,
`req_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限
制
类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`req_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限
流
类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`req_frequency`
bigint
(
20
)
DEFAULT
'100'
COMMENT
'限制次数'
,
`is_test`
tinyint
(
2
)
NOT
NULL
DEFAULT
'0'
COMMENT
'是否测试数据:0 否,1 是'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
...
...
@@ -38,7 +38,11 @@ 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自定义'
,
`api_type`
varchar
(
50
)
DEFAULT
''
COMMENT
'api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 5 DMP标签查询 6.DMP大数据表查询 7 DMP自定义'
,
`es_data_source`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'数据源id'
,
`es_data_base`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'源数据库名称'
,
`es_table`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'源数据表名称'
,
`handle_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'处理类型'
,
`request_param`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求参数'
,
`response_param`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应参数'
,
`req_headers`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'请求头'
,
...
...
@@ -105,7 +109,7 @@ CREATE TABLE `t_api_auth` (
`api_interface_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api信息表id'
,
`api_org_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api组织id'
,
`auth_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'授权类型:DATA_BANK_AUTH 数据银行购买 DMP_AUTH dmp授权'
,
`req_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限
制
类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`req_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限
流
类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`req_frequency`
bigint
(
20
)
DEFAULT
'100'
COMMENT
'限制次数'
,
`auth_code`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'授权码'
,
`salt`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'盐值'
,
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/ApiGatewayApplication.java
View file @
0a7b743c
...
...
@@ -25,4 +25,5 @@ public class ApiGatewayApplication {
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ApiGatewayApplication
.
class
,
args
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/base/BaseCurrentUserObject.java
deleted
100644 → 0
View file @
78e8094b
package
com
.
jz
.
dm
.
common
.
base
;
import
com.jz.common.bean.SysUserDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
/**
* @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: 获取当前登录用户
**/
@Component
public
class
BaseCurrentUserObject
{
@Autowired
private
RedisTemplate
redisTemplate
;
/**
* 获取登录用户
*
* @return
*/
public
SysUserDto
getUserInfo
()
{
SysUserDto
sysUserDto
=
(
SysUserDto
)
redisTemplate
.
opsForValue
().
get
(
"USER"
+
"004"
);
//RedisMessageConstant.SENDTYPE_LOGIN_SYS);
return
sysUserDto
;
}
//SysUserDto currentUser = (SysUserDto)
// redisTemplate.opsForValue().get("user" + RedisMessageConstant.SENDTYPE_LOGIN_SYS);
/*public static void main(String[] args) {
System.out.println(new BaseCurrentUserObject().getUserInfo());
}*/
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/GeneralStatusTypeEnum.java
View file @
0a7b743c
...
...
@@ -48,4 +48,13 @@ public enum GeneralStatusTypeEnum {
public
String
getText
()
{
return
text
;
}
public
static
GeneralStatusTypeEnum
fromGeneralStatus
(
String
typeName
)
{
for
(
GeneralStatusTypeEnum
type
:
GeneralStatusTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/MapUtil.java
View file @
0a7b743c
...
...
@@ -26,15 +26,13 @@ public class MapUtil {
* @param apiKey
* @param method
* @param signType
* @param timestamp
* @return
*/
public
static
String
getSignValue
(
String
apiKey
,
String
method
,
String
signType
,
String
timestamp
){
public
static
String
getSignValue
(
String
apiKey
,
String
method
,
String
signType
){
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"apiKey="
).
append
(
apiKey
).
append
(
LoggingConstants
.
AND_SPILT
)
.
append
(
"method="
).
append
(
method
).
append
(
LoggingConstants
.
AND_SPILT
)
.
append
(
"signType="
).
append
(
signType
).
append
(
LoggingConstants
.
AND_SPILT
)
.
append
(
"timestamp="
).
append
(
timestamp
);
.
append
(
"signType="
).
append
(
signType
);
return
builder
.
toString
();
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/Md5.java
deleted
100644 → 0
View file @
78e8094b
package
com
.
jz
.
dm
.
common
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
/**
* MD5加密算法
*
* @author Admin
* @version $Id: Md5Utils.java 2014年9月3日 下午4:01:08 $
*/
public
class
Md5
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
Md5
.
class
);
private
static
final
String
SIGN_TYPE
=
"MD5"
;
private
static
final
String
CHARSET_NAME
=
"UTF-8"
;
private
static
final
String
salt
=
"3zsAa6W9gfSMMhPSlQTdWFUSHY3LS8Vb"
;
/**
* MD5加密
*
* @param data
* @return
* @throws NoSuchAlgorithmException
*/
public
static
String
encrypt
(
byte
[]
data
)
{
try
{
MessageDigest
md5
=
MessageDigest
.
getInstance
(
SIGN_TYPE
);
md5
.
update
(
data
);
return
byte2hex
(
md5
.
digest
());
}
catch
(
NoSuchAlgorithmException
e
)
{
log
.
debug
(
"md5 加密异常"
,
e
);
}
return
""
;
}
/**
* MD5加密
*
* @param str
* @return
* @throws NoSuchAlgorithmException
*/
public
static
String
encrypt
(
String
str
)
{
try
{
MessageDigest
md5
=
MessageDigest
.
getInstance
(
SIGN_TYPE
);
md5
.
update
((
str
+
salt
).
getBytes
(
CHARSET_NAME
));
return
byte2hex
(
md5
.
digest
());
}
catch
(
Exception
e
)
{
log
.
debug
(
"md5 加密异常"
,
e
);
}
return
null
;
}
/**
* MD5加盐加密
*
* @param str
* @param salt
* @return
* @throws NoSuchAlgorithmException
*/
public
static
String
encrypt
(
String
str
,
String
salt
)
{
try
{
MessageDigest
md5
=
MessageDigest
.
getInstance
(
SIGN_TYPE
);
md5
.
update
((
str
+
salt
).
getBytes
(
CHARSET_NAME
));
return
byte2hex
(
md5
.
digest
());
}
catch
(
Exception
e
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"md5 加密异常"
,
e
);
}
}
return
""
;
}
public
static
String
encrypt
(
String
str
,
String
salt
,
String
charset
)
{
try
{
MessageDigest
md5
=
MessageDigest
.
getInstance
(
SIGN_TYPE
);
md5
.
update
((
str
+
salt
).
getBytes
(
charset
));
return
byte2hex
(
md5
.
digest
());
}
catch
(
Exception
e
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"md5 加密异常"
,
e
);
}
}
return
""
;
}
public
static
String
byte2hex
(
byte
[]
bytes
)
{
StringBuilder
sign
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
String
hex
=
Integer
.
toHexString
(
bytes
[
i
]
&
0xFF
);
if
(
hex
.
length
()
==
1
)
{
sign
.
append
(
"0"
);
}
sign
.
append
(
hex
.
toUpperCase
());
}
return
sign
.
toString
();
}
public
static
byte
[]
hex2byte
(
String
str
)
{
if
(
str
==
null
)
{
return
null
;
}
str
=
str
.
trim
();
int
len
=
str
.
length
();
if
(
len
<=
0
||
len
%
2
==
1
)
{
return
null
;
}
byte
[]
b
=
new
byte
[
len
/
2
];
try
{
for
(
int
i
=
0
;
i
<
str
.
length
();
i
+=
2
)
{
b
[(
i
/
2
)]
=
(
byte
)
Integer
.
decode
(
"0x"
+
str
.
substring
(
i
,
i
+
2
)).
intValue
();
}
return
b
;
}
catch
(
Exception
e
)
{
}
return
null
;
}
/**
* 给TOP请求做MD5签名。
*
* @param sortedParams 所有字符型的TOP请求参数
* @param secret 签名密钥
* @return 签名
* @throws IOException
*/
public
static
String
signRequestNew
(
Map
<
String
,
String
>
sortedParams
,
String
secret
)
throws
IOException
{
// 第一步:把字典按Key的字母顺序排序
List
<
String
>
keys
=
new
ArrayList
<
String
>(
sortedParams
.
keySet
());
Collections
.
sort
(
keys
);
// 第二步:把所有参数名和参数值串在一起
StringBuilder
query
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
keys
.
size
();
i
++)
{
String
key
=
keys
.
get
(
i
);
String
value
=
sortedParams
.
get
(
key
);
if
(!
StringUtils
.
isEmpty
(
key
)
&&
!
StringUtils
.
isEmpty
(
value
)
&&
!
"sign"
.
equals
(
key
))
{
query
.
append
(
key
).
append
(
"="
).
append
(
value
);
}
}
log
.
info
(
"获取当APP请求参数,签名前值为:"
+
query
.
toString
());
return
Md5
.
encrypt
(
query
.
toString
(),
secret
);
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
encrypt
(
"200128008012abc@123"
,
""
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/RedisSerializableUtil.java
0 → 100644
View file @
0a7b743c
package
com
.
jz
.
dm
.
common
.
util
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.util
* @PROJECT_NAME: jz-dm-parent
* @NAME: RedisSerializableUtil
* @DATE: 2021-1-12/18:26
* @DAY_NAME_SHORT: 周二
* @Description:
**/
public
class
RedisSerializableUtil
{
/**
* 序列化
* @param object
*/
public
static
byte
[]
serialize
(
Object
object
)
{
ObjectOutputStream
oos
=
null
;
ByteArrayOutputStream
baos
=
null
;
try
{
// 序列化
baos
=
new
ByteArrayOutputStream
();
oos
=
new
ObjectOutputStream
(
baos
);
oos
.
writeObject
(
object
);
byte
[]
bytes
=
baos
.
toByteArray
();
return
bytes
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 反序列化
* @param bytes
*/
public
static
Object
unserialize
(
byte
[]
bytes
)
{
ByteArrayInputStream
bais
=
null
;
try
{
// 反序列化
bais
=
new
ByteArrayInputStream
(
bytes
);
ObjectInputStream
ois
=
new
ObjectInputStream
(
bais
);
return
ois
.
readObject
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/GatewayController.java
View file @
0a7b743c
...
...
@@ -25,7 +25,6 @@ import java.util.Map;
* @author zc
*/
@RestController
@RequestMapping
(
"api"
)
@Api
(
tags
=
{
"api请求controller"
})
public
class
GatewayController
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/controller/OrganizationManageController.java
View file @
0a7b743c
...
...
@@ -74,13 +74,13 @@ public class OrganizationManageController {
return
Mono
.
fromSupplier
(()
->
organizationManageService
.
update
(
req
));
}
/**
* @Description:
删除
组织
* @Description:
注销
组织
* @Author: Mr.zhang
* @Date: 2020-12-24
*/
@ApiOperation
(
"
删除
组织"
)
@GetMapping
(
value
=
"/
deleted
"
)
@ApiOperation
(
"
注销
组织"
)
@GetMapping
(
value
=
"/
logoutOrg
"
)
public
Mono
<
Result
>
delete
(
@RequestParam
(
name
=
"id"
)
Long
id
)
{
return
Mono
.
fromSupplier
(()
->
organizationManageService
.
delete
(
id
));
return
Mono
.
fromSupplier
(()
->
organizationManageService
.
logoutOrg
(
id
));
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/controller/ProducerController.java
View file @
0a7b743c
...
...
@@ -30,11 +30,11 @@ public class ProducerController {
/**
* @Description:
Api制作(自定义)
* @Description:
获取文件夹列表
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"
Api制作(获取文件夹列表)
"
)
@ApiOperation
(
"
获取文件夹列表
"
)
@GetMapping
(
value
=
"/getFileCatalog"
)
public
Mono
<
Result
>
getFileCatalog
(
@RequestParam
(
name
=
"projectId"
)
Long
projectId
,
@RequestParam
(
name
=
"pageNum"
,
defaultValue
=
"1"
,
required
=
false
)
String
pageNum
,
...
...
@@ -42,11 +42,23 @@ public class ProducerController {
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
getFileCatalog
(
projectId
,
pageNum
,
pageSize
)));
}
/**
* @Description:
Api制作(自定义)
* @Description:
创建文件夹
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"Api制作(自定义)"
)
@ApiOperation
(
"创建项目文件夹"
)
@PostMapping
(
value
=
"/createProjectFolder"
)
public
Mono
<
Result
>
createProjectFolder
(
@RequestParam
(
name
=
"projectId"
)
Long
projectId
,
@RequestParam
(
name
=
"parentId"
)
Long
parentId
,
@RequestParam
(
name
=
"currentUser"
)
String
currentUser
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
createProjectFolder
(
projectId
,
parentId
,
currentUser
));
}
/**
* @Description:Api制作(自定义DMP)
* @Author: Mr.zhang
* @Date: 2020-12-26
*/
@ApiOperation
(
"Api制作(自定义DMP)"
)
@PostMapping
(
value
=
"/addCustomApi"
)
public
Mono
<
Result
>
makeCustomApi
(
@RequestBody
@Valid
ApiInterfaceReq
req
)
{
return
Mono
.
fromSupplier
(()
->
Result
.
of_success
(
producerService
.
addCustomApi
(
req
)));
...
...
@@ -86,7 +98,7 @@ public class ProducerController {
}
/**
* @Description:保存API基本信息
* @Description:保存API基本信息
/自定义API
* @return: (保存API基本信息)
* @Author: Mr.zhang
* @Date: 2020-12-26
...
...
@@ -152,4 +164,17 @@ public class ProducerController {
@RequestParam
(
name
=
"id"
)
Long
id
)
{
return
Mono
.
fromSupplier
(()
->
producerService
.
getIndicesTypesFields
(
indices
,
type
,
id
));
}
@ApiOperation
(
"保存数据到redis中"
)
@GetMapping
(
value
=
"/saveRedis"
)
public
Result
saveObjOnRedis
()
{
return
producerService
.
saveObjOnRedis
();
}
@ApiOperation
(
"获取redis中的数据"
)
@GetMapping
(
value
=
"/getRedisObj"
)
public
Result
getObjOnRedis
()
{
return
producerService
.
getObjOnRedis
();
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
View file @
0a7b743c
...
...
@@ -21,6 +21,7 @@ import com.jz.dm.service.ApiInterfaceService;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.service.OrganizationManageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -82,7 +83,7 @@ public class AuthFilter extends AbstractFilter {
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getParams
());
if
(
null
!=
parameter
)
{
String
authCode
=
parameter
.
getString
(
"authCode"
);
ApiAuth
authAuth
=
authService
.
getAuthUser
(
authCode
,
apiInterface
.
getId
());
ApiAuth
authAuth
=
authService
.
getAuthUser
(
authCode
,
apiInterface
.
getId
());
if
(
null
==
authAuth
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_NOT_AUTH
);
}
...
...
@@ -95,8 +96,8 @@ public class AuthFilter extends AbstractFilter {
}
chain
.
doFilter
(
request
,
response
);
}
catch
(
Exception
e
)
{
if
(
e
instanceof
GatewayException
){
throw
(
GatewayException
)
e
;
if
(
e
instanceof
GatewayException
)
{
throw
(
GatewayException
)
e
;
}
log
.
error
(
"~~~~~~~~~~~~~~~~认证过滤异常~~~~~~~~~~~~~~~~~"
);
log
.
error
(
"异常信息:{}"
,
e
.
getMessage
());
...
...
@@ -112,6 +113,7 @@ public class AuthFilter extends AbstractFilter {
/**
* 校验计费信息
*
* @param request
* @param authCode
* @param authAuth
...
...
@@ -127,24 +129,24 @@ public class AuthFilter extends AbstractFilter {
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
}
//查询数据银行银行余额是否充足
getDataAmountResult
(
request
);
//
getDataAmountResult(request);
try
{
//记录请求次数(每天限制请求次数)
String
limitKey
=
request
.
getApiKey
()
+
LoggingConstants
.
AND_SPILT
+
authCode
;
String
reqKey
=
redisUtils
.
get
(
limitKey
);
long
timeOut
=
0
;
if
(
AuthReqTypeEnum
.
DAY
.
name
().
equals
(
authAuth
.
getReqType
())){
//按天
Integer
reqValue
=
(
Integer
)
redisUtils
.
getObj
(
limitKey
);
long
timeOut
=
0
;
if
(
AuthReqTypeEnum
.
DAY
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按天
timeOut
=
DateUtil
.
calculateNowResidueTime
();
}
else
if
(
AuthReqTypeEnum
.
MONTH
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按月
timeOut
=
DateUtil
.
calculateNowMonthTime
();
}
else
if
(
AuthReqTypeEnum
.
YEAR
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按年
}
else
if
(
AuthReqTypeEnum
.
MONTH
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按月
timeOut
=
DateUtil
.
calculateNowMonthTime
();
}
else
if
(
AuthReqTypeEnum
.
YEAR
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按年
//暂时不支持年
}
if
(
null
!=
req
Key
)
{
Integer
value
=
Integer
.
valueOf
(
reqKey
);
if
(
v
alue
>
authAuth
.
getReqFrequency
())
{
//超出最大请求次数
if
(
null
!=
req
Value
&&
reqValue
!=
0
)
{
//
Integer value = Integer.valueOf(reqKey);
if
(
reqV
alue
>
authAuth
.
getReqFrequency
())
{
//超出最大请求次数
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_LIMIT_EXCEPTION
);
}
else
if
(
v
alue
<=
authAuth
.
getReqFrequency
())
{
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
v
alue
+
1
,
timeOut
);
}
else
if
(
reqV
alue
<=
authAuth
.
getReqFrequency
())
{
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
reqV
alue
+
1
,
timeOut
);
}
}
else
{
redisUtils
.
set
(
limitKey
,
1
,
timeOut
);
...
...
@@ -174,20 +176,27 @@ public class AuthFilter extends AbstractFilter {
/**
* 按次调用检查余额是否充足
*
* @param request
*/
private
void
getDataAmountResult
(
GatewayRequest
request
)
{
JSONObject
params
=
JSONObject
.
parseObject
(
request
.
getParams
());
if
(
null
!=
params
){
Integer
assetsId
=
params
.
getInteger
(
"assetsId"
);
Integer
userId
=
params
.
getInteger
(
"userId"
);
String
dataPrice
=
params
.
getString
(
"dataPrice"
);
if
(
null
==
assetsId
||
null
==
userId
||
StringUtils
.
isBlank
(
dataPrice
))
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
}
if
(
null
!=
params
)
{
JSONObject
pObject
=
new
JSONObject
();
pObject
.
put
(
"assetsId"
,
params
.
getInteger
(
"assetsId"
)
);
pObject
.
put
(
"userId"
,
params
.
getInteger
(
"userId"
)
);
pObject
.
put
(
"dataPrice"
,
params
.
getString
(
"dataPrice"
)
);
pObject
.
put
(
"assetsId"
,
assetsId
);
pObject
.
put
(
"userId"
,
userId
);
pObject
.
put
(
"dataPrice"
,
dataPrice
);
String
respResult
=
httpUtils
.
submitPost
(
balanceUrl
,
pObject
.
toString
());
JSONObject
result
=
JSONObject
.
parseObject
(
respResult
);
if
(
null
!=
result
){
if
(
200
!=
result
.
getInteger
(
"code"
))
{
log
.
info
(
"~~~~~~~~~~~~~~~~~~异常信息为:{}"
,
result
.
getString
(
"message"
));
if
(
null
!=
result
)
{
if
(
200
!=
result
.
getInteger
(
"code"
))
{
log
.
info
(
"~~~~~~~~~~~~~~~~~~异常信息为:{}"
,
result
.
getString
(
"message"
));
throw
new
GatewayException
(
GatewayResultCode
.
CALL_AMOUNT_NOT_ENOUGH
);
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
View file @
0a7b743c
package
com
.
jz
.
dm
.
filter
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.Md5
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.SignatureException
;
import
com.jz.dm.common.util.LogUtil
;
import
com.jz.dm.common.util.MapUtil
;
import
com.jz.dm.common.util.Md5
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.enity.GatewayRequest
;
import
com.jz.dm.models.enity.GatewayResponse
;
...
...
@@ -42,8 +42,7 @@ public class VerifySignFilter extends AbstractFilter {
FilterChain
chain
)
{
try
{
//对签约参数进行字典排序
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
request
.
getSignType
(),
String
.
valueOf
(
request
.
getTimestamp
()));
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
request
.
getSignType
());
if
(
StringUtils
.
isNotBlank
(
signParams
)){
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
String
authCode
=
jsonObject
.
getString
(
"authCode"
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
View file @
0a7b743c
...
...
@@ -44,7 +44,7 @@ public class ApiAuth extends BaseObject implements Serializable {
@TableField
(
"auth_type"
)
private
String
authType
;
/**
* 限
制
类型:DAY 按天,MONTH 按月, YEAR 按年
* 限
流
类型:DAY 按天,MONTH 按月, YEAR 按年
*/
@TableField
(
"req_type"
)
private
String
reqType
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
0a7b743c
...
...
@@ -49,7 +49,7 @@ public class ApiInterface extends BaseObject implements Serializable {
private
String
apiProtocl
;
/**
* api类型:1 数据银行制作
API 2 数据银行制作数据包, 3 API实时接入 6 标签查询 9
自定义'
* api类型:1 数据银行制作
大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 5 DMP标签查询 6.DMP大数据表查询 7 DMP
自定义'
*/
@TableField
(
"api_type"
)
private
String
apiType
;
...
...
@@ -109,7 +109,7 @@ public class ApiInterface extends BaseObject implements Serializable {
private
String
signType
;
/**
* 限
制
类型:DAY 按天,MONTH 按月, YEAR 按年
* 限
流
类型:DAY 按天,MONTH 按月, YEAR 按年
*/
@TableField
(
"req_type"
)
private
String
reqType
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
View file @
0a7b743c
...
...
@@ -37,6 +37,30 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
private
Long
apiInterfaceId
;
/**
* 数据源id
*/
@TableField
(
"es_data_source"
)
private
String
esDataSource
;
/**
* 源数据库名称
*/
@TableField
(
"es_data_base"
)
private
String
esDataBase
;
/**
* 源数据表名称
*/
@TableField
(
"es_table"
)
private
String
esTable
;
/**
* 处理类型
*/
@TableField
(
"handle_type"
)
private
String
handleType
;
/**
* api请求参数
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
View file @
0a7b743c
...
...
@@ -52,7 +52,7 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
* 父类id
*/
@TableField
(
"parent_id"
)
private
Stri
ng
parentId
;
private
Lo
ng
parentId
;
/**
* 文件英文名称
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/LogInfoListReq.java
View file @
0a7b743c
...
...
@@ -2,6 +2,7 @@ package com.jz.dm.models.req;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
...
...
@@ -18,4 +19,9 @@ import java.io.Serializable;
@Data
@ApiModel
(
"日志信息列表"
)
public
class
LogInfoListReq
extends
BasePageBean
implements
Serializable
{
@ApiModelProperty
(
value
=
"状态:SUCCEED 请求成功, FAIL 请求失败"
)
private
String
status
;
@ApiModelProperty
(
value
=
"ApiKey"
)
private
String
apiKey
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
View file @
0a7b743c
...
...
@@ -19,9 +19,7 @@ import java.io.Serializable;
@Data
@ApiModel
(
value
=
"api基本信息"
)
public
class
ApiInterfaceReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"api类型:1 实时接入 2 数据银行制作API, 3 数据银行制作数据包 6标签查询 9自定义"
,
required
=
true
)
@NotNull
(
message
=
"api类型不能为空"
)
public
String
apiType
;
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
...
...
@@ -46,19 +44,22 @@ public class ApiInterfaceReq implements Serializable {
@NotNull
(
message
=
"超时时间不能为空"
)
public
String
timeout
;
@ApiModelProperty
(
value
=
"限
制
类型:DAY 按天,MONTH 按月, YEAR 按年"
,
required
=
true
)
@NotNull
(
message
=
"限
制
类型不能为空"
)
@ApiModelProperty
(
value
=
"限
流
类型:DAY 按天,MONTH 按月, YEAR 按年"
,
required
=
true
)
@NotNull
(
message
=
"限
流
类型不能为空"
)
public
String
reqType
;
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
tru
e
)
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
fals
e
)
public
Long
reqFrequency
;
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"父类文件id,一级文件夹传入0"
,
required
=
true
)
@NotNull
(
message
=
"父类id文件id不能为空"
)
@ApiModelProperty
(
value
=
"父类文件id,一级文件夹传入0"
,
required
=
false
)
public
Long
parentId
;
@ApiModelProperty
(
value
=
"文件id"
,
required
=
false
)
public
Long
fileId
;
@ApiModelProperty
(
value
=
"项目id"
,
required
=
true
)
@NotNull
(
message
=
"项目id不能为空"
)
public
Long
projectId
;
...
...
@@ -69,5 +70,12 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty
(
value
=
"更新时传入api自增id"
,
required
=
false
)
public
Long
id
;
@ApiModelProperty
(
value
=
"创建用户"
,
hidden
=
true
)
public
String
createUser
;
@ApiModelProperty
(
value
=
"api类型:1.数据银行制作大数据表 "
+
"2 数据银行制作数据包,3,数据银行制作自定义API "
+
"4 API实时接入 6 标签查询 9自定义"
,
hidden
=
true
)
public
String
apiType
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeBigDataApiReq.java
View file @
0a7b743c
...
...
@@ -27,12 +27,12 @@ public class MakeBigDataApiReq implements Serializable {
@NotNull(message = "apiType不能为空")
private String apiType;*/
@ApiModelProperty
(
value
=
"
接入类型:对应字典表k
ey"
,
required
=
true
)
@NotNull
(
message
=
"
接入类型
不能为空"
)
public
String
joinType
;
@ApiModelProperty
(
value
=
"
apiK
ey"
,
required
=
true
)
@NotNull
(
message
=
"
apiKey
不能为空"
)
public
String
apiKey
;
@ApiModelProperty
(
value
=
"是否分页"
,
required
=
false
)
public
Integer
page
;
//
@ApiModelProperty(value = "是否分页",required = false)
//public Boolean
page;
@ApiModelProperty
(
value
=
"数据源Id"
,
required
=
true
)
@NotNull
(
message
=
"数据源Id不能为空"
)
...
...
@@ -40,7 +40,7 @@ public class MakeBigDataApiReq implements Serializable {
@ApiModelProperty
(
value
=
"源库名称"
,
required
=
true
)
@NotNull
(
message
=
"源库名称不能为空"
)
private
String
esData
b
ase
;
private
String
esData
B
ase
;
@ApiModelProperty
(
value
=
"源表名称"
,
required
=
true
)
@NotNull
(
message
=
"源表名称不能为空"
)
...
...
@@ -57,12 +57,24 @@ public class MakeBigDataApiReq implements Serializable {
@ApiModelProperty
(
value
=
"返回参数"
,
required
=
true
)
@NotNull
(
message
=
"返回参数不能为空"
)
private
String
res
ult
Param
;
private
String
res
ponse
Param
;
@ApiModelProperty
(
value
=
"段列表"
,
required
=
true
)
@NotNull
(
message
=
"字段列表不能为空"
)
private
String
tableFields
;
//@ApiModelProperty(value = "项目id",required = true)
//@NotNull(message="项目id不能为空")
//public Long projectId;
//@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
//public Long parentId;
//
//@ApiModelProperty(value = "文件id",required = false)
//public Long fileId;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
View file @
0a7b743c
...
...
@@ -20,13 +20,13 @@ import java.io.Serializable;
@ApiModel
(
"数据银行api制作"
)
public
class
MakeDataBankApiReq
implements
Serializable
{
//@ApiModelProperty(value = "api类型:1 数据银行制作
API 2 数据银行制作数据包, 3
API实时接入 6 标签查询 9自定义",required = true)
//@ApiModelProperty(value = "api类型:1 数据银行制作
大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4
API实时接入 6 标签查询 9自定义",required = true)
//@NotNull(message = "api类型不能为空")
//public String apiType;
@ApiModelProperty
(
value
=
"传输方式(1为HTTPS,2为HTTP)"
,
required
=
true
)
@NotNull
(
message
=
"传输方式不能为空"
)
public
String
apiProtocl
;
public
String
transMode
;
@ApiModelProperty
(
value
=
"加密方式0 无,1:MD5 2:RSA"
,
required
=
true
)
@NotNull
(
message
=
"加密方式不能为空"
)
...
...
@@ -44,15 +44,23 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"是否分页不能为空"
)
public
Boolean
page
;
@ApiModelProperty
(
value
=
"限
制
类型:DAY 按天,MONTH 按月"
,
required
=
true
)
@NotNull
(
message
=
"限
制
类型不能为空"
)
@ApiModelProperty
(
value
=
"限
流
类型:DAY 按天,MONTH 按月"
,
required
=
true
)
@NotNull
(
message
=
"限
流
类型不能为空"
)
public
String
reqType
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
true
)
@NotNull
(
message
=
"目标地址不能为空"
)
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"文件id"
,
required
=
true
)
@NotNull
(
message
=
"文件id不能为空"
)
public
Long
fileId
;
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
true
)
@ApiModelProperty
(
value
=
"签名"
,
required
=
true
)
@NotNull
(
message
=
"签名不能为空"
)
public
String
sign
;
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
false
)
public
Long
reqFrequency
;
@ApiModelProperty
(
value
=
"请求地址"
,
required
=
false
)
...
...
@@ -61,8 +69,7 @@ public class MakeDataBankApiReq implements Serializable {
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"目标地址"
,
required
=
false
)
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
false
)
public
String
timeout
;
...
...
@@ -85,13 +92,12 @@ public class MakeDataBankApiReq implements Serializable {
@ApiModelProperty
(
value
=
"api样例"
,
required
=
false
)
public
String
apiExample
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
public
String
createUser
;
//-------------------------前端无效传参----------------------
//@ApiModelProperty(value = "状态",hidden = true)
//public String status;
//
//@ApiModelProperty(value = "创建用户",hidden = true)
//public String createUser;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageAddReq.java
View file @
0a7b743c
...
...
@@ -42,4 +42,7 @@ public class OrganizationManageAddReq implements Serializable {
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
private
String
createUser
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageListQueryReq.java
View file @
0a7b743c
...
...
@@ -2,6 +2,7 @@ package com.jz.dm.models.req.organizationManage;
import
com.jz.common.bean.BasePageBean
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
...
...
@@ -18,4 +19,11 @@ import java.io.Serializable;
@Data
@ApiModel
(
"组织管理查询请求体"
)
public
class
OrganizationManageListQueryReq
extends
BasePageBean
implements
Serializable
{
@ApiModelProperty
(
value
=
"组织名称"
)
private
String
orgName
;
@ApiModelProperty
(
value
=
"组织编码(组织唯一标识)"
)
private
String
orgCode
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/organizationManage/OrganizationManageUpdateReq.java
View file @
0a7b743c
...
...
@@ -45,4 +45,9 @@ public class OrganizationManageUpdateReq implements Serializable {
@ApiModelProperty
(
value
=
"备注"
,
required
=
false
)
private
String
remark
;
@ApiModelProperty
(
value
=
"创建用户"
,
required
=
false
)
private
String
updateUser
;
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/OrganizationManageService.java
View file @
0a7b743c
...
...
@@ -47,11 +47,11 @@ public interface OrganizationManageService {
Result
update
(
OrganizationManageUpdateReq
req
);
/**
* 根据id
删除
组织
* 根据id
注销
组织
* @param id
* @return
*/
Result
delete
(
Long
id
);
Result
logoutOrg
(
Long
id
);
/**
* 获取认证组织信息
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/ProducerService.java
View file @
0a7b743c
...
...
@@ -97,4 +97,18 @@ public interface ProducerService {
* @return
*/
IPage
<
ApiInterfaceFile
>
getFileCatalog
(
Long
projectId
,
String
pageNum
,
String
pageSize
);
/**
* 创建文件夹
* @param projectId
* @param parentId
* @param currentUser
* @return
*/
Result
createProjectFolder
(
Long
projectId
,
Long
parentId
,
String
currentUser
);
Result
saveObjOnRedis
();
Result
getObjOnRedis
();
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
View file @
0a7b743c
...
...
@@ -14,6 +14,7 @@ import com.jz.dm.models.req.LogInfoListReq;
import
com.jz.dm.service.ApiLogService
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -47,6 +48,12 @@ public class ApiLogServiceImpl implements ApiLogService {
public
IPage
<
ApiReqLog
>
listApiLog
(
LogInfoListReq
req
)
{
IPage
<
ApiReqLog
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiReqLog
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
req
.
getApiKey
())){
query
.
eq
(
"api_key"
,
req
.
getApiKey
());
}
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
())){
query
.
eq
(
"status"
,
req
.
getStatus
());
}
query
.
eq
(
"is_deleted"
,
0
);
query
.
orderByDesc
(
"create_date"
);
return
apiReqLogMapper
.
selectPage
(
page
,
query
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/OrganizationManageImpl.java
View file @
0a7b743c
...
...
@@ -19,7 +19,6 @@ import com.jz.dm.service.OrganizationManageService;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
...
...
@@ -42,8 +41,6 @@ public class OrganizationManageImpl implements OrganizationManageService {
@Resource
private
ApiOrgMapper
apiOrgMapper
;
@Resource
private
RedisTemplate
redisTemplate
;
/**
* 组织列表信息查询
...
...
@@ -55,7 +52,14 @@ public class OrganizationManageImpl implements OrganizationManageService {
public
IPage
<
ApiOrg
>
listOrganization
(
OrganizationManageListQueryReq
req
)
{
IPage
<
ApiOrg
>
page
=
new
Page
<>(
req
.
getPageNum
(),
req
.
getPageSize
());
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
())){
query
.
eq
(
"org_name"
,
req
.
getOrgName
());
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgCode
())){
query
.
eq
(
"org_code"
,
req
.
getOrgCode
());
}
query
.
eq
(
"is_deleted"
,
0
);
query
.
ne
(
"status"
,
OrgStatusEnum
.
CANCEL
);
query
.
orderByDesc
(
"create_date"
);
return
apiOrgMapper
.
selectPage
(
page
,
query
);
}
...
...
@@ -71,6 +75,7 @@ public class OrganizationManageImpl implements OrganizationManageService {
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"id"
,
req
.
getId
());
query
.
ne
(
"status"
,
OrgStatusEnum
.
CANCEL
);
return
Result
.
of_success
(
apiOrgMapper
.
selectOne
(
query
));
}
...
...
@@ -82,16 +87,18 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/
@Override
public
Result
add
(
OrganizationManageAddReq
req
)
{
/* SysUserDto currentUser = (SysUserDto)redisTemplate.opsForValue().get("user"+ RedisMessageConstant.SENDTYPE_LOGIN_SYS);
if (null == currentUser){
return Result.of_error(ResultMsg.USER_NOT_EXIST);
}*/
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
()))
{
ApiOrg
orgNameInfo
=
getOrgNameInfo
(
req
.
getOrgName
());
if
(
null
!=
orgNameInfo
)
{
return
Result
.
of_error
(
"组织名称已存在!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgType
()))
{
if
(!
Constants
.
AUTH_INT
.
equals
(
req
.
getOrgType
())
||
!
Constants
.
AUTH_OUT
.
equals
(
req
.
getOrgType
()))
{
return
Result
.
of_error
(
"组织类型不存在!"
);
}
}
String
coding
=
""
;
ApiOrg
apiOrg
=
new
ApiOrg
();
BeanUtils
.
copyProperties
(
req
,
apiOrg
);
...
...
@@ -106,7 +113,6 @@ public class OrganizationManageImpl implements OrganizationManageService {
}
apiOrg
.
setOrgCode
(
coding
);
//组织编码
apiOrg
.
setStatus
(
OrgStatusEnum
.
NORMAL
.
name
());
//正常
//apiOrg.setCreateUser(currentUser.getUserName());
if
(
apiOrgMapper
.
insert
(
apiOrg
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
INSERT_SUCCESS
);
}
...
...
@@ -140,23 +146,22 @@ public class OrganizationManageImpl implements OrganizationManageService {
*/
@Override
public
Result
update
(
OrganizationManageUpdateReq
req
)
{
/* SysUserDto currentUser = (SysUserDto) redisTemplate.opsForValue().get("user" + RedisMessageConstant.SENDTYPE_LOGIN_SYS);
if (null == currentUser) {
return Result.of_error(ResultMsg.USER_NOT_EXIST);
}*/
ApiOrg
apiOrg
=
apiOrgMapper
.
selectById
(
req
.
getId
());
if
(
null
==
apiOrg
)
{
return
Result
.
of_error
(
"组织信息不存在!"
);
}
if
(
StringUtils
.
isNotBlank
(
req
.
getStatus
()))
{
if
(
null
==
fromTypeName
(
req
.
getStatus
())){
if
(
null
==
fromTypeName
(
req
.
getStatus
()))
{
return
Result
.
of_error
(
"更新组织状态不存在!"
);
}
}
//原状态为注销状态不可复原
if
(
OrgStatusEnum
.
CANCEL
.
equals
(
apiOrg
.
getStatus
())){
return
Result
.
of_error
(
"注销状态不可修改"
);
}
ApiOrg
apiOrgUpdate
=
new
ApiOrg
();
BeanUtils
.
copyProperties
(
req
,
apiOrgUpdate
);
apiOrgUpdate
.
setUpdateDate
(
new
Date
());
//apiOrgUpdate.setUpdateUser(currentUser.getUserName());
if
(
apiOrgMapper
.
updateById
(
apiOrgUpdate
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
UPDATE_SUCCESS
);
}
...
...
@@ -164,37 +169,39 @@ public class OrganizationManageImpl implements OrganizationManageService {
}
/**
*
删除
组织
*
注销
组织
*
* @param id
* @return
*/
@Override
public
Result
delete
(
Long
id
)
{
public
Result
logoutOrg
(
Long
id
)
{
ApiOrg
apiOrg
=
apiOrgMapper
.
selectById
(
id
);
if
(
null
==
apiOrg
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
}
UpdateWrapper
<
ApiOrg
>
delete
=
new
UpdateWrapper
<>();
delete
.
set
(
"is_deleted"
,
1
);
delete
.
set
(
"status"
,
OrgStatusEnum
.
CANCEL
);
delete
.
eq
(
"id"
,
id
);
if
(
apiOrgMapper
.
update
(
null
,
delete
)
>
0
)
{
return
Result
.
of_success
(
ResultMsg
.
DELE
TE_SUCCESS
);
return
Result
.
of_success
(
ResultMsg
.
UPDA
TE_SUCCESS
);
}
return
Result
.
of_success
(
ResultMsg
.
DELE
TE_FAIL
);
return
Result
.
of_success
(
ResultMsg
.
UPDA
TE_FAIL
);
}
/**
* 获取认证组织信息
*
* @param apiOrgId
* @return
*/
@Override
public
ApiOrg
getAuthOrganization
(
Long
apiOrgId
)
{
QueryWrapper
<
ApiOrg
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"id"
,
apiOrgId
);
query
.
eq
(
"id"
,
apiOrgId
);
query
.
eq
(
"status"
,
OrgStatusEnum
.
NORMAL
.
name
());
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiOrgMapper
.
selectOne
(
query
);
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
0a7b743c
This diff is collapsed.
Click to expand it.
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
0a7b743c
...
...
@@ -18,7 +18,6 @@ import com.jz.dm.models.domian.ApiInterface;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -71,7 +70,7 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param response
*/
@Override
@ApiLogAspect
(
description
=
"API请求日志"
)
//
@ApiLogAspect(description = "API请求日志")
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@SentinelResource
(
value
=
"api.gateway"
,
fallback
=
"fallbackGateway"
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
...
...
@@ -114,6 +113,10 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
}
}
catch
(
Exception
ex
)
{
if
(
ex
instanceof
GatewayException
)
{
//调用失败回调数据银行解冻
if
(
AuthModeEnum
.
POWER_CALL_MODE
.
name
().
equals
(
apiAuth
.
getAuthMode
())){
notifierMinusMoney
(
parameter
,
bResult
);
}
throw
(
GatewayException
)
ex
;
}
log
.
error
(
"~~~~~~~~~~~~~~~请求api信息异常~~~~~~~~~~~~~"
);
...
...
@@ -186,7 +189,7 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
jsonReq
.
put
(
"assetsId"
,
assetsId
);
jsonReq
.
put
(
"userId"
,
userId
);
jsonReq
.
put
(
"dataPrice"
,
dataPrice
);
jsonReq
.
put
(
"callStatus"
,
bResult
);
//调用成功 扣款 false 调用失败,解冻金额
jsonReq
.
put
(
"callStatus"
,
bResult
);
//
true
调用成功 扣款 false 调用失败,解冻金额
String
responseResult
=
httpsUtils
.
submitPost
(
withholdUrl
,
jsonReq
.
toString
());
JSONObject
paramsResult
=
JSONObject
.
parseObject
(
responseResult
);
if
(
null
!=
paramsResult
){
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
View file @
0a7b743c
...
...
@@ -83,7 +83,7 @@ public class SystemLogAspect {
String
url
=
UrlUtil
.
getServerUrl
(
request
);
// 访问项目名
String
contextPath
=
request
.
getContextPath
();
log
.
info
(
"around请求参数为{}"
,
joinPoint
.
getArgs
()
);
log
.
info
(
"around请求参数为{}"
,
params
);
//动态修改其参数
//注意,如果调用joinPoint.proceed()方法,则修改的参数值不会生效,必须调用joinPoint.proceed(Object[] args)
com
.
alibaba
.
fastjson
.
JSONObject
jsonObject
=
com
.
alibaba
.
fastjson
.
JSONObject
.
parseObject
(
params
);
...
...
jz-dm-apigateway/src/main/resources/application-test.yml
View file @
0a7b743c
...
...
@@ -92,7 +92,8 @@ sentinel: #sentinel每秒中最大的请求个数
#数据银行调用配置
data
:
bank
:
balanceUrl
:
http://localhost:8081/mall/financeCustomerAssets/findAssets
#余额信息url
withholdUrl
:
http://localhost:8081/mall/financeCustomerAssets/unfreezeMoney
#扣款信通知url
balanceUrl
:
http://192.168.1.139:8081/mall/financeCustomerAssets/findAssets
#余额信息url
withholdUrl
:
http://192.168.1.139:8081/mall/financeCustomerAssets/unfreezeMoney
#扣款信通知url
token
:
#dataBank 制作验签
dataBank
:
dataBank123
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/api/ApiReqTest.java
View file @
0a7b743c
...
...
@@ -2,8 +2,8 @@ package com.jz.dm.gateway.api;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.Md5
;
import
com.jz.dm.common.util.MapUtil
;
import
com.jz.dm.common.util.Md5
;
import
com.jz.dm.gateway.SpringTestCase
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -27,14 +27,14 @@ public class ApiReqTest extends SpringTestCase {
public
void
TestGatewayReq
()
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"apiKey"
,
"
9jNA1W5Ydn7Stp12
"
);
jsonObject
.
put
(
"apiKey"
,
"
sE862E97j7Yzo049
"
);
jsonObject
.
put
(
"method"
,
"query"
);
jsonObject
.
put
(
"signType"
,
"MD5"
);
long
time
=
System
.
currentTimeMillis
();
jsonObject
.
put
(
"timestamp"
,
"1609919983045"
);
jsonObject
.
put
(
"timestamp"
,
String
.
valueOf
(
time
)
);
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"authCode"
,
"202
00000000221231111455Jg8ug1621
"
);
params
.
put
(
"authCode"
,
"202
100000001118191258T718d78591J
"
);
params
.
put
(
"selectType"
,
"10006"
);
params
.
put
(
"reqParams"
,
new
JSONObject
());
jsonObject
.
put
(
"params"
,
params
);
...
...
@@ -42,10 +42,9 @@ public class ApiReqTest extends SpringTestCase {
String
apiKey
=
jsonObject
.
getString
(
"apiKey"
);
String
method
=
jsonObject
.
getString
(
"method"
);
String
signType
=
jsonObject
.
getString
(
"signType"
);
String
timestamp
=
jsonObject
.
getString
(
"timestamp"
);
String
signature
=
MapUtil
.
getSignValue
(
apiKey
,
method
,
signType
,
timestamp
);
String
salt
=
Md5
.
encrypt
(
signature
,
"
OOmeF1gh
"
);
String
signature
=
MapUtil
.
getSignValue
(
apiKey
,
method
,
signType
);
String
salt
=
Md5
.
encrypt
(
signature
,
"
33tgT3g2
"
);
jsonObject
.
put
(
"sign"
,
salt
);
String
response
=
httpsUtils
.
submitPost
(
url
,
jsonObject
.
toString
());
System
.
out
.
println
(
response
);
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
View file @
0a7b743c
package
com
.
jz
.
dm
.
gateway
.
orther
;
import
com.jz.dm.common.
base.BaseCurrentUserObject
;
import
com.jz.dm.common.
util.RedisSerializableUtil
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.models.req.make.MakeDataBankApiReq
;
import
net.sf.json.JSONObject
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
...
...
@@ -19,17 +21,49 @@ import org.springframework.data.redis.core.RedisTemplate;
public
class
TestRedisUserSave
extends
SpringTestCase
{
@Autowired
private
RedisTemplate
redisTemplate
;
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
/*@Autowired
private RedisUtils redisUtils;*/
@Test
public
void
saveUser
(){
redisTemplate
.
opsForValue
().
set
(
"USER004"
,
"USER9999"
);
RedisTemplate
template
=
new
RedisTemplate
();
template
.
opsForValue
().
set
(
"USER004"
,
"USER9999"
);
// this.redisTemplate.opsForValue().set("USER004","USER9999");
}
@Test
public
void
getUser
(){
//String str= (String)redisTemplate.opsForValue().get("USER"+"_99999");
//System.out.println("获取到的用户:"+str);
System
.
out
.
println
(
new
BaseCurrentUserObject
().
getUserInfo
());
redisTemplate
.
opsForValue
().
get
(
"USER004"
);
}
@Test
public
void
saveObject
(){
MakeDataBankApiReq
bankApiReq
=
new
MakeDataBankApiReq
();
bankApiReq
.
setTransMode
(
"HTTPS"
);
bankApiReq
.
setSignType
(
"MD5"
);
bankApiReq
.
setJoinType
(
"10004"
);
bankApiReq
.
setOutputType
(
"JSON"
);
bankApiReq
.
setPage
(
false
);
bankApiReq
.
setReqType
(
"DAY"
);
bankApiReq
.
setTargetUrl
(
"www.baidu.com"
);
bankApiReq
.
setFileId
(
1L
);
bankApiReq
.
setSign
(
"F2A8E3CFE528D6AE5C5B075046653F3E"
);
bankApiReq
.
setReqFrequency
(
0L
);
bankApiReq
.
setApiDesc
(
"4444"
);
bankApiReq
.
setTimeout
(
"5000"
);
String
value
=
String
.
valueOf
(
bankApiReq
);
System
.
out
.
println
(
value
);
// JSONObject jsonObject = JSONObject.parseObject(value);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
bankApiReq
);
System
.
out
.
println
(
jsonObject
);
// redisTemplate.opsForValue().set(bankApiReq,jsonObject,300, TimeUnit.SECONDS);
/*RedisUtils redisUtilsaa = new RedisUtils();*/
RedisTemplate
redisTemplate1
=
new
RedisTemplate
();
byte
[]
serialize
=
RedisSerializableUtil
.
serialize
(
jsonObject
);
// redisUtilsaa.set("bankApiReq",jsonObject,300);
redisTemplate1
.
opsForValue
().
set
(
"bankApiReq"
,
jsonObject
);
redisTemplate1
.
opsForValue
().
get
(
bankApiReq
);
}
}
jz-dm-common/pom.xml
View file @
0a7b743c
...
...
@@ -19,6 +19,7 @@
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
...
...
jz-dm-common/src/main/java/com/jz/common/utils/RedisUtils.java
View file @
0a7b743c
...
...
@@ -132,6 +132,15 @@ public class RedisUtils {
return
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
}
/**
* 实现命令:GET key,返回 key所关联的值。
*
* @param key
* @return obj
*/
public
Object
getObj
(
String
key
)
{
return
redisTemplate
.
opsForValue
().
get
(
key
);
}
/**
* Hash(哈希表)
* 实现命令:HSET key field value,将哈希表 key中的域 field的值设为 value
...
...
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