diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/aspect/annotation/RestApi.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/aspect/annotation/RestApi.java new file mode 100644 index 000000000000..3c8f00fd9517 --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/aspect/annotation/RestApi.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.aspect.annotation; + +import org.springframework.core.annotation.AliasFor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * RestApi. + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@Validated +@RestController +@RequestMapping +public @interface RestApi { + + /** + * The value may indicate a suggestion for a logical component name, + * to be turned into a Spring bean in case of an autodetected component. + * + * @return the suggested component name, if any (or empty String otherwise) + * @since 4.0.1 + */ + @AliasFor(attribute = "path", annotation = RequestMapping.class) + String[] value() default {}; + +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/aspect/controller/RestControllerAspect.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/aspect/controller/RestControllerAspect.java index 5176acecf9c7..4b709532d4bd 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/aspect/controller/RestControllerAspect.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/aspect/controller/RestControllerAspect.java @@ -47,7 +47,8 @@ public RestControllerAspect(final List methodAdviceList) /** * cut. */ - @Pointcut("@within(org.springframework.web.bind.annotation.RestController)") + @Pointcut("@within(org.springframework.web.bind.annotation.RestController) " + + "|| @within(org.apache.shenyu.admin.aspect.annotation.RestApi)") public void controller() { } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java index 6f657d8f5594..a0af3a313996 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java @@ -77,7 +77,7 @@ */ @Configuration public class DataSyncConfiguration { - + /** * http long polling. */ @@ -85,20 +85,20 @@ public class DataSyncConfiguration { @ConditionalOnProperty(name = "shenyu.sync.http.enabled", havingValue = "true") @EnableConfigurationProperties(HttpSyncProperties.class) static class HttpLongPollingListener { - + @Bean @ConditionalOnMissingBean(HttpLongPollingDataChangedListener.class) public HttpLongPollingDataChangedListener httpLongPollingDataChangedListener(final HttpSyncProperties httpSyncProperties) { return new HttpLongPollingDataChangedListener(httpSyncProperties); } - + @Bean @ConditionalOnMissingBean(ConfigController.class) public ConfigController configController(final HttpLongPollingDataChangedListener httpLongPollingDataChangedListener) { return new ConfigController(httpLongPollingDataChangedListener); } } - + /** * The type Zookeeper listener. */ @@ -106,7 +106,7 @@ public ConfigController configController(final HttpLongPollingDataChangedListene @ConditionalOnProperty(prefix = "shenyu.sync.zookeeper", name = "url") @EnableConfigurationProperties(ZookeeperProperties.class) static class ZookeeperListener { - + /** * register ZookeeperClient in spring ioc. * @@ -125,7 +125,7 @@ public ZookeeperClient zookeeperClient(final ZookeeperProperties zookeeperProp) client.start(); return client; } - + /** * Config event listener data changed listener. * @@ -137,11 +137,11 @@ public ZookeeperClient zookeeperClient(final ZookeeperProperties zookeeperProp) public DataChangedListener zookeeperDataChangedListener(final ZookeeperClient zkClient) { return new ZookeeperDataChangedListener(zkClient); } - + /** * Zookeeper data init zookeeper data init. * - * @param zkClient the zk client + * @param zkClient the zk client * @return the zookeeper data init */ @Bean @@ -150,7 +150,7 @@ public DataChangedInit zookeeperDataChangedInit(final ZookeeperClient zkClient) return new ZookeeperDataChangedInit(zkClient); } } - + /** * The type Nacos listener. */ @@ -158,7 +158,7 @@ public DataChangedInit zookeeperDataChangedInit(final ZookeeperClient zkClient) @ConditionalOnProperty(prefix = "shenyu.sync.nacos", name = "url") @EnableConfigurationProperties(NacosProperties.class) static class NacosListener { - + /** * register configService in spring ioc. * @@ -191,7 +191,7 @@ public ConfigService nacosConfigService(final NacosProperties nacosProp) throws } return NacosFactory.createConfigService(properties); } - + /** * Data changed listener data changed listener. * @@ -203,7 +203,7 @@ public ConfigService nacosConfigService(final NacosProperties nacosProp) throws public DataChangedListener nacosDataChangedListener(final ConfigService configService) { return new NacosDataChangedListener(configService); } - + /** * Nacos data init nacos data init. * @@ -216,7 +216,7 @@ public DataChangedInit nacosDataChangedInit(final ConfigService configService) { return new NacosDataChangedInit(configService); } } - + /** * The type Polaris listener. */ @@ -224,7 +224,7 @@ public DataChangedInit nacosDataChangedInit(final ConfigService configService) { @ConditionalOnProperty(prefix = "shenyu.sync.polaris", name = "url") @EnableConfigurationProperties(PolarisProperties.class) static class PolarisListener { - + /** * register configFileService in spring ioc. * @@ -237,7 +237,7 @@ public ConfigFileService polarisConfigFileService(final PolarisProperties polari configuration.getConfigFile().getServerConnector().setAddresses(Collections.singletonList(polarisProperties.getUrl())); return ConfigFileServiceFactory.createConfigFileService(configuration); } - + /** * register configFilePublishService in spring ioc. * @@ -250,7 +250,7 @@ public ConfigFilePublishService polarisConfigFilePublishService(final PolarisPro configuration.getConfigFile().getServerConnector().setAddresses(Collections.singletonList(polarisProperties.getUrl())); return ConfigFileServicePublishFactory.createConfigFilePublishService(configuration); } - + /** * Data changed listener data changed listener. * @@ -263,7 +263,7 @@ public DataChangedListener polarisDataChangedListener(final PolarisProperties po final ConfigFilePublishService configFilePublishService) { return new PolarisDataChangedListener(polarisProperties, configFileService, configFilePublishService); } - + /** * Polaris data init polaris data init. * @@ -275,9 +275,9 @@ public DataChangedListener polarisDataChangedListener(final PolarisProperties po public DataChangedInit polarisDataChangedInit(final PolarisProperties polarisProperties, final ConfigFileService configFileService) { return new PolarisDataChangedInit(polarisProperties, configFileService); } - + } - + /** * The WebsocketListener(default strategy). */ @@ -285,7 +285,7 @@ public DataChangedInit polarisDataChangedInit(final PolarisProperties polarisPro @ConditionalOnProperty(name = "shenyu.sync.websocket.enabled", havingValue = "true", matchIfMissing = true) @EnableConfigurationProperties(WebsocketSyncProperties.class) static class WebsocketListener { - + /** * Config event listener data changed listener. * @@ -296,7 +296,7 @@ static class WebsocketListener { public DataChangedListener websocketDataChangedListener() { return new WebsocketDataChangedListener(); } - + /** * Websocket collector. * @@ -307,7 +307,7 @@ public DataChangedListener websocketDataChangedListener() { public WebsocketCollector websocketCollector() { return new WebsocketCollector(); } - + /** * Server endpoint exporter server endpoint exporter. * @@ -319,7 +319,7 @@ public ServerEndpointExporter serverEndpointExporter() { return new ServerEndpointExporter(); } } - + /** * The type Etcd listener. */ @@ -327,7 +327,7 @@ public ServerEndpointExporter serverEndpointExporter() { @ConditionalOnProperty(prefix = "shenyu.sync.etcd", name = "url") @EnableConfigurationProperties(EtcdProperties.class) static class EtcdListener { - + /** * Init etcd client. * @@ -341,7 +341,7 @@ public EtcdClient etcdClient(final EtcdProperties etcdProperties) { .build(); return new EtcdClient(client); } - + /** * Config event listener data changed listener. * @@ -353,11 +353,11 @@ public EtcdClient etcdClient(final EtcdProperties etcdProperties) { public DataChangedListener etcdDataChangedListener(final EtcdClient etcdClient) { return new EtcdDataDataChangedListener(etcdClient); } - + /** * data init. * - * @param etcdClient the etcd client + * @param etcdClient the etcd client * @return the etcd data init */ @Bean @@ -366,7 +366,7 @@ public DataChangedInit etcdDataChangedInit(final EtcdClient etcdClient) { return new EtcdDataChangedInit(etcdClient); } } - + /** * The type Consul listener. */ @@ -374,9 +374,10 @@ public DataChangedInit etcdDataChangedInit(final EtcdClient etcdClient) { @ConditionalOnProperty(prefix = "shenyu.sync.consul", name = "url") @EnableConfigurationProperties(ConsulProperties.class) static class ConsulListener { - + /** * init Consul client. + * * @param consulProperties the consul properties * @return Consul client */ @@ -393,7 +394,7 @@ public ConsulClient consulClient(final ConsulProperties consulProperties) { throw new ShenyuException("sync.consul.url formatter is not incorrect."); } } - + /** * Config event listener data changed listener. * @@ -405,7 +406,7 @@ public ConsulClient consulClient(final ConsulProperties consulProperties) { public DataChangedListener consulDataChangedListener(final ConsulClient consulClient) { return new ConsulDataChangedListener(consulClient); } - + /** * Consul data init. * @@ -418,7 +419,7 @@ public DataChangedInit consulDataChangedInit(final ConsulClient consulClient) { return new ConsulDataChangedInit(consulClient); } } - + /** * the type apollo listener. */ @@ -426,7 +427,7 @@ public DataChangedInit consulDataChangedInit(final ConsulClient consulClient) { @ConditionalOnProperty(prefix = "shenyu.sync.apollo", name = "meta") @EnableConfigurationProperties(ApolloProperties.class) static class ApolloListener { - + /** * init Consul client. * @@ -437,7 +438,7 @@ static class ApolloListener { public ApolloClient apolloClient(final ApolloProperties apolloProperties) { return new ApolloClient(apolloProperties); } - + /** * Config event listener data changed listener. * @@ -449,7 +450,7 @@ public ApolloClient apolloClient(final ApolloProperties apolloProperties) { public DataChangedListener apolloDataChangeListener(final ApolloClient apolloClient) { return new ApolloDataChangedListener(apolloClient); } - + /** * apollo data init. * @@ -461,7 +462,7 @@ public DataChangedListener apolloDataChangeListener(final ApolloClient apolloCli public DataChangedInit apolloDataChangeInit(final ApolloClient apolloClient) { return new ApolloDataChangedInit(apolloClient); } - + } } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AlertReceiverController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AlertReceiverController.java index 5230bf607332..3b33e96e2ed6 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AlertReceiverController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AlertReceiverController.java @@ -17,6 +17,7 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.page.CommonPager; import org.apache.shenyu.admin.model.page.PageParameter; import org.apache.shenyu.admin.model.query.AlertReceiverQuery; @@ -25,16 +26,13 @@ import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.alert.model.AlertReceiverDTO; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -45,9 +43,7 @@ /** * Alert Receiver Controller. */ -@Validated -@RestController -@RequestMapping("/alert/receiver") +@RestApi("/alert/receiver") public class AlertReceiverController { @Autowired @@ -103,7 +99,7 @@ public ShenyuAdminResult getReceiverDetail(@PathVariable("id") final String id) /** * query receiver. - * @param currentPage current page + * @param currentPage current page * @param pageSize page size * @return receiver */ @@ -116,7 +112,7 @@ public ShenyuAdminResult getReceivers(@RequestParam @NotNull final Integer curre /** * send test message to receiver. - * @param alertReceiverDTO receiver + * @param alertReceiverDTO receiver * @return send result */ @PostMapping(path = "/test") @@ -127,7 +123,7 @@ public ShenyuAdminResult sendTestMsg(@Valid @RequestBody final AlertReceiverDTO return ShenyuAdminResult.success(); } else { return ShenyuAdminResult.error("Notify service not available, please check config!"); - } + } } catch (Exception e) { return ShenyuAdminResult.error("Notify service error: " + e.getMessage()); } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AlertReportController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AlertReportController.java index caaf40da9e4f..2ff15e517251 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AlertReportController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AlertReportController.java @@ -17,25 +17,21 @@ package org.apache.shenyu.admin.controller; -import org.apache.shenyu.common.dto.AlarmContent; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.service.AlertDispatchService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; +import org.apache.shenyu.common.dto.AlarmContent; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; /** * Alert report Controller. */ -@Validated -@RestController -@RequestMapping("/alert/report") +@RestApi("/alert/report") public class AlertReportController { @Autowired diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiController.java index a3e8b6d97723..c5eeddb39e38 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiController.java @@ -18,6 +18,7 @@ package org.apache.shenyu.admin.controller; import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.ApiMapper; import org.apache.shenyu.admin.model.dto.ApiDTO; import org.apache.shenyu.admin.model.page.CommonPager; @@ -29,15 +30,12 @@ import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -48,9 +46,7 @@ /** * this is api controller. */ -@Validated -@RestController -@RequestMapping("/api") +@RestApi("/api") public class ApiController { private final ApiService apiService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiDocController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiDocController.java index 3ec74da37044..03690c58828a 100755 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiDocController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ApiDocController.java @@ -17,11 +17,8 @@ package org.apache.shenyu.admin.controller; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.bean.DocInfo; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.model.vo.DocVO; @@ -33,14 +30,16 @@ import org.apache.shenyu.admin.service.manager.DocManager; import org.apache.shenyu.common.constant.AdminConstants; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; + +import java.util.Collection; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; /** * Api Documet Controller. */ -@RestController -@RequestMapping("/apidoc") +@RestApi("/apidoc") public class ApiDocController { private final DocManager docManager; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AppAuthController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AppAuthController.java index 3e09904d7683..ce014b9eda44 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AppAuthController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AppAuthController.java @@ -18,6 +18,7 @@ package org.apache.shenyu.admin.controller; import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.AppAuthMapper; import org.apache.shenyu.admin.mapper.AuthPathMapper; import org.apache.shenyu.admin.model.dto.AppAuthDTO; @@ -35,13 +36,10 @@ import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -52,9 +50,7 @@ /** * this is application authority controller. */ -@Validated -@RestController -@RequestMapping("/appAuth") +@RestApi("/appAuth") public class AppAuthController implements PagedController { private final AppAuthService appAuthService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigController.java index 39f983a0c8f3..3e2b14a81997 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ConfigController.java @@ -23,10 +23,10 @@ import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.common.dto.ConfigData; import org.apache.shenyu.common.enums.ConfigGroupEnum; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DashboardUserController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DashboardUserController.java index ce0f62ae015c..81c263bfb5d3 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DashboardUserController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DashboardUserController.java @@ -19,6 +19,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.exception.ValidFailException; import org.apache.shenyu.admin.mapper.DashboardUserMapper; import org.apache.shenyu.admin.model.custom.UserInfo; @@ -40,34 +41,27 @@ import org.apache.shenyu.common.utils.DigestUtils; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; - -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Optional; /** * this is dashboard user controller. */ -@Validated -@RestController -@RequestMapping("/dashboardUser") +@RestApi("/dashboardUser") public class DashboardUserController { private final DashboardUserService dashboardUserService; @@ -186,7 +180,7 @@ public ShenyuAdminResult modifyPassword(@PathVariable("id") @GetMapping("check/password") public AdminResult checkUserPassword() { try { - return ResultUtil.ok(dashboardUserService.checkUserPassword(SessionUtil.visitor().getUserId())); + return ResultUtil.ok(dashboardUserService.checkUserPassword(SessionUtil.visitor().getUserId())); } catch (ValidFailException exception) { return ResultUtil.error(exception.getMessage()); } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DataPermissionController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DataPermissionController.java index e444f6d20c11..fd84ae6a0c7d 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DataPermissionController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DataPermissionController.java @@ -17,6 +17,7 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.dto.DataPermissionDTO; import org.apache.shenyu.admin.model.page.CommonPager; import org.apache.shenyu.admin.model.page.PageParameter; @@ -26,14 +27,11 @@ import org.apache.shenyu.admin.model.vo.DataPermissionPageVO; import org.apache.shenyu.admin.service.DataPermissionService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotNull; @@ -41,9 +39,7 @@ /** * this is dataPermission controller. */ -@Validated -@RestController -@RequestMapping("/data-permission") +@RestApi("/data-permission") public class DataPermissionController { private final DataPermissionService dataPermissionService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DetailController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DetailController.java index 6f20b5420341..9fcd162f80fc 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DetailController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DetailController.java @@ -17,20 +17,18 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.dto.DetailDTO; import org.apache.shenyu.admin.model.page.PageParameter; import org.apache.shenyu.admin.model.query.DetailQuery; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.service.DetailService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -38,9 +36,7 @@ import javax.validation.constraints.NotNull; import java.util.List; -@Validated -@RestController -@RequestMapping("/detail") +@RestApi("/detail") public class DetailController { private final DetailService detailService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryController.java index 348131f3ac7f..627fe8985a96 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryController.java @@ -17,27 +17,23 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.dto.DiscoveryDTO; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.service.DiscoveryService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; -import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.DeleteMapping; import javax.validation.Valid; /** * this is discovery controller. */ -@Validated -@RestController -@RequestMapping("/discovery") +@RestApi("/discovery") public class DiscoveryController { private final DiscoveryService discoveryService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryUpstreamController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryUpstreamController.java index bf2a3d08af9c..d9350d1c4ced 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryUpstreamController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryUpstreamController.java @@ -17,28 +17,24 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.PluginMapper; import org.apache.shenyu.admin.model.dto.DiscoveryUpstreamDTO; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.service.DiscoveryUpstreamService; import org.apache.shenyu.admin.validation.annotation.Existed; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import java.util.List; -@RestController -@RequestMapping("/discovery-upstream") -@Validated +@RestApi("/discovery-upstream") public class DiscoveryUpstreamController { private final DiscoveryUpstreamService discoveryUpstreamService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/FieldController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/FieldController.java index 0e29a9810e80..9058d49ca7a5 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/FieldController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/FieldController.java @@ -17,20 +17,18 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.dto.FieldDTO; import org.apache.shenyu.admin.model.page.PageParameter; import org.apache.shenyu.admin.model.query.FieldQuery; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.service.FieldService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -38,9 +36,7 @@ import javax.validation.constraints.NotNull; import java.util.List; -@Validated -@RestController -@RequestMapping("/field") +@RestApi("/field") public class FieldController { private final FieldService fieldService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MetaDataController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MetaDataController.java index 8fb4d8bb6a35..4a474f14a52a 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MetaDataController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MetaDataController.java @@ -17,9 +17,8 @@ package org.apache.shenyu.admin.controller; -import java.util.List; - import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.dto.BatchCommonDTO; import org.apache.shenyu.admin.model.dto.MetaDataDTO; import org.apache.shenyu.admin.model.page.CommonPager; @@ -31,27 +30,23 @@ import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; /** * The type Meta data controller. */ -@Validated -@RestController -@RequestMapping("/meta-data") +@RestApi("/meta-data") public class MetaDataController { private final MetaDataService metaDataService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MockRequestRecordController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MockRequestRecordController.java index 2d06a99f028b..5414e7311e67 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MockRequestRecordController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/MockRequestRecordController.java @@ -17,6 +17,7 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.MockRequestRecordMapper; import org.apache.shenyu.admin.model.dto.MockRequestRecordDTO; import org.apache.shenyu.admin.model.page.PageParameter; @@ -25,15 +26,12 @@ import org.apache.shenyu.admin.service.MockRequestRecordService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -44,9 +42,7 @@ /** * AlertTemplate MockRequestRecordController. */ -@Validated -@RestController -@RequestMapping("/mock") +@RestApi("/mock") public class MockRequestRecordController { private final MockRequestRecordService mockRequestRecordService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/OperationRecordLogController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/OperationRecordLogController.java index c4f1b038dd3a..59e5abc663af 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/OperationRecordLogController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/OperationRecordLogController.java @@ -17,6 +17,7 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.entity.OperationRecordLog; import org.apache.shenyu.admin.model.query.RecordLogQueryCondition; import org.apache.shenyu.admin.model.result.AdminResult; @@ -26,12 +27,9 @@ import org.apache.shenyu.common.utils.DateUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import java.util.Date; import java.util.List; @@ -39,9 +37,7 @@ /** * OperationRecordLogController. */ -@Validated -@RestController -@RequestMapping("/operation-record/log") +@RestApi("/operation-record/log") public class OperationRecordLogController implements PagedController { private final OperationRecordLogService recordLogService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PermissionController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PermissionController.java index a29ed1ed43bd..898af4a379f9 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PermissionController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PermissionController.java @@ -17,22 +17,20 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.model.vo.PermissionMenuVO; import org.apache.shenyu.admin.service.PermissionService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import java.util.Optional; /** * this is permission controller. */ -@RestController -@RequestMapping("/permission") +@RestApi("/permission") public class PermissionController { private final PermissionService permissionService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PlatformController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PlatformController.java index bf60929a6b27..e31ea4973c09 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PlatformController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PlatformController.java @@ -17,22 +17,20 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.model.vo.LoginDashboardUserVO; import org.apache.shenyu.admin.service.DashboardUserService; import org.apache.shenyu.admin.service.EnumService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import java.util.Optional; /** * this is platform controller. */ -@RestController -@RequestMapping("/platform") +@RestApi("/platform") public class PlatformController { private final DashboardUserService dashboardUserService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginController.java index f768ba4b3db6..bd9b2f0b30cb 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginController.java @@ -18,6 +18,7 @@ package org.apache.shenyu.admin.controller; import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.PluginMapper; import org.apache.shenyu.admin.model.dto.BatchCommonDTO; import org.apache.shenyu.admin.model.dto.PluginDTO; @@ -35,15 +36,12 @@ import org.apache.shenyu.common.dto.PluginData; import org.apache.shenyu.common.enums.DataEventTypeEnum; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestBody; import javax.validation.Valid; @@ -55,9 +53,7 @@ /** * this is plugin controller. */ -@Validated -@RestController -@RequestMapping("/plugin") +@RestApi("/plugin") public class PluginController implements PagedController { private final PluginService pluginService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginHandleController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginHandleController.java index f5ea74170afe..4ac02088db27 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginHandleController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginHandleController.java @@ -17,8 +17,7 @@ package org.apache.shenyu.admin.controller; -import java.util.List; - +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.PluginHandleMapper; import org.apache.shenyu.admin.model.dto.PluginHandleDTO; import org.apache.shenyu.admin.model.page.CommonPager; @@ -30,28 +29,24 @@ import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; /** * this is a plugin handle controller. */ -@Validated -@RestController -@RequestMapping("/plugin-handle") +@RestApi("/plugin-handle") public class PluginHandleController { private final PluginHandleService pluginHandleService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ProxySelectorController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ProxySelectorController.java index 0c07f098a186..58fc050383e2 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ProxySelectorController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ProxySelectorController.java @@ -17,6 +17,7 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.dto.ProxySelectorAddDTO; import org.apache.shenyu.admin.model.page.CommonPager; import org.apache.shenyu.admin.model.page.PageParameter; @@ -25,15 +26,12 @@ import org.apache.shenyu.admin.model.vo.ProxySelectorVO; import org.apache.shenyu.admin.service.ProxySelectorService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; -import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.DeleteMapping; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -41,9 +39,7 @@ import javax.validation.constraints.NotNull; import java.util.List; -@Validated -@RestController -@RequestMapping("/proxy-selector") +@RestApi("/proxy-selector") public class ProxySelectorController { private final ProxySelectorService proxySelectorService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ResourceController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ResourceController.java index 76ab49cd3f81..98a1fa6b29c6 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ResourceController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ResourceController.java @@ -18,6 +18,7 @@ package org.apache.shenyu.admin.controller; import org.apache.commons.collections4.CollectionUtils; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.ResourceMapper; import org.apache.shenyu.admin.model.dto.CreateResourceDTO; import org.apache.shenyu.admin.model.dto.ResourceDTO; @@ -32,32 +33,25 @@ import org.apache.shenyu.admin.validation.annotation.Existed; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; - -import java.util.List; -import java.util.Optional; - -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Optional; /** * this is resource controller. */ -@Validated -@RestController -@RequestMapping("/resource") +@RestApi("/resource") public class ResourceController { private final ResourceService resourceService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RoleController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RoleController.java index 3999384416d8..659c8027c16c 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RoleController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RoleController.java @@ -17,9 +17,7 @@ package org.apache.shenyu.admin.controller; -import java.util.List; -import java.util.Optional; - +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.RoleMapper; import org.apache.shenyu.admin.model.dto.RoleDTO; import org.apache.shenyu.admin.model.page.CommonPager; @@ -32,28 +30,25 @@ import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Optional; /** * this is role controller. */ -@Validated -@RestController -@RequestMapping("/role") +@RestApi("/role") public class RoleController { private static final String SUPER = "super"; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RuleController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RuleController.java index 103de3131126..49be6a1069c7 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RuleController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RuleController.java @@ -17,6 +17,7 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.RuleMapper; import org.apache.shenyu.admin.model.dto.RuleDTO; import org.apache.shenyu.admin.model.page.CommonPager; @@ -27,20 +28,17 @@ import org.apache.shenyu.admin.model.vo.RuleVO; import org.apache.shenyu.admin.service.PageService; import org.apache.shenyu.admin.service.RuleService; -import org.apache.shenyu.common.utils.ListUtil; import org.apache.shenyu.admin.utils.SessionUtil; import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; -import org.springframework.validation.annotation.Validated; +import org.apache.shenyu.common.utils.ListUtil; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -51,9 +49,7 @@ /** * this is rule controller. */ -@Validated -@RestController -@RequestMapping("/rule") +@RestApi("/rule") public class RuleController implements PagedController { private final RuleService ruleService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SandboxController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SandboxController.java index e500782c678b..6a6490282c79 100755 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SandboxController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SandboxController.java @@ -17,12 +17,11 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.dto.ProxyGatewayDTO; import org.apache.shenyu.admin.service.SandboxService; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -32,8 +31,7 @@ /** * Sandbox environment. */ -@RestController -@RequestMapping("/sandbox") +@RestApi("/sandbox") public class SandboxController { private final SandboxService sandboxService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SelectorController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SelectorController.java index b5ea707bd9d3..2f5e5f8f88f8 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SelectorController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SelectorController.java @@ -17,6 +17,7 @@ package org.apache.shenyu.admin.controller; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.SelectorMapper; import org.apache.shenyu.admin.model.dto.SelectorDTO; import org.apache.shenyu.admin.model.page.CommonPager; @@ -27,20 +28,17 @@ import org.apache.shenyu.admin.model.vo.SelectorVO; import org.apache.shenyu.admin.service.PageService; import org.apache.shenyu.admin.service.SelectorService; -import org.apache.shenyu.common.utils.ListUtil; import org.apache.shenyu.admin.utils.SessionUtil; import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; -import org.springframework.validation.annotation.Validated; +import org.apache.shenyu.common.utils.ListUtil; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; @@ -51,9 +49,7 @@ /** * this is selector controller. */ -@Validated -@RestController -@RequestMapping("/selector") +@RestApi("/selector") public class SelectorController implements PagedController { private final SelectorService selectorService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ShenyuDictController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ShenyuDictController.java index 40feae4578ae..a072ba888327 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ShenyuDictController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ShenyuDictController.java @@ -17,8 +17,7 @@ package org.apache.shenyu.admin.controller; -import java.util.List; - +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.ShenyuDictMapper; import org.apache.shenyu.admin.model.dto.BatchCommonDTO; import org.apache.shenyu.admin.model.dto.ShenyuDictDTO; @@ -30,28 +29,24 @@ import org.apache.shenyu.admin.validation.annotation.Existed; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; /** * this is a shenyu dict controller. */ -@Validated -@RestController -@RequestMapping("/shenyu-dict") +@RestApi("/shenyu-dict") public class ShenyuDictController { private final ShenyuDictService shenyuDictService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/TagController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/TagController.java index 6ef5c2d53673..382628753774 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/TagController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/TagController.java @@ -18,11 +18,7 @@ package org.apache.shenyu.admin.controller; import com.google.common.collect.Lists; -import java.util.List; -import java.util.Optional; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.TagMapper; import org.apache.shenyu.admin.model.dto.TagDTO; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; @@ -30,19 +26,20 @@ import org.apache.shenyu.admin.service.TagService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -@Validated -@RestController -@RequestMapping("/tag") +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import java.util.List; +import java.util.Optional; + +@RestApi("/tag") public class TagController { private final TagService tagService; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/TagRelationController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/TagRelationController.java index 588b2bf47917..847067b62b10 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/TagRelationController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/TagRelationController.java @@ -18,28 +18,25 @@ package org.apache.shenyu.admin.controller; import com.google.common.collect.Lists; -import java.util.List; -import java.util.Optional; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; +import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.model.dto.TagRelationDTO; import org.apache.shenyu.admin.model.entity.TagRelationDO; import org.apache.shenyu.admin.model.result.ShenyuAdminResult; import org.apache.shenyu.admin.service.TagRelationService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -@Validated -@RestController -@RequestMapping("/tag-relation/") +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import java.util.List; +import java.util.Optional; + +@RestApi("/tag-relation/") public class TagRelationController { private final TagRelationService tagRelationService;