11package com .github .cadecode .uniboot .framework .svc .controller ;
22
3- import cn .hutool .core .util .ObjectUtil ;
43import com .github .cadecode .uniboot .common .core .web .response .PageResult ;
54import com .github .cadecode .uniboot .framework .api .consts .KeyPrefixConst ;
65import com .github .cadecode .uniboot .framework .base .annotation .ApiFormat ;
76import com .github .cadecode .uniboot .framework .base .annotation .ApiInner ;
87import com .github .cadecode .uniboot .framework .svc .bean .po .SysApi ;
98import com .github .cadecode .uniboot .framework .svc .bean .vo .SysApiVo .SysApiRolesReqVo ;
109import com .github .cadecode .uniboot .framework .svc .bean .vo .SysApiVo .SysApiRolesResVo ;
11- import com .github .cadecode .uniboot .framework .svc .bean .vo .SysApiVo .SysApiSwaggerResVo ;
1210import com .github .cadecode .uniboot .framework .svc .convert .SysApiConvert ;
1311import com .github .cadecode .uniboot .framework .svc .service .SysApiService ;
1412import com .github .cadecode .uniboot .framework .svc .service .SysRoleService ;
2422import org .springframework .web .bind .annotation .RequestBody ;
2523import org .springframework .web .bind .annotation .RequestMapping ;
2624import org .springframework .web .bind .annotation .RestController ;
27- import org .springframework .web .method .HandlerMethod ;
28- import org .springframework .web .servlet .mvc .method .RequestMappingInfo ;
29- import org .springframework .web .servlet .mvc .method .annotation .RequestMappingHandlerMapping ;
3025
3126import javax .validation .Valid ;
3227import javax .validation .constraints .NotEmpty ;
33- import java .util .ArrayList ;
34- import java .util .Comparator ;
3528import java .util .List ;
36- import java .util .Map ;
37- import java .util .stream .Collectors ;
3829
3930import static com .github .cadecode .uniboot .framework .svc .bean .vo .SysApiVo .SysApiAddReqVo ;
4031import static com .github .cadecode .uniboot .framework .svc .bean .vo .SysApiVo .SysApiUpdateReqVo ;
@@ -57,10 +48,6 @@ public class SysApiController {
5748 private final SysApiService sysApiService ;
5849 private final SysRoleService sysRoleService ;
5950
60- /**
61- * 获取全部接口的处理器 mapping
62- */
63- private final RequestMappingHandlerMapping handlerMapping ;
6451
6552 @ ApiOperation ("查询API列表(带角色)" )
6653 @ PostMapping ("page_roles_vo" )
@@ -100,31 +87,6 @@ public List<SysApiRolesResVo> listRolesVoByApiIds(@RequestBody @NotEmpty List<Lo
10087 return sysApiService .listRolesVoByApiIds (apiIdList );
10188 }
10289
103- @ ApiOperation ("获取全部接口及 swagger 注解" )
104- @ PostMapping ("list_swagger_vo" )
105- public List <SysApiSwaggerResVo > listSwaggerVo () {
106- Map <RequestMappingInfo , HandlerMethod > methodMap = handlerMapping .getHandlerMethods ();
107- return methodMap .entrySet ()
108- .stream ()
109- .map (e -> {
110- ArrayList <String > urlList = new ArrayList <>(e .getKey ().getPatternsCondition ().getPatterns ());
111- String url = null ;
112- if (ObjectUtil .isNotEmpty (urlList )) {
113- url = urlList .get (0 );
114- }
115- ApiOperation operation = e .getValue ().getMethod ().getAnnotation (ApiOperation .class );
116- String description = null ;
117- if (ObjectUtil .isNotNull (operation )) {
118- description = operation .value ();
119- }
120- return SysApiSwaggerResVo .builder ().url (url ).description (description ).build ();
121- })
122- .filter (o -> ObjectUtil .isNotEmpty (o .getUrl ()))
123- .distinct ()
124- .sorted (Comparator .comparing (SysApiSwaggerResVo ::getUrl ))
125- .collect (Collectors .toList ());
126- }
127-
12890 @ ApiInner (onlyClient = true )
12991 @ ApiOperation ("查询API列表-全部" )
13092 @ PostMapping ("list_roles_vo" )
0 commit comments