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
51b10b2a
Commit
51b10b2a
authored
Feb 20, 2021
by
zhangc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
4e66f97f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
19 deletions
+60
-19
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
+6
-1
AuthServiceImpl.java
...src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
+2
-2
ApiInterfaceMapper.xml
...igateway/src/main/resources/mapper/ApiInterfaceMapper.xml
+3
-1
No files found.
jz-dm-apigateway/src/main/java/com/jz/dm/common/util/MapUtil.java
View file @
51b10b2a
...
...
@@ -23,37 +23,39 @@ 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
)
.
append
(
"signType="
).
append
(
signType
);
.
append
(
"method="
).
append
(
method
).
append
(
LoggingConstants
.
AND_SPILT
)
.
append
(
"signType="
).
append
(
signType
);
return
builder
.
toString
();
}
/**
* 给map集合中的key实现字典排序
*
* @param map
* @return
*/
public
Map
<
String
,
Object
>
MapKeySort
(
Map
<
String
,
Object
>
map
)
{
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,19 +120,45 @@ 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
)
{
public
static
String
createLinkStringByGet
(
Map
<
String
,
String
>
params
)
{
List
<
String
>
keys
=
new
ArrayList
<
String
>(
params
.
keySet
());
Collections
.
sort
(
keys
);
String
prestr
=
""
;
for
(
int
i
=
0
;
i
<
keys
.
size
();
i
++)
{
String
key
=
keys
.
get
(
i
);
String
value
=
params
.
get
(
key
);
String
value
=
params
.
get
(
key
);
try
{
value
=
URLEncoder
.
encode
(
value
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
...
...
@@ -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
{
...
...
@@ -160,10 +189,15 @@ 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
));
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));
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 @
51b10b2a
...
...
@@ -143,6 +143,11 @@ public class ApiInterface extends BaseObject implements Serializable {
*/
@TableField
(
exist
=
false
)
private
String
responseParam
;
/**
* 固定参数
*/
@TableField
(
exist
=
false
)
private
String
inboxParam
;
/**
* 响应状态码
*/
...
...
@@ -152,7 +157,7 @@ public class ApiInterface extends BaseObject implements Serializable {
/*---------------------------------日志查询--------------------------------*/
/**
* 日志id
*
*/
**/
@TableField
(
exist
=
false
)
private
Long
logId
;
/**
...
...
jz-dm-apigateway/src/main/java/com/jz/dm/service/impl/AuthServiceImpl.java
View file @
51b10b2a
...
...
@@ -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/resources/mapper/ApiInterfaceMapper.xml
View file @
51b10b2a
...
...
@@ -28,6 +28,7 @@
</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.resp_code AS respCode
...
...
@@ -70,11 +71,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