Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-backend
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
cloud-backend
Commits
28516662
Commit
28516662
authored
May 19, 2022
by
袁伟铭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.0.0
parent
a49d0ead
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
16 deletions
+80
-16
api-server/pom.xml
+7
-0
api-server/src/main/java/com/zq/api/controller/MethodController.java
+18
-16
api-server/src/main/java/com/zq/api/vo/MethodVo.java
+24
-0
api-server/src/main/resources/templates/mothod.html
+31
-0
No files found.
api-server/pom.xml
View file @
28516662
...
...
@@ -52,6 +52,13 @@
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- thymeleaf html模板引擎 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
...
...
api-server/src/main/java/com/zq/api/controller/MethodController.java
View file @
28516662
...
...
@@ -3,38 +3,37 @@ package com.zq.api.controller;
import
cn.hutool.core.util.StrUtil
;
import
com.zq.api.constant.ApiMethod
;
import
com.zq.api.form.ApiForm
;
import
com.zq.api.form.ApiResp
;
import
com.zq.api.service.IApiLogic
;
import
com.zq.api.utils.ApiUtils
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.api.vo.MethodVo
;
import
io.swagger.annotations.Api
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.annotation.AnnotationUtils
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.
HashMap
;
import
java.util.
Comparator
;
import
java.util.List
;
import
java.util.
Map
;
import
java.util.
stream.Collectors
;
/**
* @author wilmiam
* @since 2022/1/21 1
7:00
* @since 2022/1/21 1
6:44
*/
@Api
(
tags
=
"方法接口"
)
@Slf4j
@
Rest
Controller
@Controller
@RequiredArgsConstructor
@RequestMapping
(
"/api"
)
public
class
MethodController
{
@RequestMapping
(
"/method"
)
public
ApiResp
getAllMethod
(
@RequestParam
(
required
=
false
)
String
service
,
@RequestParam
(
required
=
false
)
String
name
)
{
List
<
M
ap
<
String
,
Object
>
>
methodList
=
new
ArrayList
<>();
public
String
getAllMethod
(
Model
model
,
@RequestParam
(
required
=
false
)
String
service
,
@RequestParam
(
required
=
false
)
String
name
)
{
List
<
M
ethodVo
>
methodList
=
new
ArrayList
<>();
Method
[]
methods
=
IApiLogic
.
class
.
getMethods
();
for
(
Method
method
:
methods
)
{
Class
<?>[]
params
=
method
.
getParameterTypes
();
...
...
@@ -51,14 +50,17 @@ public class MethodController {
}
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"value"
,
method
.
getName
());
data
.
put
(
"name"
,
apiMethod
==
null
?
""
:
apiMethod
.
name
());
data
.
put
(
"service"
,
apiMethod
==
null
?
""
:
apiMethod
.
service
());
methodList
.
add
(
data
);
methodList
.
add
(
MethodVo
.
builder
()
.
name
(
apiMethod
==
null
?
""
:
apiMethod
.
value
())
.
service
(
apiMethod
==
null
?
""
:
apiMethod
.
service
())
.
value
(
method
.
getName
())
.
build
()
);
}
}
return
ApiUtils
.
toApiResp
(
new
ApiForm
(),
ResultVo
.
success
(
methodList
));
methodList
=
methodList
.
stream
().
sorted
(
Comparator
.
comparing
(
MethodVo:
:
getService
).
reversed
()).
collect
(
Collectors
.
toList
());
model
.
addAttribute
(
"methodList"
,
methodList
);
return
"mothod"
;
}
}
api-server/src/main/java/com/zq/api/vo/MethodVo.java
0 → 100644
View file @
28516662
package
com
.
zq
.
api
.
vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author wilmiam
* @since 2022/1/27 12:30
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
MethodVo
{
private
String
name
;
private
String
service
;
private
String
value
;
}
api-server/src/main/resources/templates/mothod.html
0 → 100644
View file @
28516662
<!DOCTYPE html>
<html
lang=
"en"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
方法列表
</title>
</head>
<body>
<div>
<table
border=
"1"
cellspacing=
"0"
style=
"margin: auto;text-align: center;"
>
<tr>
<th
class=
"row"
>
方法名
</th>
<th
class=
"row"
>
所属服务
</th>
<th
class=
"row"
>
调用方法名
</th>
</tr>
<tr
th:each=
"method : ${methodList}"
>
<td
class=
"row"
th:text=
"${method.name}"
></td>
<td
class=
"row"
th:text=
"${method.service}"
></td>
<td
class=
"row"
th:text=
"${method.value}"
></td>
</tr>
</table>
</div>
</body>
<style>
.row
{
padding
:
3px
20px
;
}
</style>
<script>
</script>
</html>
\ 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