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
93162abe
Commit
93162abe
authored
Jan 22, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加api测试接口
parent
edbf048a
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
412 additions
and
112 deletions
+412
-112
api_gateway.sql
database/zc/api_gateway.sql
+3
-0
GatewayResultCode.java
...c/main/java/com/jz/dm/common/enums/GatewayResultCode.java
+6
-1
AuthFilter.java
...apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
+15
-12
VerifySignFilter.java
...eway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
+17
-14
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+5
-0
ApiInterfaceCustom.java
...main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
+10
-0
ApiInterfaceReq.java
.../main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
+5
-2
MakeDataBankApiReq.java
...in/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
+17
-6
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+6
-4
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+262
-66
application-test.yml
jz-dm-apigateway/src/main/resources/application-test.yml
+3
-0
TestRedisUserSave.java
...test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
+2
-2
TestStr.java
...teway/src/test/java/com/jz/dm/gateway/orther/TestStr.java
+61
-5
No files found.
database/zc/api_gateway.sql
View file @
93162abe
...
@@ -9,6 +9,7 @@ CREATE TABLE `t_api_interface` (
...
@@ -9,6 +9,7 @@ CREATE TABLE `t_api_interface` (
`api_path`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'请求地址'
,
`api_path`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'请求地址'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 6 标签查询 9自定义'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 数据银行制作大数据表 2 数据银行制作数据包,3,数据银行制作自定义API 4 API实时接入 6 标签查询 9自定义'
,
`req_method`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'请求方式: GET, POST'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`test_example`
varchar
(
255
)
NULL
DEFAULT
NULL
COMMENT
'测试实例'
,
`test_example`
varchar
(
255
)
NULL
DEFAULT
NULL
COMMENT
'测试实例'
,
...
@@ -49,6 +50,8 @@ CREATE TABLE `t_api_interface_custom` (
...
@@ -49,6 +50,8 @@ CREATE TABLE `t_api_interface_custom` (
`resp_code`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应状态码'
,
`resp_code`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'响应状态码'
,
`api_example`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api返回样例'
,
`api_example`
varchar
(
300
)
DEFAULT
NULL
COMMENT
'api返回样例'
,
`inbox_param`
varchar
(
300
)
NULL
DEFAULT
NULL
COMMENT
'固定参数'
,
`inbox_param`
varchar
(
300
)
NULL
DEFAULT
NULL
COMMENT
'固定参数'
,
`page_num`
int
(
10
)
NULL
DEFAULT
'1'
COMMENT
'当前页'
,
`page_size`
int
(
10
)
NULL
DEFAULT
'100'
COMMENT
'当前页显示数'
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`remark`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'备注'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_date`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
`create_user`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'创建人'
,
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/GatewayResultCode.java
View file @
93162abe
...
@@ -37,7 +37,6 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -37,7 +37,6 @@ public enum GatewayResultCode implements ResultCode {
ILLEGAL_TIMETEMP
(
"ILLEGAL_TIMETEMP"
,
"无效时间戳"
),
ILLEGAL_TIMETEMP
(
"ILLEGAL_TIMETEMP"
,
"无效时间戳"
),
/** 请求次数受限 */
/** 请求次数受限 */
REQUEST_LIMIT_EXCEPTION
(
"REQUEST_LIMIT_EXCEPTION"
,
"请求次数受限"
),
REQUEST_LIMIT_EXCEPTION
(
"REQUEST_LIMIT_EXCEPTION"
,
"请求次数受限"
),
...
@@ -60,6 +59,12 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -60,6 +59,12 @@ public enum GatewayResultCode implements ResultCode {
/** API状态异常 */
/** API状态异常 */
API_STATUS_EXCEPTION
(
"API_STATUS_EXCEPTION"
,
"API状态异常"
),
API_STATUS_EXCEPTION
(
"API_STATUS_EXCEPTION"
,
"API状态异常"
),
/** API类型错误 */
API_TYPE_ERROR
(
"API_TYPE_ERROR"
,
"API类型错误"
),
/** 文件地址不存在 */
DATA_BIG_ADDR_UNEXIST
(
"DATA_BIG_ADDR_UNEXIST"
,
"文件地址不存在!"
),
/** 请求组织状态异常 */
/** 请求组织状态异常 */
ORG_STATE_EXCEPTION
(
"ORG_STATE_EXCEPTION"
,
"请求组织状态异常"
),
ORG_STATE_EXCEPTION
(
"ORG_STATE_EXCEPTION"
,
"请求组织状态异常"
),
/** 请求信息不存在 */
/** 请求信息不存在 */
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
View file @
93162abe
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.Constants
;
import
com.jz.dm.common.constant.TagConstants
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.enums.auth.AuthReqTypeEnum
;
import
com.jz.dm.common.enums.auth.AuthReqTypeEnum
;
...
@@ -89,7 +90,11 @@ public class AuthFilter extends AbstractFilter {
...
@@ -89,7 +90,11 @@ public class AuthFilter extends AbstractFilter {
}
}
}
}
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getParams
());
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getParams
());
if
(
null
!=
parameter
)
{
if
(
null
==
parameter
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_PARAM_EMPTY
);
}
Boolean
isTest
=
parameter
.
getBoolean
(
"isTest"
);
if
(!
isTest
)
{
//是否测试数据
String
authCode
=
parameter
.
getString
(
"authCode"
);
String
authCode
=
parameter
.
getString
(
"authCode"
);
ApiAuth
authAuth
=
authService
.
getAuthUser
(
authCode
,
apiInterface
.
getId
());
ApiAuth
authAuth
=
authService
.
getAuthUser
(
authCode
,
apiInterface
.
getId
());
if
(
null
==
authAuth
)
{
if
(
null
==
authAuth
)
{
...
@@ -107,7 +112,7 @@ public class AuthFilter extends AbstractFilter {
...
@@ -107,7 +112,7 @@ public class AuthFilter extends AbstractFilter {
if
(!
apiOrg
.
getStatus
())
{
if
(!
apiOrg
.
getStatus
())
{
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
}
}
checkBill
(
request
,
authCode
,
authAuth
,
apiOrg
);
checkBill
(
request
,
authCode
,
authAuth
);
}
}
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -132,19 +137,17 @@ public class AuthFilter extends AbstractFilter {
...
@@ -132,19 +137,17 @@ public class AuthFilter extends AbstractFilter {
* @param request
* @param request
* @param authCode
* @param authCode
* @param authAuth
* @param authAuth
* @param apiOrg
* @throws ParseException
* @throws ParseException
*/
*/
private
void
checkBill
(
GatewayRequest
request
,
String
authCode
,
private
void
checkBill
(
GatewayRequest
request
,
String
authCode
,
ApiAuth
authAuth
,
ApiOrg
apiOrg
)
throws
ParseException
{
ApiAuth
authAuth
)
throws
ParseException
{
switch
(
authAuth
.
getAuthMode
())
{
switch
(
authAuth
.
getAuthMode
())
{
case
"POWER_CALL_MODE"
:
//按次调用
case
"POWER_CALL_MODE"
:
//按次调用
//查询数据银行银行余额是否充足
//查询数据银行银行余额是否充足
getDataAmountResult
(
request
);
getDataAmountResult
(
request
);
try
{
//记录请求次数(每天限制请求次数)
try
{
//记录请求次数(每天限制请求次数)
// String limitKey = TagConstants.OPEN_API_REDIS_LIMIT_KEY + authCode;
String
limitKey
=
TagConstants
.
OPEN_API_REDIS_LIMIT_KEY
+
authCode
;
String
limitKey
=
authCode
;
Integer
reqValue
=
(
Integer
)
redisUtils
.
getObj
(
limitKey
);
String
reqValue
=
(
String
)
redisUtils
.
getObj
(
limitKey
);
long
timeOut
=
0
;
long
timeOut
=
0
;
if
(
AuthReqTypeEnum
.
DAY
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按天
if
(
AuthReqTypeEnum
.
DAY
.
name
().
equals
(
authAuth
.
getReqType
()))
{
//按天
timeOut
=
DateUtil
.
calculateNowResidueTime
();
timeOut
=
DateUtil
.
calculateNowResidueTime
();
...
@@ -154,11 +157,11 @@ public class AuthFilter extends AbstractFilter {
...
@@ -154,11 +157,11 @@ public class AuthFilter extends AbstractFilter {
//暂时不支持年
//暂时不支持年
}
}
if
(
null
!=
reqValue
)
{
if
(
null
!=
reqValue
)
{
Integer
value
=
Integer
.
valueOf
(
reqValue
);
/* Integer value = Integer.valueOf(reqValue);*/
if
(
v
alue
>
authAuth
.
getReqFrequency
())
{
//超出最大请求次数
if
(
reqV
alue
>
authAuth
.
getReqFrequency
())
{
//超出最大请求次数
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_LIMIT_EXCEPTION
);
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_LIMIT_EXCEPTION
);
}
else
if
(
v
alue
<=
authAuth
.
getReqFrequency
())
{
}
else
if
(
reqV
alue
<=
authAuth
.
getReqFrequency
())
{
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
v
alue
+
1
,
timeOut
);
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
reqV
alue
+
1
,
timeOut
);
}
}
}
else
{
}
else
{
redisUtils
.
set
(
limitKey
,
1
,
timeOut
);
redisUtils
.
set
(
limitKey
,
1
,
timeOut
);
...
@@ -217,7 +220,7 @@ public class AuthFilter extends AbstractFilter {
...
@@ -217,7 +220,7 @@ public class AuthFilter extends AbstractFilter {
pObject
.
put
(
"assetsId"
,
assetsId
);
pObject
.
put
(
"assetsId"
,
assetsId
);
pObject
.
put
(
"userId"
,
userId
);
pObject
.
put
(
"userId"
,
userId
);
pObject
.
put
(
"dataPrice"
,
dataPrice
);
pObject
.
put
(
"dataPrice"
,
dataPrice
);
String
respResult
=
httpUtils
.
submitPost
(
balanceUrl
+
"/mall/financeCustomerAssets/findAssets"
,
pObject
.
toString
());
String
respResult
=
httpUtils
.
submitPost
(
balanceUrl
+
"/mall/financeCustomerAssets/findAssets"
,
pObject
.
toString
());
JSONObject
result
=
JSONObject
.
parseObject
(
respResult
);
JSONObject
result
=
JSONObject
.
parseObject
(
respResult
);
if
(
null
!=
result
)
{
if
(
null
!=
result
)
{
if
(
200
!=
result
.
getInteger
(
"code"
))
{
if
(
200
!=
result
.
getInteger
(
"code"
))
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
View file @
93162abe
...
@@ -41,22 +41,25 @@ public class VerifySignFilter extends AbstractFilter {
...
@@ -41,22 +41,25 @@ public class VerifySignFilter extends AbstractFilter {
protected
void
internalDoFilter
(
GatewayRequest
request
,
GatewayResponse
response
,
protected
void
internalDoFilter
(
GatewayRequest
request
,
GatewayResponse
response
,
FilterChain
chain
)
{
FilterChain
chain
)
{
try
{
try
{
//对签约参数进行字典排序
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
request
.
getSignType
());
if
(!
jsonObject
.
getBoolean
(
"isTest"
)){
//是否测试调用
if
(
StringUtils
.
isNotBlank
(
signParams
)){
//对签约参数进行字典排序
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
request
.
getSignType
());
String
authCode
=
jsonObject
.
getString
(
"authCode"
);
if
(
StringUtils
.
isNotBlank
(
signParams
)){
//需要传入授权码
ApiAuth
apiAuthInfo
=
apiInterfaceService
.
getApiAuthInfo
(
request
.
getApiKey
(),
authCode
);
String
authCode
=
jsonObject
.
getString
(
"authCode"
);
if
(
null
==
apiAuthInfo
){
//需要传入授权码
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
ApiAuth
apiAuthInfo
=
apiInterfaceService
.
getApiAuthInfo
(
request
.
getApiKey
(),
authCode
);
}
if
(
null
==
apiAuthInfo
){
String
sign
=
Md5
.
encrypt
(
signParams
,
apiAuthInfo
.
getSalt
());
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
if
(!
request
.
getSign
().
equals
(
sign
)){
}
String
sign
=
Md5
.
encrypt
(
signParams
,
apiAuthInfo
.
getSalt
());
if
(!
request
.
getSign
().
equals
(
sign
)){
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
}
}
else
{
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
}
}
}
else
{
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
}
}
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
catch
(
SignatureException
ex
)
{
}
catch
(
SignatureException
ex
)
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
93162abe
...
@@ -66,6 +66,11 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -66,6 +66,11 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
*/
@TableField
(
"target_url"
)
@TableField
(
"target_url"
)
private
String
targetUrl
;
private
String
targetUrl
;
/**
* 请求方式:GET POST
*/
@TableField
(
"req_method"
)
private
String
reqMethod
;
/**
/**
* 接入类型:对应字典表key
* 接入类型:对应字典表key
*/
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceCustom.java
View file @
93162abe
...
@@ -93,5 +93,15 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
...
@@ -93,5 +93,15 @@ public class ApiInterfaceCustom extends BaseObject implements Serializable {
*/
*/
@TableField
(
"inbox_param"
)
@TableField
(
"inbox_param"
)
private
String
inboxParam
;
private
String
inboxParam
;
/**
* 当前页
*/
@TableField
(
"page_num"
)
private
Integer
pageNum
;
/**
* 当前页显示数据
*/
@TableField
(
"page_size"
)
private
Integer
pageSize
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
View file @
93162abe
...
@@ -40,6 +40,9 @@ public class ApiInterfaceReq implements Serializable {
...
@@ -40,6 +40,9 @@ public class ApiInterfaceReq implements Serializable {
@NotNull
(
message
=
"目标地址不能为空"
)
@NotNull
(
message
=
"目标地址不能为空"
)
public
String
targetUrl
;
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"请求方式:GET POST"
,
required
=
false
)
public
String
reqMethod
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
true
)
@NotNull
(
message
=
"超时时间不能为空"
)
@NotNull
(
message
=
"超时时间不能为空"
)
public
String
timeout
;
public
String
timeout
;
...
@@ -54,7 +57,7 @@ public class ApiInterfaceReq implements Serializable {
...
@@ -54,7 +57,7 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
public
String
apiFunction
;
@ApiModelProperty
(
value
=
"父类文件id,一级文件夹传入0"
,
required
=
false
)
/*
@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
public Long parentId;
public Long parentId;
@ApiModelProperty(value = "文件id",required = false)
@ApiModelProperty(value = "文件id",required = false)
...
@@ -62,7 +65,7 @@ public class ApiInterfaceReq implements Serializable {
...
@@ -62,7 +65,7 @@ public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "项目id",required = true)
@ApiModelProperty(value = "项目id",required = true)
@NotNull(message="项目id不能为空")
@NotNull(message="项目id不能为空")
public
Long
projectId
;
public Long projectId;
*/
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
@ApiModelProperty
(
value
=
"状态"
,
required
=
false
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
View file @
93162abe
...
@@ -40,9 +40,13 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -40,9 +40,13 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"输出类型不能为空"
)
@NotNull
(
message
=
"输出类型不能为空"
)
public
String
outputType
;
public
String
outputType
;
@ApiModelProperty
(
value
=
"是否分页:"
,
required
=
true
)
@ApiModelProperty
(
value
=
"请求方式:GET POST"
,
required
=
true
)
@NotNull
(
message
=
"请求方式不能为空"
)
public
String
reqMethod
;
/*@ApiModelProperty(value = "是否分页:",required = true)
@NotNull(message = "是否分页不能为空")
@NotNull(message = "是否分页不能为空")
public
Boolean
page
;
public Boolean page;
*/
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月"
,
required
=
true
)
@ApiModelProperty
(
value
=
"限流类型:DAY 按天,MONTH 按月"
,
required
=
true
)
@NotNull
(
message
=
"限流类型不能为空"
)
@NotNull
(
message
=
"限流类型不能为空"
)
...
@@ -52,9 +56,15 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -52,9 +56,15 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"目标地址不能为空"
)
@NotNull
(
message
=
"目标地址不能为空"
)
public
String
targetUrl
;
public
String
targetUrl
;
@ApiModelProperty
(
value
=
"文件id"
,
required
=
true
)
@ApiModelProperty
(
value
=
"当前页"
,
required
=
true
)
@NotNull
(
message
=
"文件id不能为空"
)
public
Integer
pageNum
;
public
Long
fileId
;
@ApiModelProperty
(
value
=
"当前页显示条数"
,
required
=
true
)
public
Integer
pageSize
;
//@ApiModelProperty(value = "文件id",required = true)
//@NotNull(message = "文件id不能为空")
//public Long fileId;
@ApiModelProperty
(
value
=
"签名"
,
required
=
true
)
@ApiModelProperty
(
value
=
"签名"
,
required
=
true
)
@NotNull
(
message
=
"签名不能为空"
)
@NotNull
(
message
=
"签名不能为空"
)
...
@@ -69,7 +79,8 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -69,7 +79,8 @@ public class MakeDataBankApiReq implements Serializable {
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"接口描述"
,
required
=
false
)
public
String
apiDesc
;
public
String
apiDesc
;
@ApiModelProperty
(
value
=
"数据包下载路径"
,
required
=
false
)
public
String
fileLocation
;
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
false
)
@ApiModelProperty
(
value
=
"超时时间"
,
required
=
false
)
public
String
timeout
;
public
String
timeout
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
93162abe
...
@@ -146,13 +146,13 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -146,13 +146,13 @@ public class ProducerServiceImpl implements ProducerService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
)
{
public
Result
addDataBankApiInfo
(
MakeDataBankApiReq
req
)
{
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
/*
QueryWrapper<ApiInterfaceFile> query = new QueryWrapper<>();
query.eq("file_source", "2");
query.eq("file_source", "2");
query.eq("is_deleted", 0);
query.eq("is_deleted", 0);
List<ApiInterfaceFile> fileSource = apiInterfaceFileMapper.selectList(query);
List<ApiInterfaceFile> fileSource = apiInterfaceFileMapper.selectList(query);
if (fileSource.size() == 0 || fileSource.size() >= 2) {
if (fileSource.size() == 0 || fileSource.size() >= 2) {
return Result.of_error("文件夹信息异常!");
return Result.of_error("文件夹信息异常!");
}
}
*/
if
(
StringUtils
.
isNotBlank
(
req
.
getOutputType
()))
{
if
(
StringUtils
.
isNotBlank
(
req
.
getOutputType
()))
{
if
(!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
JSON
.
name
())
||
if
(!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
JSON
.
name
())
||
!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
FLOW
.
name
()))
{
!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
FLOW
.
name
()))
{
...
@@ -175,6 +175,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -175,6 +175,7 @@ public class ProducerServiceImpl implements ProducerService {
saveDataBanker
(
req
,
apiKey
,
"3"
);
saveDataBanker
(
req
,
apiKey
,
"3"
);
break
;
break
;
case
"10007"
:
//数据银行数据包上传
case
"10007"
:
//数据银行数据包上传
if
(
StringUtils
.
isNotBlank
(
req
.
getFileLocation
()))
return
Result
.
of_error
(
"文件地址不存在!"
);
saveDataBanker
(
req
,
apiKey
,
"2"
);
saveDataBanker
(
req
,
apiKey
,
"2"
);
break
;
break
;
case
"10008"
:
//数据银行制作大数据表
case
"10008"
:
//数据银行制作大数据表
...
@@ -199,6 +200,7 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -199,6 +200,7 @@ public class ProducerServiceImpl implements ProducerService {
JSONObject
object
=
new
JSONObject
();
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"targetUrl"
,
req
.
getTargetUrl
());
object
.
put
(
"outputType"
,
req
.
getOutputType
());
object
.
put
(
"outputType"
,
req
.
getOutputType
());
object
.
put
(
"reqMethod"
,
req
.
getReqMethod
());
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
saveObjOnRedis
(
apiInterface
.
getApiKey
(),
object
);
}
}
...
@@ -340,10 +342,10 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -340,10 +342,10 @@ public class ProducerServiceImpl implements ProducerService {
//生成ApiKey
//生成ApiKey
String
apiKey
=
getApiKey
();
String
apiKey
=
getApiKey
();
ApiInterface
apiInterface
=
new
ApiInterface
();
ApiInterface
apiInterface
=
new
ApiInterface
();
if
(
null
==
req
.
getFileId
())
{
//创建下级文件夹
/*
if (null == req.getFileId()) {//创建下级文件夹
Long fileId = checkFileExist(req.getProjectId(), req.getParentId(), req.getCreateUser());
Long fileId = checkFileExist(req.getProjectId(), req.getParentId(), req.getCreateUser());
req.setFileId(fileId);
req.setFileId(fileId);
}
}
*/
BeanUtils
.
copyProperties
(
req
,
apiInterface
);
BeanUtils
.
copyProperties
(
req
,
apiInterface
);
apiInterface
.
setApiKey
(
apiKey
);
apiInterface
.
setApiKey
(
apiKey
);
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
apiInterface
.
setApiProtocl
(
req
.
getTransMode
());
//传输方式 https http
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
93162abe
This diff is collapsed.
Click to expand it.
jz-dm-apigateway/src/main/resources/application-test.yml
View file @
93162abe
...
@@ -107,5 +107,8 @@ logging:
...
@@ -107,5 +107,8 @@ logging:
zhl
:
zhl
:
springbootlogback
:
off
springbootlogback
:
off
#数据包访问链接
dataPackage
:
downloadUrl
:
http://xxx.com
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
View file @
93162abe
...
@@ -43,10 +43,10 @@ public class TestRedisUserSave extends SpringTestCase {
...
@@ -43,10 +43,10 @@ public class TestRedisUserSave extends SpringTestCase {
bankApiReq
.
setSignType
(
"MD5"
);
bankApiReq
.
setSignType
(
"MD5"
);
bankApiReq
.
setJoinType
(
"10004"
);
bankApiReq
.
setJoinType
(
"10004"
);
bankApiReq
.
setOutputType
(
"JSON"
);
bankApiReq
.
setOutputType
(
"JSON"
);
bankApiReq
.
setPage
(
false
);
//
bankApiReq.setPage(false);
bankApiReq
.
setReqType
(
"DAY"
);
bankApiReq
.
setReqType
(
"DAY"
);
bankApiReq
.
setTargetUrl
(
"www.baidu.com"
);
bankApiReq
.
setTargetUrl
(
"www.baidu.com"
);
bankApiReq
.
setFileId
(
1L
);
//
bankApiReq.setFileId(1L);
bankApiReq
.
setSign
(
"F2A8E3CFE528D6AE5C5B075046653F3E"
);
bankApiReq
.
setSign
(
"F2A8E3CFE528D6AE5C5B075046653F3E"
);
bankApiReq
.
setReqFrequency
(
0L
);
bankApiReq
.
setReqFrequency
(
0L
);
bankApiReq
.
setApiDesc
(
"4444"
);
bankApiReq
.
setApiDesc
(
"4444"
);
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestStr.java
View file @
93162abe
package
com
.
jz
.
dm
.
gateway
.
orther
;
package
com
.
jz
.
dm
.
gateway
.
orther
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* @ClassName:
* @ClassName:
* @Author: Carl
* @Author: Carl
...
@@ -8,10 +12,62 @@ package com.jz.dm.gateway.orther;
...
@@ -8,10 +12,62 @@ package com.jz.dm.gateway.orther;
*/
*/
public
class
TestStr
{
public
class
TestStr
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
str
=
"/picture/logo/T6gxlv137nFA555z.jpg"
;
List
<
String
>
list1
=
new
ArrayList
<
String
>();
// String[] split = str.split("\\/");
list1
.
add
(
"1"
);
System
.
out
.
println
(
str
.
substring
(
0
,
str
.
lastIndexOf
(
"/"
)
+
1
));
list1
.
add
(
"2"
);
String
substring
=
str
.
substring
(
str
.
lastIndexOf
(
"."
));
list1
.
add
(
"3"
);
System
.
out
.
println
(
substring
);
list1
.
add
(
"4"
);
list1
.
add
(
"5"
);
List
<
String
>
list2
=
new
ArrayList
<
String
>();
list2
.
add
(
"1"
);
list2
.
add
(
"2"
);
list2
.
add
(
"3"
);
list2
.
add
(
"4"
);
list2
.
add
(
"5"
);
list2
.
add
(
"7"
);
list2
.
add
(
"9"
);
// 交集
List
<
String
>
intersection
=
list1
.
stream
().
filter
(
item
->
list2
.
contains
(
item
)).
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
"---交集 intersection---"
);
intersection
.
parallelStream
().
forEach
(
System
.
out
::
println
);
// 差集 (list1 - list2)
List
<
String
>
reduce1
=
list1
.
stream
().
filter
(
item
->
!
list2
.
contains
(
item
)).
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
"---差集 reduce1 (list1 - list2)---"
);
reduce1
.
parallelStream
().
forEach
(
System
.
out
::
println
);
// 差集 (list2 - list1)
List
<
String
>
reduce2
=
list2
.
stream
().
filter
(
item
->
!
list1
.
contains
(
item
)).
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
"---差集 reduce2 (list2 - list1)---"
);
reduce2
.
parallelStream
().
forEach
(
System
.
out
::
println
);
//合拼差
reduce1
.
addAll
(
reduce2
);
System
.
out
.
println
(
"---合拼差 reduce1 (list2 -> list1)---"
);
reduce1
.
parallelStream
().
forEach
(
System
.
out
::
println
);
// 并集
List
<
String
>
listAll
=
list1
.
parallelStream
().
collect
(
Collectors
.
toList
());
List
<
String
>
listAll2
=
list2
.
parallelStream
().
collect
(
Collectors
.
toList
());
listAll
.
addAll
(
listAll2
);
System
.
out
.
println
(
"---并集 listAll---"
);
listAll
.
parallelStream
().
forEachOrdered
(
System
.
out
::
println
);
// 去重并集
List
<
String
>
listAllDistinct
=
listAll
.
stream
().
distinct
().
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
"---得到去重并集 listAllDistinct---"
);
listAllDistinct
.
parallelStream
().
forEachOrdered
(
System
.
out
::
println
);
System
.
out
.
println
(
"---原来的List1---"
);
list1
.
parallelStream
().
forEachOrdered
(
System
.
out
::
println
);
System
.
out
.
println
(
"---原来的List2---"
);
list2
.
parallelStream
().
forEachOrdered
(
System
.
out
::
println
);
}
}
}
}
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