Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
Details
Activity
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
黄营
datax-cloud
Commits
1dfee283
Commit
1dfee283
authored
Apr 08, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
c044641a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
12 deletions
+68
-12
MD5Util.java
...mon-core/src/main/java/cn/datax/common/utils/MD5Util.java
+1
-1
ApiInterceptor.java
...x/service/data/market/api/call/config/ApiInterceptor.java
+9
-2
ApiCallServiceImpl.java
...data/market/api/call/service/impl/ApiCallServiceImpl.java
+0
-2
ApiLogEntity.java
...cn/datax/service/data/market/api/entity/ApiLogEntity.java
+1
-1
DataType.java
...java/cn/datax/service/data/market/api/enums/DataType.java
+57
-6
No files found.
datax-common/datax-common-core/src/main/java/cn/datax/common/utils/MD5Util.java
View file @
1dfee283
...
@@ -47,7 +47,7 @@ public class MD5Util {
...
@@ -47,7 +47,7 @@ public class MD5Util {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
try
{
try
{
String
value
=
"12
14835832967581698
"
;
String
value
=
"12
46656415670484994
"
;
MD5Util
mt
=
new
MD5Util
();
MD5Util
mt
=
new
MD5Util
();
System
.
out
.
println
(
"加密前的字符:"
+
value
);
System
.
out
.
println
(
"加密前的字符:"
+
value
);
System
.
out
.
println
(
"加密后的字符:"
+
mt
.
encode
(
value
));
System
.
out
.
println
(
"加密后的字符:"
+
mt
.
encode
(
value
));
...
...
datax-modules/data-market-service-parent/data-market-service-api-call/src/main/java/cn/datax/service/data/market/api/call/config/ApiInterceptor.java
View file @
1dfee283
...
@@ -6,9 +6,11 @@ import cn.datax.common.utils.HttpUtil;
...
@@ -6,9 +6,11 @@ import cn.datax.common.utils.HttpUtil;
import
cn.datax.common.utils.IPUtil
;
import
cn.datax.common.utils.IPUtil
;
import
cn.datax.common.utils.MD5Util
;
import
cn.datax.common.utils.MD5Util
;
import
cn.datax.common.utils.ResponseUtil
;
import
cn.datax.common.utils.ResponseUtil
;
import
cn.datax.service.data.market.api.call.service.ApiLogService
;
import
cn.datax.service.data.market.api.call.utils.ThreadUtil
;
import
cn.datax.service.data.market.api.call.utils.ThreadUtil
;
import
cn.datax.service.data.market.api.dto.ApiLogDto
;
import
cn.datax.service.data.market.api.dto.ApiLogDto
;
import
cn.datax.service.data.market.api.entity.DataApiEntity
;
import
cn.datax.service.data.market.api.entity.DataApiEntity
;
import
cn.datax.service.data.market.api.enums.DataType
;
import
cn.datax.service.data.market.api.feign.DataApiServiceFeign
;
import
cn.datax.service.data.market.api.feign.DataApiServiceFeign
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
...
@@ -39,6 +41,9 @@ public class ApiInterceptor implements HandlerInterceptor {
...
@@ -39,6 +41,9 @@ public class ApiInterceptor implements HandlerInterceptor {
@Autowired
@Autowired
private
DataApiServiceFeign
dataApiServiceFeign
;
private
DataApiServiceFeign
dataApiServiceFeign
;
@Autowired
private
ApiLogService
apiLogService
;
@Override
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
System
.
out
.
println
(
"************ApiInterceptor preHandle executed**********"
);
System
.
out
.
println
(
"************ApiInterceptor preHandle executed**********"
);
...
@@ -91,7 +96,8 @@ public class ApiInterceptor implements HandlerInterceptor {
...
@@ -91,7 +96,8 @@ public class ApiInterceptor implements HandlerInterceptor {
dataApiEntity
.
getReqParams
().
stream
().
forEach
(
param
->
{
dataApiEntity
.
getReqParams
().
stream
().
forEach
(
param
->
{
if
(
params
.
containsKey
(
param
.
getParamName
()))
{
if
(
params
.
containsKey
(
param
.
getParamName
()))
{
Integer
dataType
=
param
.
getDataType
();
Integer
dataType
=
param
.
getDataType
();
// 数据类型转换
// 数据类型是否正确
DataType
.
parse
(
DataType
.
getDataType
(
dataType
),
params
.
get
(
param
.
getParamName
()));
}
}
});
});
String
apiName
=
dataApiEntity
.
getApiName
();
String
apiName
=
dataApiEntity
.
getApiName
();
...
@@ -143,8 +149,9 @@ public class ApiInterceptor implements HandlerInterceptor {
...
@@ -143,8 +149,9 @@ public class ApiInterceptor implements HandlerInterceptor {
@Override
@Override
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
throws
Exception
{
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
throws
Exception
{
ThreadUtil
.
getInstance
().
get
().
setTime
(
System
.
currentTimeMillis
()
-
ThreadUtil
.
getInstance
().
get
().
getTime
());
ThreadUtil
.
getInstance
().
get
().
setTime
(
System
.
currentTimeMillis
()
-
ThreadUtil
.
getInstance
().
get
().
getTime
());
log
.
info
(
"调用
消耗时间
:"
+
ThreadUtil
.
getInstance
().
get
().
getTime
());
log
.
info
(
"调用
耗时
:"
+
ThreadUtil
.
getInstance
().
get
().
getTime
());
log
.
info
(
"调用日志:"
+
ThreadUtil
.
getInstance
().
get
());
log
.
info
(
"调用日志:"
+
ThreadUtil
.
getInstance
().
get
());
apiLogService
.
saveApiLog
(
ThreadUtil
.
getInstance
().
get
());
ThreadUtil
.
getInstance
().
remove
();
ThreadUtil
.
getInstance
().
remove
();
}
}
}
}
datax-modules/data-market-service-parent/data-market-service-api-call/src/main/java/cn/datax/service/data/market/api/call/service/impl/ApiCallServiceImpl.java
View file @
1dfee283
...
@@ -40,8 +40,6 @@ public class ApiCallServiceImpl implements ApiCallService {
...
@@ -40,8 +40,6 @@ public class ApiCallServiceImpl implements ApiCallService {
@Override
@Override
public
PageResult
<
Map
<
String
,
Object
>>
v1
()
{
public
PageResult
<
Map
<
String
,
Object
>>
v1
()
{
// 缓存取数据
// redisTemplate.opsForValue().get("myCache::userName")
R
apiResult
=
dataApiServiceFeign
.
getDataApiById
(
ThreadUtil
.
getInstance
().
get
().
getApiId
());
R
apiResult
=
dataApiServiceFeign
.
getDataApiById
(
ThreadUtil
.
getInstance
().
get
().
getApiId
());
if
(
apiResult
==
null
||
!
apiResult
.
isSuccess
()
||
ObjectUtil
.
isEmpty
(
apiResult
.
getData
())){
if
(
apiResult
==
null
||
!
apiResult
.
isSuccess
()
||
ObjectUtil
.
isEmpty
(
apiResult
.
getData
())){
ThreadUtil
.
getInstance
().
get
().
setStatus
(
0
);
ThreadUtil
.
getInstance
().
get
().
setStatus
(
0
);
...
...
datax-modules/data-market-service-parent/data-market-service-api/src/main/java/cn/datax/service/data/market/api/entity/ApiLogEntity.java
View file @
1dfee283
...
@@ -45,7 +45,7 @@ public class ApiLogEntity implements Serializable {
...
@@ -45,7 +45,7 @@ public class ApiLogEntity implements Serializable {
*/
*/
private
String
callerParams
;
private
String
callerParams
;
/**
/**
* 调用
返回
数据量
* 调用数据量
*/
*/
private
Integer
callerSize
;
private
Integer
callerSize
;
/**
/**
...
...
datax-modules/data-market-service-parent/data-market-service-api/src/main/java/cn/datax/service/data/market/api/enums/DataType.java
View file @
1dfee283
package
cn
.
datax
.
service
.
data
.
market
.
api
.
enums
;
package
cn
.
datax
.
service
.
data
.
market
.
api
.
enums
;
import
cn.datax.common.exception.DataException
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
java.math.BigDecimal
;
public
enum
DataType
{
public
enum
DataType
{
String
(
1
,
"字符串"
),
String
(
1
,
"字符串"
),
...
@@ -25,10 +31,55 @@ public enum DataType {
...
@@ -25,10 +31,55 @@ public enum DataType {
return
val
;
return
val
;
}
}
// public Object parse(Object obj) {
public
static
Object
parse
(
DataType
dataType
,
Object
obj
)
{
// if (obj == null) return null;
if
(
ObjectUtil
.
isEmpty
(
obj
))
{
// switch (this) {
return
null
;
//
}
// }
switch
(
dataType
)
{
// }
case
String:
try
{
return
(
java
.
lang
.
String
)
obj
;
}
catch
(
Exception
e
)
{
throw
new
DataException
(
"参数值["
+
obj
+
"]不是"
+
String
.
getVal
()
+
"数据类型]"
);
}
case
Float:
try
{
return
new
BigDecimal
(
obj
.
toString
()).
doubleValue
();
}
catch
(
Exception
e
)
{
throw
new
DataException
(
"参数值["
+
obj
+
"]不是"
+
Float
.
getVal
()
+
"数据类型]"
);
}
case
Integer:
try
{
return
(
java
.
lang
.
Integer
)
obj
;
}
catch
(
Exception
e
)
{
throw
new
DataException
(
"参数值["
+
obj
+
"]不是"
+
Integer
.
getVal
()
+
"数据类型]"
);
}
case
List:
try
{
return
(
java
.
util
.
List
<?>)
obj
;
}
catch
(
Exception
e
)
{
throw
new
DataException
(
"参数值["
+
obj
+
"]不是"
+
List
.
getVal
()
+
"数据类型]"
);
}
case
Date:
try
{
return
DateUtil
.
parse
(
obj
.
toString
(),
"yyyy-MM-dd HH:mm:ss"
);
}
catch
(
Exception
e
)
{
try
{
return
DateUtil
.
parse
(
obj
.
toString
(),
"yyyy-MM-dd"
);
}
catch
(
Exception
ex
)
{
throw
new
DataException
(
"参数值["
+
obj
+
"]不是"
+
Date
.
getVal
()
+
"数据类型]"
);
}
}
}
return
null
;
}
public
static
DataType
getDataType
(
Integer
dataType
)
{
for
(
DataType
type
:
DataType
.
values
())
{
if
(
type
.
key
==
dataType
)
{
return
type
;
}
}
return
String
;
}
}
}
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