This is an automated email from the ASF dual-hosted git repository.

min pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-ops.git


The following commit(s) were added to refs/heads/develop by this push:
     new 86e7ec4  api to restful
86e7ec4 is described below

commit 86e7ec4d803accd794ccce6d8f0f242f23697529
Author: nzomkxia <[email protected]>
AuthorDate: Mon Oct 15 11:09:47 2018 +0800

    api to restful
---
 .../admin/controller/LoadBalanceController.java    | 37 +++++-----
 .../admin/controller/OverridesController.java      | 30 ++++----
 .../dubbo/admin/controller/RoutesController.java   | 50 ++++++-------
 .../dubbo/admin/controller/ServiceController.java  | 82 ++++++++++------------
 .../dubbo/admin/controller/WeightController.java   | 39 +++++-----
 .../admin/registry/common/util/OverrideUtils.java  |  4 ++
 .../java/org/apache/dubbo/admin/util/MD5Util.java  |  1 -
 .../src/components/ServiceDetail.vue               |  2 +-
 .../src/components/ServiceSearch.vue               | 18 +++--
 .../src/components/governance/Overrides.vue        | 74 +++++++++++--------
 .../src/components/governance/RoutingRule.vue      | 68 +++++++++---------
 .../src/components/governance/WeightAdjust.vue     | 71 ++++++++++++-------
 12 files changed, 259 insertions(+), 217 deletions(-)

diff --git 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java
 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java
index 1b0d0c7..29665c2 100644
--- 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java
+++ 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java
@@ -18,7 +18,6 @@
 package org.apache.dubbo.admin.controller;
 
 import org.apache.dubbo.admin.dto.BalancingDTO;
-import org.apache.dubbo.admin.dto.BaseDTO;
 import org.apache.dubbo.admin.governance.service.OverrideService;
 import org.apache.dubbo.admin.registry.common.domain.LoadBalance;
 import org.apache.dubbo.admin.registry.common.domain.Override;
@@ -32,14 +31,14 @@ import java.util.List;
 import static 
org.apache.dubbo.admin.registry.common.util.OverrideUtils.overrideToLoadBalance;
 
 @RestController
-@RequestMapping("/api/balancing")
+@RequestMapping("/api/{env}/rules/balancing")
 public class LoadBalanceController {
 
     @Autowired
     private OverrideService overrideService;
 
-    @RequestMapping(value = "/create", method = RequestMethod.POST)
-    public boolean createLoadbalance(@RequestBody BalancingDTO balancingDTO) {
+    @RequestMapping(method = RequestMethod.POST)
+    public boolean createLoadbalance(@RequestBody BalancingDTO balancingDTO, 
@PathVariable String env) {
         String serviceName = balancingDTO.getService();
         if (serviceName == null || serviceName.length() == 0) {
             //TODO throw exception
@@ -52,9 +51,8 @@ public class LoadBalanceController {
         return true;
     }
 
-    @RequestMapping(value = "/update", method = RequestMethod.POST)
-    public boolean updateLoadbalance(@RequestBody BalancingDTO balancingDTO) {
-        String id = balancingDTO.getId();
+    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
+    public boolean updateLoadbalance(@PathVariable String id, @RequestBody 
BalancingDTO balancingDTO, @PathVariable String env) {
         Override override = overrideService.findById(id);
         if (override == null) {
             //TODO throw exception
@@ -64,17 +62,20 @@ public class LoadBalanceController {
         loadBalance.setStrategy(balancingDTO.getStrategy());
         loadBalance.setMethod(formatMethodName(balancingDTO.getMethodName()));
         loadBalance.setService(old.getService());
-        loadBalance.setId(old.getId());
+        loadBalance.setHash(id);
         
overrideService.updateOverride(OverrideUtils.loadBalanceToOverride(loadBalance));
         return true;
     }
 
-    @RequestMapping(value = "/search", method = RequestMethod.GET)
-    public List<BalancingDTO> allLoadbalances(@RequestParam String 
serviceName) {
-        if (serviceName == null || serviceName.length() == 0) {
+    @RequestMapping(method = RequestMethod.GET)
+    public List<BalancingDTO> searchLoadbalances(@RequestParam(required = 
false) String service, @PathVariable String env) {
+        List<Override> overrides;
+        if (service == null || service.length() == 0) {
+            overrides = overrideService.findAll();
            //TODO throw Exception
+        } else {
+            overrides = overrideService.findByService(service);
         }
-        List<Override> overrides = overrideService.findByService(serviceName);
         List<BalancingDTO> loadBalances = new ArrayList<>();
         if (overrides != null) {
             for (Override override : overrides) {
@@ -92,8 +93,8 @@ public class LoadBalanceController {
         return loadBalances;
     }
 
-    @RequestMapping("/detail")
-    public BalancingDTO detail(@RequestParam String id) {
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public BalancingDTO detailLoadBalance(@PathVariable String id, 
@PathVariable String env) {
         Override override =  overrideService.findById(id);
         if (override == null) {
             //TODO throw exception
@@ -107,9 +108,11 @@ public class LoadBalanceController {
         return balancingDTO;
     }
 
-    @RequestMapping(value  = "/delete", method = RequestMethod.POST)
-    public boolean delete(@RequestBody BaseDTO baseDTO) {
-        String id = baseDTO.getId();
+    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
+    public boolean deleteLoadBalance(@PathVariable String id, @PathVariable 
String env) {
+        if (id == null) {
+            throw new IllegalArgumentException("Argument of id is null!");
+        }
         overrideService.deleteOverride(id);
         return true;
     }
diff --git 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/OverridesController.java
 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/OverridesController.java
index ef5cddf..4673601 100644
--- 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/OverridesController.java
+++ 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/OverridesController.java
@@ -31,14 +31,14 @@ import java.util.List;
 import java.util.Map;
 
 @RestController
-@RequestMapping("/api/override")
+@RequestMapping("/api/{env}/rules/override")
 public class OverridesController {
 
     @Autowired
     private OverrideService overrideService;
 
-    @RequestMapping(value = "/create", method = RequestMethod.POST)
-    public boolean createOverride(@RequestBody OverrideDTO overrideDTO) {
+    @RequestMapping(method = RequestMethod.POST)
+    public boolean createOverride(@RequestBody OverrideDTO overrideDTO, 
@PathVariable String env) {
         String serviceName = overrideDTO.getService();
         if (serviceName == null || serviceName.length() == 0) {
             //TODO throw exception
@@ -53,9 +53,8 @@ public class OverridesController {
         return true;
     }
 
-    @RequestMapping(value = "/update", method = RequestMethod.POST)
-    public boolean updateOverride(@RequestBody OverrideDTO overrideDTO) {
-        String id = overrideDTO.getId();
+    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
+    public boolean updateOverride(@PathVariable String id, @RequestBody 
OverrideDTO overrideDTO, @PathVariable String env) {
         Override old = overrideService.findById(id);
         if (old == null) {
             //TODO handle exception
@@ -71,9 +70,13 @@ public class OverridesController {
         return true;
     }
 
-    @RequestMapping(value = "/search", method = RequestMethod.GET)
-    public List<OverrideDTO> allOverride(@RequestParam String serviceName) {
-        List<Override> overrides = overrideService.findByService(serviceName);
+    @RequestMapping(method = RequestMethod.GET)
+    public List<OverrideDTO> searchOverride(@RequestParam(required = false) 
String service, @PathVariable String env) {
+        List<Override> overrides;
+        if (service == null || service.length() == 0) {
+           overrides = overrideService.findAll();
+        }
+        overrides = overrideService.findByService(service);
         List<OverrideDTO> result = new ArrayList<>();
         for (Override override : overrides) {
             OverrideDTO overrideDTO = new OverrideDTO();
@@ -88,8 +91,8 @@ public class OverridesController {
         return result;
     }
 
-    @RequestMapping("/detail")
-    public OverrideDTO detail(@RequestParam String id) {
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public OverrideDTO detailOverride(@PathVariable String id, @PathVariable 
String env) {
         Override override = overrideService.findById(id);
         if (override == null) {
             //TODO throw exception
@@ -103,9 +106,8 @@ public class OverridesController {
         return overrideDTO;
     }
 
-    @RequestMapping(value  = "/delete", method = RequestMethod.POST)
-    public boolean delete(@RequestBody BaseDTO baseDTO) {
-        String id = baseDTO.getId();
+    @RequestMapping(value  = "/{id}", method = RequestMethod.DELETE)
+    public boolean deleteOverride(@PathVariable String id, @PathVariable 
String env) {
         overrideService.deleteOverride(id);
         return true;
     }
diff --git 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/RoutesController.java
 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/RoutesController.java
index bc71551..3d3c264 100644
--- 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/RoutesController.java
+++ 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/RoutesController.java
@@ -30,7 +30,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 @RestController
-@RequestMapping("/api/routes")
+@RequestMapping("/api/{env}/rules/route")
 public class RoutesController {
 
     @Autowired
@@ -38,8 +38,8 @@ public class RoutesController {
     @Autowired
     private ProviderService providerService;
 
-    @RequestMapping(value = "/create", method = RequestMethod.POST)
-    public boolean createRule(@RequestBody RouteDTO routeDTO) {
+    @RequestMapping(method = RequestMethod.POST)
+    public boolean createRule(@RequestBody RouteDTO routeDTO, @PathVariable 
String env) {
         String serviceName = routeDTO.getService();
         String app = routeDTO.getApp();
         if (serviceName == null && app == null) {
@@ -75,9 +75,8 @@ public class RoutesController {
         return true;
     }
 
-    @RequestMapping(value = "/update", method = RequestMethod.POST)
-    public boolean updateRule(@RequestBody RouteDTO routeDTO) {
-        String id = routeDTO.getId();
+    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
+    public boolean updateRule(@PathVariable String id, @RequestBody RouteDTO 
routeDTO, @PathVariable String env) {
         Route route = routeService.findRoute(id);
         if (route == null) {
             //TODO Exception
@@ -99,18 +98,17 @@ public class RoutesController {
         return true;
     }
 
-    @RequestMapping(value = "/search", method = RequestMethod.GET)
-    public List<RouteDTO> allRoutes(@RequestParam(required = false) String app,
-                                    @RequestParam(required = false) String 
serviceName) {
-        List<Route> routes = null;
+    @RequestMapping(method = RequestMethod.GET)
+    public List<RouteDTO> searchRoutes(@RequestParam(required = false) String 
app,
+                                    @RequestParam(required = false) String 
service, @PathVariable String env) {
+        List<Route> routes;
         if (app != null) {
            // app scope in 2.7
         }
-        if (serviceName != null) {
-            routes = routeService.findByService(serviceName);
-        }
-        if (serviceName == null && app == null) {
-            // TODO throw exception
+        if (service != null) {
+            routes = routeService.findByService(service);
+        } else {
+            routes = routeService.findAll();
         }
         List<RouteDTO> routeDTOS = new ArrayList<>();
         for (Route route : routes) {
@@ -123,15 +121,14 @@ public class RoutesController {
             routeDTO.setPriority(route.getPriority());
             routeDTO.setRuntime(route.isRuntime());
             routeDTO.setService(route.getService());
-            routeDTO.setId(MD5Util.MD5_16bit(route.toUrl().toFullString()));
+            routeDTO.setId(route.getHash());
             routeDTOS.add(routeDTO);
         }
-        //no support for findAll or findByaddress
         return routeDTOS;
     }
 
-    @RequestMapping("/detail")
-    public RouteDTO routeDetail(@RequestParam String id) {
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public RouteDTO detailRoute(@PathVariable String id, @PathVariable String 
env) {
         Route route = routeService.findRoute(id);
         if (route == null) {
             // TODO throw exception
@@ -149,25 +146,22 @@ public class RoutesController {
         return routeDTO;
     }
 
-    @RequestMapping(value = "/delete", method = RequestMethod.POST)
-    public boolean deleteRoute(@RequestBody BaseDTO baseDTO) {
-        String id = baseDTO.getId();
+    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
+    public boolean deleteRoute(@PathVariable String id, @PathVariable String 
env) {
         routeService.deleteRoute(id);
         return true;
     }
 
-    @RequestMapping(value = "/enable", method = RequestMethod.POST)
-    public boolean enableRoute(@RequestBody BaseDTO baseDTO) {
+    @RequestMapping(value = "/enable/{id}", method = RequestMethod.PUT)
+    public boolean enableRoute(@PathVariable String id, @PathVariable String 
env) {
 
-        String id = baseDTO.getId();
         routeService.enableRoute(id);
         return true;
     }
 
-    @RequestMapping(value = "/disable", method = RequestMethod.POST)
-    public boolean disableRoute(@RequestBody BaseDTO baseDTO) {
+    @RequestMapping(value = "/disable/{id}", method = RequestMethod.PUT)
+    public boolean disableRoute(@PathVariable String id, @PathVariable String 
env) {
 
-        String id = baseDTO.getId();
         routeService.disableRoute(id);
         return true;
     }
diff --git 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/ServiceController.java
 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/ServiceController.java
index b73754a..7629877 100644
--- 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/ServiceController.java
+++ 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/ServiceController.java
@@ -37,7 +37,7 @@ import java.util.Map;
 
 
 @RestController
-@RequestMapping("/api/service")
+@RequestMapping("/api/{env}/service")
 public class ServiceController {
 
     @Autowired
@@ -46,60 +46,45 @@ public class ServiceController {
     @Autowired
     private ConsumerService consumerService;
 
-    @RequestMapping(value = "/search", method = RequestMethod.GET)
-    public List<ServiceDTO> search(@RequestParam String pattern,
-                                   @RequestParam String filter) {
+    @RequestMapping(method = RequestMethod.GET)
+    public List<ServiceDTO> searchService(@RequestParam String pattern,
+                                   @RequestParam(required = false) String 
filter) {
 
         List<Provider> allProviders = providerService.findAll();
 
         List<ServiceDTO> result = new ArrayList<>();
-        if (pattern.equals("application")) {
-            for (Provider provider : allProviders) {
-                Map<String, String> map = 
StringUtils.parseQueryString(provider.getParameters());
-                String app = map.get(Constants.APPLICATION_KEY);
-                if (app.toLowerCase().contains(filter)) {
-                    ServiceDTO s = new ServiceDTO();
-                    s.setAppName(app);
-                    s.setService(provider.getService());
-                    s.setGroup(map.get(Constants.GROUP_KEY));
-                    s.setVersion(map.get(Constants.VERSION_KEY));
-                    result.add(s);
+        for (Provider provider : allProviders) {
+            Map<String, String> map = 
StringUtils.parseQueryString(provider.getParameters());
+            ServiceDTO s = new ServiceDTO();
+            if (filter == null || filter.length() == 0) {
+                s.setAppName(provider.getApplication());
+                s.setService(provider.getService());
+                s.setGroup(map.get(Constants.GROUP_KEY));
+                s.setVersion(map.get(Constants.VERSION_KEY));
+                result.add(s);
+            } else {
+                filter = filter.toLowerCase();
+                String key = null;
+                switch (pattern) {
+                    case "application":
+                        key = provider.getApplication().toLowerCase();
+                        break;
+                    case "service name":
+                        key = provider.getService().toLowerCase();
+                        break;
+                    case "IP":
+                        key = provider.getService().toLowerCase();
+                        break;
                 }
-            }
-
-        } else if (pattern.equals("service name")) {
-            for (Provider provider : allProviders) {
-                String service = provider.getService();
-                Map<String, String> map = 
StringUtils.parseQueryString(provider.getParameters());
-                if (service.toLowerCase().contains(filter.toLowerCase())) {
-                    ServiceDTO s = new ServiceDTO();
-                    s.setAppName(map.get(Constants.APPLICATION_KEY));
-                    s.setService(service);
-                    s.setGroup(map.get(Constants.GROUP_KEY));
-                    s.setVersion(map.get(Constants.VERSION_KEY));
-                    result.add(s);
-                }
-            }
-
-        } else if (pattern.equals("IP")) {
-            for (Provider provider : allProviders) {
-                String address = provider.getAddress();
-                Map<String, String> map = 
StringUtils.parseQueryString(provider.getParameters());
-                if (address.contains(filter)) {
-                    ServiceDTO s = new ServiceDTO();
-                    s.setAppName(map.get(Constants.APPLICATION_KEY));
-                    s.setService(provider.getService());
-                    s.setGroup(map.get(Constants.GROUP_KEY));
-                    s.setVersion(map.get(Constants.VERSION_KEY));
-                    result.add(s);
+                if (key.contains(filter)) {
+                    result.add(createService(provider, map));
                 }
-
             }
         }
         return result;
     }
 
-    @RequestMapping("/detail")
+    @RequestMapping("/{app}/{service}")
     public ServiceDetailDTO serviceDetail(@RequestParam String app, 
@RequestParam String service) {
         List<Provider> providers = providerService.findByAppandService(app, 
service);
 
@@ -111,4 +96,13 @@ public class ServiceController {
         return serviceDetailDTO;
     }
 
+    private ServiceDTO createService(Provider provider, Map<String, String> 
map) {
+        ServiceDTO serviceDTO = new ServiceDTO();
+        serviceDTO.setAppName(provider.getApplication());
+        serviceDTO.setService(provider.getService());
+        serviceDTO.setGroup(map.get(Constants.GROUP_KEY));
+        serviceDTO.setVersion(map.get(Constants.VERSION_KEY));
+        return serviceDTO;
+    }
+
 }
diff --git 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/WeightController.java
 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/WeightController.java
index 01f0cc8..7a8e3de 100644
--- 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/WeightController.java
+++ 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/WeightController.java
@@ -17,7 +17,6 @@
 
 package org.apache.dubbo.admin.controller;
 
-import org.apache.dubbo.admin.dto.BaseDTO;
 import org.apache.dubbo.admin.dto.WeightDTO;
 import org.apache.dubbo.admin.governance.service.OverrideService;
 import org.apache.dubbo.admin.registry.common.domain.Override;
@@ -30,14 +29,14 @@ import java.util.ArrayList;
 import java.util.List;
 
 @RestController
-@RequestMapping("/api/weight")
+@RequestMapping("/api/{env}/rules/weight")
 public class WeightController {
 
     @Autowired
     private OverrideService overrideService;
 
-    @RequestMapping(value = "/create", method = RequestMethod.POST)
-    public boolean createWeight(@RequestBody WeightDTO weightDTO) {
+    @RequestMapping(method = RequestMethod.POST)
+    public boolean createWeight(@RequestBody WeightDTO weightDTO, 
@PathVariable String env) {
         String[] addresses = weightDTO.getProvider();
         for (String address : addresses) {
             Weight weight = new Weight();
@@ -49,9 +48,8 @@ public class WeightController {
         return true;
     }
 
-    @RequestMapping(value = "/update", method = RequestMethod.POST)
-    public boolean updateWeight(@RequestBody WeightDTO weightDTO) {
-        String id = weightDTO.getId();
+    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
+    public boolean updateWeight(@PathVariable String id, @RequestBody 
WeightDTO weightDTO, @PathVariable String env) {
         if (id == null) {
             //TODO throw exception
         }
@@ -60,14 +58,22 @@ public class WeightController {
             //TODO throw exception
         }
         Weight old = OverrideUtils.overrideToWeight(override);
-        old.setWeight(weightDTO.getWeight());
-        overrideService.updateOverride(OverrideUtils.weightToOverride(old));
+        Weight weight = new Weight();
+        weight.setWeight(weightDTO.getWeight());
+        weight.setHash(id);
+        weight.setService(old.getService());
+        overrideService.updateOverride(OverrideUtils.weightToOverride(weight));
         return true;
     }
 
-    @RequestMapping(value = "/search", method = RequestMethod.GET)
-    public List<WeightDTO> allWeight(@RequestParam String serviceName) {
-        List<Override> overrides = overrideService.findByService(serviceName);
+    @RequestMapping(method = RequestMethod.GET)
+    public List<WeightDTO> searchWeight(@RequestParam(required = false) String 
service, @PathVariable String env) {
+        List<Override> overrides;
+        if (service == null || service.length() == 0) {
+            overrides = overrideService.findAll();
+        } else {
+            overrides = overrideService.findByService(service);
+        }
         List<WeightDTO> weightDTOS = new ArrayList<>();
         for (Override override : overrides) {
             Weight w = OverrideUtils.overrideToWeight(override);
@@ -83,8 +89,8 @@ public class WeightController {
         return weightDTOS;
     }
 
-    @RequestMapping("/detail")
-    public WeightDTO detail(@RequestParam String id) {
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public WeightDTO detailWeight(@PathVariable String id, @PathVariable 
String env) {
         Override override = overrideService.findById(id);
         if (override != null) {
 
@@ -99,9 +105,8 @@ public class WeightController {
         return null;
     }
 
-    @RequestMapping(value = "/delete", method = RequestMethod.POST)
-    public boolean delete(@RequestBody BaseDTO baseDTO) {
-        String id = baseDTO.getId();
+    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
+    public boolean deleteWeight(@PathVariable String id, @PathVariable String 
env) {
         overrideService.deleteOverride(id);
         return true;
     }
diff --git 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/registry/common/util/OverrideUtils.java
 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/registry/common/util/OverrideUtils.java
index 0f9f439..2f64195 100644
--- 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/registry/common/util/OverrideUtils.java
+++ 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/registry/common/util/OverrideUtils.java
@@ -46,6 +46,7 @@ public class OverrideUtils {
                         Weight weight = new Weight();
                         weight.setAddress(o.getAddress());
                         weight.setId(o.getId());
+                        weight.setHash(o.getHash());
                         weight.setService(o.getService());
                         weight.setWeight(Integer.valueOf(entry.getValue()));
                         weights.add(weight);
@@ -67,6 +68,7 @@ public class OverrideUtils {
     public static Override weightToOverride(Weight weight) {
         Override override = new Override();
         override.setId(weight.getId());
+        override.setHash(weight.getHash());
         override.setAddress(weight.getAddress());
         override.setEnabled(true);
         override.setParams("weight=" + weight.getWeight());
@@ -96,6 +98,7 @@ public class OverrideUtils {
 
                         loadBalance.setMethod(method);
                         loadBalance.setId(o.getId());
+                        loadBalance.setHash(o.getHash());
                         loadBalance.setService(o.getService());
                         loadBalance.setStrategy(entry.getValue());
                         loadBalances.add(loadBalance);
@@ -118,6 +121,7 @@ public class OverrideUtils {
     public static Override loadBalanceToOverride(LoadBalance loadBalance) {
         Override override = new Override();
         override.setId(loadBalance.getId());
+        override.setHash(loadBalance.getHash());
         override.setService(loadBalance.getService());
         override.setEnabled(true);
         String method = loadBalance.getMethod();
diff --git 
a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/util/MD5Util.java 
b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/util/MD5Util.java
index 6e8655f..ac03388 100644
--- a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/util/MD5Util.java
+++ b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/util/MD5Util.java
@@ -19,7 +19,6 @@ package org.apache.dubbo.admin.util;
 
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
-import javax.sound.midi.Soundbank;
 import javax.xml.bind.DatatypeConverter;
 
 public class MD5Util {
diff --git a/dubbo-admin-frontend/src/components/ServiceDetail.vue 
b/dubbo-admin-frontend/src/components/ServiceDetail.vue
index 9138594..caf3967 100644
--- a/dubbo-admin-frontend/src/components/ServiceDetail.vue
+++ b/dubbo-admin-frontend/src/components/ServiceDetail.vue
@@ -170,7 +170,7 @@
     }),
     methods: {
       detail: function (app, service) {
-        AXIOS.get('/service/detail?' + 'app=' + app + '&service=' + service)
+        AXIOS.get('/service/' + app + '/' + service)
             .then(response => {
               this.providerDetails = response.data.providers
               this.consumerDetails = response.data.consumers
diff --git a/dubbo-admin-frontend/src/components/ServiceSearch.vue 
b/dubbo-admin-frontend/src/components/ServiceSearch.vue
index 9c425aa..0642459 100644
--- a/dubbo-admin-frontend/src/components/ServiceSearch.vue
+++ b/dubbo-admin-frontend/src/components/ServiceSearch.vue
@@ -144,13 +144,17 @@
         this.search(this.filter, pattern, true)
       },
       search: function (filter, pattern, rewrite) {
-        AXIOS.get('service/search?pattern=' + pattern + '&filter=' + filter)
-          .then(response => {
-            this.services = response.data
-            if (rewrite) {
-              this.$router.push({path: 'service', query: {filter: filter, 
pattern: pattern}})
-            }
-          })
+        AXIOS.get('/service', {
+          params: {
+            pattern: pattern,
+            filter: filter
+          }
+        }).then(response => {
+          this.services = response.data
+          if (rewrite) {
+            this.$router.push({path: 'service', query: {filter: filter, 
pattern: pattern}})
+          }
+        })
       }
     },
     mounted: function () {
diff --git a/dubbo-admin-frontend/src/components/governance/Overrides.vue 
b/dubbo-admin-frontend/src/components/governance/Overrides.vue
index 2206b2d..26985ab 100644
--- a/dubbo-admin-frontend/src/components/governance/Overrides.vue
+++ b/dubbo-admin-frontend/src/components/governance/Overrides.vue
@@ -115,6 +115,7 @@
       dialog: false,
       warn: false,
       application: '',
+      updateId: '',
       service: '',
       warnTitle: '',
       warnText: '',
@@ -159,18 +160,22 @@
         this.search(this.filter, true)
       },
       search: function (filter, rewrite) {
-        AXIOS.get('/override/search?serviceName=' + filter)
-          .then(response => {
-            this.configs = response.data
-            if (rewrite) {
-              this.$router.push({path: 'config', query: {service: filter}})
-            }
-          })
+        AXIOS.get('/rules/override', {
+          params: {
+            service: filter
+          }
+        }).then(response => {
+          this.configs = response.data
+          if (rewrite) {
+            this.$router.push({path: 'config', query: {service: filter}})
+          }
+        })
       },
       closeDialog: function () {
         this.ruleText = this.template
         this.service = ''
         this.dialog = false
+        this.updateId = ''
         this.readonly = false
       },
       openDialog: function () {
@@ -187,39 +192,45 @@
         this.warn = false
       },
       saveItem: function () {
-        let override = yaml.safeLoad(this.ruleText)  // contains illegal url 
character, need encode
+        let override = yaml.safeLoad(this.ruleText)
         override.service = this.service
-        AXIOS.post('/override/create', override)
-          .then(response => {
-            if (response.data) {
-              this.search(this.service, true)
-              this.filter = this.service
-            }
+        if (this.updateId !== '') {
+          if (this.updateId === 'close') {
             this.closeDialog()
-          })
+          } else {
+            AXIOS.put('/rules/override/' + this.updateId, override)
+              .then(response => {
+                this.search(this.service, true)
+                this.filter = this.service
+              })
+          }
+        } else {
+          AXIOS.post('/rules/override', override)
+            .then(response => {
+              if (response.data) {
+                this.search(this.service, true)
+                this.filter = this.service
+              }
+              this.closeDialog()
+            })
+        }
       },
       itemOperation: function (icon, item) {
         switch (icon) {
           case 'visibility':
-            AXIOS.get('/override/detail?id=' + item.id)
+            AXIOS.get('/rules/override/' + item.id)
               .then(response => {
                 let config = response.data
-                this.service = config.service
-                delete config.service
-                this.ruleText = yaml.safeDump(config)
-                this.readonly = true
-                this.dialog = true
+                this.handleConfig(config, true)
+                this.updateId = 'close'
               })
             break
           case 'edit':
-            AXIOS.get('/override/detail?id=' + item.id)
+            AXIOS.get('/rules/override/' + item.id)
               .then(response => {
                 let config = response.data
-                this.service = config.service
-                delete config.service
-                this.ruleText = yaml.safeDump(config)
-                this.readonly = false
-                this.dialog = true
+                this.handleConfig(config, false)
+                this.updateId = item.id
               })
             break
           case 'delete':
@@ -228,13 +239,20 @@
             this.warnStatus.id = item.id
         }
       },
+      handleConfig: function (config, readonly) {
+        this.service = config.service
+        delete config.service
+        this.ruleText = yaml.safeDump(config)
+        this.readonly = readonly
+        this.dialog = true
+      },
       setHeight: function () {
         this.height = window.innerHeight * 0.5
       },
       deleteItem: function (warnStatus) {
         let id = {}
         id.id = warnStatus.id
-        AXIOS.post('/override/delete', id)
+        AXIOS.delete('/rules/override/' + id)
           .then(response => {
             this.warn = false
             this.search(this.filter, false)
diff --git a/dubbo-admin-frontend/src/components/governance/RoutingRule.vue 
b/dubbo-admin-frontend/src/components/governance/RoutingRule.vue
index 8cbbff3..5d0fedf 100644
--- a/dubbo-admin-frontend/src/components/governance/RoutingRule.vue
+++ b/dubbo-admin-frontend/src/components/governance/RoutingRule.vue
@@ -125,7 +125,7 @@
       filter: '',
       dialog: false,
       warn: false,
-      updateId: -1,
+      updateId: '',
       application: '',
       service: '',
       warnTitle: '',
@@ -218,17 +218,20 @@
         this.search(this.filter, true)
       },
       search: function (filter, rewrite) {
-        AXIOS.get('/routes/search?serviceName=' + filter)
-          .then(response => {
-            this.routingRules = response.data
-            if (rewrite) {
-              this.$router.push({path: 'routingRule', query: {service: 
filter}})
-            }
-          })
+        AXIOS.get('/rules/route/', {
+          params: {
+            service: filter
+          }
+        }).then(response => {
+          this.routingRules = response.data
+          if (rewrite) {
+            this.$router.push({path: 'routingRule', query: {service: filter}})
+          }
+        })
       },
       closeDialog: function () {
         this.ruleText = this.template
-        this.updateId = -1
+        this.updateId = ''
         this.service = ''
         this.dialog = false
         this.readonly = false
@@ -249,17 +252,21 @@
       saveItem: function () {
         let rule = yaml.safeLoad(this.ruleText)
         rule.service = this.service
-        if (this.updateId !== -1) {
-          rule.id = this.updateId
-          AXIOS.post('/routes/update', rule)
-            .then(response => {
-              if (response.data) {
-                this.search(this.service, true)
-              }
-              this.closeDialog()
-            })
+        if (this.updateId !== '') {
+          if (this.updateId === 'close') {
+            this.closeDialog()
+          } else {
+            rule.id = this.updateId
+            AXIOS.put('/rules/route/' + rule.id, rule)
+              .then(response => {
+                if (response.data) {
+                  this.search(this.service, true)
+                }
+                this.closeDialog()
+              })
+          }
         } else {
-          AXIOS.post('/routes/create', rule)
+          AXIOS.post('/rules/route/', rule)
             .then(response => {
               if (response.data) {
                 this.search(this.service, true)
@@ -272,19 +279,20 @@
       itemOperation: function (icon, item) {
         switch (icon) {
           case 'visibility':
-            AXIOS.get('/routes/detail?id=' + item.id)
+            AXIOS.get('/rules/route/' + item.id)
               .then(response => {
                 let route = response.data
-                this.handleRoute(route, true)
+                this.handleBalance(route, true)
+                this.updateId = 'close'
               })
             break
           case 'edit':
             let id = {}
             id.id = item.id
-            AXIOS.get('/routes/detail?id=' + item.id)
+            AXIOS.get('/rules/route/' + item.id)
               .then(response => {
                 let route = response.data
-                this.handleRoute(route, false)
+                this.handleBalance(route, false)
                 this.updateId = item.id
               })
             break
@@ -304,7 +312,7 @@
             this.warnStatus.id = item.id
         }
       },
-      handleRoute: function (route, readonly) {
+      handleBalance: function (route, readonly) {
         this.service = route.service
         delete route.service
         delete route.id
@@ -319,25 +327,19 @@
       },
       deleteItem: function (warnStatus) {
         if (warnStatus.operation === 'delete') {
-          let id = {}
-          id.id = warnStatus.id
-          AXIOS.post('/routes/delete', id)
+          AXIOS.delete('/rules/route/' + warnStatus.id)
             .then(response => {
               this.warn = false
               this.search(this.filter, false)
             })
         } else if (warnStatus.operation === 'disable') {
-          let id = {}
-          id.id = warnStatus.id
-          AXIOS.post('/routes/disable', id)
+          AXIOS.put('/rules/route/disable/' + warnStatus.id)
             .then(response => {
               this.warn = false
               this.search(this.filter, false)
             })
         } else if (warnStatus.operation === 'enable') {
-          let id = {}
-          id.id = warnStatus.id
-          AXIOS.post('/routes/enable', id)
+          AXIOS.put('/rules/route/enable/' + warnStatus.id)
             .then(response => {
               this.warn = false
               this.search(this.filter, false)
diff --git a/dubbo-admin-frontend/src/components/governance/WeightAdjust.vue 
b/dubbo-admin-frontend/src/components/governance/WeightAdjust.vue
index 80fcad2..8ae0f16 100644
--- a/dubbo-admin-frontend/src/components/governance/WeightAdjust.vue
+++ b/dubbo-admin-frontend/src/components/governance/WeightAdjust.vue
@@ -119,6 +119,7 @@
       dialog: false,
       warn: false,
       application: '',
+      updateId: '',
       service: '',
       warnTitle: '',
       warnText: '',
@@ -162,13 +163,16 @@
         this.search(this.filter, true)
       },
       search: function (filter, rewrite) {
-        AXIOS.get('/weight/search?serviceName=' + filter)
-            .then(response => {
-              this.weights = response.data
-              if (rewrite) {
-                this.$router.push({path: 'weight', query: {service: filter}})
-              }
-            })
+        AXIOS.get('/rules/weight/', {
+          params: {
+            service: filter
+          }
+        }).then(response => {
+          this.weights = response.data
+          if (rewrite) {
+            this.$router.push({path: 'weight', query: {service: filter}})
+          }
+        })
       },
       closeDialog: function () {
         this.ruleText = this.template
@@ -192,35 +196,43 @@
       saveItem: function () {
         let weight = yaml.safeLoad(this.ruleText)
         weight.service = this.service
-        AXIOS.post('/weight/create', weight)
-          .then(response => {
-            this.search(this.service, true)
-            this.filter = this.service
+        if (this.updateId !== '') {
+          if (this.updateId === 'close') {
             this.closeDialog()
-          })
+          } else {
+            weight.id = this.updateId
+            AXIOS.put('/rules/weight/' + weight.id, weight)
+              .then(response => {
+                this.search(this.service, true)
+                this.filter = this.service
+                this.closeDialog()
+              })
+          }
+        } else {
+          AXIOS.post('/rules/weight', weight)
+            .then(response => {
+              this.search(this.service, true)
+              this.filter = this.service
+              this.closeDialog()
+            })
+        }
       },
       itemOperation: function (icon, item) {
         switch (icon) {
           case 'visibility':
-            AXIOS.get('/weight/detail?id=' + item.id)
+            AXIOS.get('/rules/weight/' + item.id)
                 .then(response => {
                   let weight = response.data
-                  this.service = weight.service
-                  delete weight.service
-                  this.ruleText = yaml.safeDump(weight)
-                  this.readonly = true
-                  this.dialog = true
+                  this.handleWeight(weight, true)
+                  this.updateId = 'close'
                 })
             break
           case 'edit':
-            AXIOS.get('/weight/detail?id=' + item.id)
+            AXIOS.get('/rules/weight/' + item.id)
                 .then(response => {
                   let weight = response.data
-                  this.service = weight.service
-                  delete weight.service
-                  this.ruleText = yaml.safeDump(weight)
-                  this.readonly = false
-                  this.dialog = true
+                  this.handleWeight(weight, false)
+                  this.updateId = item.id
                 })
             break
           case 'delete':
@@ -229,13 +241,18 @@
             this.warnStatus.id = item.id
         }
       },
+      handleWeight: function (weight, readonly) {
+        this.service = weight.service
+        delete weight.service
+        this.ruleText = yaml.safeDump(weight)
+        this.readonly = readonly
+        this.dialog = true
+      },
       setHeight: function () {
         this.height = window.innerHeight * 0.5
       },
       deleteItem: function (warnStatus) {
-        let id = {}
-        id.id = warnStatus.id
-        AXIOS.post('/weight/delete', id)
+        AXIOS.delete('/rules/weight/' + warnStatus.id)
           .then(response => {
             this.warn = false
             this.search(this.filter, false)

Reply via email to