in api/internal/handler/plugin_config/plugin_config.go [195:228]
func (h *Handler) BatchDelete(c droplet.Context) (interface{}, error) {
input := c.Input().(*BatchDelete)
IDs := strings.Split(input.IDs, ",")
IDMap := map[string]bool{}
for _, id := range IDs {
IDMap[id] = true
}
ret, err := h.routeStore.List(c.Context(), store.ListInput{
Predicate: func(obj interface{}) bool {
id := utils.InterfaceToString(obj.(*entity.Route).PluginConfigID)
if _, ok := IDMap[id]; ok {
return true
}
return false
},
})
if err != nil {
return nil, err
}
if len(ret.Rows) > 0 {
return &data.SpecCodeResponse{StatusCode: http.StatusBadRequest},
fmt.Errorf("please disconnect the route (ID: %s) with this plugin config first",
ret.Rows[0].(*entity.Route).ID)
}
if err := h.pluginConfigStore.BatchDelete(c.Context(), strings.Split(input.IDs, ",")); err != nil {
return handler.SpecCodeResponse(err), err
}
return nil, nil
}