strategyGroup.go 1.4 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
)

Y
Your Name 已提交
10
//AddStrategyGroup 新建策略组分组
E
eoLinker API Management 已提交
11 12 13 14
func AddStrategyGroup(groupName string) (bool, interface{}, error) {
	return console_mysql.AddStrategyGroup(groupName)
}

Y
Your Name 已提交
15
//EditStrategyGroup 修改策略组分组
E
eoLinker API Management 已提交
16 17 18 19 20 21 22 23 24 25
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")
	}
Y
Your Name 已提交
26 27 28 29 30 31 32 33 34
	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
E
eoLinker API Management 已提交
35 36
}

Y
Your Name 已提交
37
//GetStrategyGroupList 获取策略组分组列表
E
eoLinker API Management 已提交
38 39 40 41
func GetStrategyGroupList() (bool, []map[string]interface{}, error) {
	return console_mysql.GetStrategyGroupList()
}

Y
Your Name 已提交
42
//CheckIsOpenGroup 判断是否是开放分组
E
eoLinker API Management 已提交
43 44 45
func CheckIsOpenGroup(groupID int) bool {
	return console_mysql.CheckIsOpenGroup(groupID)
}