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
d6402b13
Commit
d6402b13
authored
Feb 25, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化API调用代码
parent
196e03a6
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
1025 additions
and
655 deletions
+1025
-655
api_gateway.sql
database/zc/api_gateway.sql
+1
-0
pom.xml
jz-dm-apigateway/pom.xml
+8
-1
GatewayResultCode.java
...c/main/java/com/jz/dm/common/enums/GatewayResultCode.java
+8
-5
ResultFlowCode.java
.../src/main/java/com/jz/dm/common/enums/ResultFlowCode.java
+59
-0
LimitFlowException.java
...n/java/com/jz/dm/common/exception/LimitFlowException.java
+63
-0
MapUtil.java
...igateway/src/main/java/com/jz/dm/common/util/MapUtil.java
+10
-33
GatewayUrlBlockHandler.java
...rc/main/java/com/jz/dm/config/GatewayUrlBlockHandler.java
+47
-0
AuthFilter.java
...apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
+2
-2
CheckArgsFilter.java
...teway/src/main/java/com/jz/dm/filter/CheckArgsFilter.java
+0
-1
VerifySignFilter.java
...eway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
+19
-3
ApiFunctionMapper.java
...way/src/main/java/com/jz/dm/mapper/ApiFunctionMapper.java
+10
-0
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+6
-0
DataTableSelectTO.java
...c/main/java/com/jz/dm/models/enity/DataTableSelectTO.java
+49
-0
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+149
-118
DataBagService.java
...c/main/java/com/jz/dm/service/request/DataBagService.java
+22
-0
DataSelectService.java
...ain/java/com/jz/dm/service/request/DataSelectService.java
+21
-0
ThirdSelectService.java
...in/java/com/jz/dm/service/request/ThirdSelectService.java
+22
-0
DataBagHandle.java
...in/java/com/jz/dm/service/request/impl/DataBagHandle.java
+54
-0
DataTableSelectHandle.java
...com/jz/dm/service/request/impl/DataTableSelectHandle.java
+209
-0
ThirdSelectHandle.java
...ava/com/jz/dm/service/request/impl/ThirdSelectHandle.java
+171
-0
ApiReqTest.java
...teway/src/test/java/com/jz/dm/gateway/api/ApiReqTest.java
+70
-11
TestHttpReq.java
...y/src/test/java/com/jz/dm/gateway/orther/TestHttpReq.java
+1
-1
TestMakeApi.java
...y/src/test/java/com/jz/dm/gateway/orther/TestMakeApi.java
+1
-1
ResultCode.java
...mmon/src/main/java/com/jz/common/constant/ResultCode.java
+6
-6
ResultMsg.java
...ommon/src/main/java/com/jz/common/constant/ResultMsg.java
+13
-468
HttpsUtils.java
...-common/src/main/java/com/jz/common/utils/HttpsUtils.java
+4
-5
No files found.
database/zc/api_gateway.sql
View file @
d6402b13
...
...
@@ -8,6 +8,7 @@ CREATE TABLE `t_api_interface` (
`target_url`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'目标url'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'接入类型:字典表对应key值'
,
`req_type`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'请求方式: GET, POST'
,
`post_type`
varchar
(
20
)
NULL
DEFAULT
NULL
COMMENT
'post请求类型:1.x-www-form-urlencoded 2.form-data 3.json'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`output_type`
varchar
(
50
)
NULL
DEFAULT
'JSON'
COMMENT
'输出类型:flow 流形式输出, json格式输出'
,
...
...
jz-dm-apigateway/pom.xml
View file @
d6402b13
...
...
@@ -117,7 +117,12 @@
<groupId>
com.alibaba.csp
</groupId>
<artifactId>
sentinel-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba.csp
</groupId>
<artifactId>
sentinel-spring-webmvc-adapter
</artifactId>
<version>
1.8.0
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
net.sf.json-lib
</groupId>
<artifactId>
json-lib
</artifactId>
...
...
@@ -149,6 +154,8 @@
<artifactId>
velocity-engine-core
</artifactId>
<version>
2.0
</version>
</dependency>
<!-- 代码自动生成依赖 end-->
</dependencies>
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/GatewayResultCode.java
View file @
d6402b13
...
...
@@ -36,6 +36,9 @@ public enum GatewayResultCode implements ResultCode {
/** 无效请求 */
ILLEGAL_TIMETEMP
(
"ILLEGAL_TIMETEMP"
,
"无效时间戳"
),
/** 无效授权 */
ILLEGAL_AUTHORIZATION
(
"ILLEGAL_AUTHORIZATION"
,
"无效授权"
),
/** 请求次数受限 */
REQUEST_LIMIT_EXCEPTION
(
"REQUEST_LIMIT_EXCEPTION"
,
"请求次数受限"
),
...
...
@@ -53,8 +56,8 @@ public enum GatewayResultCode implements ResultCode {
/** 请求未授权 */
REQUEST_NOT_AUTH
(
"REQUEST_NOT_AUTH"
,
"请求未授权"
),
/**
请求
组织不存在 */
ORG_NOT_EXIST
(
"ORG_NOT_EXIST"
,
"
请求
组织不存在"
),
/** 组织不存在 */
ORG_NOT_EXIST
(
"ORG_NOT_EXIST"
,
"组织不存在"
),
/** API状态异常 */
API_STATUS_EXCEPTION
(
"API_STATUS_EXCEPTION"
,
"API状态异常"
),
...
...
@@ -65,12 +68,12 @@ public enum GatewayResultCode implements ResultCode {
/** 文件地址不存在 */
DATA_BIG_ADDR_UNEXIST
(
"DATA_BIG_ADDR_UNEXIST"
,
"文件地址不存在!"
),
/**
请求
组织状态异常 */
ORG_STATE_EXCEPTION
(
"ORG_STATE_EXCEPTION"
,
"
请求
组织状态异常"
),
/** 组织状态异常 */
ORG_STATE_EXCEPTION
(
"ORG_STATE_EXCEPTION"
,
"组织状态异常"
),
/** 请求信息不存在 */
REQUEST_INFO_UNEXIST
(
"REQUEST_INFO_UNEXIST"
,
"请求信息不存在"
),
/** 远程请求异常 */
DISTANCE_REQUEST_EXCEPTION
(
"DISTANCE_REQUEST_EXCEPTION"
,
"
流形式输出
异常"
),
DISTANCE_REQUEST_EXCEPTION
(
"DISTANCE_REQUEST_EXCEPTION"
,
"
远程请求
异常"
),
/** 单次调用金额不足 */
CALL_AMOUNT_NOT_ENOUGH
(
"CALL_AMOUNT_NOT_ENOUGH"
,
"单次调用金额不足"
),
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/ResultFlowCode.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
common
.
enums
;
import
com.alibaba.fastjson.JSON
;
import
com.jz.common.constant.ResultMsg
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums
* @PROJECT_NAME: jz-dm-parent
* @NAME: ResultFlowCode
* @DATE: 2021-2-25/14:40
* @DAY_NAME_SHORT: 周四
* @Description:
**/
public
enum
ResultFlowCode
{
/** 限流异常 */
FLOW_EXCEPTION
(
410
,
ResultMsg
.
LIMIT_FLOW_EXCEPTION
),
/** 降级异常 */
DEGRADE_EXCEPTION
(
411
,
ResultMsg
.
LIMIT_DEGRADE_EXCEPTION
),
/** 热点异常 */
PARAM_EXCEPTION
(
412
,
ResultMsg
.
LIMIT_PARAM_EXCEPTION
),
/** 系统规则异常 */
SYSTEM_EXCEPTION
(
413
,
ResultMsg
.
LIMIT_SYSTEM_EXCEPTION
),
/** 认证异常 */
AUTHORITY_EXCEPTION
(
414
,
ResultMsg
.
LIMIT_AUTHORITY_EXCEPTION
);
private
int
code
;
/**
* 提示信息
*/
private
ResultMsg
msg
;
private
ResultFlowCode
(
int
code
,
ResultMsg
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
@Override
public
String
toString
()
{
return
JSON
.
toJSONString
(
this
);
}
public
int
getCode
()
{
return
code
;
}
public
ResultMsg
getMsg
()
{
return
this
.
msg
;
}
public
void
setMsg
(
ResultMsg
msg
)
{
this
.
msg
=
msg
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/exception/LimitFlowException.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
common
.
exception
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.dm.common.enums.ResultFlowCode
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.exception
* @PROJECT_NAME: jz-dm-parent
* @NAME: LimitFlowException
* @DATE: 2021-2-25/14:27
* @DAY_NAME_SHORT: 周四
* @Description: 限流异常处理器
**/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
LimitFlowException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
-
3963657380514719229L
;
/**
* 错误代码
*/
protected
ResultFlowCode
code
;
/**
* 错误信息
*/
protected
String
message
;
private
Throwable
cause
;
public
static
LimitFlowException
of
(
ResultMsg
errorMsg
)
{
return
LimitFlowException
.
of
(
ResultFlowCode
.
FLOW_EXCEPTION
,
errorMsg
.
getMsg
());
}
public
static
LimitFlowException
of_error
(
String
errorMsg
)
{
return
LimitFlowException
.
of
(
ResultFlowCode
.
FLOW_EXCEPTION
,
errorMsg
);
}
public
static
LimitFlowException
of
(
ResultFlowCode
code
)
{
LimitFlowException
ufaceException
=
new
LimitFlowException
();
ufaceException
.
setCode
(
code
);
ufaceException
.
setMessage
(
code
.
getMsg
().
getMsg
());
return
ufaceException
;
}
public
static
LimitFlowException
of
(
ResultFlowCode
code
,
String
message
)
{
LimitFlowException
ufaceException
=
new
LimitFlowException
();
ufaceException
.
setCode
(
code
);
ufaceException
.
setMessage
(
message
);
return
ufaceException
;
}
public
static
LimitFlowException
of
(
ResultFlowCode
code
,
Throwable
cause
)
{
LimitFlowException
ufaceException
=
new
LimitFlowException
();
ufaceException
.
setCode
(
code
);
ufaceException
.
setCause
(
cause
);
ufaceException
.
setMessage
(
"todo need get from db/properties"
);
return
ufaceException
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/MapUtil.java
View file @
d6402b13
package
com
.
jz
.
dm
.
common
.
util
;
import
com.alibaba.fastjson.JSON
;
import
com.jz.dm.common.constant.LoggingConstants
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.UnsupportedEncodingException
;
...
...
@@ -29,36 +28,15 @@ public class MapUtil {
* @param signType
* @return
*/
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
);
return
builder
.
toString
();
}
//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);
// return builder.toString();
//}
/**
* 给map集合中的key实现字典排序
*
* @param map
* @return
*/
public
Map
<
String
,
Object
>
mapKeySort
(
Map
<
String
,
Object
>
map
)
{
ArrayList
list
=
new
ArrayList
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
map
.
entrySet
())
{
list
.
add
(
entry
.
getKey
());
//System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
}
HashMap
<
String
,
Object
>
newMap
=
new
HashMap
<
String
,
Object
>();
//运用Collections的sort()方法对其进行排序 sort()方法需要传 连个参数,一个是需要进行排序的Collection 另一个是一个Comparator
Collections
.
sort
(
list
,
new
SpellComparatorUtils
());
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
newMap
.
put
(
list
.
get
(
i
).
toString
(),
map
.
get
(
list
.
get
(
i
).
toString
()));
}
return
newMap
;
}
/**
* 将对象转成TreeMap,属性名为key,属性值为value
...
...
@@ -147,12 +125,11 @@ public class MapUtil {
}
/**
* * 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* * 把数组所有元素
字典
排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* * @param params 需要排序并参与字符拼接的参数组
* * @return 拼接后字符串
*
* * @return 拼接后字符串
*/
public
static
String
createLinkStringByGe
t
(
Map
<
String
,
String
>
params
)
{
public
static
String
stringNormalSor
t
(
Map
<
String
,
String
>
params
)
{
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
sort
(
keys
);
String
prestr
=
""
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/config/GatewayUrlBlockHandler.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
config
;
import
com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler
;
import
com.alibaba.csp.sentinel.slots.block.BlockException
;
import
com.alibaba.csp.sentinel.slots.block.authority.AuthorityException
;
import
com.alibaba.csp.sentinel.slots.block.degrade.DegradeException
;
import
com.alibaba.csp.sentinel.slots.block.flow.FlowException
;
import
com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowException
;
import
com.alibaba.csp.sentinel.slots.system.SystemBlockException
;
import
com.jz.dm.common.enums.ResultFlowCode
;
import
com.jz.dm.common.exception.LimitFlowException
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.config
* @PROJECT_NAME: jz-dm-parent
* @NAME: GatewayUrlBlockHandler
* @DATE: 2021-2-25/14:16
* @DAY_NAME_SHORT: 周四
* @Description: sentinel限流异常处理类
**/
@Component
public
class
GatewayUrlBlockHandler
implements
BlockExceptionHandler
{
@Override
public
void
handle
(
HttpServletRequest
httpServletRequest
,
HttpServletResponse
httpServletResponse
,
BlockException
e
)
throws
Exception
{
if
(
e
instanceof
FlowException
){
throw
LimitFlowException
.
of
(
ResultFlowCode
.
FLOW_EXCEPTION
);
}
else
if
(
e
instanceof
DegradeException
){
throw
LimitFlowException
.
of
(
ResultFlowCode
.
DEGRADE_EXCEPTION
);
}
else
if
(
e
instanceof
ParamFlowException
){
throw
LimitFlowException
.
of
(
ResultFlowCode
.
PARAM_EXCEPTION
);
}
else
if
(
e
instanceof
SystemBlockException
){
throw
LimitFlowException
.
of
(
ResultFlowCode
.
SYSTEM_EXCEPTION
);
}
else
if
(
e
instanceof
AuthorityException
){
throw
LimitFlowException
.
of
(
ResultFlowCode
.
AUTHORITY_EXCEPTION
);
}
/*// 设置返回json数据
httpServletResponse.setStatus(200);
httpServletResponse.setHeader("Content-Type","application/json;charset=UTF-8");
httpServletResponse.getWriter().write(JSON.toJSONString(backMap));*/
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
View file @
d6402b13
...
...
@@ -101,7 +101,7 @@ public class AuthFilter extends AbstractFilter {
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_NOT_AUTH
);
}
if
(
"1"
.
equals
(
authAuth
.
getHandler
()))
{
//处理状态,已经调用成功后授权码失效
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_
REQUEST
);
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_
AUTHORIZATION
);
}
//查询认证组织信息
ApiOrg
apiOrg
=
organizationManageService
.
getAuthOrganization
(
authAuth
.
getApiOrgId
());
...
...
@@ -231,7 +231,7 @@ public class AuthFilter extends AbstractFilter {
JSONObject
result
=
JSONObject
.
parseObject
(
respResult
);
if
(
null
!=
result
)
{
if
(
200
!=
result
.
getInteger
(
"code"
))
{
log
.
info
(
"~~~~~~~~~~~~~~~~~~
异常信息为
:{}"
,
result
.
getString
(
"message"
));
log
.
info
(
"~~~~~~~~~~~~~~~~~~
远程调用异常
:{}"
,
result
.
getString
(
"message"
));
throw
new
GatewayException
(
GatewayResultCode
.
CALL_AMOUNT_NOT_ENOUGH
);
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/CheckArgsFilter.java
View file @
d6402b13
...
...
@@ -37,7 +37,6 @@ public class CheckArgsFilter extends AbstractFilter {
||
StringUtil
.
isEmpty
(
request
.
getTimestamp
())
||
StringUtil
.
isEmpty
(
request
.
getParams
()))
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_ARGUMENT
);
//无效参数
}
// 设置默认值
if
(
StringUtil
.
isEmpty
(
request
.
getFormat
()))
{
request
.
setFormat
(
Format
.
JSON
.
name
());
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
View file @
d6402b13
...
...
@@ -17,6 +17,9 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @Description: 验签过滤器(验证签名信息)
* @Author: Mr.zhang
...
...
@@ -45,7 +48,7 @@ public class VerifySignFilter extends AbstractFilter {
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
if
(!
jsonObject
.
getBoolean
(
"isTest"
))
{
//是否测试调用
//对签约参数进行字典排序
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
request
.
getSignType
(
));
String
signParams
=
MapUtil
.
stringNormalSort
(
assembleSignMap
(
request
));
if
(
StringUtils
.
isNotBlank
(
signParams
))
{
String
authCode
=
jsonObject
.
getString
(
"authCode"
);
//需要传入授权码
...
...
@@ -54,7 +57,7 @@ public class VerifySignFilter extends AbstractFilter {
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_NOT_AUTH
);
}
String
sign
=
Md5
.
encrypt
(
signParams
,
apiAuthInfo
.
getSalt
());
if
(!
request
.
getSign
().
equals
(
sign
))
{
if
(!
request
.
getSign
().
equals
IgnoreCase
(
sign
))
{
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
}
}
else
{
...
...
@@ -63,7 +66,7 @@ public class VerifySignFilter extends AbstractFilter {
}
chain
.
doFilter
(
request
,
response
);
}
catch
(
GatewayException
ex
)
{
LogUtil
.
error
(
LOGGER
,
ex
,
"sign response error. response="
+
response
.
getResponse
());
LogUtil
.
error
(
LOGGER
,
ex
,
"sign response error. response="
+
response
.
getResponse
());
response
.
clearAttributes
();
response
.
setCode
(
ex
.
getResultCode
().
getCode
());
response
.
setMsg
(
ex
.
getResultCode
().
getMsg
());
...
...
@@ -74,4 +77,17 @@ public class VerifySignFilter extends AbstractFilter {
}
}
/**
* 组装签名参数
* @param request
* @return
*/
private
Map
assembleSignMap
(
GatewayRequest
request
)
{
Map
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
paramsMap
.
put
(
"apiKey"
,
request
.
getApiKey
());
paramsMap
.
put
(
"method"
,
request
.
getMethod
());
paramsMap
.
put
(
"signType"
,
request
.
getSignType
());
paramsMap
.
put
(
"params"
,
request
.
getParams
());
return
paramsMap
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/mapper/ApiFunctionMapper.java
View file @
d6402b13
...
...
@@ -2,6 +2,9 @@ package com.jz.dm.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.jz.dm.models.domian.ApiFunction
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
/**
* <p>
...
...
@@ -13,4 +16,11 @@ import com.jz.dm.models.domian.ApiFunction;
*/
public
interface
ApiFunctionMapper
extends
BaseMapper
<
ApiFunction
>
{
/**
* 查询function名称列表
* @return
*/
@Select
(
"SELECT `name` FROM t_api_function WHERE `status`=1 AND is_deleted=0"
)
List
<
String
>
listFunctionNames
();
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
d6402b13
...
...
@@ -60,6 +60,12 @@ public class ApiInterface extends BaseObject implements Serializable {
@TableField
(
"req_type"
)
private
String
reqType
;
/**
* post请求类型:1.x-www-form-urlencoded 2.form-data 3.json
*/
@TableField
(
"post_type"
)
private
String
postType
;
/**
* '输出类型:flow 流形式输出, json格式输出',
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/enity/DataTableSelectTO.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
models
.
enity
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.models.domian.ApiInterface
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.enity
* @PROJECT_NAME: jz-dm-parent
* @NAME: DataTableSelectTO
* @DATE: 2021-2-24/10:10
* @DAY_NAME_SHORT: 周三
* @Description: 数据表查询-数据传输对象
**/
@Data
@ApiModel
(
"数据表查询领域对象"
)
public
class
DataTableSelectTO
implements
Serializable
{
@ApiModelProperty
(
value
=
"api对象"
)
private
ApiInterface
apiInterface
;
@ApiModelProperty
(
value
=
"业务请求参数"
)
private
String
reqParams
;
@ApiModelProperty
(
value
=
"业务返回体对象"
)
private
OpenApiResponse
openApiResponse
;
@ApiModelProperty
(
value
=
"授权码"
)
private
String
authCode
;
public
DataTableSelectTO
(
ApiInterface
apiInterface
,
String
reqParams
,
OpenApiResponse
openApiResponse
){
this
.
apiInterface
=
apiInterface
;
this
.
reqParams
=
reqParams
;
this
.
openApiResponse
=
openApiResponse
;
}
public
DataTableSelectTO
(
ApiInterface
apiInterface
,
String
reqParams
,
OpenApiResponse
openApiResponse
,
String
authCode
){
this
.
apiInterface
=
apiInterface
;
this
.
reqParams
=
reqParams
;
this
.
openApiResponse
=
openApiResponse
;
this
.
authCode
=
authCode
;
}
public
DataTableSelectTO
(){}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
d6402b13
...
...
@@ -4,33 +4,26 @@ import com.alibaba.csp.sentinel.annotation.SentinelResource;
import
com.alibaba.csp.sentinel.slots.block.BlockException
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.dm.common.constant.LoggingConstants
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum
;
import
com.jz.dm.common.enums.auth.AuthModeEnum
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.stream.HttpDownload
;
import
com.jz.dm.gateway.OpenApiService
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.
domian.ApiInterfaceCustom
;
import
com.jz.dm.models.
enity.DataTableSelectTO
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request
...
...
@@ -59,11 +52,15 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
@Autowired
private
AuthService
authService
;
@Autowired
private
RedisUtils
redisUtils
;
@Autowired
private
HttpsUtils
httpsUtils
;
@Autowired
private
ApiLogService
reqLogService
;
@Autowired
private
DataSelectService
dataSelectService
;
@Autowired
private
ThirdSelectService
thirdSelectService
;
@Autowired
private
DataBagService
dataBagService
;
/**
* 数据银行扣款链接
...
...
@@ -80,47 +77,27 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
@Override
@ApiLogAspect
(
description
=
"API请求日志"
)
//@AccessLimit(limit = 10000, sec = 1)
@SentinelResource
(
value
=
"api.gateway"
,
fallback
=
"fallbackGateway"
,
blockHandler
=
"exceptionHandler"
)
@SentinelResource
(
value
=
"api.gateway"
,
fallback
=
"fallbackGateway"
,
blockHandler
=
"exceptionHandler"
)
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
boolean
bResult
=
false
;
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getOpenApiParams
());
ApiInterface
apiInterface
=
apiInterfaceService
.
getApiInfo
(
request
.
getApiKey
());
ApiAuth
apiAuth
=
null
;
JSONObject
jsonParams
=
null
;
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getOpenApiParams
())
;
try
{
ApiInterface
apiInterface
=
apiInterfaceService
.
getApiInfo
(
request
.
getApiKey
());
Boolean
isTest
=
parameter
.
getBoolean
(
"isTest"
);
String
reqParams
=
parameter
.
getString
(
"reqParams"
);
Map
paramMap
=
null
;
JSONObject
jsonParams
=
JSONObject
.
parseObject
(
reqParams
)
;
if
(
StringUtils
.
isNotBlank
(
reqParams
))
{
jsonParams
=
JSONObject
.
parseObject
(
reqParams
);
paramMap
=
JSONObject
.
parseObject
(
jsonParams
.
getString
(
"request_fileds"
),
Map
.
class
);
jsonParams
.
put
(
"is_test"
,
isTest
);
apiInterface
.
setIsTest
(
isTest
);
}
if
(!
isTest
)
{
//是否是测试
apiInterface
.
setLogId
(
reqLogService
.
getReqLogging
(
apiInterface
.
getApiKey
()));
String
authCode
=
parameter
.
getString
(
"authCode"
);
if
(
StringUtils
.
isBlank
(
authCode
))
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
verifyApiInterface
(
apiInterface
);
apiAuth
=
authService
.
getAuthInfo
(
authCode
);
verifyApiInterface
(
apiInterface
);
verifyAuth
(
apiAuth
);
//取出缓存数据
//String redisReqParam = redisUtils.get(request.getApiKey());
String
redisReqParam
=
null
;
if
(
StringUtils
.
isNotBlank
(
redisReqParam
))
{
//redis中存在
//解析出API制作成功时的参数配置
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
redisReqParam
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
String
apiType
=
jsonObject
.
getString
(
"apiType"
);
bResult
=
rangRequestTarget
(
outputType
,
targetUrl
,
paramMap
,
jsonParams
,
apiType
,
apiInterface
,
response
);
}
else
{
//不存在查询数据库
bResult
=
rangRequestTarget
(
apiInterface
.
getOutputType
(),
apiInterface
.
getTargetUrl
(),
paramMap
,
jsonParams
,
apiInterface
.
getApiType
(),
apiInterface
,
response
);
}
rangRequestTarget
(
apiInterface
,
jsonParams
.
toString
(),
response
,
authCode
);
//调用成功请求数据银行扣款
if
(
AuthModeEnum
.
POWER_CALL_MODE
.
name
().
equals
(
apiAuth
.
getAuthMode
()))
{
notifierMinusMoney
(
parameter
,
bResult
);
...
...
@@ -128,8 +105,7 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
authService
.
updateApiAuthStatus
(
apiAuth
);
}
}
else
{
bResult
=
rangRequestTarget
(
apiInterface
.
getOutputType
(),
apiInterface
.
getTargetUrl
(),
paramMap
,
jsonParams
,
apiInterface
.
getApiType
(),
apiInterface
,
response
);
rangRequestTarget
(
apiInterface
,
jsonParams
.
toString
(),
response
,
null
);
}
}
catch
(
Exception
ex
)
{
if
(
ex
instanceof
GatewayException
)
{
...
...
@@ -145,8 +121,108 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
}
}
/**
* 远程请求获取数据
* @param apiInterface API基本信息
* @param reqParams 远程请求参数
* @param authCode 授权码
* @param response 响应数据
*/
private
boolean
rangRequestTarget
(
ApiInterface
apiInterface
,
String
reqParams
,
OpenApiResponse
response
,
String
authCode
)
{
if
(
StringUtils
.
isBlank
(
apiInterface
.
getOutputType
()))
{
apiInterface
.
setOutputType
(
ApiInfoOutTypeEnum
.
JSON
.
name
());
}
if
(
StringUtils
.
isBlank
(
apiInterface
.
getTargetUrl
()))
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_PARAM_EMPTY
);
}
if
(
StringUtils
.
isBlank
(
apiInterface
.
getApiType
()))
{
throw
new
GatewayException
(
GatewayResultCode
.
API_TYPE_ERROR
);
}
switch
(
apiInterface
.
getApiType
())
{
case
"10002"
:
//数据表查询
case
"10009"
:
return
dataSelectService
.
dataTableHandle
(
new
DataTableSelectTO
(
apiInterface
,
reqParams
,
response
));
case
"10004"
:
//三方查询
case
"10008"
:
return
thirdSelectService
.
thirdSelectHandle
(
new
DataTableSelectTO
(
apiInterface
,
reqParams
,
response
,
authCode
));
case
"10005"
:
//数据包查询
case
"10007"
:
return
dataBagService
.
dataBagSelect
(
new
DataTableSelectTO
(
apiInterface
,
reqParams
,
response
));
default
:
throw
new
GatewayException
(
GatewayResultCode
.
API_TYPE_ERROR
);
}
}
/**
* 通知扣款
*
* @param parameter
* @param bResult
*/
private
void
notifierMinusMoney
(
JSONObject
parameter
,
boolean
bResult
)
{
Integer
assetsId
=
parameter
.
getInteger
(
"assetsId"
);
Integer
userId
=
parameter
.
getInteger
(
"userId"
);
String
dataPrice
=
parameter
.
getString
(
"dataPrice"
);
JSONObject
jsonReq
=
new
JSONObject
();
jsonReq
.
put
(
"assetsId"
,
assetsId
);
jsonReq
.
put
(
"userId"
,
userId
);
jsonReq
.
put
(
"dataPrice"
,
dataPrice
);
jsonReq
.
put
(
"callStatus"
,
bResult
);
//true 调用成功 扣款 false 调用失败,解冻金额
String
responseResult
=
httpsUtils
.
submitPost
(
balanceUrl
+
"/mall/financeCustomerAssets/unfreezeMoney"
,
jsonReq
.
toString
());
JSONObject
paramsResult
=
JSONObject
.
parseObject
(
responseResult
);
if
(
null
!=
paramsResult
)
{
if
(
200
!=
paramsResult
.
getInteger
(
"code"
))
{
log
.
info
(
"~~~~~~~~~~~~~~~调用数据银行扣款失败~~~~~~~~~~~~~"
);
throw
new
GatewayException
(
GatewayResultCode
.
CALL_AMOUNT_NOT_ENOUGH
);
}
}
}
/**
* 限流返回方法
*
* @param request
* @param response
*/
public
void
fallbackGateway
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
log
.
info
(
"用户请求过于频繁触发限流接口:ApiKey为:{}"
+
request
.
getApiKey
());
//throw new GatewayException(GatewayResultCode.RATE_LIMIT_EXCEEDED);
response
.
setCode
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
.
getMsg
());
}
/**
* 熔断方法
*
* @param request
* @param response
*/
public
void
exceptionHandler
(
OpenApiRequest
request
,
OpenApiResponse
response
,
BlockException
ex
)
{
log
.
info
(
"用户请求过于频繁触发限流接口:ApiKey为:{}"
+
request
.
getApiKey
());
//log.error("异常信息:{}",ex);
//throw new GatewayException(GatewayResultCode.RATE_LIMIT_EXCEEDED);
response
.
setCode
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
.
getMsg
());
}
/* *//**
* 远程请求获取数据
*
* @param outputType
...
...
@@ -154,7 +230,7 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param param
* @param apiType
* @param response
*/
*/
/*
private boolean rangRequestTarget(String outputType, String targetUrl,
Map<String, String> param, JSONObject jsonParams, String apiType,
ApiInterface apiInterface, OpenApiResponse response) {
...
...
@@ -169,40 +245,44 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
}
if ("10002".equals(apiType) || "10009".equals(apiType)) {//数据表查询
return dataTableSelect(outputType, targetUrl, param, jsonParams, apiInterface, response);
dataSelectService.dataTableHandle();
} else if ("10004".equals(apiType) || "10008".equals(apiType)) {//三方查询
thirdSelectService.thirdSelectHandle();
return thirdSelect(targetUrl, apiInterface, jsonParams, response);
} else if ("10005".equals(apiType) || "10007".equals(apiType)) {//数据包查询
dataBagService.dataBagSelect();
return dataBagDownload(targetUrl, jsonParams, response,apiInterface);
} else {
throw new GatewayException(GatewayResultCode.API_TYPE_ERROR);
}
}
}
*/
/**
/* */
/**
* 三方查询 $$ 数据银行+DMP
*
* @param targetUrl
* @param apiInterface
* @param response
* @return
*/
*/
/*
private boolean thirdSelect(String targetUrl, ApiInterface apiInterface, JSONObject jsonParams, OpenApiResponse response) {
if ("POST".equalsIgnoreCase(apiInterface.getReqType())) {
return
callMethodResponse
(
httpsUtils
.
submitPost
(
targetUrl
,
jsonParams
.
toString
()),
response
,
apiInterface
);
return callMethodResponse(httpsUtils.submitPost(targetUrl, jsonParams.toString()), response,
apiInterface);
} else {
Map map = JSONObject.parseObject(jsonParams.toString(), Map.class);
return
callMethodResponse
(
httpsUtils
.
doGet
(
targetUrl
,
map
),
response
,
apiInterface
);
return callMethodResponse(httpsUtils.doGet(targetUrl, map), response,
apiInterface);
}
}
/**
*/
/**
* 数据包下载 $$ 数据银行+DMP
*
* @param targetUrl
* @param param
* @return
*/
private
boolean
dataBagDownload
(
String
targetUrl
,
JSONObject
param
,
OpenApiResponse
response
,
ApiInterface
apiInterface
)
{
*/
/*
private boolean dataBagDownload(String targetUrl, JSONObject param, OpenApiResponse response,
ApiInterface apiInterface) {
String fileLocation = param.getString("file_location");
String datasourceId = param.getString("datasourceId");
if (null == fileLocation || null == datasourceId) {
...
...
@@ -212,13 +292,13 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
requestParams.put("file_location", fileLocation);
requestParams.put("datasourceId", datasourceId);
HttpDownload.postDownload(targetUrl, requestParams);
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
null
);
reqLogService.updateLog(apiInterface.getLogId(),
null);
response.setCode(GatewayResultCode.SUCCESS.getCode());
response.setMsg(GatewayResultCode.SUCCESS.getMsg());
return true;
}
/**
*/
/**
* 数据表查询
*
* @param outputType
...
...
@@ -227,12 +307,12 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param apiInterface
* @param response
* @return
*/
*/
/*
protected boolean dataTableSelect(String outputType, String targetUrl, Map<String, String> param,
JSONObject jsonParams, ApiInterface apiInterface, OpenApiResponse response) {
ApiInterfaceCustom apiCustomInfo = checkParamLegal(param, apiInterface);
if (ApiInfoOutTypeEnum.FLOW.name().equals(outputType)) {//文件流形式请求
return
flowRequestMethod
(
targetUrl
,
param
,
response
,
apiCustomInfo
,
apiInterface
);
return flowRequestMethod(targetUrl, param, response, apiCustomInfo,
apiInterface);
} else if (ApiInfoOutTypeEnum.JSON.name().equals(outputType)) { //json格式请求
return jsonRequestMethod(targetUrl, param, jsonParams, response, apiCustomInfo);
} else {
...
...
@@ -240,13 +320,13 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
}
}
/**
*/
/**
* 校验参数合法性
*
* @param param
* @param apiInterface
* @return
*/
*/
/*
private ApiInterfaceCustom checkParamLegal(Map<String, String> param, ApiInterface apiInterface) {
ApiInterfaceCustom apiCustomInfo = apiInterfaceService.getApiCustomInfo(apiInterface.getId());
boolean tag = false;
...
...
@@ -270,14 +350,14 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
return apiCustomInfo;
}
/**
*/
/**
* 数据查询---flow流请求方式
*
* @param targetUrl
* @param param
* @param response
* @return
*/
*/
/*
private boolean flowRequestMethod(String targetUrl, Map<String, String> param,
OpenApiResponse response, ApiInterfaceCustom apiCustomInfo,
ApiInterface apiInterface) {
...
...
@@ -295,13 +375,13 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
requestParams.put("response_fields", assembleResponseParams(apiCustomInfo.getResponseParam()));
requestParams.put("data_size", valueOf);
HttpDownload.postDownload(targetUrl, requestParams);
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
null
);
reqLogService.updateLog(apiInterface.getLogId(),
null);
response.setCode(GatewayResultCode.SUCCESS.getCode());
response.setMsg(GatewayResultCode.SUCCESS.getMsg());
return true;
}
/**
*/
/**
* 数据查询--json请求方式
*
* @param targetUrl
...
...
@@ -309,7 +389,7 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
* @param response
* @param apiCustomInfo
* @return
*/
*/
/*
private boolean jsonRequestMethod(String targetUrl, Map<String, String> param, JSONObject jsonParams,
OpenApiResponse response, ApiInterfaceCustom apiCustomInfo) {
JSONObject params = new JSONObject();
...
...
@@ -341,15 +421,15 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
}
String respResult = httpsUtils.submitPost(targetUrl, params.toString());
return
callMethodResponse
(
respResult
,
response
,
apiInterface
);
return callMethodResponse(respResult, response,
apiInterface);
}
/**
*/
/**
* 组装响应参数
*
* @param respParams
* @return
*/
*/
/*
private String assembleResponseParams(String respParams) {
StringBuilder builder = new StringBuilder();
List<Map> mapList = JSONObject.parseArray(respParams, Map.class);
...
...
@@ -362,13 +442,13 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
return builder.substring(0, builder.length() - 1);
}
/**
*/
/**
* 调用方法处理结果
*
* @param result
* @param response
*/
private
boolean
callMethodResponse
(
String
result
,
OpenApiResponse
response
,
ApiInterface
apiInterface
)
{
*/
/*
private boolean callMethodResponse(String result, OpenApiResponse response,
ApiInterface apiInterface) {
if (null == result) {
throw new GatewayException(GatewayResultCode.DISTANCE_REQUEST_EXCEPTION);
}
...
...
@@ -376,66 +456,17 @@ public class ApiQueryService extends ApiParamVerify implements OpenApiService {
if (null != resp && "ESC00000".equals(resp.getString("return_code"))) {
response.setCode(GatewayResultCode.SUCCESS.getCode());
response.setMsg(GatewayResultCode.SUCCESS.getMsg());
response
.
setAttribute
(
"responseResult"
,
resp
);
if
(
null
!=
apiInterface
.
getLogId
()){
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
result
);
response.setAttribute("responseResult",
resp);
if (null != apiInterface.getLogId())
{
reqLogService.updateLog(apiInterface.getLogId(),
result);
}
return true;
} else {
log.error("~~~~~~~~~~~~~~~~远程请求异常~~~~~~~~~~~~~~~~~");
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
result
);
reqLogService.updateLog(apiInterface.getLogId(),
result);
throw new GatewayException(GatewayResultCode.DISTANCE_REQUEST_EXCEPTION);
}
}
/**
* 通知扣款
*
* @param parameter
* @param bResult
*/
private
void
notifierMinusMoney
(
JSONObject
parameter
,
boolean
bResult
)
{
Integer
assetsId
=
parameter
.
getInteger
(
"assetsId"
);
Integer
userId
=
parameter
.
getInteger
(
"userId"
);
String
dataPrice
=
parameter
.
getString
(
"dataPrice"
);
JSONObject
jsonReq
=
new
JSONObject
();
jsonReq
.
put
(
"assetsId"
,
assetsId
);
jsonReq
.
put
(
"userId"
,
userId
);
jsonReq
.
put
(
"dataPrice"
,
dataPrice
);
jsonReq
.
put
(
"callStatus"
,
bResult
);
//true 调用成功 扣款 false 调用失败,解冻金额
String
responseResult
=
httpsUtils
.
submitPost
(
balanceUrl
+
"/mall/financeCustomerAssets/unfreezeMoney"
,
jsonReq
.
toString
());
JSONObject
paramsResult
=
JSONObject
.
parseObject
(
responseResult
);
if
(
null
!=
paramsResult
)
{
if
(
200
!=
paramsResult
.
getInteger
(
"code"
))
{
log
.
info
(
"~~~~~~~~~~~~~~~调用数据银行扣款失败~~~~~~~~~~~~~"
);
throw
new
GatewayException
(
GatewayResultCode
.
CALL_AMOUNT_NOT_ENOUGH
);
}
}
}
}*/
/**
* 限流返回方法
*
* @param request
* @param response
*/
public
void
fallbackGateway
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
log
.
info
(
"用户请求过于频繁触发限流接口:ApiKey为:{}"
+
request
.
getApiKey
());
//throw new GatewayException(GatewayResultCode.RATE_LIMIT_EXCEEDED);
response
.
setCode
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
.
getMsg
());
}
/**
* 熔断方法
* @param request
* @param response
*/
public
void
exceptionHandler
(
OpenApiRequest
request
,
OpenApiResponse
response
,
BlockException
ex
)
{
log
.
info
(
"用户请求过于频繁触发限流接口:ApiKey为:{}"
+
request
.
getApiKey
());
//log.error("异常信息:{}",ex);
//throw new GatewayException(GatewayResultCode.RATE_LIMIT_EXCEEDED);
response
.
setCode
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
RATE_LIMIT_EXCEEDED
.
getMsg
());
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/DataBagService.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
service
.
request
;
import
com.jz.dm.models.enity.DataTableSelectTO
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: DataBagService
* @DATE: 2021-2-24/10:55
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
interface
DataBagService
{
/**
* 数据包查询
* @param dataBagSelectTO
* @return
*/
public
boolean
dataBagSelect
(
DataTableSelectTO
dataBagSelectTO
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/DataSelectService.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
service
.
request
;
import
com.jz.dm.models.enity.DataTableSelectTO
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request
* @PROJECT_NAME: jz-dm-parent
* @NAME: DataSelectService
* @DATE: 2021-2-24/10:36
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
interface
DataSelectService
{
/**
* 数据查询处理类
* @param dataTableSelectTO
*/
public
Boolean
dataTableHandle
(
DataTableSelectTO
dataTableSelectTO
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ThirdSelectService.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
service
.
request
;
import
com.jz.dm.models.enity.DataTableSelectTO
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request
* @PROJECT_NAME: jz-dm-parent
* @NAME: ThirdSelectService
* @DATE: 2021-2-24/10:43
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
interface
ThirdSelectService
{
/**
* 三方查询处理
* @param dataTableSelectTO
* @return
*/
public
boolean
thirdSelectHandle
(
DataTableSelectTO
dataTableSelectTO
);
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/impl/DataBagHandle.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
service
.
request
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.stream.HttpDownload
;
import
com.jz.dm.models.enity.DataTableSelectTO
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.service.request.DataBagService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request.impl
* @PROJECT_NAME: jz-dm-parent
* @NAME: DataBagHandle
* @DATE: 2021-2-24/10:56
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Slf4j
@Component
public
class
DataBagHandle
implements
DataBagService
{
@Autowired
private
ApiLogService
reqLogService
;
/**
* 数据包下载 $$ 数据银行+DMP
*
* @param dataBagSelectTO
* @return
*/
@Override
public
boolean
dataBagSelect
(
DataTableSelectTO
dataBagSelectTO
)
{
JSONObject
param
=
JSONObject
.
parseObject
(
dataBagSelectTO
.
getReqParams
());
String
fileLocation
=
param
.
getString
(
"file_location"
);
String
datasourceId
=
param
.
getString
(
"datasourceId"
);
if
(
null
==
fileLocation
||
null
==
datasourceId
)
{
throw
new
GatewayException
(
GatewayResultCode
.
DATA_BIG_ADDR_UNEXIST
);
}
JSONObject
requestParams
=
new
JSONObject
();
requestParams
.
put
(
"file_location"
,
fileLocation
);
requestParams
.
put
(
"datasourceId"
,
datasourceId
);
HttpDownload
.
postDownload
(
dataBagSelectTO
.
getApiInterface
().
getTargetUrl
(),
requestParams
);
reqLogService
.
updateLog
(
dataBagSelectTO
.
getApiInterface
().
getLogId
(),
null
);
dataBagSelectTO
.
getOpenApiResponse
().
setCode
(
GatewayResultCode
.
SUCCESS
.
getCode
());
dataBagSelectTO
.
getOpenApiResponse
().
setMsg
(
GatewayResultCode
.
SUCCESS
.
getMsg
());
return
true
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/impl/DataTableSelectHandle.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
service
.
request
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.dm.common.constant.LoggingConstants
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.stream.HttpDownload
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.enity.DataTableSelectTO
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.service.request.DataSelectService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request
* @PROJECT_NAME: jz-dm-parent
* @NAME: DataTableSelectHandle
* @DATE: 2021-2-24/10:06
* @DAY_NAME_SHORT: 周三
* @Description: 数据表查询处理类
**/
@Slf4j
@Component
public
class
DataTableSelectHandle
implements
DataSelectService
{
@Autowired
private
ApiInterfaceService
apiInterfaceService
;
@Autowired
private
ApiLogService
reqLogService
;
@Autowired
private
HttpsUtils
httpsUtils
;
/**
* 数据表查询处理
* @param dataTableSelectTO
*/
@Override
public
Boolean
dataTableHandle
(
DataTableSelectTO
dataTableSelectTO
)
{
JSONObject
jsonParams
=
JSONObject
.
parseObject
(
dataTableSelectTO
.
getReqParams
());
Map
param
=
JSONObject
.
parseObject
(
jsonParams
.
getString
(
"request_fileds"
),
Map
.
class
);
//校验参数合法性
ApiInterfaceCustom
apiCustomInfo
=
checkParamLegal
(
param
,
dataTableSelectTO
.
getApiInterface
());
if
(
ApiInfoOutTypeEnum
.
FLOW
.
name
().
equals
(
dataTableSelectTO
.
getApiInterface
().
getOutputType
()))
{
//文件流形式请求
return
flowRequestMethod
(
dataTableSelectTO
.
getApiInterface
().
getTargetUrl
(),
param
,
dataTableSelectTO
.
getOpenApiResponse
(),
apiCustomInfo
,
dataTableSelectTO
.
getApiInterface
());
}
else
if
(
ApiInfoOutTypeEnum
.
JSON
.
name
().
equals
(
dataTableSelectTO
.
getApiInterface
().
getOutputType
()))
{
//json格式请求
return
jsonRequestMethod
(
dataTableSelectTO
.
getApiInterface
().
getTargetUrl
(),
param
,
jsonParams
,
dataTableSelectTO
.
getOpenApiResponse
(),
apiCustomInfo
,
dataTableSelectTO
.
getApiInterface
());
}
else
{
throw
new
GatewayException
(
GatewayResultCode
.
OUTPUT_TYPE_EXCEPTION
);
}
}
/**
* 校验参数合法性
*
* @param param
* @param apiInterface
* @return
*/
private
ApiInterfaceCustom
checkParamLegal
(
Map
<
String
,
String
>
param
,
ApiInterface
apiInterface
)
{
ApiInterfaceCustom
apiCustomInfo
=
apiInterfaceService
.
getApiCustomInfo
(
apiInterface
.
getId
());
boolean
tag
=
false
;
if
(
null
!=
apiCustomInfo
)
{
List
<
Map
>
mapList
=
JSONObject
.
parseArray
(
apiCustomInfo
.
getRequestParam
(),
Map
.
class
);
if
(
CollectionUtils
.
isNotEmpty
(
mapList
))
{
for
(
Map
map
:
mapList
)
{
if
((
Boolean
)
map
.
get
(
"required"
))
{
String
name
=
(
String
)
map
.
get
(
"name"
);
String
field
=
param
.
get
(
name
);
if
(
null
==
field
)
{
tag
=
true
;
}
}
}
if
(
tag
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_PARAM_EMPTY
);
}
}
}
return
apiCustomInfo
;
}
/**
* 数据查询---flow流请求方式
*
* @param targetUrl
* @param param
* @param response
* @return
*/
private
boolean
flowRequestMethod
(
String
targetUrl
,
Map
<
String
,
String
>
param
,
OpenApiResponse
response
,
ApiInterfaceCustom
apiCustomInfo
,
ApiInterface
apiInterface
)
{
String
dataSize
=
param
.
get
(
"dataSize"
);
Integer
valueOf
=
-
1
;
if
(
StringUtils
.
isNotBlank
(
dataSize
))
{
valueOf
=
Integer
.
valueOf
(
dataSize
);
}
net
.
sf
.
json
.
JSONObject
reqParams
=
net
.
sf
.
json
.
JSONObject
.
fromObject
(
param
);
JSONObject
requestParams
=
new
JSONObject
();
requestParams
.
put
(
"datasourceId"
,
apiCustomInfo
.
getEsDataSource
());
requestParams
.
put
(
"query_database"
,
apiCustomInfo
.
getEsDataBase
());
requestParams
.
put
(
"query_table"
,
apiCustomInfo
.
getEsTable
());
requestParams
.
put
(
"request_fileds"
,
reqParams
);
requestParams
.
put
(
"response_fields"
,
assembleResponseParams
(
apiCustomInfo
.
getResponseParam
()));
requestParams
.
put
(
"data_size"
,
valueOf
);
HttpDownload
.
postDownload
(
targetUrl
,
requestParams
);
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
null
);
response
.
setCode
(
GatewayResultCode
.
SUCCESS
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
SUCCESS
.
getMsg
());
return
true
;
}
/**
* 组装响应参数
*
* @param respParams
* @return
*/
private
String
assembleResponseParams
(
String
respParams
)
{
StringBuilder
builder
=
new
StringBuilder
();
List
<
Map
>
mapList
=
JSONObject
.
parseArray
(
respParams
,
Map
.
class
);
if
(
CollectionUtils
.
isNotEmpty
(
mapList
))
{
for
(
Map
map
:
mapList
)
{
String
name
=
(
String
)
map
.
get
(
"name"
);
builder
.
append
(
name
).
append
(
LoggingConstants
.
SEP
);
}
}
return
builder
.
substring
(
0
,
builder
.
length
()
-
1
);
}
/**
* 数据查询--json请求方式
*
* @param targetUrl
* @param param
* @param response
* @param apiCustomInfo
* @return
*/
private
boolean
jsonRequestMethod
(
String
targetUrl
,
Map
<
String
,
String
>
param
,
JSONObject
jsonParams
,
OpenApiResponse
response
,
ApiInterfaceCustom
apiCustomInfo
,
ApiInterface
apiInterface
)
{
JSONObject
params
=
new
JSONObject
();
try
{
params
.
put
(
"datasourceId"
,
apiCustomInfo
.
getEsDataSource
());
//数据源id
params
.
put
(
"query_database"
,
apiCustomInfo
.
getEsDataBase
());
//数据源库名称
params
.
put
(
"query_table"
,
apiCustomInfo
.
getEsTable
());
//数据源库表
// net.sf.json.JSONObject reqParams = net.sf.json.JSONObject.fromObject(param);
params
.
put
(
"request_fileds"
,
jsonParams
.
getJSONObject
(
"request_fileds"
));
//请求参数
params
.
put
(
"response_fields"
,
assembleResponseParams
(
apiCustomInfo
.
getResponseParam
()));
//响应参数
params
.
put
(
"is_test"
,
jsonParams
.
getBoolean
(
"is_test"
));
//是否是测试
Integer
pageNum
=
jsonParams
.
getInteger
(
"page_num"
);
Integer
pageSize
=
jsonParams
.
getInteger
(
"page_size"
);
params
.
put
(
"page_size"
,
apiCustomInfo
.
getPageRow
());
params
.
put
(
"page_num"
,
1
);
if
(
null
!=
pageNum
)
{
params
.
put
(
"page_num"
,
pageNum
);
}
if
(
null
!=
pageSize
)
{
params
.
put
(
"page_size"
,
pageSize
);
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"数据转换异常:{}"
,
ex
.
getMessage
());
ex
.
printStackTrace
();
}
String
respResult
=
httpsUtils
.
submitPost
(
targetUrl
,
params
.
toString
());
return
callMethodResponse
(
respResult
,
response
,
apiInterface
);
}
/**
* 调用方法处理结果
*
* @param result
* @param response
*/
private
boolean
callMethodResponse
(
String
result
,
OpenApiResponse
response
,
ApiInterface
apiInterface
)
{
if
(
null
==
result
)
{
throw
new
GatewayException
(
GatewayResultCode
.
DISTANCE_REQUEST_EXCEPTION
);
}
JSONObject
resp
=
JSONObject
.
parseObject
(
result
);
if
(
null
!=
resp
&&
"ESC00000"
.
equals
(
resp
.
getString
(
"return_code"
)))
{
response
.
setCode
(
GatewayResultCode
.
SUCCESS
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
SUCCESS
.
getMsg
());
response
.
setAttribute
(
"responseResult"
,
resp
);
if
(
null
!=
apiInterface
.
getLogId
()){
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
result
);
}
return
true
;
}
else
{
log
.
error
(
"~~~~~~~~~~~~~~~~远程请求异常~~~~~~~~~~~~~~~~~"
);
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
result
);
throw
new
GatewayException
(
GatewayResultCode
.
DISTANCE_REQUEST_EXCEPTION
);
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/impl/ThirdSelectHandle.java
0 → 100644
View file @
d6402b13
package
com
.
jz
.
dm
.
service
.
request
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.mapper.ApiFunctionMapper
;
import
com.jz.dm.models.domian.ApiFunction
;
import
com.jz.dm.models.domian.ApiInterface
;
import
com.jz.dm.models.domian.ApiInterfaceCustom
;
import
com.jz.dm.models.enity.DataTableSelectTO
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.service.request.ThirdSelectService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request
* @PROJECT_NAME: jz-dm-parent
* @NAME: ThirdSelectHandle
* @DATE: 2021-2-24/10:42
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@Slf4j
@Component
public
class
ThirdSelectHandle
implements
ThirdSelectService
{
public
static
final
String
JSON_CONTENT_FORM
=
"application/json; charset=utf-8"
;
public
static
final
String
CONTENT_FORM
=
"application/x-www-form-urlencoded;charset=UTF-8"
;
public
static
final
String
FROM_DATA_CONTENT_FORM
=
"application/from-data;charset=UTF-8"
;
@Autowired
private
ApiLogService
reqLogService
;
@Autowired
private
HttpsUtils
httpsUtils
;
@Autowired
private
ApiFunctionMapper
apiFunctionMapper
;
@Autowired
private
ApiInterfaceService
apiInterfaceService
;
/**
* 三方查询处理
* @param dataTableSelectTO
* @return
*/
@Override
public
boolean
thirdSelectHandle
(
DataTableSelectTO
dataTableSelectTO
)
{
if
(
"POST"
.
equalsIgnoreCase
(
dataTableSelectTO
.
getApiInterface
().
getReqType
()))
{
Map
map
=
JSONObject
.
parseObject
(
dataTableSelectTO
.
getReqParams
(),
Map
.
class
);
Map
reqParam
=
assembleReqParam
(
map
,
dataTableSelectTO
.
getApiInterface
(),
dataTableSelectTO
.
getAuthCode
());
net
.
sf
.
json
.
JSONObject
fromObject
=
net
.
sf
.
json
.
JSONObject
.
fromObject
(
reqParam
);
HashMap
<
String
,
String
>
headers
=
new
HashMap
<>();
if
(
"1"
.
equals
(
dataTableSelectTO
.
getApiInterface
().
getPostType
()))
{
headers
.
put
(
"Content-type"
,
CONTENT_FORM
);
}
else
if
(
"2"
.
equals
(
dataTableSelectTO
.
getApiInterface
().
getPostType
()))
{
headers
.
put
(
"Content-type"
,
FROM_DATA_CONTENT_FORM
);
}
else
{
headers
.
put
(
"Content-type"
,
JSON_CONTENT_FORM
);
}
String
result
=
httpsUtils
.
submitPost
(
dataTableSelectTO
.
getApiInterface
().
getTargetUrl
(),
fromObject
.
toString
(),
headers
);
return
callMethodResponse
(
result
,
dataTableSelectTO
.
getOpenApiResponse
(),
dataTableSelectTO
.
getApiInterface
());
}
else
{
Map
map
=
JSONObject
.
parseObject
(
dataTableSelectTO
.
getReqParams
(),
Map
.
class
);
Map
reqParam
=
assembleReqParam
(
map
,
dataTableSelectTO
.
getApiInterface
(),
dataTableSelectTO
.
getAuthCode
());
String
result
=
httpsUtils
.
doGet
(
dataTableSelectTO
.
getApiInterface
().
getTargetUrl
(),
reqParam
);
return
callMethodResponse
(
result
,
dataTableSelectTO
.
getOpenApiResponse
(),
dataTableSelectTO
.
getApiInterface
());
}
}
/**
* 组装请求参数
*
* @param param
* @param apiInterface
* @return
*/
private
Map
assembleReqParam
(
Map
param
,
ApiInterface
apiInterface
,
String
authCode
)
{
List
<
String
>
listFuncNames
=
apiFunctionMapper
.
listFunctionNames
();
ApiInterfaceCustom
apiCustomInfo
=
apiInterfaceService
.
getApiCustomInfo
(
apiInterface
.
getId
());
if
(
null
!=
apiCustomInfo
)
{
List
<
JSONObject
>
jsonList
=
JSONObject
.
parseArray
(
apiCustomInfo
.
getInboxParam
(),
JSONObject
.
class
);
if
(
CollectionUtils
.
isNotEmpty
(
jsonList
))
{
for
(
JSONObject
paObject
:
jsonList
)
{
String
functionName
=
paObject
.
getString
((
"type"
));
if
(
listFuncNames
.
contains
(
functionName
))
{
String
name
=
paObject
.
getString
(
"name"
);
if
(
functionName
.
equals
(
"function03"
))
{
String
functionVal
=
getFunctionReqData
(
functionName
,
authCode
,
null
);
if
(
StringUtils
.
isNotBlank
(
functionVal
))
{
param
.
put
(
name
,
functionVal
);
}
}
else
{
String
functionVal
=
getFunctionReqData
(
functionName
,
null
,
param
);
if
(
StringUtils
.
isNotBlank
(
functionVal
))
{
param
.
put
(
name
,
functionVal
);
}
}
}
}
}
}
return
param
;
}
private
String
getFunctionReqData
(
String
name
,
String
authCode
,
Map
<
String
,
String
>
signMap
)
{
String
resultStr
=
""
;
QueryWrapper
<
ApiFunction
>
queryWra
=
new
QueryWrapper
<>();
queryWra
.
eq
(
"name"
,
name
);
queryWra
.
eq
(
"status"
,
true
);
queryWra
.
eq
(
"is_deleted"
,
0
);
ApiFunction
apiFunction
=
apiFunctionMapper
.
selectOne
(
queryWra
);
if
(
null
!=
apiFunction
)
{
JSONObject
reqParameter
=
new
JSONObject
();
if
(
"name"
.
equals
(
"function03"
))
{
//根据不同模板组装不同请求参数
reqParameter
.
put
(
"authCode"
,
authCode
);
}
else
{
reqParameter
.
put
(
"signParams"
,
signMap
);
}
String
result
=
httpsUtils
.
submitPost
(
apiFunction
.
getTemplateUrl
(),
reqParameter
.
toString
());
if
(
null
!=
result
)
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
if
(
200
==
jsonObject
.
getInteger
(
"code"
))
{
if
(
"name"
.
equals
(
"function03"
))
{
resultStr
=
jsonObject
.
getString
(
"data"
);
}
else
{
JSONObject
data
=
jsonObject
.
getJSONObject
(
"data"
);
resultStr
=
data
.
getString
(
"signStr"
);
}
}
}
}
return
resultStr
;
}
/**
* 调用方法处理结果
*
* @param result
* @param response
*/
private
boolean
callMethodResponse
(
String
result
,
OpenApiResponse
response
,
ApiInterface
apiInterface
)
{
if
(
null
==
result
)
{
throw
new
GatewayException
(
GatewayResultCode
.
DISTANCE_REQUEST_EXCEPTION
);
}
JSONObject
resp
=
JSONObject
.
parseObject
(
result
);
if
(
null
!=
resp
&&
"ESC00000"
.
equals
(
resp
.
getString
(
"return_code"
)))
{
response
.
setCode
(
GatewayResultCode
.
SUCCESS
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
SUCCESS
.
getMsg
());
response
.
setAttribute
(
"responseResult"
,
resp
);
if
(
null
!=
apiInterface
.
getLogId
())
{
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
result
);
}
return
true
;
}
else
{
log
.
error
(
"~~~~~~~~~~~~~~~~远程请求异常~~~~~~~~~~~~~~~~~"
);
reqLogService
.
updateLog
(
apiInterface
.
getLogId
(),
result
);
throw
new
GatewayException
(
GatewayResultCode
.
DISTANCE_REQUEST_EXCEPTION
);
}
}
}
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/api/ApiReqTest.java
View file @
d6402b13
...
...
@@ -8,6 +8,9 @@ import com.jz.dm.gateway.SpringTestCase;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.gateway.api
...
...
@@ -23,12 +26,16 @@ public class ApiReqTest extends SpringTestCase {
@Autowired
private
HttpsUtils
httpsUtils
;
/**
* 生成数据查询json请求签名
*/
@Test
public
void
TestGatewayReq
()
{
public
void
TestGateway
Json
Req
()
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"apiKey"
,
"Y18q7v2Rq332H3ox"
);
jsonObject
.
put
(
"method"
,
"
query
"
);
jsonObject
.
put
(
"method"
,
"
request
"
);
jsonObject
.
put
(
"signType"
,
"MD5"
);
long
time
=
System
.
currentTimeMillis
();
String
date
=
String
.
valueOf
(
time
);
...
...
@@ -36,21 +43,73 @@ public class ApiReqTest extends SpringTestCase {
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"authCode"
,
"20210000021281934021n275Hn63qaxP"
);
params
.
put
(
"reqParams"
,
new
JSONObject
());
params
.
put
(
"isTest"
,
false
);
JSONObject
reqParams
=
new
JSONObject
();
reqParams
.
put
(
"datasourceId"
,
"1"
);
reqParams
.
put
(
"query_database"
,
"product"
);
reqParams
.
put
(
"query_table"
,
"table1"
);
JSONObject
fields
=
new
JSONObject
();
fields
.
put
(
"flelds1"
,
"xxxxxx"
);
fields
.
put
(
"flelds2"
,
"xxxxxx"
);
reqParams
.
put
(
"request_fileds"
,
fields
);
reqParams
.
put
(
"response_fields"
,
"field1,field2,field3,field4"
);
reqParams
.
put
(
"page_num"
,
1
);
reqParams
.
put
(
"page_size"
,
100
);
params
.
put
(
"reqParams"
,
reqParams
);
jsonObject
.
put
(
"params"
,
params
);
try
{
String
apiKey
=
jsonObject
.
getString
(
"apiKey"
);
String
method
=
jsonObject
.
getString
(
"method"
);
String
signType
=
jsonObject
.
getString
(
"signType"
);
String
signature
=
MapUtil
.
getSignValue
(
apiKey
,
method
,
signType
);
String
sign
=
Md5
.
encrypt
(
signature
,
"RPf8HL36"
);
jsonObject
.
put
(
"sign"
,
sign
);
/* String response = httpsUtils.submitPost(url, jsonObject.toString());*/
Map
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
paramsMap
.
put
(
"apiKey"
,
jsonObject
.
getString
(
"apiKey"
));
paramsMap
.
put
(
"method"
,
jsonObject
.
getString
(
"method"
));
paramsMap
.
put
(
"signType"
,
jsonObject
.
getString
(
"signType"
));
paramsMap
.
put
(
"params"
,
params
.
toString
());
String
signParams
=
MapUtil
.
stringNormalSort
(
paramsMap
);
String
sign
=
Md5
.
encrypt
(
signParams
,
"RPf8HL36"
);
System
.
out
.
println
(
"时间戳为:"
+
date
+
"--签名为:=="
+
sign
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 生成数据查询flow请求签名
*/
@Test
public
void
TestGatewayFlowReq
()
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"apiKey"
,
"fM59D6210E3K436m"
);
jsonObject
.
put
(
"method"
,
"request"
);
jsonObject
.
put
(
"signType"
,
"MD5"
);
long
time
=
System
.
currentTimeMillis
();
String
date
=
String
.
valueOf
(
time
);
jsonObject
.
put
(
"timestamp"
,
date
);
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"authCode"
,
"20210000000111181048520T38nzc5x7"
);
params
.
put
(
"isTest"
,
false
);
JSONObject
reqParams
=
new
JSONObject
();
reqParams
.
put
(
"datasourceId"
,
"1"
);
reqParams
.
put
(
"query_database"
,
"product"
);
reqParams
.
put
(
"query_table"
,
"table1"
);
JSONObject
fields
=
new
JSONObject
();
fields
.
put
(
"flelds1"
,
"xxxxxx"
);
fields
.
put
(
"flelds2"
,
"xxxxxx"
);
reqParams
.
put
(
"request_fileds"
,
fields
);
reqParams
.
put
(
"response_fields"
,
"field1,field2,field3,field4"
);
reqParams
.
put
(
"data_size"
,
500
);
params
.
put
(
"reqParams"
,
reqParams
);
jsonObject
.
put
(
"params"
,
params
);
try
{
Map
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
paramsMap
.
put
(
"apiKey"
,
jsonObject
.
getString
(
"apiKey"
));
paramsMap
.
put
(
"method"
,
jsonObject
.
getString
(
"method"
));
paramsMap
.
put
(
"signType"
,
jsonObject
.
getString
(
"signType"
));
paramsMap
.
put
(
"params"
,
params
.
toString
());
String
signParams
=
MapUtil
.
stringNormalSort
(
paramsMap
);
String
sign
=
Md5
.
encrypt
(
signParams
,
"IE36FItU"
);
System
.
out
.
println
(
"时间戳为:"
+
date
+
"--签名为:=="
+
sign
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestHttpReq.java
View file @
d6402b13
...
...
@@ -38,7 +38,7 @@ public class TestHttpReq extends SpringTestCase {
headers
.
put
(
"connection"
,
"keep-alive"
);
headers
.
put
(
"Charsert"
,
"UTF-8"
);
headers
.
put
(
"Accept"
,
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
);
String
response
=
httpsUtils
.
submitPost
(
baseUrlPost
,
jsonObject
,
headers
);
String
response
=
httpsUtils
.
submitPost
(
baseUrlPost
,
jsonObject
.
toString
()
,
headers
);
System
.
out
.
println
(
response
);
}
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestMakeApi.java
View file @
d6402b13
...
...
@@ -38,7 +38,7 @@ public class TestMakeApi extends SpringTestCase {
params
.
put
(
"apiProtocl"
,
"HTTPS"
);
params
.
put
(
"type"
,
"1"
);
try
{
String
result
=
httpsUtils
.
submitPost
(
url
,
params
,
headers
);
String
result
=
httpsUtils
.
submitPost
(
url
,
params
.
toString
()
,
headers
);
System
.
out
.
println
(
"接受到的结果为:"
+
result
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
jz-dm-common/src/main/java/com/jz/common/constant/ResultCode.java
View file @
d6402b13
...
...
@@ -17,14 +17,14 @@ public enum ResultCode {
/** 执行成功 */
SUCCESS
(
200
,
ResultMsg
.
SUCCESS
),
/** 执行失败 */
FAILURE
(
300
,
ResultMsg
.
DATA_NOT_FOUND
)
,
/** 未授权的访问 */
FAILURE
(
300
,
ResultMsg
.
DATA_NOT_FOUND
)
;
/*
*//** 未授权的访问 *//*
UNAUTHORIZED(401, ResultMsg.UNAUTHORIZED),
/** 授权过期 */
*//** 授权过期 *//*
INVALID_TOKEN(402, ResultMsg.INVALID_TOKEN),
/** 禁止访问 */
FORBIDOM
(
403
,
ResultMsg
.
FORBIDOM
);
*//** 禁止访问 *//*
FORBIDOM(403, ResultMsg.FORBIDOM);
*/
private
int
code
;
...
...
jz-dm-common/src/main/java/com/jz/common/constant/ResultMsg.java
View file @
d6402b13
package
com
.
jz
.
common
.
constant
;
/**
* @Description: 异常处理状态码枚举
* @Author: Mr.zhang
* @Date: 2021-2-25
*/
public
enum
ResultMsg
{
/**
* 执行失败
...
...
@@ -23,487 +29,26 @@ public enum ResultMsg {
TRANS_FAIL
(
"转账失败"
),
RECHARGE_SUCCESS
(
"充值成功"
),
RECHARGE_FAIL
(
"充值失败"
),
/**
* 需审核
*/
NEED_AUDIT
(
"已提交审核"
),
/**
* 查询结果为空
*/
DATA_NOT_FOUND
(
"查询结果为空"
),
/**
* 重复请求
*/
REPEATED_REQUEST
(
"重复请求"
),
/**
* 邮箱格式错误
*/
EMAIL_FORMAT
(
"邮箱格式错误"
),
/**
* 邮箱格式已存在
*/
EMAIL_EXIST
(
"邮箱已存在"
),
/**
* 合伙人不存在
*/
BROKER_NO_EXIST
(
"合伙人不存在"
),
/**
* 上级合伙人不存在
*/
ON_BROKER_NO_EXIST
(
"上级合伙人不存在"
),
/**
* 验证码异常
*/
VALID_UNUSUAL
(
"验证码错误"
),
/**
* 验证码异常
*/
VALID_EMPTY
(
"验证码不能为空"
),
/**
* 邀请人不存在
*/
INVITE_UNUSUAL
(
"邀请人信息不存在"
),
/**
* 数据已存在
*/
DATA_EXIST
(
"数据已存在"
),
/**
* 用户名或者密码错误
*/
INVALID_LOGIN
(
"用户名或者密码错误"
),
/**
* 用户名不存在
*/
INVALID_USERNAME
(
"用户名错误"
),
/**
* 用户错误
*/
INVALID_USER
(
"用户错误"
),
/**
* 用户未登录
*/
USER_NOT_LOGIN
(
"用户未登录"
),
/**
* 用户名错误
*/
USER_NAME_ERROR
(
"用户名错误"
),
/**
* 用户名不符合规则
*/
USER_NAME_INVALIDE
(
"用户名不符合规则"
),
/**
* 用户是系统用户
*/
USER_IS_SYSTEM_USER
(
"用户是系统用户"
),
/**
* 用户名字重复
*/
USER_LOGIN_NAME_IS_EXIST
(
"用户名字重复"
),
/**
* 用户用户存在角色
*/
USER_HAVE_ROLE
(
"用户用户存在角色"
),
/**
* 用户需要定义角色
*/
USER_NEED_AT_LEASE_ONE_ROLE
(
"用户自少需要定义一个角色"
),
/**
* 用户在同一平台多个角色
*/
USER_ROLE_NOT_IN_SAME_PLATFORM
(
"用户在同一平台多个角色"
),
/**
* 用户不存在
*/
USER_NOT_EXIST
(
"用户不存在"
),
/**
* 发包方用户不存在
*/
USERBAG_NOT_EXIST
(
"发包方用户不存在"
),
/**
* 退出成功
*/
USER_LOGOUT_SUCCESS
(
"退出成功"
),
/**
* 用户状态异常
*/
USER_IN_UNABLE_STATUS
(
"用户状态异常,请联系客服"
),
/**
* 用户存在多个
*/
USER_EXIST_MANY
(
"用户存在多个"
),
/**
* 用户手机号已经注册
*/
USER_MOBILE_REGISTED
(
"用户手机号已经注册"
),
/**
* 用户在待审批状态
*/
USER_IN_UNAPPROVAL_STATUS
(
"用户待审批,注意邮箱状态变更"
),
/**
* 用户在驳回状态
*/
USER_IN_APPROVALNO_STATUS
(
"用户审核驳回,请重新登陆"
),
/**
* 原密码不正确
*/
OLDPASSWORD_NOT_RIGHT
(
"原密码不正确"
),
/**
* 用户错误
*/
INVALID_AUTHOR
(
"不合法的权限"
),
/**
* 用户错误
*/
MENU_URL_EXIST
(
"菜单url已经存在了"
),
/**
* 菜单不存在
*/
MENU_NO_EXIST
(
"菜单不存在"
),
/**
* 用户错误
*/
MENU_USE_IN_ROLE
(
"菜单有角色在使用"
),
/**
* 有权限在页面使用
*/
PERMISSION_USED
(
"有权限在页面使用"
),
/**
* 权限已经存在
*/
PERMISSION_EXIST
(
"权限已经存在"
),
/**
* 权限不存在
*/
PERMISSION_NO_EXIST
(
"权限不存在"
),
/**
* 系统权限不能删除
*/
PERMISSION_IS_SYSTEM
(
"系统权限不能删除"
),
/**
* 权限不存在
*/
PERMISSION_MEHTOD_INVALID
(
"权限方法名称不合法"
),
/**
* 请求参数错误
*/
INVALID_PARAM
(
"请求参数错误"
),
/**
* 找不到请求的资源
*/
NOT_FOUND
(
"找不到请求的资源"
),
/**
* 日期格式错误
*/
DATE_FORMAT_INVALIDE
(
"日期格式错误"
),
/**
* 操作数据不存在
*/
DATA_NOT_EXIST
(
"操作数据不存在"
),
/**
* 操作数据状态不正确
*/
DATA_STATUS_ERROR
(
"操作数据状态不正确"
),
/**
* 找不到请求的资源
*/
SHARE_UNUSUAL
(
"分润异常"
),
/**
* 商户信息不存在
*/
MERCHANT_EXIST
(
"商户信息不存在"
),
/**
* 商户状态异常
*/
MERCHANT_INVALID
(
"商户状态异常"
),
/**
* 商户状态异常
*/
SUPPLIER_INVALID
(
"商户状态异常"
),
/**
* 服务不可达
*/
SERVICE_UNAVILABLE
(
"服务不可达,请稍后重试"
),
/**
* 系统发生异常
*/
ERROR
(
"系统发生异常"
),
/**
* 验证失败
*/
VERIFICATION_FAILURE
(
"验证失败"
),
/**
* 未授权的访问
*/
UNAUTHORIZED
(
"未授权的访问"
),
/**
* token过期
*/
INVALID_TOKEN
(
"token过期"
),
/**
* 禁止访问
*/
FORBIDOM
(
"禁止访问"
),
/**
* 手机号已存在
*/
MOBILE_USEED
(
"手机号已存在,请更换手机号!"
),
/**
* 角色名字已经存在
*/
ADD_ROLE_NAME_ERROR
(
"角色名字已经存在"
),
/**
* 角色不存在
*/
ROLE_NOT_EXIST
(
"角色不存在"
),
/**
* 角色在页面中使用
*/
ROLE_USED_IN_MENU
(
"角色在页面中使用"
),
/**
* 角色还有用户在使用
*/
ROLE_USED_IN_USER
(
"角色还有用户在使用,请去用户设置里删除用户或改变用户角色"
),
/**
* 系统角色不能解绑
*/
ROLE_SYSTEM_NO_UNBIND
(
"系统角色不能解绑"
),
/**
* 系统角色不能接口添加
*/
ROLE_SYSTEM_CAN_NO_INSRT
(
"系统角色不能接口添加"
),
/**
* 权限在页面中使用
*/
MEHTOD_USE_IN_MENU
(
"方法在页面中使用,请先解绑页面"
),
/**
* 数据状态不允许操作
*/
DATE_STATUS_IN_ERROR_OPERATION
(
"数据状态不允许操作"
),
SHARE_STSTE_MESSAGR_NOT_EXIST
(
"分润统计信息不存在!"
),
/**
* 添加成功
*/
INSERT_SUCCESS
(
"添加成功"
),
/**
* 添加失败
*/
INSERT_FAIL
(
"添加失败"
),
/**
* 修改成功
*/
UPDATE_SUCCESS
(
"修改成功"
),
/**
* 修改失败
*/
UPDATE_FAIL
(
"修改失败"
),
/**
* 修改内容不存在
*/
UPDATA_DATA_UNABLE
(
"修改数据不存在"
),
/**
* 删除成功
*/
DELETE_SUCCESS
(
"删除成功"
),
/**
* 删除失败
*/
DELETE_FAIL
(
"删除失败"
),
/**
* 邮箱格式错误
*/
EMAIL_FORMAT_ERROR
(
"邮箱格式错误"
),
/**
* 手机号格式错误
*/
MOBILE_EXIST
(
"手机号已存在"
),
/**
* 手机号格式错误
*/
MOBILE_FORMAT_ERROR
(
"手机号格式错误"
),
/**
* 身份证格式错误
*/
IDCARD_FORMAT_ERROR
(
"身份证格式错误"
),
/**
* 身份证错误
*/
IDCARD_ERROR
(
"身份证格式错误"
),
/**
* 修改cron表达式成功
*/
CRON_CHNAGE_SUCCESS
(
"修改cron表达式成功"
),
ERROR_OPERATE
(
"非法操作"
),
EMPTY_PARAM
(
"参数不能为空"
),
INVALID_STATUS
(
"订单已成功"
),
ERROR_PAY_PASSWORD
(
"支付密码错误"
),
INVALID_ORDER
(
"无效的代付订单"
),
INVALID_ORDER_NO
(
"无效的订单号"
),
NOT_EXIST_ORDER
(
"订单不存在"
),
NOT_EXIST_COMPLETION
(
"完工证明不存在"
),
CLOSED_ORDER
(
"订单已关闭"
),
REPEAT_COMMIT
(
"订单已提交"
),
SIGNED_ORDER
(
"订单已签约"
),
NOT_SUBMIT_ORDER
(
"订单未提交"
),
NOT_EXIST_PAYMENT
(
"明细不存在"
),
NOT_EXIST_ACCOUNT
(
"账户不存在"
),
ERROR_ACCOUNT_NO
(
"银行卡号错误"
),
ERROR_ALI_ACCOUNT_NO
(
"支付宝账号错误"
),
ERROR_MOBILE
(
"手机号格式不正确"
),
ERROR_AGE
(
"客户年龄受限"
),
INVALID_MAX
(
"单比人数已超限"
),
INVALID_REQ
(
"已创建清算明细"
),
INVALID_EMPTY
(
"参数不能为空"
),
INVALID_BAL
(
"账户余额不足"
),
INVALID_ACC
(
"无效的收款账号"
),
LIMITED_AMOUNT
(
"每月金额受限"
),
INVALID_AMOUNT
(
"金额格式不正确"
),
NOT_EXIST_USER
(
"操作人不存在"
),
INVALID_ACC_STATUS
(
"账户已经被锁定,不允许支付"
),
DON_HAVA_BACK_ORDER
(
"没有生成回单"
),
/**
* 上传目录没有写权限
*/
UPLOAD_FAIL
(
"文件上传失败"
),
FILE_ANALYSIS_ERROR
(
"文件解析出错,请重新确认再试"
),
/**
* 上传目录没有写权限
*/
FILE_UPLOAD_PATH_NOT_WRITE
(
"上传目录没有写权限"
),
/**
* 文件格式错误
*/
FILE_UPLOAD_TYPE_ERROR
(
"文件格式错误"
),
/**
* 文件大小超过限制
*/
FILE_UPLOAD_SIZE_MAX
(
"文件大小超过限制"
),
/**
* 上传目录不存在
*/
FILE_UPLOAD_PATH_NOT_EXIST
(
"上传目录不存在"
),
/**
* 企业组织请先提交注册申请
*/
PERSON_NO_APPLY_DATA
(
"请先提交注册申请"
),
/**
* 该企业组织已经申请
*/
PERSON_MERCHANT_EXIST
(
"该企业组织已经申请"
),
/**
* 商户名字或者身份证重复
*/
PERSON_MERCHANT_NAME_OR_IDCARD_REPECT
(
"商户名字或者身份证重复"
),
/**
* 订单信息不存在
*/
ORDER_NO_EXIST
(
"订单信息不存在"
),
/**
* 分润金额小于指定值
*/
SHARE_AMOUNT_ERROR
(
"分润金额小于指定值"
),
/**
* 商户类型不能参与分润
*/
MERCHANT_TYPE_ERROR
(
"商户类型不能参与分润"
),
/**
* 可看合伙人等级信息不存在
*/
VISIBLE_LEVEL_ERROR
(
"可看合伙人等级信息不存在"
),
/**
* 合伙人费率信息不存在
*/
BROKER_RATE_NO_EXIST
(
"合伙人费率信息不存在"
),
/**
* 合伙人分润表里用户不存在
*/
BROKER_SHARE_STAT_NO_EXIST
(
"合伙人分润表里用户不存在"
),
/**
* 合伙人分润表里用户存在多条
*/
BROKER_SHARE_STAT_EXIST_MANY
(
"合伙人分润表里用户存在多条"
),
/**
* 商户费率信息不存在
*/
MERCHANT_RATE_NO_EXIST
(
"商户费率信息不存在"
),
ERROR_REPORT_INFO
(
"报备商户名与营业执照信息不符,请检查后重新申请!"
),
EXIST_REPORT_INFO
(
"商户报备信息已存在,请查询确认!"
),
NOT_EXIST_SUPPLIER
(
"申请人信息不存在!"
),
REPORTED_MERCHANT
(
"该商户已报备!"
),
REPORT_EXCEPTION
(
"添加报备信息异常"
),
VOUCHER_NOT_NULL
(
"转账凭证不能为空"
),
/**
* 银行开户提交成功
*/
ACCOUNT_INSERT_SUCCESS
(
"银行开户提交成功"
),
/**
* BPO项目相关
*/
APPLY_SUCCESS
(
"申请成功"
),
APPLY_FAILED
(
"申请失败"
),
PROJECT_ASSIGNED
(
"项目已指派,请勿重复指派"
),
USER_NOT_EXIST
(
"用户不存在"
),
/*限流状态码*/
LIMIT_FLOW_EXCEPTION
(
"限流异常"
),
LIMIT_DEGRADE_EXCEPTION
(
"降级异常"
),
LIMIT_PARAM_EXCEPTION
(
"热点异常"
),
LIMIT_SYSTEM_EXCEPTION
(
"系统规则异常"
),
LIMIT_AUTHORITY_EXCEPTION
(
"认证异常"
);
NULL_RECEIVER
(
"请选择接包方"
);
private
String
msg
;
...
...
jz-dm-common/src/main/java/com/jz/common/utils/HttpsUtils.java
View file @
d6402b13
package
com
.
jz
.
common
.
utils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -45,20 +44,20 @@ public class HttpsUtils {
* @param headers 请求头
* @return
*/
public
String
submitPost
(
String
url
,
JSONObject
params
,
Map
<
String
,
String
>
headers
)
{
public
String
submitPost
(
String
url
,
String
params
,
Map
<
String
,
String
>
headers
)
{
CloseableHttpClient
httpClient
=
getHttpClient
();
String
body
=
null
;
CloseableHttpResponse
response
=
null
;
try
{
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
setHeader
(
"Content-type"
,
JSON_CONTENT_FORM
);
/* httpPost.setHeader("Content-type",JSON_CONTENT_FORM );*/
if
(
null
!=
headers
&&
headers
.
size
()
>
0
)
{
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
httpPost
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
}
if
(
StringUtils
.
isNotBlank
(
params
.
toString
()
))
{
httpPost
.
setEntity
(
new
StringEntity
(
params
.
toString
()
,
Consts
.
UTF_8
));
if
(
StringUtils
.
isNotBlank
(
params
))
{
httpPost
.
setEntity
(
new
StringEntity
(
params
,
Consts
.
UTF_8
));
}
response
=
httpClient
.
execute
(
httpPost
);
body
=
getBody
(
response
.
getEntity
());
...
...
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