nic-chen commented on a change in pull request #1606:
URL: https://github.com/apache/apisix-dashboard/pull/1606#discussion_r595895070
##########
File path: api/internal/handler/route/route.go
##########
@@ -489,12 +503,32 @@ func (h *Handler) Update(c droplet.Context) (interface{},
error) {
}
}
- ret, err := h.routeStore.Update(c.Context(), &input.Route, true)
+ // check name existed
+ ret, err := h.routeStore.List(c.Context(), store.ListInput{
Review comment:
updated. thanks.
##########
File path: api/internal/handler/route/route.go
##########
@@ -379,12 +380,25 @@ func (h *Handler) Create(c droplet.Context) (interface{},
error) {
}
}
- ret, err := h.routeStore.Create(c.Context(), input)
+ // check name existed
+ ret, err := h.routeStore.List(c.Context(), store.ListInput{
+ Predicate: func(obj interface{}) bool {
+ return obj.(*entity.Route).Name == input.Name
+ },
+ })
+ if err != nil {
+ return &data.SpecCodeResponse{StatusCode:
http.StatusInternalServerError}, err
+ }
+ if ret.TotalSize > 0 {
+ return &data.SpecCodeResponse{StatusCode:
http.StatusBadRequest}, errors.New("route name is existed")
Review comment:
fixed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]