strategyGroup.go 1.3 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5
package strategy

import (
	"errors"

黄孟柱 已提交
6 7
	"github.com/eolinker/goku-api-gateway/server/dao"
	console_mysql "github.com/eolinker/goku-api-gateway/server/dao/console-mysql"
E
eoLinker API Management 已提交
8 9 10 11 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 37 38 39 40 41 42 43 44 45
)

// 新建策略组分组
func AddStrategyGroup(groupName string) (bool, interface{}, error) {
	return console_mysql.AddStrategyGroup(groupName)
}

// 修改策略组分组
func EditStrategyGroup(groupName string, groupID int) (bool, string, error) {
	return console_mysql.EditStrategyGroup(groupName, groupID)
}

// DeleteStrategyGroup 删除策略组分组
func DeleteStrategyGroup(groupID int) (bool, string, error) {
	flag := console_mysql.CheckIsOpenGroup(groupID)
	if flag {
		return false, "[ERROR]The group is an open group", errors.New("[ERROR]The group is an open group")
	} else {
		flag, result, err := console_mysql.DeleteStrategyGroup(groupID)
		if flag {
			dao.UpdateTable("goku_gateway_strategy")
			dao.UpdateTable("goku_gateway_api")
			dao.UpdateTable("goku_conn_strategy_api")
			dao.UpdateTable("goku_conn_plugin_strategy")
			dao.UpdateTable("goku_conn_plugin_api")
		}
		return flag, result, err
	}
}

// 获取策略组分组列表
func GetStrategyGroupList() (bool, []map[string]interface{}, error) {
	return console_mysql.GetStrategyGroupList()
}

func CheckIsOpenGroup(groupID int) bool {
	return console_mysql.CheckIsOpenGroup(groupID)
}