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
1031aad6
Commit
1031aad6
authored
Feb 20, 2021
by
ysongq
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dm_dev' into dm_dev
parents
b9097432
d1e3e360
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
36 deletions
+87
-36
MapUtil.java
...igateway/src/main/java/com/jz/dm/common/util/MapUtil.java
+49
-15
ApiInterface.java
...y/src/main/java/com/jz/dm/models/domian/ApiInterface.java
+16
-1
ApiInterfaceDetailReq.java
.../java/com/jz/dm/models/req/api/ApiInterfaceDetailReq.java
+2
-2
ApiInterfaceServiceImpl.java
.../java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
+12
-12
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+2
-2
ProducerServiceImpl.java
...main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
+1
-0
ApiInterfaceMapper.xml
...igateway/src/main/resources/mapper/ApiInterfaceMapper.xml
+5
-4
No files found.
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/MapUtil.java
View file @
1031aad6
...
...
@@ -23,12 +23,13 @@ public class MapUtil {
/**
* 获取签名参数
*
* @param apiKey
* @param method
* @param signType
* @return
*/
public
static
String
getSignValue
(
String
apiKey
,
String
method
,
String
signType
)
{
public
static
String
getSignValue
(
String
apiKey
,
String
method
,
String
signType
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"apiKey="
).
append
(
apiKey
).
append
(
LoggingConstants
.
AND_SPILT
)
.
append
(
"method="
).
append
(
method
).
append
(
LoggingConstants
.
AND_SPILT
)
...
...
@@ -39,21 +40,22 @@ public class MapUtil {
/**
* 给map集合中的key实现字典排序
*
* @param map
* @return
*/
public
Map
<
String
,
Object
>
MapKeySort
(
Map
<
String
,
Object
>
map
)
{
public
Map
<
String
,
Object
>
mapKeySort
(
Map
<
String
,
Object
>
map
)
{
ArrayList
list
=
new
ArrayList
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
map
.
entrySet
())
{
list
.
add
(
entry
.
getKey
());
//System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
}
HashMap
<
String
,
Object
>
newMap
=
new
HashMap
<
String
,
Object
>();
HashMap
<
String
,
Object
>
newMap
=
new
HashMap
<
String
,
Object
>();
//运用Collections的sort()方法对其进行排序 sort()方法需要传 连个参数,一个是需要进行排序的Collection 另一个是一个Comparator
Collections
.
sort
(
list
,
new
SpellComparatorUtils
());
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
newMap
.
put
(
list
.
get
(
i
).
toString
()
,
map
.
get
(
list
.
get
(
i
).
toString
()));
newMap
.
put
(
list
.
get
(
i
).
toString
(),
map
.
get
(
list
.
get
(
i
).
toString
()));
}
return
newMap
;
}
...
...
@@ -118,11 +120,37 @@ public class MapUtil {
return
sb
.
toString
();
}
/**
* * 把数组元素按照按照字典倒序排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* @param params 需要排序并参与字符拼接的参数组
* @return 拼接后字符串
*/
public
static
String
stringInvertSort
(
Map
<
String
,
String
>
params
)
{
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
reverse
(
keys
);
String
prestr
=
""
;
for
(
int
i
=
0
;
i
<
keys
.
size
();
i
++)
{
String
key
=
keys
.
get
(
i
);
String
value
=
params
.
get
(
key
);
try
{
value
=
URLEncoder
.
encode
(
value
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
if
(
i
==
keys
.
size
()
-
1
)
{
//拼接时,不包括最后一个&字符
prestr
=
prestr
+
key
+
"="
+
value
;
}
else
{
prestr
=
prestr
+
key
+
"="
+
value
+
"&"
;
}
}
return
prestr
;
}
/**
* * 把数组所有元素排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* * @param params 需要排序并参与字符拼接的参数组
* * @return 拼接后字符串
*
* @throws UnsupportedEncodingException
*
*/
public
static
String
createLinkStringByGet
(
Map
<
String
,
String
>
params
)
{
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
...
...
@@ -144,7 +172,8 @@ public class MapUtil {
}
return
prestr
;
}
class
SpellComparatorUtils
implements
Comparator
{
class
SpellComparatorUtils
implements
Comparator
{
@Override
public
int
compare
(
Object
o1
,
Object
o2
)
{
try
{
...
...
@@ -161,9 +190,14 @@ class SpellComparatorUtils implements Comparator {
}
public
static
void
main
(
String
[]
args
)
{
Map
<
String
,
String
>
map
=
new
HashMap
();
map
.
put
(
"name"
,
"hello"
);
map
.
put
(
"value"
,
"world"
);
System
.
out
.
println
(
createLinkStringByGet
(
map
));
//Map<String, String> map = new HashMap();
//map.put("name", "hello");
//map.put("value", "world");
//System.out.println(createLinkStringByGet(map));
StringJoiner
joiner
=
new
StringJoiner
(
","
,
"["
,
"]"
);
joiner
.
add
(
"123"
);
joiner
.
add
(
"456"
);
joiner
.
add
(
"789"
);
System
.
out
.
println
(
joiner
);
}
}
jz-dm-apigateway/src/main/java/com/jz/dm/models/domian/ApiInterface.java
View file @
1031aad6
...
...
@@ -143,16 +143,31 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
@TableField
(
exist
=
false
)
private
String
responseParam
;
/**
* 固定参数
*/
@TableField
(
exist
=
false
)
private
String
inboxParam
;
/**
* 响应状态码
*/
@TableField
(
exist
=
false
)
private
String
respCode
;
/**
* 最大行数
*/
@TableField
(
exist
=
false
)
private
Integer
maxRow
;
/**
* 每页返回行数
*/
@TableField
(
exist
=
false
)
private
Integer
pageRow
;
/*---------------------------------日志查询--------------------------------*/
/**
* 日志id
*
*/
**/
@TableField
(
exist
=
false
)
private
Long
logId
;
/**
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/models/req/api/ApiInterfaceDetailReq.java
View file @
1031aad6
...
...
@@ -20,8 +20,8 @@ import java.io.Serializable;
@ApiModel
(
"API详情信息"
)
public
class
ApiInterfaceDetailReq
implements
Serializable
{
@ApiModelProperty
(
value
=
"id"
,
required
=
false
)
private
Long
id
;
/*
@ApiModelProperty(value = "id",required = false)
private Long id;
*/
@ApiModelProperty
(
value
=
"apiKey"
,
required
=
true
)
@NotNull
(
message
=
"apiKey不能为空"
)
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ApiInterfaceServiceImpl.java
View file @
1031aad6
...
...
@@ -173,8 +173,8 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
if
(
ApiStatusEnum
.
EXPIRY
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
return
Result
.
of_error
(
"API已失效无法再次操作!"
);
}
Integer
authStat
=
getAuthCall
(
api
Key
,
AuthModeEnum
.
POWER_CALL_MODE
.
name
(),
null
);
Integer
authDateStat
=
getAuthCall
(
api
Key
,
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
(),
new
Date
());
Integer
authStat
=
getAuthCall
(
api
Interface
.
getId
()
,
AuthModeEnum
.
POWER_CALL_MODE
.
name
(),
null
);
Integer
authDateStat
=
getAuthCall
(
api
Interface
.
getId
()
,
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
(),
new
Date
());
UpdateWrapper
<
ApiInterface
>
updateInfo
=
new
UpdateWrapper
<>();
if
(
authStat
+
authDateStat
>
0
)
{
//有已授权未使用的先将状态置为$$ 下架
updateInfo
.
set
(
"status"
,
ApiStatusEnum
.
SOLDOUT
);
//下架状态%%可以调用,但不可以购买
...
...
@@ -197,17 +197,17 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
*/
@Override
public
Result
dmpDeleteAuth
(
String
type
,
String
apiKey
)
{
ApiInterface
apiInterface
=
getApiInfo
(
apiKey
);
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
}
if
(
"0"
.
equals
(
type
))
{
//确认是否删除
Integer
call
=
getAuthCall
(
api
Key
,
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
(),
null
);
Integer
call
=
getAuthCall
(
api
Interface
.
getId
()
,
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
(),
null
);
if
(
call
>
0
)
{
return
Result
.
of_error
(
"已存在授权用户,是否要删除!"
);
}
return
Result
.
of_success
(
ResultMsg
.
SUCCESS
);
}
else
if
(
"1"
.
equals
(
type
))
{
//正式删除
ApiInterface
apiInterface
=
getApiInfo
(
apiKey
);
if
(
null
==
apiInterface
)
{
return
Result
.
of_error
(
ResultMsg
.
DATA_NOT_EXIST
);
}
if
(
ApiStatusEnum
.
EXPIRY
.
name
().
equals
(
apiInterface
.
getStatus
()))
{
return
Result
.
of_error
(
"API已失效无法再次操作!"
);
}
...
...
@@ -244,15 +244,15 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
/**
* 获取单次调用有效授权
*
* @param api
Key
* @param api
Id
* @param modeType
* @param date
* @return
*/
private
Integer
getAuthCall
(
String
apiKey
,
String
modeType
,
Date
date
)
{
private
Integer
getAuthCall
(
Long
apiId
,
String
modeType
,
Date
date
)
{
//按次调用统计
QueryWrapper
<
ApiAuth
>
query
=
new
QueryWrapper
<>();
query
.
eq
(
"api_
key"
,
apiKey
);
query
.
eq
(
"api_
interface_id"
,
apiId
);
query
.
eq
(
"handler"
,
0
);
//主要是确认单次调用是否调用
query
.
eq
(
"auth_mode"
,
modeType
);
if
(
null
!=
date
)
{
...
...
@@ -272,8 +272,8 @@ public class ApiInterfaceServiceImpl implements ApiInterfaceService {
*/
@Override
public
Integer
getValidAuthStatus
(
ApiInterface
apiInterface
)
{
Integer
authCall
=
getAuthCall
(
apiInterface
.
get
ApiKey
(),
AuthModeEnum
.
POWER_CALL_MODE
.
name
(),
null
);
Integer
authDateCall
=
getAuthCall
(
apiInterface
.
get
ApiKey
(),
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
(),
new
Date
());
Integer
authCall
=
getAuthCall
(
apiInterface
.
get
Id
(),
AuthModeEnum
.
POWER_CALL_MODE
.
name
(),
null
);
Integer
authDateCall
=
getAuthCall
(
apiInterface
.
get
Id
(),
AuthModeEnum
.
PERMANENT_TIME_MODE
.
name
(),
new
Date
());
return
authCall
+
authDateCall
;
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
1031aad6
...
...
@@ -114,10 +114,10 @@ public class AuthServiceImpl implements AuthService {
query
.
eq
(
"ai.api_name"
,
req
.
getApiName
());
}
if
(
StringUtils
.
isNotBlank
(
req
.
getOrgName
())){
query
.
like
(
"a
u
.org_name"
,
req
.
getOrgName
());
query
.
like
(
"a
r
.org_name"
,
req
.
getOrgName
());
}
query
.
eq
(
"ai.is_deleted"
,
0
);
query
.
orderByDesc
(
"au.create_
tim
e"
);
query
.
orderByDesc
(
"au.create_
dat
e"
);
return
Result
.
of_success
(
apiInterfaceMapper
.
listApiAuthService
(
page
,
query
));
}
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/ProducerServiceImpl.java
View file @
1031aad6
...
...
@@ -239,6 +239,7 @@ public class ProducerServiceImpl implements ProducerService {
}
UpdateWrapper
<
ApiInterface
>
updateWra
=
new
UpdateWrapper
<>();
updateWra
.
set
(
"is_send_bank"
,
1
);
updateWra
.
eq
(
"id"
,
id
);
if
(
apiInterfaceMapper
.
update
(
null
,
updateWra
)
==
0
){
return
Result
.
of_error
(
ResultMsg
.
UPDATE_FAIL
);
}
...
...
jz-dm-apigateway/src/main/resources/mapper/ApiInterfaceMapper.xml
View file @
1031aad6
...
...
@@ -28,8 +28,11 @@
</select>
<select
id=
"selectDetail"
resultType=
"com.jz.dm.models.domian.ApiInterface"
>
SELECT ai.*,
aic.inbox_param AS inboxParam,
aic.request_param AS requestParam,
aic.response_param AS responseParam,
aic.max_row AS maxRow,
aic.page_row AS pageRow,
aic.resp_code AS respCode
FROM t_api_interface AS ai
LEFT JOIN t_api_interface_custom AS aic ON ai.id = aic.api_interface_id AND aic.is_deleted =0
...
...
@@ -37,9 +40,6 @@
<if
test=
"apiKey != null and apiKey !=''"
>
ai.api_key =#{apiKey}
</if>
<if
test=
"id != null and id !=''"
>
AND ai.id =#{id}
</if>
</select>
<select
id=
"getTestData"
resultType=
"com.jz.dm.models.domian.ApiInterfaceCustom"
>
SELECT aic.*
...
...
@@ -73,11 +73,12 @@
aic.max_row AS maxRow,
aic.page_row AS pageRow,
au.auth_code AS authCode,
a
u
.org_name AS orgName,
a
r
.org_name AS orgName,
au.create_date AS createDate
FROM t_api_interface AS ai
JOIN t_api_interface_custom AS aic ON ai.id =aic.api_interface_id AND aic.is_deleted =0
JOIN t_api_auth AS au ON au.api_interface_id = ai.id AND aic.is_deleted =0
JOIN t_api_org AS ar ON ar.id = au.api_org_id AND ar.is_deleted =0
${ew.customSqlSegment}
</select>
<select
id=
"listApiDetail"
resultType=
"com.jz.dm.models.dto.ApiServiceApplyDto"
>
...
...
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