delete.go 1.5 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5 6
package balance

import (
	"net/http"
	"strings"

黄孟柱 已提交
7 8
	"github.com/eolinker/goku-api-gateway/console/controller"
	"github.com/eolinker/goku-api-gateway/console/module/balance"
E
eoLinker API Management 已提交
9 10
)

Y
Your Name 已提交
11
//DeleteBalance 删除负载配置
E
eoLinker API Management 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
func DeleteBalance(httpResponse http.ResponseWriter, httpRequest *http.Request) {
	_, e := controller.CheckLogin(httpResponse, httpRequest, controller.OperationLoadBalance, controller.OperationEDIT)
	if e != nil {
		return
	}

	if err := httpRequest.ParseForm(); err != nil {
		controller.WriteError(httpResponse, "260000", "data", "[param_check] Parse form body error | 解析form表单参数错误", err)
		return
	}
	balanceName := httpRequest.PostFormValue("balanceName")

	restlt, err := balance.Delete(balanceName)
	if err != nil {

		controller.WriteError(httpResponse, "260000", "balance", restlt, err)
		return

	}

	controller.WriteResultInfo(httpResponse, "balance", "", nil)

	return
}

Y
Your Name 已提交
37
//BatchDeleteBalance 批量删除负载
E
eoLinker API Management 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
func BatchDeleteBalance(httpResponse http.ResponseWriter, httpRequest *http.Request) {

	_, e := controller.CheckLogin(httpResponse, httpRequest, controller.OperationLoadBalance, controller.OperationEDIT)
	if e != nil {
		return
	}
	balanceNames := httpRequest.PostFormValue("balanceNames")
	result, err := balance.BatchDeleteBalance(strings.Split(balanceNames, ","))
	if err != nil {
		controller.WriteError(httpResponse, "260000,", "balance", result, err)
		return
	}

	controller.WriteResultInfo(httpResponse, "balance", "", nil)

	return
}