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
0717005a
Commit
0717005a
authored
Jan 09, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加api请求接口
parent
a0979d18
Changes
37
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
1204 additions
and
468 deletions
+1204
-468
api_gateway.sql
database/zc/api_gateway.sql
+5
-1
pom.xml
jz-dm-apigateway/pom.xml
+12
-1
LoggingConstants.java
...main/java/com/jz/dm/common/constant/LoggingConstants.java
+3
-0
GatewayResultCode.java
...c/main/java/com/jz/dm/common/enums/GatewayResultCode.java
+5
-0
AuthReqTypeEnum.java
...ain/java/com/jz/dm/common/enums/auth/AuthReqTypeEnum.java
+34
-0
DateUtil.java
...gateway/src/main/java/com/jz/dm/common/util/DateUtil.java
+40
-1
MapUtil.java
...igateway/src/main/java/com/jz/dm/common/util/MapUtil.java
+4
-3
HttpDownload.java
.../main/java/com/jz/dm/common/util/stream/HttpDownload.java
+192
-0
SentinelConfig.java
...ateway/src/main/java/com/jz/dm/config/SentinelConfig.java
+72
-0
AuthFilter.java
...apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
+39
-6
VerifySignFilter.java
...eway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
+5
-3
ApiAuth.java
...ateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
+11
-0
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+11
-0
ApiInterfaceFile.java
...c/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
+0
-1
ApiInterfaceReq.java
.../main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
+6
-0
MakeDataBankApiReq.java
...in/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
+14
-5
AuthService.java
...igateway/src/main/java/com/jz/dm/service/AuthService.java
+7
-0
ApiInterfaceServiceImpl.java
.../java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
+2
-0
ApiLogServiceImpl.java
...c/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
+17
-8
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+16
-2
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+16
-0
ApiParamVerify.java
...c/main/java/com/jz/dm/service/request/ApiParamVerify.java
+57
-0
ApiQueryService.java
.../main/java/com/jz/dm/service/request/ApiQueryService.java
+136
-85
SystemLogAspect.java
...y/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
+14
-11
AccessLimitInterceptor.java
...ava/com/jz/dm/web/interceptor/AccessLimitInterceptor.java
+10
-8
application-test.yml
jz-dm-apigateway/src/main/resources/application-test.yml
+19
-3
application.yml
jz-dm-apigateway/src/main/resources/application.yml
+15
-1
ApiReqTest.java
...teway/src/test/java/com/jz/dm/gateway/api/ApiReqTest.java
+57
-0
TestOrganizationManage.java
...st/java/com/jz/dm/gateway/org/TestOrganizationManage.java
+4
-5
TestAmountCall.java
...rc/test/java/com/jz/dm/gateway/orther/TestAmountCall.java
+71
-0
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
TestRedisUserSave.java
...test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
+1
-1
TestStreamReq.java
...src/test/java/com/jz/dm/gateway/orther/TestStreamReq.java
+26
-0
HttpsUtils.java
...-common/src/main/java/com/jz/common/utils/HttpsUtils.java
+4
-3
manageApplicationTests.java
...e/src/test/java/com/jz/manage/manageApplicationTests.java
+24
-31
pom.xml
pom.xml
+253
-287
No files found.
database/zc/api_gateway.sql
View file @
0717005a
...
@@ -11,7 +11,7 @@ CREATE TABLE `t_api_interface` (
...
@@ -11,7 +11,7 @@ CREATE TABLE `t_api_interface` (
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 数据银行制作API 2 数据银行制作数据包, 3 API实时接入 6 标签查询 9自定义'
,
`api_type`
varchar
(
50
)
NULL
DEFAULT
''
COMMENT
'api类型:1 数据银行制作API 2 数据银行制作数据包, 3 API实时接入 6 标签查询 9自定义'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`api_function`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接口功能'
,
`join_type`
varchar
(
50
)
NULL
DEFAULT
NULL
COMMENT
'接入类型:字典表对应key值'
,
`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
'测试实例'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`status`
varchar
(
50
)
NOT
NULL
COMMENT
'状态(DRAFT-草稿 ISSUE-发布 OUTMODED-过时 4FREEZE-冻结 EXPIRY-失效)'
,
`output_type`
varchar
(
50
)
NULL
DEFAULT
'JSON'
COMMENT
'输出类型:flow 流形式输出, json格式输出'
,
`output_type`
varchar
(
50
)
NULL
DEFAULT
'JSON'
COMMENT
'输出类型:flow 流形式输出, json格式输出'
,
`page`
tinyint
(
2
)
NULL
DEFAULT
'0'
COMMENT
'是否分页:0 false ,1 true'
,
`page`
tinyint
(
2
)
NULL
DEFAULT
'0'
COMMENT
'是否分页:0 false ,1 true'
,
...
@@ -19,6 +19,8 @@ CREATE TABLE `t_api_interface` (
...
@@ -19,6 +19,8 @@ CREATE TABLE `t_api_interface` (
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`sign_type`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'加密方式: MD5 RSA'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`timeout`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'超时时间'
,
`file_id`
bigint
(
20
)
NOT
NULL
COMMENT
'文件夹id'
,
`file_id`
bigint
(
20
)
NOT
NULL
COMMENT
'文件夹id'
,
`req_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限制类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`req_frequency`
bigint
(
20
)
DEFAULT
'100'
COMMENT
'限制次数'
,
`is_test`
tinyint
(
2
)
NOT
NULL
DEFAULT
'0'
COMMENT
'是否测试数据:0 否,1 是'
,
`is_test`
tinyint
(
2
)
NOT
NULL
DEFAULT
'0'
COMMENT
'是否测试数据:0 否,1 是'
,
`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
'创建时间'
,
...
@@ -103,6 +105,8 @@ CREATE TABLE `t_api_auth` (
...
@@ -103,6 +105,8 @@ CREATE TABLE `t_api_auth` (
`api_interface_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api信息表id'
,
`api_interface_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api信息表id'
,
`api_org_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api组织id'
,
`api_org_id`
bigint
(
20
)
NOT
NULL
COMMENT
'api组织id'
,
`auth_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'授权类型:DATA_BANK_AUTH 数据银行购买 DMP_AUTH dmp授权'
,
`auth_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'授权类型:DATA_BANK_AUTH 数据银行购买 DMP_AUTH dmp授权'
,
`req_type`
varchar
(
20
)
DEFAULT
NULL
COMMENT
'限制类型:DAY 按天,MONTH 按月, YEAR 按年'
,
`req_frequency`
bigint
(
20
)
DEFAULT
'100'
COMMENT
'限制次数'
,
`auth_code`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'授权码'
,
`auth_code`
varchar
(
100
)
DEFAULT
NULL
COMMENT
'授权码'
,
`salt`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'盐值'
,
`salt`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'盐值'
,
`auth_mode`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效'
,
`auth_mode`
varchar
(
50
)
DEFAULT
NULL
COMMENT
'授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用 PERMANENT_TIME_MODE 永久有效'
,
...
...
jz-dm-apigateway/pom.xml
View file @
0717005a
...
@@ -97,18 +97,29 @@
...
@@ -97,18 +97,29 @@
<artifactId>
spring-boot-starter-aop
</artifactId>
<artifactId>
spring-boot-starter-aop
</artifactId>
</dependency>
</dependency>
<!-- 校验-->
<!--
validation
校验-->
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-validation
</artifactId>
<artifactId>
spring-boot-starter-validation
</artifactId>
</dependency>
</dependency>
<!--Sentinel 限流框架依赖-->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
<!-- <version>0.9.0.RELEASE</version>-->
</dependency>
<dependency>
<dependency>
<groupId>
net.sf.json-lib
</groupId>
<groupId>
net.sf.json-lib
</groupId>
<artifactId>
json-lib
</artifactId>
<artifactId>
json-lib
</artifactId>
<version>
2.2.3
</version>
<version>
2.2.3
</version>
<classifier>
jdk15
</classifier>
<!-- jdk版本 -->
<classifier>
jdk15
</classifier>
<!-- jdk版本 -->
</dependency>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/constant/LoggingConstants.java
View file @
0717005a
...
@@ -48,4 +48,7 @@ public class LoggingConstants {
...
@@ -48,4 +48,7 @@ public class LoggingConstants {
/** "&" 符号*/
/** "&" 符号*/
public
static
final
String
AND_SPILT
=
"&"
;
public
static
final
String
AND_SPILT
=
"&"
;
/** "=" 符号*/
public
static
final
String
AND_EQUAL
=
"="
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/GatewayResultCode.java
View file @
0717005a
...
@@ -67,6 +67,11 @@ public enum GatewayResultCode implements ResultCode {
...
@@ -67,6 +67,11 @@ public enum GatewayResultCode implements ResultCode {
ORG_STATE_EXCEPTION
(
"ORG_STATE_EXCEPTION"
,
"请求组织状态异常"
),
ORG_STATE_EXCEPTION
(
"ORG_STATE_EXCEPTION"
,
"请求组织状态异常"
),
/** 请求信息不存在 */
/** 请求信息不存在 */
REQUEST_INFO_UNEXIST
(
"REQUEST_INFO_UNEXIST"
,
"请求信息不存在"
),
REQUEST_INFO_UNEXIST
(
"REQUEST_INFO_UNEXIST"
,
"请求信息不存在"
),
/** 远程请求异常 */
DISTANCE_REQUEST_EXCEPTION
(
"DISTANCE_REQUEST_EXCEPTION"
,
"流形式输出异常"
),
/** 单次调用金额不足 */
CALL_AMOUNT_NOT_ENOUGH
(
"CALL_AMOUNT_NOT_ENOUGH"
,
"单次调用金额不足"
),
/** 输出类型错误 */
/** 输出类型错误 */
OUTPUT_TYPE_EXCEPTION
(
"OUTPUT_TYPE_EXCEPTION"
,
"输出类型错误!"
);
OUTPUT_TYPE_EXCEPTION
(
"OUTPUT_TYPE_EXCEPTION"
,
"输出类型错误!"
);
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/enums/auth/AuthReqTypeEnum.java
0 → 100644
View file @
0717005a
package
com
.
jz
.
dm
.
common
.
enums
.
auth
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.enums.auth
* @PROJECT_NAME: jz-dm-parent
* @NAME: AuthReqTypeEnum
* @DATE: 2021-1-8/18:44
* @DAY_NAME_SHORT: 周五
* @Description:
**/
public
enum
AuthReqTypeEnum
{
DAY
(
"天"
),
MONTH
(
"月"
),
YEAR
(
"年"
);
private
String
text
;
AuthReqTypeEnum
(
String
text
)
{
this
.
text
=
text
;
}
public
String
getText
()
{
return
text
;
}
public
static
AuthReqTypeEnum
fromAuthReqTypeEnum
(
String
typeName
)
{
for
(
AuthReqTypeEnum
type
:
AuthReqTypeEnum
.
values
())
{
if
(
type
.
name
().
equals
(
typeName
))
{
return
type
;
}
}
return
null
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/DateUtil.java
View file @
0717005a
package
com
.
jz
.
dm
.
common
.
util
;
package
com
.
jz
.
dm
.
common
.
util
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
/**
* @author ZC
* @author ZC
...
@@ -27,7 +29,44 @@ public class DateUtil {
...
@@ -27,7 +29,44 @@ public class DateUtil {
return
(
cal
.
getTimeInMillis
()
-
System
.
currentTimeMillis
())
/
1000
;
return
(
cal
.
getTimeInMillis
()
-
System
.
currentTimeMillis
())
/
1000
;
}
}
/**
* 计算当前距离下月一号剩余时间
* @return
*/
public
static
long
calculateNowMonthTime
(){
Calendar
c
=
Calendar
.
getInstance
();
//获取一个Calendar对象
c
.
setTime
(
new
Date
()
);
c
.
add
(
Calendar
.
MONTH
,
1
);
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
0
);
c
.
set
(
Calendar
.
HOUR_OF_DAY
,
23
);
c
.
set
(
Calendar
.
MINUTE
,
59
);
c
.
set
(
Calendar
.
SECOND
,
59
);
return
(
c
.
getTimeInMillis
()
-
System
.
currentTimeMillis
())
/
1000
;
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
calculateNowResidueTime
());
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//System.out.println(calculateNowResidueTime());
Calendar
c
=
Calendar
.
getInstance
();
//获取一个Calendar对象
c
.
setTime
(
new
Date
()
);
c
.
add
(
Calendar
.
MONTH
,
1
);
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
0
);
c
.
set
(
Calendar
.
HOUR_OF_DAY
,
23
);
c
.
set
(
Calendar
.
MINUTE
,
59
);
c
.
set
(
Calendar
.
SECOND
,
59
);
Date
time
=
c
.
getTime
();
String
format
=
dateFormat
.
format
(
time
);
System
.
out
.
println
(
format
);
Calendar
cal
=
Calendar
.
getInstance
();
//获取一个Calendar对象
cal
.
setTime
(
new
Date
()
);
cal
.
add
(
Calendar
.
MONTH
,
0
);
//获取当前时间的下一个月
cal
.
set
(
Calendar
.
DAY_OF_MONTH
,
cal
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
));
//获取下一个月的最后一天
Date
preMonth
=
cal
.
getTime
();
//得到下个月的最后一天
String
format1
=
dateFormat
.
format
(
preMonth
);
System
.
out
.
println
(
format1
);
System
.
out
.
println
(
calculateNowMonthTime
()/
60
/
60
/
24
);
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/MapUtil.java
View file @
0717005a
package
com
.
jz
.
dm
.
common
.
util
;
package
com
.
jz
.
dm
.
common
.
util
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.jz.dm.common.constant.LoggingConstants
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
...
@@ -30,9 +31,9 @@ public class MapUtil {
...
@@ -30,9 +31,9 @@ public class MapUtil {
*/
*/
public
static
String
getSignValue
(
String
apiKey
,
String
method
,
String
signType
,
String
timestamp
){
public
static
String
getSignValue
(
String
apiKey
,
String
method
,
String
signType
,
String
timestamp
){
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"apiKey="
).
append
(
apiKey
).
append
(
"&"
)
builder
.
append
(
"apiKey="
).
append
(
apiKey
).
append
(
LoggingConstants
.
AND_SPILT
)
.
append
(
"method="
).
append
(
method
).
append
(
"&"
)
.
append
(
"method="
).
append
(
method
).
append
(
LoggingConstants
.
AND_SPILT
)
.
append
(
"signType="
).
append
(
signType
).
append
(
"&"
)
.
append
(
"signType="
).
append
(
signType
).
append
(
LoggingConstants
.
AND_SPILT
)
.
append
(
"timestamp="
).
append
(
timestamp
);
.
append
(
"timestamp="
).
append
(
timestamp
);
return
builder
.
toString
();
return
builder
.
toString
();
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/stream/HttpDownload.java
0 → 100644
View file @
0717005a
package
com
.
jz
.
dm
.
common
.
util
.
stream
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.*
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.text.MessageFormat
;
import
static
com
.
jz
.
common
.
utils
.
HttpClientPool
.
getHttpClient
;
/**
* @author ZC
* @PACKAGE_NAME: com.sentinel.project.util
* @PROJECT_NAME: jz-dm-parent
* @NAME: HttpDownload
* @DATE: 2021-1-7/18:04
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Slf4j
public
class
HttpDownload
{
public
static
final
int
cache
=
10
*
1024
;
public
static
final
boolean
isWindows
;
public
static
final
String
splash
;
public
static
final
String
root
;
static
{
if
(
System
.
getProperty
(
"name"
)
!=
null
&&
System
.
getProperty
(
"name"
).
toLowerCase
().
contains
(
"windows"
))
{
isWindows
=
true
;
splash
=
"\\"
;
root
=
"D:"
;
}
else
{
isWindows
=
false
;
splash
=
"/"
;
root
=
"/search"
;
}
}
/**
* 根据url下载文件,文件名从response header头中获取
*
* @param url
* @return
*/
public
static
void
download
(
String
url
)
{
download
(
url
,
null
);
}
/**
* 根据url下载文件,保存到filepath中
*
* @param baseUrl
* @param filepath
* @return
*/
public
static
void
download
(
String
baseUrl
,
String
filepath
)
{
InputStream
is
=
null
;
FileOutputStream
fileOut
=
null
;
try
{
CloseableHttpClient
client
=
getHttpClient
();
HttpGet
httpGet
=
new
HttpGet
(
baseUrl
);
HttpResponse
response
=
client
.
execute
(
httpGet
);
//获取消息头
Header
[]
headers
=
response
.
getAllHeaders
();
for
(
Header
header
:
headers
)
{
System
.
out
.
println
(
MessageFormat
.
format
(
"header:{0}={1}"
,
header
.
getName
(),
header
.
getValue
()));
}
String
fileName
=
response
.
getHeaders
(
"Content-Disposition"
)[
0
].
getValue
().
split
(
"filename="
)[
1
];
System
.
out
.
println
(
"文件名为"
+
fileName
);
HttpEntity
entity
=
response
.
getEntity
();
is
=
entity
.
getContent
();
if
(
fileName
==
null
)
{
fileName
=
getFilePath
(
response
);
}
if
(
filepath
!=
null
)
{
fileName
=
filepath
+
splash
+
fileName
;
}
else
{
fileName
=
splash
+
fileName
;
}
File
file
=
new
File
(
fileName
);
file
.
getParentFile
().
mkdirs
();
fileOut
=
new
FileOutputStream
(
file
);
/**
* 根据实际运行效果 设置缓冲区大小
*/
byte
[]
buffer
=
new
byte
[
cache
];
int
ch
=
0
;
while
((
ch
=
is
.
read
(
buffer
))
!=
-
1
)
{
fileOut
.
write
(
buffer
,
0
,
ch
);
}
fileOut
.
flush
();
log
.
info
(
"文件下载成功!"
);
}
catch
(
Exception
e
)
{
log
.
info
(
"数据下载异常:{}"
,
e
.
getMessage
());
e
.
printStackTrace
();
}
finally
{
if
(
is
!=
null
)
{
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
null
!=
fileOut
)
{
try
{
fileOut
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
/**
* 获取response要下载的文件的默认路径
*
* @param response
* @return
*/
public
static
String
getFilePath
(
HttpResponse
response
)
{
String
filepath
=
root
+
splash
;
String
filename
=
getFileName
(
response
);
if
(
filename
!=
null
)
{
filepath
+=
filename
;
}
else
{
filepath
+=
getRandomFileName
();
}
return
filepath
;
}
/**
* 获取response header中Content-Disposition中的filename值
*
* @param response
* @return
*/
public
static
String
getFileName
(
HttpResponse
response
)
{
Header
contentHeader
=
response
.
getFirstHeader
(
"Content-Disposition"
);
String
filename
=
null
;
if
(
contentHeader
!=
null
)
{
HeaderElement
[]
values
=
contentHeader
.
getElements
();
if
(
values
.
length
==
1
)
{
NameValuePair
param
=
values
[
0
].
getParameterByName
(
"filename"
);
if
(
param
!=
null
)
{
try
{
//filename = new String(param.getValue().toString().getBytes(), "utf-8");
//filename=URLDecoder.decode(param.getValue(),"utf-8");
filename
=
param
.
getValue
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
return
filename
;
}
/**
* 获取随机文件名
*
* @return
*/
public
static
String
getRandomFileName
()
{
return
String
.
valueOf
(
System
.
currentTimeMillis
());
}
public
static
void
outHeaders
(
HttpResponse
response
)
{
Header
[]
headers
=
response
.
getAllHeaders
();
for
(
int
i
=
0
;
i
<
headers
.
length
;
i
++)
{
System
.
out
.
println
(
headers
[
i
]);
}
}
public
static
void
main
(
String
[]
args
)
{
String
zip
=
"http://192.168.1.140:8090/api/download/"
;
String
text
=
"http://192.168.1.140:8090/api/download/txt"
;
String
docx
=
"http://192.168.1.140:8090/api/download/docx"
;
String
pdf
=
"http://192.168.1.140:8090/api/download/pdf"
;
String
xlsx
=
"http://192.168.1.140:8090/api/download/xlsx"
;
String
filepath
=
"C:\\Users\\key\\Desktop\\ideaIU-2019.3.3"
;
HttpDownload
.
download
(
xlsx
,
filepath
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/config/SentinelConfig.java
0 → 100644
View file @
0717005a
package
com
.
jz
.
dm
.
config
;
import
com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect
;
import
com.alibaba.csp.sentinel.slots.block.RuleConstant
;
import
com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule
;
import
com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager
;
import
com.alibaba.csp.sentinel.slots.block.flow.FlowRule
;
import
com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.PostConstruct
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.config
* @PROJECT_NAME: jz-dm-parent
* @NAME: SentinelConfig
* @DATE: 2021-1-7/15:57
* @DAY_NAME_SHORT: 周四
* @Description: 限流熔断初始化配置
**/
@Configuration
public
class
SentinelConfig
{
@Bean
public
SentinelResourceAspect
sentinelResourceAspect
()
{
return
new
SentinelResourceAspect
();
}
/**
* 默认最大请求数
*/
@Value
(
"${sentinel.request.max}"
)
private
Integer
defaultMaxRequest
;
/**
* 限流/熔断资源配置
*/
@Value
(
"${sentinel.resource}"
)
private
String
limitSource
;
@PostConstruct
private
void
initFlowRules
()
{
List
<
FlowRule
>
rules
=
new
ArrayList
<>();
FlowRule
rule
=
new
FlowRule
();
rule
.
setResource
(
limitSource
);
rule
.
setGrade
(
RuleConstant
.
FLOW_GRADE_QPS
);
rule
.
setCount
(
defaultMaxRequest
);
//每秒中可以有多少个请求
rules
.
add
(
rule
);
FlowRuleManager
.
loadRules
(
rules
);
//降级规则,可以多个degradeRule rule
//DegradeRuleManager.getRules()可以获取到已经设置的降级规则
List
<
DegradeRule
>
degradeRules
=
new
ArrayList
<>();
DegradeRule
degradeRule
=
new
DegradeRule
();
//设置资源名称,sentinel降级都是以资源为单位进行
degradeRule
.
setResource
(
limitSource
);
//使用异常统计降级,分钟统计,滑动时间窗口
degradeRule
.
setGrade
(
RuleConstant
.
DEGRADE_GRADE_EXCEPTION_COUNT
);
//异常数达到的数量阈值
degradeRule
.
setCount
(
defaultMaxRequest
);
//秒级时间窗口,该值必须有且必须大于零,否则降级将无法生效
degradeRule
.
setTimeWindow
(
1
);
degradeRules
.
add
(
degradeRule
);
//重新加载限流规则,此处将覆盖原有的限流,所以如果想要不覆盖
//请使用DegradeRuleManager.getRules()获取到的加入到rules中
DegradeRuleManager
.
loadRules
(
degradeRules
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/AuthFilter.java
View file @
0717005a
package
com
.
jz
.
dm
.
filter
;
package
com
.
jz
.
dm
.
filter
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
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.LoggingConstants
;
import
com.jz.dm.common.constant.LoggingConstants
;
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.org.OrgStatusEnum
;
import
com.jz.dm.common.enums.org.OrgStatusEnum
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.common.util.DateUtil
;
import
com.jz.dm.common.util.DateUtil
;
...
@@ -51,9 +53,10 @@ public class AuthFilter extends AbstractFilter {
...
@@ -51,9 +53,10 @@ public class AuthFilter extends AbstractFilter {
private
ApiInterfaceService
apiInterfaceService
;
private
ApiInterfaceService
apiInterfaceService
;
@Autowired
@Autowired
private
RedisUtils
redisUtils
;
private
RedisUtils
redisUtils
;
@Autowired
@Value
(
"${request.limit.max}"
)
private
HttpsUtils
httpUtils
;
private
Long
limit
;
@Value
(
"${data.bank.balanceUrl}"
)
private
String
balanceUrl
;
@Override
@Override
public
String
getFilterName
()
{
public
String
getFilterName
()
{
...
@@ -124,15 +127,23 @@ public class AuthFilter extends AbstractFilter {
...
@@ -124,15 +127,23 @@ public class AuthFilter extends AbstractFilter {
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
throw
new
GatewayException
(
GatewayResultCode
.
ORG_STATE_EXCEPTION
);
}
}
//查询数据银行银行余额是否充足
//查询数据银行银行余额是否充足
getDataAmountResult
(
request
);
try
{
//记录请求次数(每天限制请求次数)
try
{
//记录请求次数(每天限制请求次数)
String
limitKey
=
request
.
getApiKey
()
+
LoggingConstants
.
AND_SPILT
+
authCode
;
String
limitKey
=
request
.
getApiKey
()
+
LoggingConstants
.
AND_SPILT
+
authCode
;
String
reqKey
=
redisUtils
.
get
(
limitKey
);
String
reqKey
=
redisUtils
.
get
(
limitKey
);
long
timeOut
=
DateUtil
.
calculateNowResidueTime
();
long
timeOut
=
0
;
if
(
AuthReqTypeEnum
.
DAY
.
name
().
equals
(
authAuth
.
getReqType
())){
//按天
timeOut
=
DateUtil
.
calculateNowResidueTime
();
}
else
if
(
AuthReqTypeEnum
.
MONTH
.
name
().
equals
(
authAuth
.
getReqType
())){
//按月
timeOut
=
DateUtil
.
calculateNowMonthTime
();
}
else
if
(
AuthReqTypeEnum
.
YEAR
.
name
().
equals
(
authAuth
.
getReqType
())){
//按年
//暂时不支持年
}
if
(
null
!=
reqKey
)
{
if
(
null
!=
reqKey
)
{
Integer
value
=
Integer
.
valueOf
(
reqKey
);
Integer
value
=
Integer
.
valueOf
(
reqKey
);
if
(
value
>
limit
)
{
//超出最大请求次数
if
(
value
>
authAuth
.
getReqFrequency
()
)
{
//超出最大请求次数
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_LIMIT_EXCEPTION
);
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_LIMIT_EXCEPTION
);
}
else
if
(
value
<=
limit
)
{
}
else
if
(
value
<=
authAuth
.
getReqFrequency
()
)
{
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
value
+
1
,
timeOut
);
redisUtils
.
delAndAdd
(
limitKey
,
limitKey
,
value
+
1
,
timeOut
);
}
}
}
else
{
}
else
{
...
@@ -160,4 +171,26 @@ public class AuthFilter extends AbstractFilter {
...
@@ -160,4 +171,26 @@ public class AuthFilter extends AbstractFilter {
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
}
}
}
/**
* 按次调用检查余额是否充足
* @param request
*/
private
void
getDataAmountResult
(
GatewayRequest
request
)
{
JSONObject
params
=
JSONObject
.
parseObject
(
request
.
getParams
());
if
(
null
!=
params
){
JSONObject
pObject
=
new
JSONObject
();
pObject
.
put
(
"assetsId"
,
params
.
getInteger
(
"assetsId"
));
pObject
.
put
(
"userId"
,
params
.
getInteger
(
"userId"
));
pObject
.
put
(
"dataPrice"
,
params
.
getString
(
"dataPrice"
));
String
respResult
=
httpUtils
.
submitPost
(
balanceUrl
,
pObject
.
toString
());
JSONObject
result
=
JSONObject
.
parseObject
(
respResult
);
if
(
null
!=
result
){
if
(
200
!=
result
.
getInteger
(
"code"
)){
log
.
info
(
"~~~~~~~~~~~~~~~~~~异常信息为:{}"
,
result
.
getString
(
"message"
));
throw
new
GatewayException
(
GatewayResultCode
.
CALL_AMOUNT_NOT_ENOUGH
);
}
}
}
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/filter/VerifySignFilter.java
View file @
0717005a
...
@@ -41,17 +41,19 @@ public class VerifySignFilter extends AbstractFilter {
...
@@ -41,17 +41,19 @@ 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
{
//对签约参数进行字典排序
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
String
signParams
=
MapUtil
.
getSignValue
(
request
.
getApiKey
(),
request
.
getMethod
(),
request
.
getSignType
(),
String
.
valueOf
(
request
.
getTimestamp
()));
request
.
getSignType
(),
String
.
valueOf
(
request
.
getTimestamp
()));
if
(
StringUtils
.
isNotBlank
(
signParams
)){
if
(
StringUtils
.
isNotBlank
(
signParams
)){
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
request
.
getParams
());
String
authCode
=
jsonObject
.
getString
(
"authCode"
);
//需要传入授权码
//需要传入授权码
ApiAuth
apiAuthInfo
=
apiInterfaceService
.
getApiAuthInfo
(
request
.
getApiKey
(),
jsonObject
.
getString
(
"authCode"
)
);
ApiAuth
apiAuthInfo
=
apiInterfaceService
.
getApiAuthInfo
(
request
.
getApiKey
(),
authCode
);
if
(
null
==
apiAuthInfo
){
if
(
null
==
apiAuthInfo
){
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
}
String
s
alt
=
Md5
.
encrypt
(
signParams
,
apiAuthInfo
.
getSalt
());
String
s
ign
=
Md5
.
encrypt
(
signParams
,
apiAuthInfo
.
getSalt
());
if
(!
request
.
getSign
().
equals
(
s
alt
)){
if
(!
request
.
getSign
().
equals
(
s
ign
)){
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
throw
new
GatewayException
(
GatewayResultCode
.
SIGN_ERROR
);
}
}
}
else
{
}
else
{
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiAuth.java
View file @
0717005a
...
@@ -43,6 +43,17 @@ public class ApiAuth extends BaseObject implements Serializable {
...
@@ -43,6 +43,17 @@ public class ApiAuth extends BaseObject implements Serializable {
*/
*/
@TableField
(
"auth_type"
)
@TableField
(
"auth_type"
)
private
String
authType
;
private
String
authType
;
/**
* 限制类型:DAY 按天,MONTH 按月, YEAR 按年
*/
@TableField
(
"req_type"
)
private
String
reqType
;
/**
* 限制次数
*/
@TableField
(
"req_frequency"
)
private
Long
reqFrequency
;
/**
/**
* 授权码
* 授权码
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
0717005a
...
@@ -108,6 +108,17 @@ public class ApiInterface extends BaseObject implements Serializable {
...
@@ -108,6 +108,17 @@ public class ApiInterface extends BaseObject implements Serializable {
@TableField
(
"sign_type"
)
@TableField
(
"sign_type"
)
private
String
signType
;
private
String
signType
;
/**
* 限制类型:DAY 按天,MONTH 按月, YEAR 按年
*/
@TableField
(
"req_type"
)
private
String
reqType
;
/**
* 限制次数
*/
@TableField
(
"req_frequency"
)
private
Long
reqFrequency
;
/**
/**
* 超时时间
* 超时时间
*/
*/
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterfaceFile.java
View file @
0717005a
...
@@ -64,5 +64,4 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
...
@@ -64,5 +64,4 @@ public class ApiInterfaceFile extends BaseObject implements Serializable {
@TableField
(
"status"
)
@TableField
(
"status"
)
private
String
status
;
private
String
status
;
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/ApiInterfaceReq.java
View file @
0717005a
...
@@ -46,6 +46,12 @@ public class ApiInterfaceReq implements Serializable {
...
@@ -46,6 +46,12 @@ public class ApiInterfaceReq implements Serializable {
@NotNull
(
message
=
"超时时间不能为空"
)
@NotNull
(
message
=
"超时时间不能为空"
)
public
String
timeout
;
public
String
timeout
;
@ApiModelProperty
(
value
=
"限制类型:DAY 按天,MONTH 按月, YEAR 按年"
,
required
=
true
)
@NotNull
(
message
=
"限制类型不能为空"
)
public
String
reqType
;
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
true
)
public
Long
reqFrequency
;
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
@ApiModelProperty
(
value
=
"api描述"
,
required
=
false
)
public
String
apiFunction
;
public
String
apiFunction
;
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/make/MakeDataBankApiReq.java
View file @
0717005a
...
@@ -40,10 +40,21 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -40,10 +40,21 @@ public class MakeDataBankApiReq implements Serializable {
@NotNull
(
message
=
"输出类型不能为空"
)
@NotNull
(
message
=
"输出类型不能为空"
)
public
String
outputType
;
public
String
outputType
;
@ApiModelProperty
(
value
=
"是否分页:"
,
required
=
fals
e
)
@ApiModelProperty
(
value
=
"是否分页:"
,
required
=
tru
e
)
//
@NotNull(message = "是否分页不能为空")
@NotNull
(
message
=
"是否分页不能为空"
)
public
Boolean
page
;
public
Boolean
page
;
@ApiModelProperty
(
value
=
"限制类型:DAY 按天,MONTH 按月"
,
required
=
true
)
@NotNull
(
message
=
"限制类型不能为空"
)
public
String
reqType
;
@ApiModelProperty
(
value
=
"文件id"
,
required
=
true
)
@NotNull
(
message
=
"文件id不能为空"
)
public
Long
fileId
;
@ApiModelProperty
(
value
=
"限制次数"
,
required
=
true
)
public
Long
reqFrequency
;
@ApiModelProperty
(
value
=
"请求地址"
,
required
=
false
)
@ApiModelProperty
(
value
=
"请求地址"
,
required
=
false
)
public
String
apiPath
;
public
String
apiPath
;
...
@@ -74,9 +85,7 @@ public class MakeDataBankApiReq implements Serializable {
...
@@ -74,9 +85,7 @@ public class MakeDataBankApiReq implements Serializable {
@ApiModelProperty
(
value
=
"api样例"
,
required
=
false
)
@ApiModelProperty
(
value
=
"api样例"
,
required
=
false
)
public
String
apiExample
;
public
String
apiExample
;
@ApiModelProperty
(
value
=
"文件id"
,
required
=
false
)
//@NotNull(message = "文件id不能为空")
public
Long
fileId
;
//-------------------------前端无效传参----------------------
//-------------------------前端无效传参----------------------
//@ApiModelProperty(value = "状态",hidden = true)
//@ApiModelProperty(value = "状态",hidden = true)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/AuthService.java
View file @
0717005a
...
@@ -63,4 +63,11 @@ public interface AuthService {
...
@@ -63,4 +63,11 @@ public interface AuthService {
* @return
* @return
*/
*/
ApiAuth
getAuthUser
(
String
authCode
,
Long
apiId
);
ApiAuth
getAuthUser
(
String
authCode
,
Long
apiId
);
/**
* 获取API授权信息
* @param authCode
* @return
*/
ApiAuth
getAuthInfo
(
String
authCode
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
View file @
0717005a
package
com
.
jz
.
dm
.
service
.
impl
;
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiAuthMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.mapper.ApiInterfaceMapper
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiAuth
;
...
@@ -69,6 +70,7 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
...
@@ -69,6 +70,7 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
public
ApiInterface
getReqTargetInfo
(
String
apiKey
)
{
public
ApiInterface
getReqTargetInfo
(
String
apiKey
)
{
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterface
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"api_key"
,
apiKey
);
query
.
eq
(
"api_key"
,
apiKey
);
query
.
eq
(
"status"
,
ApiStatusEnum
.
ISSUE
.
name
());
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiInterfaceMapper
.
selectOne
(
query
);
return
apiInterfaceMapper
.
selectOne
(
query
);
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiLogServiceImpl.java
View file @
0717005a
package
com
.
jz
.
dm
.
service
.
impl
;
package
com
.
jz
.
dm
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.enums.GeneralStatusTypeEnum
;
import
com.jz.dm.config.ReentrantRedisLock
;
import
com.jz.dm.config.ReentrantRedisLock
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.models.domian.ApiReqLog
;
...
@@ -78,16 +80,23 @@ public class ApiLogServiceImpl implements ApiLogService {
...
@@ -78,16 +80,23 @@ public class ApiLogServiceImpl implements ApiLogService {
@Override
@Override
public
void
updateLog
(
Long
id
,
JSONObject
jsonObject
)
{
public
void
updateLog
(
Long
id
,
JSONObject
jsonObject
)
{
try
{
try
{
ApiReqLog
apiReqLog
=
apiReqLogMapper
.
maxId
(
id
);
/*ApiReqLog apiReqLog = apiReqLogMapper.maxId(id);*/
ApiReqLog
apiReqLog
=
apiReqLogMapper
.
selectById
(
id
);
if
(
null
!=
apiReqLog
){
if
(
null
!=
apiReqLog
){
ApiReqLog
reqLog
=
new
ApiReqLog
();
UpdateWrapper
<
ApiReqLog
>
update
=
new
UpdateWrapper
<>();
reqLog
.
setId
(
apiReqLog
.
getId
());
if
(
200
==
jsonObject
.
getInt
(
"code"
)){
reqLog
.
setStatus
(
apiReqLog
.
getStatus
());
update
.
set
(
"status"
,
GeneralStatusTypeEnum
.
SUCCEED
);
reqLog
.
setResponseParams
(
jsonObject
.
toString
());
}
else
{
reqLog
.
setUpdateDate
(
new
Date
());
update
.
set
(
"status"
,
GeneralStatusTypeEnum
.
FAIL
);
apiReqLogMapper
.
updateById
(
reqLog
);
}
update
.
set
(
"response_params"
,
jsonObject
.
toString
());
update
.
set
(
"update_date"
,
new
Date
());
update
.
eq
(
"id"
,
id
);
if
(
apiReqLogMapper
.
update
(
null
,
update
)
==
0
){
log
.
info
(
"~~~~~~~~~~~更新日志信息失败~~~~~~~~"
);
}
}
else
{
}
else
{
log
.
info
(
"id为:{}"
,
id
+
"--------------
---
日志信息不存在"
);
log
.
info
(
"id为:{}"
,
id
+
"--------------日志信息不存在"
);
}
}
}
catch
(
Exception
ex
){
}
catch
(
Exception
ex
){
log
.
error
(
"更新日志返回信息异常:{}"
,
ex
.
getMessage
());
log
.
error
(
"更新日志返回信息异常:{}"
,
ex
.
getMessage
());
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
0717005a
...
@@ -189,6 +189,8 @@ public class AuthServiceImpl implements AuthService {
...
@@ -189,6 +189,8 @@ public class AuthServiceImpl implements AuthService {
ApiAuth
apiAuth
=
new
ApiAuth
();
ApiAuth
apiAuth
=
new
ApiAuth
();
apiAuth
.
setApiInterfaceId
(
apiInterface
.
getId
());
apiAuth
.
setApiInterfaceId
(
apiInterface
.
getId
());
apiAuth
.
setApiOrgId
(
apiOrg
.
getId
());
apiAuth
.
setApiOrgId
(
apiOrg
.
getId
());
apiAuth
.
setReqType
(
apiInterface
.
getReqType
());
apiAuth
.
setReqFrequency
(
apiInterface
.
getReqFrequency
());
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
BeanUtils
.
copyProperties
(
req
,
apiAuth
);
//商城只有外部授权
//商城只有外部授权
String
authCode
=
""
;
String
authCode
=
""
;
...
@@ -274,8 +276,8 @@ public class AuthServiceImpl implements AuthService {
...
@@ -274,8 +276,8 @@ public class AuthServiceImpl implements AuthService {
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
String
salt
=
RandomUtil
.
getStringRandom
(
8
);
UpdateWrapper
<
ApiAuth
>
update
=
new
UpdateWrapper
<>();
UpdateWrapper
<
ApiAuth
>
update
=
new
UpdateWrapper
<>();
update
.
set
(
"salt"
,
salt
);
update
.
set
(
"salt"
,
salt
);
update
.
set
(
"
cre
ate_date"
,
new
Date
());
update
.
set
(
"
upd
ate_date"
,
new
Date
());
update
.
set
(
"
cre
ate_user"
,
""
);
update
.
set
(
"
upd
ate_user"
,
""
);
update
.
eq
(
"id"
,
apiAuth
.
getId
());
update
.
eq
(
"id"
,
apiAuth
.
getId
());
if
(
apiAuthMapper
.
update
(
null
,
update
)
>
0
)
{
if
(
apiAuthMapper
.
update
(
null
,
update
)
>
0
)
{
response
.
setSalt
(
salt
);
response
.
setSalt
(
salt
);
...
@@ -299,6 +301,18 @@ public class AuthServiceImpl implements AuthService {
...
@@ -299,6 +301,18 @@ public class AuthServiceImpl implements AuthService {
query
.
eq
(
"is_deleted"
,
0
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiAuthMapper
.
selectOne
(
query
);
return
apiAuthMapper
.
selectOne
(
query
);
}
}
/**
* 获取API授权信息
* @param authCode
* @return
*/
@Override
public
ApiAuth
getAuthInfo
(
String
authCode
)
{
QueryWrapper
<
ApiAuth
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"auth_code"
,
authCode
);
query
.
eq
(
"is_deleted"
,
0
);
return
apiAuthMapper
.
selectOne
(
query
);
}
private
ApiInterface
getInterface
(
String
apiKey
)
{
private
ApiInterface
getInterface
(
String
apiKey
)
{
QueryWrapper
<
ApiInterface
>
queryInface
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterface
>
queryInface
=
new
QueryWrapper
<>();
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
0717005a
...
@@ -38,6 +38,7 @@ import javax.annotation.Resource;
...
@@ -38,6 +38,7 @@ import javax.annotation.Resource;
import
java.util.*
;
import
java.util.*
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
apiInterface
.
ApiStatusEnum
.
fromApiStatusName
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
apiInterface
.
ApiStatusEnum
.
fromApiStatusName
;
import
static
com
.
jz
.
dm
.
common
.
enums
.
auth
.
AuthReqTypeEnum
.
fromAuthReqTypeEnum
;
/**
/**
* @author ZC
* @author ZC
...
@@ -133,6 +134,11 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -133,6 +134,11 @@ public class ProducerServiceImpl implements ProducerService {
!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
FLOW
.
name
())
)){
!
req
.
getOutputType
().
contains
(
ApiInfoOutTypeEnum
.
FLOW
.
name
())
)){
return
Result
.
of_error
(
"输出类型不存在!"
);
return
Result
.
of_error
(
"输出类型不存在!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getReqType
())
){
if
(
null
==
fromAuthReqTypeEnum
(
req
.
getReqType
())){
return
Result
.
of_error
(
"限制类型不存在!"
);
}
}
String
apiKey
=
""
;
String
apiKey
=
""
;
if
(
StringUtils
.
isNotBlank
(
req
.
getJoinType
())
if
(
StringUtils
.
isNotBlank
(
req
.
getJoinType
())
&&
"10006"
.
equals
(
req
.
getJoinType
()))
{
//数据银行制作API
&&
"10006"
.
equals
(
req
.
getJoinType
()))
{
//数据银行制作API
...
@@ -263,6 +269,11 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -263,6 +269,11 @@ public class ProducerServiceImpl implements ProducerService {
if
(
null
==
currentUser
)
{
if
(
null
==
currentUser
)
{
return
Result
.
of_error
(
"用户信息不存在"
);
return
Result
.
of_error
(
"用户信息不存在"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getReqType
())
){
if
(
null
==
fromAuthReqTypeEnum
(
req
.
getReqType
())){
return
Result
.
of_error
(
"限制类型不存在!"
);
}
}
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
QueryWrapper
<
ApiInterfaceFile
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"project_id"
,
req
.
getProjectId
());
query
.
eq
(
"project_id"
,
req
.
getProjectId
());
query
.
eq
(
"parent_id"
,
req
.
getParentId
());
query
.
eq
(
"parent_id"
,
req
.
getParentId
());
...
@@ -329,6 +340,11 @@ public class ProducerServiceImpl implements ProducerService {
...
@@ -329,6 +340,11 @@ public class ProducerServiceImpl implements ProducerService {
if
(
StringUtils
.
isBlank
(
req
.
getSignType
())
||
"0"
.
equals
(
req
.
getSignType
()))
{
if
(
StringUtils
.
isBlank
(
req
.
getSignType
())
||
"0"
.
equals
(
req
.
getSignType
()))
{
return
Result
.
of_error
(
"加密类型错误!"
);
return
Result
.
of_error
(
"加密类型错误!"
);
}
}
if
(
StringUtils
.
isNotBlank
(
req
.
getReqType
())
){
if
(
null
==
fromAuthReqTypeEnum
(
req
.
getReqType
())){
return
Result
.
of_error
(
"限制类型不存在!"
);
}
}
apiInterface
.
setApiType
(
req
.
getApiType
());
apiInterface
.
setApiType
(
req
.
getApiType
());
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setApiDesc
(
req
.
getApiDesc
());
apiInterface
.
setJoinType
(
req
.
getJoinType
());
apiInterface
.
setJoinType
(
req
.
getJoinType
());
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiParamVerify.java
0 → 100644
View file @
0717005a
package
com
.
jz
.
dm
.
service
.
request
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.utils.Result
;
import
com.jz.dm.common.enums.GeneralStatusTypeEnum
;
import
com.jz.dm.common.enums.apiInterface.ApiStatusEnum
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.models.domian.ApiAuth
;
import
com.jz.dm.models.domian.ApiInterface
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.service.request
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiParamVerify
* @DATE: 2021-1-9/15:53
* @DAY_NAME_SHORT: 周六
* @Description: api参数验证
**/
public
class
ApiParamVerify
{
/**
* 校验Api信息
* @param apiInterface
* @return
*/
public
Result
verifyApiInterface
(
ApiInterface
apiInterface
){
if
(
null
==
apiInterface
){
throw
new
GatewayException
(
"300"
,
ResultMsg
.
DATA_NOT_FOUND
.
getMsg
());
}
if
(!
ApiStatusEnum
.
ISSUE
.
name
().
equals
(
apiInterface
.
getStatus
())){
throw
new
GatewayException
(
"300"
,
"API未发布!"
);
}
if
(
1
==
apiInterface
.
getIsDeleted
()){
throw
new
GatewayException
(
"300"
,
"API不存在!"
);
}
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
}
/**
* 校验授权
* @param apiAuth
* @return
*/
public
Result
verifyAuth
(
ApiAuth
apiAuth
){
if
(
null
==
apiAuth
){
throw
new
GatewayException
(
"300"
,
ResultMsg
.
DATA_NOT_FOUND
.
getMsg
());
}
if
(!
GeneralStatusTypeEnum
.
VALID
.
name
().
equals
(
apiAuth
.
getStatus
())){
throw
new
GatewayException
(
"300"
,
"无效授权!"
);
}
if
(
1
==
apiAuth
.
getIsDeleted
()){
throw
new
GatewayException
(
"300"
,
"授权信息无效!"
);
}
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/service/request/ApiQueryService.java
View file @
0717005a
package
com
.
jz
.
dm
.
service
.
request
;
package
com
.
jz
.
dm
.
service
.
request
;
import
com.alibaba.csp.sentinel.annotation.SentinelResource
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
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.LoggingConstants
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.enums.apiInterface.ApiInfoOutTypeEnum
;
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.exception.GatewayException
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiRequest
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.OpenApiResponse
;
import
com.jz.dm.common.util.stream.HttpDownload
;
import
com.jz.dm.gateway.OpenApiService
;
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.ApiInterface
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.ApiInterfaceService
;
import
com.jz.dm.service.AuthService
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
com.jz.dm.web.annotation.ApiLogAspect
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -33,7 +40,8 @@ import java.util.Map;
...
@@ -33,7 +40,8 @@ import java.util.Map;
**/
**/
@Service
(
"apiQueryService"
)
@Service
(
"apiQueryService"
)
@Slf4j
@Slf4j
public
class
ApiQueryService
implements
OpenApiService
{
public
class
ApiQueryService
extends
ApiParamVerify
implements
OpenApiService
{
@Override
@Override
public
String
getOpenApiMethod
()
{
public
String
getOpenApiMethod
()
{
return
"query"
;
return
"query"
;
...
@@ -47,112 +55,155 @@ public class ApiQueryService implements OpenApiService {
...
@@ -47,112 +55,155 @@ public class ApiQueryService implements OpenApiService {
@Autowired
@Autowired
private
ApiInterfaceService
apiInterfaceService
;
private
ApiInterfaceService
apiInterfaceService
;
@Autowired
@Autowired
private
AuthService
authService
;
@Autowired
private
RedisUtils
redisUtils
;
private
RedisUtils
redisUtils
;
@Autowired
@Autowired
private
HttpsUtils
httpsUtils
;
private
HttpsUtils
httpsUtils
;
@Value
(
"${data.bank.withholdUrl}"
)
private
String
withholdUrl
;
/**
* API请求逻辑处理
*
* @param request
* @param response
*/
@Override
@Override
@ApiLogAspect
(
description
=
"API请求日志"
)
@ApiLogAspect
(
description
=
"API请求日志"
)
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@AccessLimit
(
limit
=
10000
,
sec
=
1
)
@SentinelResource
(
value
=
"api.gateway"
,
fallback
=
"fallbackGateway"
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRES_NEW
)
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
public
void
doService
(
OpenApiRequest
request
,
OpenApiResponse
response
)
{
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getOpenApiParams
());
JSONObject
parameter
=
JSONObject
.
parseObject
(
request
.
getOpenApiParams
());
String
selectType
=
parameter
.
getString
(
"selectType"
);
String
authCode
=
parameter
.
getString
(
"authCode"
);
if
(
StringUtils
.
isBlank
(
authCode
))
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
verifyApiInterface
(
apiInterfaceService
.
getApiInfo
(
request
.
getApiKey
()));
ApiAuth
apiAuth
=
authService
.
getAuthInfo
(
authCode
);
verifyAuth
(
apiAuth
);
String
reqParams
=
parameter
.
getString
(
"reqParams"
);
String
reqParams
=
parameter
.
getString
(
"reqParams"
);
Map
paramMap
=
null
;
Map
paramMap
=
null
;
if
(
null
!=
reqParams
&&
reqParams
.
length
()
>
0
)
{
if
(
StringUtils
.
isNotBlank
(
reqParams
)
)
{
paramMap
=
(
Map
)
JSONObject
.
parseObject
(
reqParams
);
paramMap
=
(
Map
)
JSONObject
.
parseObject
(
reqParams
);
}
}
String
apiInterface
=
redisUtils
.
get
(
request
.
getApiKey
());
//取出缓存数据
if
(
StringUtils
.
isNotBlank
(
selectType
))
{
String
redisReqParam
=
redisUtils
.
get
(
request
.
getApiKey
());
try
{
boolean
bResult
=
false
;
switch
(
selectType
)
{
try
{
case
"10001"
:
//实时接入查询
if
(
StringUtils
.
isNotBlank
(
redisReqParam
))
{
//redis中存在
break
;
//解析出API制作成功时的参数配置
case
"10003"
:
//标签查询
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
redisReqParam
);
break
;
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
case
"10002"
:
//大数据查询
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
if
(
StringUtils
.
isNotBlank
(
apiInterface
)){
//redis中存在
bResult
=
rangRequestTarget
(
outputType
,
targetUrl
,
paramMap
,
response
);
JSONObject
jsonBigData
=
JSONObject
.
parseObject
(
apiInterface
);
}
else
{
//不存在查询数据库
String
targetUrl
=
jsonBigData
.
getString
(
"targetUrl"
);
ApiInterface
apiInterface
=
rangRequestTarget
(
ApiInfoOutTypeEnum
.
JSON
.
name
(),
targetUrl
,
paramMap
,
response
);
apiInterfaceService
.
getReqTargetInfo
(
request
.
getApiKey
());
}
else
{
//缓存中不存在 查询数据库
if
(
null
==
apiInterface
)
{
ApiInterface
apiInfo
=
apiInterfaceService
.
getApiInfo
(
request
.
getApiKey
());
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
if
(
apiInfo
==
null
){
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
}
rangRequestTarget
(
ApiInfoOutTypeEnum
.
JSON
.
name
(),
apiInfo
.
getTargetUrl
(),
paramMap
,
response
);
}
break
;
case
"10004"
:
//自定义查询(三方查询)
if
(
StringUtils
.
isNotBlank
(
apiInterface
)){
//redis中存在
JSONObject
jsonCustom
=
JSONObject
.
parseObject
(
apiInterface
);
String
targetUrl
=
jsonCustom
.
getString
(
"targetUrl"
);
rangRequestTarget
(
ApiInfoOutTypeEnum
.
JSON
.
name
(),
targetUrl
,
null
,
response
);
}
else
{
//redis中不存在,查询数据库
ApiInterface
apiReqDto
=
apiInterfaceService
.
getReqTargetInfo
(
request
.
getApiKey
());
if
(
null
==
apiReqDto
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
}
rangRequestTarget
(
ApiInfoOutTypeEnum
.
JSON
.
name
(),
apiReqDto
.
getTargetUrl
(),
null
,
response
);
}
break
;
case
"10006"
:
//数据银行查询
if
(
StringUtils
.
isNotBlank
(
apiInterface
))
{
//redis中存在
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
apiInterface
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
rangRequestTarget
(
outputType
,
targetUrl
,
paramMap
,
response
);
}
else
{
//不存在查询数据库
ApiInterface
apiReqDto
=
apiInterfaceService
.
getReqTargetInfo
(
request
.
getApiKey
());
if
(
null
==
apiReqDto
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
}
rangRequestTarget
(
apiReqDto
.
getOutputType
(),
apiReqDto
.
getTargetUrl
(),
paramMap
,
response
);
}
break
;
case
"10007"
:
//数据银行数据包查询
if
(
StringUtils
.
isNotBlank
(
apiInterface
)){
//从redis中获取数据
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
apiInterface
);
String
targetUrl
=
jsonObject
.
getString
(
"targetUrl"
);
String
outputType
=
jsonObject
.
getString
(
"outputType"
);
rangRequestTarget
(
outputType
,
targetUrl
,
paramMap
,
response
);
}
else
{
//不存在查询数据库
ApiInterface
apiReqDto
=
apiInterfaceService
.
getReqTargetInfo
(
request
.
getApiKey
());
if
(
null
==
apiReqDto
)
{
throw
new
GatewayException
(
GatewayResultCode
.
REQUEST_INFO_UNEXIST
);
}
rangRequestTarget
(
apiReqDto
.
getOutputType
(),
apiReqDto
.
getTargetUrl
(),
paramMap
,
response
);
}
break
;
default
:
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
}
catch
(
Exception
ex
)
{
if
(
ex
instanceof
GatewayException
){
throw
(
GatewayException
)
ex
;
}
}
log
.
error
(
"~~~~~~~~~~~~~~~请求api信息异常~~~~~~~~~~~~~"
);
bResult
=
rangRequestTarget
(
apiInterface
.
getOutputType
(),
apiInterface
.
getTargetUrl
(),
paramMap
,
response
);
log
.
error
(
"异常信息:{}"
,
ex
.
getMessage
());
}
response
.
setCode
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getCode
());
//调用成功请求数据银行扣款
response
.
setMsg
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getMsg
());
if
(
AuthModeEnum
.
POWER_CALL_MODE
.
name
().
equals
(
apiAuth
.
getAuthMode
())){
notifierMinusMoney
(
parameter
,
bResult
);
}
}
}
catch
(
Exception
ex
)
{
if
(
ex
instanceof
GatewayException
)
{
throw
(
GatewayException
)
ex
;
}
log
.
error
(
"~~~~~~~~~~~~~~~请求api信息异常~~~~~~~~~~~~~"
);
log
.
error
(
"异常信息:{}"
,
ex
.
getMessage
());
response
.
setCode
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
ILLEGAL_REQUEST
.
getMsg
());
}
}
}
}
private
void
rangRequestTarget
(
String
outputType
,
String
targetUrl
,
Map
<
String
,
String
>
param
,
OpenApiResponse
response
)
{
/**
* 远程请求获取数据
*
* @param outputType
* @param targetUrl
* @param param
* @param response
*/
private
boolean
rangRequestTarget
(
String
outputType
,
String
targetUrl
,
Map
<
String
,
String
>
param
,
OpenApiResponse
response
)
{
if
(
StringUtils
.
isBlank
(
outputType
))
{
outputType
=
ApiInfoOutTypeEnum
.
JSON
.
name
();
}
if
(
StringUtils
.
isBlank
(
targetUrl
))
{
throw
new
GatewayException
(
GatewayResultCode
.
ILLEGAL_REQUEST
);
}
if
(
ApiInfoOutTypeEnum
.
FLOW
.
name
().
equals
(
outputType
))
{
//文件流形式请求
if
(
ApiInfoOutTypeEnum
.
FLOW
.
name
().
equals
(
outputType
))
{
//文件流形式请求
// httpsUtils.doGetImg()TODO 流形式未实现
StringBuilder
builder
=
new
StringBuilder
();
}
else
if
(
ApiInfoOutTypeEnum
.
JSON
.
name
().
equals
(
outputType
))
{
builder
.
append
(
targetUrl
).
append
(
"?"
);
for
(
Map
.
Entry
<
String
,
String
>
entry
:
param
.
entrySet
())
{
String
key
=
entry
.
getKey
();
String
value
=
entry
.
getValue
();
builder
.
append
(
key
).
append
(
LoggingConstants
.
AND_EQUAL
)
.
append
(
value
).
append
(
LoggingConstants
.
AND_SPILT
);
}
String
baseUrl
=
builder
.
substring
(
0
,
builder
.
length
()
-
1
);
HttpDownload
.
download
(
baseUrl
);
response
.
setCode
(
GatewayResultCode
.
SUCCESS
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
SUCCESS
.
getMsg
());
return
true
;
}
else
if
(
ApiInfoOutTypeEnum
.
JSON
.
name
().
equals
(
outputType
))
{
//json格式请求
response
.
setAttribute
(
"调用成功!"
);
response
.
setAttribute
(
"调用成功!"
);
/*String respResult = httpsUtils.doGet(targetUrl, param);
String
respResult
=
httpsUtils
.
doGet
(
targetUrl
,
param
);
response.setAttribute(respResult);*/
JSONObject
resp
=
JSONObject
.
parseObject
(
respResult
);
if
(
null
!=
resp
&&
200
==
resp
.
getInteger
(
"code"
))
{
response
.
setCode
(
GatewayResultCode
.
SUCCESS
.
getCode
());
response
.
setMsg
(
GatewayResultCode
.
SUCCESS
.
getMsg
());
response
.
setAttribute
(
resp
.
getString
(
"data"
));
return
true
;
}
else
{
log
.
error
(
"~~~~~~~~~~~~~~~~远程请求异常~~~~~~~~~~~~~~~~~"
);
throw
new
GatewayException
(
GatewayResultCode
.
DISTANCE_REQUEST_EXCEPTION
);
}
}
else
{
}
else
{
throw
new
GatewayException
(
GatewayResultCode
.
OUTPUT_TYPE_EXCEPTION
);
throw
new
GatewayException
(
GatewayResultCode
.
OUTPUT_TYPE_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
);
//调用成功 扣款 false 调用失败,解冻金额
String
responseResult
=
httpsUtils
.
submitPost
(
withholdUrl
,
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
);
}
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/web/aspect/SystemLogAspect.java
View file @
0717005a
...
@@ -4,7 +4,6 @@ package com.jz.dm.web.aspect;
...
@@ -4,7 +4,6 @@ package com.jz.dm.web.aspect;
import
com.jz.common.utils.IpUtils
;
import
com.jz.common.utils.IpUtils
;
import
com.jz.common.utils.JsonUtils
;
import
com.jz.common.utils.JsonUtils
;
import
com.jz.common.utils.UrlUtil
;
import
com.jz.common.utils.UrlUtil
;
import
com.jz.dm.common.enums.SignType
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.mapper.ApiReqLogMapper
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.models.domian.ApiReqLog
;
import
com.jz.dm.service.ApiLogService
;
import
com.jz.dm.service.ApiLogService
;
...
@@ -17,7 +16,9 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -17,7 +16,9 @@ import lombok.extern.slf4j.Slf4j;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.*
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
...
@@ -36,7 +37,7 @@ import java.util.Map;
...
@@ -36,7 +37,7 @@ import java.util.Map;
* @NAME: SystemLogAspect
* @NAME: SystemLogAspect
* @DATE: 2020-12-25/16:03
* @DATE: 2020-12-25/16:03
* @DAY_NAME_SHORT: 周五
* @DAY_NAME_SHORT: 周五
* @Description:
* @Description:
日志收集
**/
**/
@Aspect
@Aspect
...
@@ -85,28 +86,30 @@ public class SystemLogAspect {
...
@@ -85,28 +86,30 @@ public class SystemLogAspect {
log
.
info
(
"around请求参数为{}"
,
joinPoint
.
getArgs
());
log
.
info
(
"around请求参数为{}"
,
joinPoint
.
getArgs
());
//动态修改其参数
//动态修改其参数
//注意,如果调用joinPoint.proceed()方法,则修改的参数值不会生效,必须调用joinPoint.proceed(Object[] args)
//注意,如果调用joinPoint.proceed()方法,则修改的参数值不会生效,必须调用joinPoint.proceed(Object[] args)
com
.
alibaba
.
fastjson
.
JSONObject
jsonObject
=
com
.
alibaba
.
fastjson
.
JSONObject
.
parseObject
(
params
);
String
paramsList
=
jsonObject
.
getString
(
"params"
);
com
.
alibaba
.
fastjson
.
JSONObject
jsonParamsList
=
com
.
alibaba
.
fastjson
.
JSONObject
.
parseObject
(
paramsList
);
try
{
try
{
ApiReqLog
reqLog
=
new
ApiReqLog
();
ApiReqLog
reqLog
=
new
ApiReqLog
();
reqLog
.
setRequestIp
(
ip
);
reqLog
.
setRequestIp
(
ip
);
//
reqLog.setApiKey(jsonObject.getString("apiKey"));
reqLog
.
setApiKey
(
jsonObject
.
getString
(
"apiKey"
));
reqLog
.
setRequestParams
(
params
);
reqLog
.
setRequestParams
(
params
);
reqLog
.
setResponseParams
(
""
);
//响应参数
reqLog
.
setResponseParams
(
""
);
//响应参数
reqLog
.
setRequestUrl
(
url
);
reqLog
.
setRequestUrl
(
url
);
reqLog
.
setRequestMethod
(
contextPath
);
reqLog
.
setRequestMethod
(
contextPath
);
reqLog
.
setEncryMode
(
SignType
.
MD5
.
name
(
));
//加密方式:MD5,RSA
reqLog
.
setEncryMode
(
jsonObject
.
getString
(
"signType"
));
//加密方式:MD5,RSA
reqLog
.
setTransMode
(
request
.
getMethod
());
//传输方式 GET POST
reqLog
.
setTransMode
(
request
.
getMethod
());
//传输方式 GET POST
// reqLog.setRequestToken(token
);
reqLog
.
setRequestToken
(
jsonParamsList
.
getString
(
"authCode"
)
);
reqLog
.
setRequestTime
(
new
Date
());
reqLog
.
setRequestTime
(
new
Date
());
reqLog
.
setRemark
(
getServiceMethodDescription
(
joinPoint
));
reqLog
.
setRemark
(
getServiceMethodDescription
(
joinPoint
));
System
.
out
.
println
(
reqLog
);
log
.
info
(
"请求参数:"
,
reqLog
);
if
(
null
!=
reqLog
)
{
if
(
null
!=
reqLog
)
{
apiReqLogMapper
.
insert
(
reqLog
);
apiReqLogMapper
.
insert
(
reqLog
);
}
}
Object
result
=
joinPoint
.
proceed
(
joinPoint
.
getArgs
());
Object
result
=
joinPoint
.
proceed
(
joinPoint
.
getArgs
());
JSONObject
json
Objec
t
=
JSONObject
.
fromObject
(
result
);
JSONObject
json
Resul
t
=
JSONObject
.
fromObject
(
result
);
log
.
info
(
"around响应结果为{}"
,
json
Objec
t
);
log
.
info
(
"around响应结果为{}"
,
json
Resul
t
);
apiLogService
.
updateLog
(
reqLog
.
getId
(),
json
Objec
t
);
apiLogService
.
updateLog
(
reqLog
.
getId
(),
json
Resul
t
);
}
catch
(
Throwable
throwable
)
{
}
catch
(
Throwable
throwable
)
{
throwable
.
printStackTrace
();
throwable
.
printStackTrace
();
}
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/web/interceptor/AccessLimitInterceptor.java
View file @
0717005a
package
com
.
jz
.
dm
.
web
.
interceptor
;
package
com
.
jz
.
dm
.
web
.
interceptor
;
import
com.jz.common.utils.IpUtils
;
import
com.jz.common.utils.IpUtils
;
import
com.jz.common.utils.RedisUtils
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
com.jz.dm.web.annotation.AccessLimit
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
...
@@ -19,13 +21,12 @@ import java.lang.reflect.Method;
...
@@ -19,13 +21,12 @@ import java.lang.reflect.Method;
* @NAME: AccessLimitInterceptor
* @NAME: AccessLimitInterceptor
* @DATE: 2020-12-26/17:39
* @DATE: 2020-12-26/17:39
* @DAY_NAME_SHORT: 周六
* @DAY_NAME_SHORT: 周六
* @Description:
* @Description:
使用redis限流
**/
**/
public
class
AccessLimitInterceptor
implements
HandlerInterceptor
{
public
class
AccessLimitInterceptor
implements
HandlerInterceptor
{
//使用RedisTemplate操作redis
@Autowired
/* @Autowired
private
RedisUtils
redisUtils
;
private RedisTemplate<String, Integer> redisTemplate;*/
@Override
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
public
boolean
preHandle
(
HttpServletRequest
request
,
...
@@ -44,16 +45,17 @@ public class AccessLimitInterceptor implements HandlerInterceptor {
...
@@ -44,16 +45,17 @@ public class AccessLimitInterceptor implements HandlerInterceptor {
int
limit
=
accessLimit
.
limit
();
int
limit
=
accessLimit
.
limit
();
int
sec
=
accessLimit
.
sec
();
int
sec
=
accessLimit
.
sec
();
String
key
=
IpUtils
.
getIpAddr
(
request
)
+
request
.
getRequestURI
();
String
key
=
IpUtils
.
getIpAddr
(
request
)
+
request
.
getRequestURI
();
/*Integer maxLimit = redisTemplate.opsForValue().get(key);
String
result
=
redisUtils
.
get
(
key
);
Integer
maxLimit
=
Integer
.
valueOf
(
result
);
if
(
maxLimit
==
null
)
{
if
(
maxLimit
==
null
)
{
//set时一定要加过期时间
//set时一定要加过期时间
redis
Template.opsForValue().set(key, 1, sec, TimeUnit.SECONDS
);
redis
Utils
.
set
(
key
,
1
,
sec
);
}
else
if
(
maxLimit
<
limit
)
{
}
else
if
(
maxLimit
<
limit
)
{
redis
Template.opsForValue().set(key, maxLimit + 1, sec, TimeUnit.SECONDS
);
redis
Utils
.
set
(
key
,
maxLimit
+
1
,
sec
);
}
else
{
}
else
{
output
(
response
,
"请求太频繁~!"
);
output
(
response
,
"请求太频繁~!"
);
return
false
;
return
false
;
}
*/
}
}
}
return
true
;
return
true
;
}
}
...
...
jz-dm-apigateway/src/main/resources/application-test.yml
View file @
0717005a
...
@@ -77,6 +77,22 @@ dmp:
...
@@ -77,6 +77,22 @@ dmp:
timeout
:
timeout
:
default
:
5000
default
:
5000
max
:
5000
max
:
5000
request
:
#api请求次数
limit
:
#流处理配置
max
:
10
windows
:
#文件流输出地址设置
name
:
stream
isWindows
:
true
#sentinel限流配置
sentinel
:
#sentinel每秒中最大的请求个数
resource
:
api.gateway
request
:
max
:
100
#数据银行调用配置
data
:
bank
:
balanceUrl
:
http://localhost:8081/mall/financeCustomerAssets/findAssets
#余额信息url
withholdUrl
:
http://localhost:8081/mall/financeCustomerAssets/unfreezeMoney
#扣款信通知url
jz-dm-apigateway/src/main/resources/application.yml
View file @
0717005a
...
@@ -19,7 +19,21 @@ spring:
...
@@ -19,7 +19,21 @@ spring:
max-request-size
:
50MB
max-request-size
:
50MB
profiles
:
profiles
:
active
:
test
#默认使用的配置文件
active
:
test
#默认使用的配置文件
cloud
:
sentinel
:
#sentinel 限流框架配置
transport
:
# 项目本地会启动一个服务的端口号,默认8719,用于与sentinel-dashboard通讯
port
:
8719
# sentinel-dashboard服务地址 # sentinel-dashboard-1.6.0 的访问路径 ,启动方式java -jar sentinel-dashboard-1.6.0.jar
dashboard
:
localhost:9090
filter
:
# 需要进行限流监控的接口,多个匹配用逗号隔开
url-patterns
:
/*
servlet
:
# 触发限流后重定向的页面
block-page
:
/sentinel/block
#取消Sentinel控制台懒加载
#eager: true
# ====================MybatisPlus====================
# ====================MybatisPlus====================
mybatis-plus
:
mybatis-plus
:
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/api/ApiReqTest.java
0 → 100644
View file @
0717005a
package
com
.
jz
.
dm
.
gateway
.
api
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.dm.common.util.MapUtil
;
import
com.jz.dm.common.util.Md5
;
import
com.jz.dm.gateway.SpringTestCase
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.gateway.api
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiReqTest
* @DATE: 2021-1-6/14:13
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public
class
ApiReqTest
extends
SpringTestCase
{
public
static
final
String
url
=
""
;
@Autowired
private
HttpsUtils
httpsUtils
;
@Test
public
void
TestGatewayReq
()
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"apiKey"
,
"9jNA1W5Ydn7Stp12"
);
jsonObject
.
put
(
"method"
,
"query"
);
jsonObject
.
put
(
"signType"
,
"MD5"
);
long
time
=
System
.
currentTimeMillis
();
jsonObject
.
put
(
"timestamp"
,
"1609919983045"
);
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"authCode"
,
"20200000000221231111455Jg8ug1621"
);
params
.
put
(
"selectType"
,
"10006"
);
params
.
put
(
"reqParams"
,
new
JSONObject
());
jsonObject
.
put
(
"params"
,
params
);
try
{
String
apiKey
=
jsonObject
.
getString
(
"apiKey"
);
String
method
=
jsonObject
.
getString
(
"method"
);
String
signType
=
jsonObject
.
getString
(
"signType"
);
String
timestamp
=
jsonObject
.
getString
(
"timestamp"
);
String
signature
=
MapUtil
.
getSignValue
(
apiKey
,
method
,
signType
,
timestamp
);
String
salt
=
Md5
.
encrypt
(
signature
,
"OOmeF1gh"
);
jsonObject
.
put
(
"sign"
,
salt
);
String
response
=
httpsUtils
.
submitPost
(
url
,
jsonObject
.
toString
());
System
.
out
.
println
(
response
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/org/TestOrganizationManage.java
View file @
0717005a
...
@@ -10,7 +10,6 @@ import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
...
@@ -10,7 +10,6 @@ import com.jz.dm.models.req.organizationManage.OrganizationManageDetailQueryReq;
import
com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageListQueryReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq
;
import
com.jz.dm.models.req.organizationManage.OrganizationManageUpdateReq
;
import
com.jz.dm.service.OrganizationManageService
;
import
com.jz.dm.service.OrganizationManageService
;
import
org.junit.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
/**
...
@@ -30,7 +29,7 @@ public class TestOrganizationManage extends SpringTestCase {
...
@@ -30,7 +29,7 @@ public class TestOrganizationManage extends SpringTestCase {
/**
/**
* 查询类列表信息
* 查询类列表信息
*/
*/
@Test
//
@Test
public
void
getOrgList
(){
public
void
getOrgList
(){
OrganizationManageListQueryReq
req
=
new
OrganizationManageListQueryReq
();
OrganizationManageListQueryReq
req
=
new
OrganizationManageListQueryReq
();
req
.
setPageNum
(
1
);
req
.
setPageNum
(
1
);
...
@@ -41,7 +40,7 @@ public class TestOrganizationManage extends SpringTestCase {
...
@@ -41,7 +40,7 @@ public class TestOrganizationManage extends SpringTestCase {
/**
/**
* 查询详情信息
* 查询详情信息
*/
*/
@Test
//
@Test
public
void
getOrgDetail
(){
public
void
getOrgDetail
(){
OrganizationManageDetailQueryReq
req
=
new
OrganizationManageDetailQueryReq
();
OrganizationManageDetailQueryReq
req
=
new
OrganizationManageDetailQueryReq
();
req
.
setId
(
1L
);
req
.
setId
(
1L
);
...
@@ -52,7 +51,7 @@ public class TestOrganizationManage extends SpringTestCase {
...
@@ -52,7 +51,7 @@ public class TestOrganizationManage extends SpringTestCase {
/**
/**
* 添加组织信息
* 添加组织信息
*/
*/
@Test
//
@Test
public
void
addOrg
(){
public
void
addOrg
(){
OrganizationManageAddReq
req
=
new
OrganizationManageAddReq
();
OrganizationManageAddReq
req
=
new
OrganizationManageAddReq
();
req
.
setOrgName
(
"数据银行"
);
req
.
setOrgName
(
"数据银行"
);
...
@@ -69,7 +68,7 @@ public class TestOrganizationManage extends SpringTestCase {
...
@@ -69,7 +68,7 @@ public class TestOrganizationManage extends SpringTestCase {
/**
/**
* 更新组织信息
* 更新组织信息
*/
*/
@Test
//
@Test
public
void
updateOrg
(){
public
void
updateOrg
(){
OrganizationManageUpdateReq
req
=
new
OrganizationManageUpdateReq
();
OrganizationManageUpdateReq
req
=
new
OrganizationManageUpdateReq
();
req
.
setId
(
8L
);
req
.
setId
(
8L
);
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestAmountCall.java
0 → 100644
View file @
0717005a
package
com
.
jz
.
dm
.
gateway
.
orther
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.dm.common.enums.GatewayResultCode
;
import
com.jz.dm.common.exception.GatewayException
;
import
com.jz.dm.gateway.SpringTestCase
;
import
org.junit.jupiter.api.Test
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.gateway.orther
* @PROJECT_NAME: jz-dm-parent
* @NAME: TestAmountCall
* @DATE: 2021-1-9/15:04
* @DAY_NAME_SHORT: 周六
* @Description:
**/
public
class
TestAmountCall
extends
SpringTestCase
{
private
static
final
String
baseUrl
=
"http://192.168.1.139:8081/mall/financeCustomerAssets/findAssets"
;
private
static
final
String
baseUrl2
=
"http://192.168.1.139:8081/mall/financeCustomerAssets/unfreezeMoney"
;
/* @Autowired
private HttpsUtils httpUtils;*/
@Test
public
void
TestDataBankReq
(){
HttpsUtils
utils
=
new
HttpsUtils
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"assetsId"
,
1
);
jsonObject
.
put
(
"userId"
,
1
);
jsonObject
.
put
(
"dataPrice"
,
"50"
);
String
respResult
=
utils
.
submitPost
(
baseUrl
,
jsonObject
.
toString
());
JSONObject
paramsResult
=
JSONObject
.
parseObject
(
respResult
);
if
(
null
!=
paramsResult
){
Integer
code
=
paramsResult
.
getInteger
(
"code"
);
if
(
200
!=
code
){
System
.
out
.
println
(
"~~~~~~~~~~~~~~~~~~单次调用金额不足~~~~~~~~~~~~~~~"
);
System
.
out
.
println
(
respResult
);
throw
new
GatewayException
(
GatewayResultCode
.
CALL_AMOUNT_NOT_ENOUGH
);
}
else
{
System
.
out
.
println
(
paramsResult
.
getString
(
"message"
));
}
}
}
/**
* 通知扣款
*/
@Test
public
void
notifierDataBankReq
(){
HttpsUtils
utils
=
new
HttpsUtils
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"assetsId"
,
1
);
jsonObject
.
put
(
"userId"
,
1
);
jsonObject
.
put
(
"dataPrice"
,
"50"
);
jsonObject
.
put
(
"callStatus"
,
true
);
//调用成功 扣款 false 调用失败,解冻金额
String
respResult
=
utils
.
submitPost
(
baseUrl2
,
jsonObject
.
toString
());
JSONObject
paramsResult
=
JSONObject
.
parseObject
(
respResult
);
if
(
null
!=
paramsResult
){
Integer
code
=
paramsResult
.
getInteger
(
"code"
);
if
(
200
!=
code
){
System
.
out
.
println
(
"~~~~~~~~~~~~~~~~~~操作失败~~~~~~~~~~~~~~~"
);
System
.
out
.
println
(
respResult
);
throw
new
GatewayException
(
GatewayResultCode
.
CALL_AMOUNT_NOT_ENOUGH
);
}
else
{
System
.
out
.
println
(
paramsResult
.
getString
(
"message"
));
}
}
}
}
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestHttpReq.java
View file @
0717005a
...
@@ -3,7 +3,7 @@ package com.jz.dm.gateway.orther;
...
@@ -3,7 +3,7 @@ package com.jz.dm.gateway.orther;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.gateway.SpringTestCase
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestMakeApi.java
View file @
0717005a
...
@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.common.utils.HttpsUtils
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.service.ProducerService
;
import
com.jz.dm.service.ProducerService
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestRedisUserSave.java
View file @
0717005a
...
@@ -2,7 +2,7 @@ package com.jz.dm.gateway.orther;
...
@@ -2,7 +2,7 @@ package com.jz.dm.gateway.orther;
import
com.jz.dm.common.base.BaseCurrentUserObject
;
import
com.jz.dm.common.base.BaseCurrentUserObject
;
import
com.jz.dm.gateway.SpringTestCase
;
import
com.jz.dm.gateway.SpringTestCase
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
...
...
jz-dm-apigateway/src/test/java/com/jz/dm/gateway/orther/TestStreamReq.java
0 → 100644
View file @
0717005a
package
com
.
jz
.
dm
.
gateway
.
orther
;
import
com.jz.dm.gateway.SpringTestCase
;
import
lombok.extern.slf4j.Slf4j
;
import
static
com
.
jz
.
dm
.
common
.
util
.
stream
.
HttpDownload
.
download
;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.gateway.orther
* @PROJECT_NAME: jz-dm-parent
* @NAME: TestStreamReq
* @DATE: 2021-1-7/16:51
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Slf4j
public
class
TestStreamReq
extends
SpringTestCase
{
private
static
final
String
baseUrl
=
"http://192.168.1.140:8090/api/download"
;
//@Test
public
void
testStreamReq
()
{
download
(
baseUrl
);
}
}
jz-dm-common/src/main/java/com/jz/common/utils/HttpsUtils.java
View file @
0717005a
...
@@ -195,15 +195,16 @@ public class HttpsUtils {
...
@@ -195,15 +195,16 @@ public class HttpsUtils {
* @param url
* @param url
* @throws IOException
* @throws IOException
*/
*/
public
CloseableHttp
Client
doGetImg
(
String
url
)
{
public
CloseableHttp
Response
doGetImg
(
String
url
)
{
CloseableHttpClient
httpClient
=
getHttpClient
();
CloseableHttpClient
httpClient
=
getHttpClient
();
CloseableHttpResponse
response
=
null
;
HttpGet
httpGet
=
new
HttpGet
(
url
);
HttpGet
httpGet
=
new
HttpGet
(
url
);
try
{
try
{
httpClient
.
execute
(
httpGet
);
response
=
httpClient
.
execute
(
httpGet
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
log
.
error
(
"发起http request异常:{}"
,
e
);
log
.
error
(
"发起http request异常:{}"
,
e
);
}
}
return
httpClient
;
return
response
;
}
}
/**
/**
...
...
jz-dm-manage/src/test/java/com/jz/manage/manageApplicationTests.java
View file @
0717005a
package
com
.
jz
.
manage
;
package
com
.
jz
.
manage
;
import
com.jz.common.utils.DateUtils
;
import
com.jz.manage.moduls.controller.goods.bean.request.DataApiUpReq
;
import
com.jz.manage.moduls.entity.DataGoodsApiParams
;
import
com.jz.manage.moduls.service.DataGoodsService
;
import
com.jz.manage.moduls.service.DataGoodsService
;
import
com.jz.manage.moduls.service.SysUserService
;
import
com.jz.manage.moduls.service.SysUserService
;
import
com.jz.manage.moduls.service.TestUserService
;
import
com.jz.manage.moduls.service.TestUserService
;
...
@@ -12,10 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -12,10 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.List
;
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@SpringBootTest
public
class
manageApplicationTests
{
public
class
manageApplicationTests
{
...
@@ -38,29 +31,29 @@ public class manageApplicationTests {
...
@@ -38,29 +31,29 @@ public class manageApplicationTests {
@Test
@Test
public
void
getUserRoleByAccount
()
throws
Exception
{
public
void
getUserRoleByAccount
()
throws
Exception
{
DataApiUpReq
dataApiUpReq
=
new
DataApiUpReq
();
//
DataApiUpReq dataApiUpReq = new DataApiUpReq();
dataApiUpReq
.
setApiName
(
"华为"
);
//
dataApiUpReq.setApiName("华为");
dataApiUpReq
.
setRequestType
(
"的撒旦"
);
//
dataApiUpReq.setRequestType("的撒旦");
dataApiUpReq
.
setApiUrl
(
"http://localhost/dataGoods/uploadApi"
);
//
dataApiUpReq.setApiUrl("http://localhost/dataGoods/uploadApi");
dataApiUpReq
.
setReturnDataExample
(
"dadasdadafaf"
);
//
dataApiUpReq.setReturnDataExample("dadasdadafaf");
dataApiUpReq
.
setApiKey
(
"5"
);
//
dataApiUpReq.setApiKey("5");
dataApiUpReq
.
setEncryMode
(
"MD5"
);
//
dataApiUpReq.setEncryMode("MD5");
dataApiUpReq
.
setTransMode
(
"http"
);
//
dataApiUpReq.setTransMode("http");
dataApiUpReq
.
setApiFunction
(
"fafafaffaf"
);
//
dataApiUpReq.setApiFunction("fafafaffaf");
dataApiUpReq
.
setVersionNumber
(
"1.0"
);
//
dataApiUpReq.setVersionNumber("1.0");
dataApiUpReq
.
setPriceType
(
"01"
);
//
dataApiUpReq.setPriceType("01");
dataApiUpReq
.
setApiType
(
"1"
);
//
dataApiUpReq.setApiType("1");
dataApiUpReq
.
setApiDesc
(
"fafsafafasff"
);
//
dataApiUpReq.setApiDesc("fafsafafasff");
dataApiUpReq
.
setDataPicture
(
"http://wx4.sinaimg.cn/bmiddle/006GJQvhly1gkx4ezwcr4j328g28g1kx.jpg"
);
//
dataApiUpReq.setDataPicture("http://wx4.sinaimg.cn/bmiddle/006GJQvhly1gkx4ezwcr4j328g28g1kx.jpg");
dataApiUpReq
.
setYearType
(
BigDecimal
.
valueOf
(
1
));
//
dataApiUpReq.setYearType(BigDecimal.valueOf(1));
List
<
DataGoodsApiParams
>
paramsList
=
new
ArrayList
<>();
//
List<DataGoodsApiParams> paramsList = new ArrayList<>();
for
(
DataGoodsApiParams
params
:
paramsList
)
{
//
for (DataGoodsApiParams params : paramsList) {
params
.
setParamsDiff
(
"01"
);
//
params.setParamsDiff("01");
params
.
setParamsName
(
"xiaomi"
);
//
params.setParamsName("xiaomi");
params
.
setParamsType
(
"哒哒哒"
);
//
params.setParamsType("哒哒哒");
params
.
setCreTime
(
DateUtils
.
getToday
());
//
params.setCreTime(DateUtils.getToday());
}
//
}
dataApiUpReq
.
setParamsList
(
paramsList
);
//
dataApiUpReq.setParamsList(paramsList);
dataGoodsService
.
uploadApi
(
dataApiUpReq
);
//
dataGoodsService.uploadApi(dataApiUpReq);
}
}
}
}
pom.xml
View file @
0717005a
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.jz.dm
</groupId>
<groupId>
com.jz.dm
</groupId>
<artifactId>
jz-dm-parent
</artifactId>
<artifactId>
jz-dm-parent
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
0.0.1-SNAPSHOT
</version>
<packaging>
pom
</packaging>
<packaging>
pom
</packaging>
<name>
jz-dm-parent
</name>
<name>
jz-dm-parent
</name>
<description>
jz-dm-parent
</description>
<description>
jz-dm-parent
</description>
<properties>
<properties>
<java.version>
1.8
</java.version>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<alibaba.fastjson.version>
1.2.47
</alibaba.fastjson.version>
<alibaba.fastjson.version>
1.2.47
</alibaba.fastjson.version>
<mybatis-pagehelper.version>
5.1.6
</mybatis-pagehelper.version>
<mybatis-pagehelper.version>
5.1.6
</mybatis-pagehelper.version>
<mysql-connector.version>
5.1.48
</mysql-connector.version>
<mysql-connector.version>
5.1.48
</mysql-connector.version>
<druid.version>
1.1.12
</druid.version>
<druid.version>
1.1.12
</druid.version>
<mybatis-spring.version>
1.3.1
</mybatis-spring.version>
<mybatis-spring.version>
1.3.1
</mybatis-spring.version>
<mybatisplus.version>
3.3.1.tmp
</mybatisplus.version>
<mybatisplus.version>
3.3.1.tmp
</mybatisplus.version>
<hibernate.validator.version>
5.2.4.Final
</hibernate.validator.version>
<hibernate.validator.version>
5.2.4.Final
</hibernate.validator.version>
<validation.version>
1.1.0.Final
</validation.version>
<validation.version>
1.1.0.Final
</validation.version>
<fasterxml.jackson.version>
2.6.4
</fasterxml.jackson.version>
<fasterxml.jackson.version>
2.6.4
</fasterxml.jackson.version>
<spring-security-version>
4.1.1.RELEASE
</spring-security-version>
<spring-security-version>
4.1.1.RELEASE
</spring-security-version>
<org.springframework-version>
4.3.2.RELEASE
</org.springframework-version>
<org.springframework-version>
4.3.2.RELEASE
</org.springframework-version>
<spring.data.redis.version>
1.7.2.RELEASE
</spring.data.redis.version>
<spring.data.redis.version>
1.7.2.RELEASE
</spring.data.redis.version>
<spring.data.commons.version>
1.12.2.RELEASE
</spring.data.commons.version>
<spring.data.commons.version>
1.12.2.RELEASE
</spring.data.commons.version>
<spring.security.bom.version>
4.1.1.RELEASE
</spring.security.bom.version>
<spring.security.bom.version>
4.1.1.RELEASE
</spring.security.bom.version>
<spring.security.oauth.version>
2.0.10.RELEASE
</spring.security.oauth.version>
<spring.security.oauth.version>
2.0.10.RELEASE
</spring.security.oauth.version>
<mysql.driver.version>
5.1.30
</mysql.driver.version>
<mysql.driver.version>
5.1.30
</mysql.driver.version>
<netty-version>
4.0.0.Alpha8
</netty-version>
<netty-version>
4.0.0.Alpha8
</netty-version>
<mysql.driver.version>
5.1.30
</mysql.driver.version>
<mysql.driver.version>
5.1.30
</mysql.driver.version>
<aspectj.version>
1.8.9
</aspectj.version>
<aspectj.version>
1.8.9
</aspectj.version>
<!--<logback-version>1.1.7</logback-version> -->
<!--<logback-version>1.1.7</logback-version> -->
<disruptor.version>
3.3.5
</disruptor.version>
<disruptor.version>
3.3.5
</disruptor.version>
<slf4j.version>
1.7.21
</slf4j.version>
<slf4j.version>
1.7.21
</slf4j.version>
<log4j2.version>
2.6.2
</log4j2.version>
<log4j2.version>
2.6.2
</log4j2.version>
<dom4j.version>
1.6.1
</dom4j.version>
<dom4j.version>
1.6.1
</dom4j.version>
<!-- baidu disconf -->
<!-- baidu disconf -->
<disconf.version>
2.6.35
</disconf.version>
<disconf.version>
2.6.35
</disconf.version>
<junit.version>
4.12
</junit.version>
<junit.version>
4.12
</junit.version>
<commons-lang3.version>
3.8.1
</commons-lang3.version>
<commons-lang3.version>
3.8.1
</commons-lang3.version>
<springfox-swagger2.version>
2.9.2
</springfox-swagger2.version>
<springfox-swagger2.version>
2.9.2
</springfox-swagger2.version>
<swagger-bootstrap-ui.version>
1.9.6
</swagger-bootstrap-ui.version>
<swagger-bootstrap-ui.version>
1.9.6
</swagger-bootstrap-ui.version>
<lombok.version>
1.18.16
</lombok.version>
<lombok.version>
1.18.16
</lombok.version>
</properties>
<spring-cloud.version>
Finchley.SR1
</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<dependencyManagement>
<dependency>
<dependencies>
<groupId>
io.projectreactor
</groupId>
<dependency>
<artifactId>
reactor-bom
</artifactId>
<groupId>
io.projectreactor
</groupId>
<version>
Dysprosium-SR8
</version>
<artifactId>
reactor-bom
</artifactId>
<type>
pom
</type>
<version>
Dysprosium-SR8
</version>
<scope>
import
</scope>
<type>
pom
</type>
</dependency>
<scope>
import
</scope>
<!-- spring-boot-starter-parent -->
</dependency>
<dependency>
<!-- spring-boot-starter-parent -->
<groupId>
org.springframework.boot
</groupId>
<dependency>
<artifactId>
spring-boot-starter-parent
</artifactId>
<groupId>
org.springframework.boot
</groupId>
<version>
1.5.2.RELEASE
</version>
<artifactId>
spring-boot-starter-parent
</artifactId>
<type>
pom
</type>
<version>
1.5.2.RELEASE
</version>
<scope>
import
</scope>
<type>
pom
</type>
</dependency>
<scope>
import
</scope>
</dependency>
<!-- fastjson -->
<dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
fastjson
</artifactId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
${alibaba.fastjson.version}
</version>
<version>
${spring-cloud.version}
</version>
</dependency>
<type>
pom
</type>
<scope>
import
</scope>
<!-- spring boot 和mybatis -->
</dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<dependency>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<groupId>
org.springframework.cloud
</groupId>
<version>
${mybatis-spring.version}
</version>
<artifactId>
spring-cloud-alibaba-dependencies
</artifactId>
</dependency>
<version>
0.1.2.RELEASE
</version>
<type>
pom
</type>
<!-- mybatis plus -->
<scope>
import
</scope>
<dependency>
</dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<!-- fastjson -->
<version>
${mybatisplus.version}
</version>
<dependency>
</dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<!--mybatis分页插件 -->
<version>
${alibaba.fastjson.version}
</version>
<dependency>
</dependency>
<groupId>
com.github.pagehelper
</groupId>
<artifactId>
pagehelper
</artifactId>
<!-- spring boot 和mybatis -->
<version>
${mybatis-pagehelper.version}
</version>
<dependency>
</dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<!-- druid数据库连接池 -->
<version>
${mybatis-spring.version}
</version>
<dependency>
</dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<!-- mybatis plus -->
<version>
${druid.version}
</version>
<dependency>
</dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<!-- mysql连接 -->
<version>
${mybatisplus.version}
</version>
<dependency>
</dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<!--mybatis分页插件 -->
<version>
${mysql-connector.version}
</version>
<dependency>
</dependency>
<groupId>
com.github.pagehelper
</groupId>
<artifactId>
pagehelper
</artifactId>
<!-- ***************************************************************** -->
<version>
${mybatis-pagehelper.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.flume
</groupId>
<!-- druid数据库连接池 -->
<artifactId>
flume-ng-core
</artifactId>
<dependency>
<version>
1.5.0
</version>
<groupId>
com.alibaba
</groupId>
</dependency>
<artifactId>
druid
</artifactId>
<dependency>
<version>
${druid.version}
</version>
<groupId>
org.apache.flume.flume-ng-clients
</groupId>
</dependency>
<artifactId>
flume-ng-log4jappender
</artifactId>
<version>
1.5.0
</version>
<!-- mysql连接 -->
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<!-- Netty -->
<artifactId>
mysql-connector-java
</artifactId>
<dependency>
<version>
${mysql-connector.version}
</version>
<groupId>
io.netty
</groupId>
</dependency>
<artifactId>
netty-transport
</artifactId>
<version>
${netty-version}
</version>
<!-- ***************************************************************** -->
</dependency>
<dependency>
<dependency>
<groupId>
io.netty
</groupId>
<groupId>
org.apache.flume
</groupId>
<artifactId>
netty-handler
</artifactId>
<artifactId>
flume-ng-core
</artifactId>
<version>
${netty-version}
</version>
<version>
1.5.0
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
io.netty
</groupId>
<groupId>
org.apache.flume.flume-ng-clients
</groupId>
<artifactId>
netty-codec-http
</artifactId>
<artifactId>
flume-ng-log4jappender
</artifactId>
<version>
${netty-version}
</version>
<version>
1.5.0
</version>
</dependency>
</dependency>
<dependency>
<!-- Netty -->
<groupId>
org.springframework.security
</groupId>
<dependency>
<artifactId>
spring-security-core
</artifactId>
<groupId>
io.netty
</groupId>
<version>
${spring-security-version}
</version>
<artifactId>
netty-transport
</artifactId>
</dependency>
<version>
${netty-version}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<groupId>
io.netty
</groupId>
<artifactId>
spring-security-web
</artifactId>
<artifactId>
netty-handler
</artifactId>
<version>
${spring-security-version}
</version>
<version>
${netty-version}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<groupId>
io.netty
</groupId>
<artifactId>
spring-security-taglibs
</artifactId>
<artifactId>
netty-codec-http
</artifactId>
<version>
${spring-security-version}
</version>
<version>
${netty-version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<dependency>
<artifactId>
spring-security-acl
</artifactId>
<groupId>
org.springframework.security
</groupId>
<version>
${spring-security-version}
</version>
<artifactId>
spring-security-core
</artifactId>
</dependency>
<version>
${spring-security-version}
</version>
<dependency>
</dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-crypto
</artifactId>
<dependency>
<version>
${spring-security-version}
</version>
<groupId>
org.springframework.security
</groupId>
</dependency>
<artifactId>
spring-security-web
</artifactId>
<dependency>
<version>
${spring-security-version}
</version>
<groupId>
org.springframework.security
</groupId>
</dependency>
<artifactId>
spring-security-config
</artifactId>
<dependency>
<version>
${spring-security-version}
</version>
<groupId>
org.springframework.security
</groupId>
</dependency>
<artifactId>
spring-security-taglibs
</artifactId>
<version>
${spring-security-version}
</version>
<dependency>
</dependency>
<groupId>
org.springframework.security.oauth
</groupId>
<dependency>
<artifactId>
spring-security-oauth2
</artifactId>
<groupId>
org.springframework.security
</groupId>
<version>
${spring.security.oauth.version}
</version>
<artifactId>
spring-security-acl
</artifactId>
</dependency>
<version>
${spring-security-version}
</version>
<!-- 统一配置 -->
</dependency>
<dependency>
<dependency>
<groupId>
com.baidu.disconf
</groupId>
<groupId>
org.springframework.security
</groupId>
<artifactId>
disconf-client
</artifactId>
<artifactId>
spring-security-crypto
</artifactId>
<version>
${disconf.version}
</version>
<version>
${spring-security-version}
</version>
</dependency>
</dependency>
<!--单元测试-->
<dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<groupId>
junit
</groupId>
<artifactId>
spring-security-config
</artifactId>
<artifactId>
junit
</artifactId>
<version>
${spring-security-version}
</version>
<version>
${junit.version}
</version>
</dependency>
<scope>
test
</scope>
</dependency>
<dependency>
<!--工具类-->
<groupId>
org.springframework.security.oauth
</groupId>
<dependency>
<artifactId>
spring-security-oauth2
</artifactId>
<groupId>
org.apache.commons
</groupId>
<version>
${spring.security.oauth.version}
</version>
<artifactId>
commons-lang3
</artifactId>
</dependency>
<version>
${commons-lang3.version}
</version>
<!-- 统一配置 -->
</dependency>
<dependency>
<!-- swagger2接口文档 -->
<groupId>
com.baidu.disconf
</groupId>
<dependency>
<artifactId>
disconf-client
</artifactId>
<groupId>
io.springfox
</groupId>
<version>
${disconf.version}
</version>
<artifactId>
springfox-swagger2
</artifactId>
</dependency>
<version>
${springfox-swagger2.version}
</version>
<!--单元测试-->
</dependency>
<dependency>
<dependency>
<groupId>
junit
</groupId>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
junit
</artifactId>
<artifactId>
swagger-bootstrap-ui
</artifactId>
<version>
${junit.version}
</version>
<version>
${swagger-bootstrap-ui.version}
</version>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<!--工具类-->
<groupId>
org.projectlombok
</groupId>
<dependency>
<artifactId>
lombok
</artifactId>
<groupId>
org.apache.commons
</groupId>
<version>
${lombok.version}
</version>
<artifactId>
commons-lang3
</artifactId>
</dependency>
<version>
${commons-lang3.version}
</version>
</dependencies>
</dependency>
</dependencyManagement>
<!-- swagger2接口文档 -->
<dependency>
<modules>
<groupId>
io.springfox
</groupId>
<module>
jz-dm-mall
</module>
<artifactId>
springfox-swagger2
</artifactId>
<module>
jz-dm-manage
</module>
<version>
${springfox-swagger2.version}
</version>
<module>
jz-dm-common
</module>
</dependency>
<module>
jz-dm-apigateway
</module>
<dependency>
</modules>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
swagger-bootstrap-ui
</artifactId>
<!-- <build>-->
<version>
${swagger-bootstrap-ui.version}
</version>
<!-- <defaultGoal>compile</defaultGoal>-->
</dependency>
<!-- <finalName>${project.artifactId}</finalName>-->
<dependency>
<!-- <resources>-->
<groupId>
org.projectlombok
</groupId>
<!-- <resource>-->
<artifactId>
lombok
</artifactId>
<!-- <directory>src/main/resources</directory>-->
<version>
${lombok.version}
</version>
<!-- <filtering>true</filtering>-->
</dependency>
<!-- <excludes>-->
</dependencies>
<!-- <exclude>disconf.properties</exclude>-->
</dependencyManagement>
<!-- </excludes>-->
<!-- </resource>-->
<modules>
<!-- </resources>-->
<module>
jz-dm-mall
</module>
<!-- <plugins>-->
<module>
jz-dm-manage
</module>
<!-- <plugin>-->
<module>
jz-dm-common
</module>
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<module>
jz-dm-apigateway
</module>
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
</modules>
<!-- <version>2.3.2</version>-->
<!-- <executions>-->
<!-- <execution>-->
<build>
<!-- <id>default-compile</id>-->
<finalName>
${project.artifactId}
</finalName>
<!-- <phase>compile</phase>-->
<plugins>
<!-- <goals>-->
<plugin>
<!-- <goal>compile</goal>-->
<groupId>
org.apache.maven.plugins
</groupId>
<!-- </goals>-->
<artifactId>
maven-compiler-plugin
</artifactId>
<!-- </execution>-->
<configuration>
<!-- </executions>-->
<source>
1.8
</source>
<!-- <configuration>-->
<target>
1.8
</target>
<!-- <source>1.8</source>-->
<encoding>
${project.build.sourceEncoding}
</encoding>
<!-- <target>1.8</target>-->
</configuration>
<!-- <encoding>UTF-8</encoding>-->
</plugin>
<!-- </configuration>-->
</plugins>
<!-- </plugin>-->
</build>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-resources-plugin</artifactId>-->
<!-- <version>2.5</version>-->
<!-- <configuration>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-eclipse-plugin</artifactId>-->
<!-- <version>2.8</version>-->
<!-- <configuration>-->
<!-- <downloadSources>true</downloadSources>-->
<!-- <downloadJavadocs>false</downloadJavadocs>-->
<!-- <wtpversion>2.0</wtpversion>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
<build>
<finalName>
${project.artifactId}
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>
\ No newline at end of file
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