apiStrategy.go 2.8 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3
package api

import (
黄孟柱 已提交
4 5
	"github.com/eolinker/goku-api-gateway/server/dao"
	console_mysql "github.com/eolinker/goku-api-gateway/server/dao/console-mysql"
E
eoLinker API Management 已提交
6 7
)

Y
Your Name 已提交
8 9
//AddAPIToStrategy 将接口加入策略组
func AddAPIToStrategy(apiList []string, strategyID string) (bool, string, error) {
E
eoLinker API Management 已提交
10
	name := "goku_conn_strategy_api"
Y
Your Name 已提交
11
	flag, result, err := console_mysql.AddAPIToStrategy(apiList, strategyID)
E
eoLinker API Management 已提交
12 13 14 15 16 17
	if flag {
		dao.UpdateTable(name)
	}
	return flag, result, err
}

Y
Your Name 已提交
18 19
//SetTarget 重置目标地址
func SetTarget(apiID int, strategyID string, target string) (bool, string, error) {
E
eoLinker API Management 已提交
20
	name := "goku_conn_strategy_api"
Y
Your Name 已提交
21
	flag, result, err := console_mysql.SetAPITargetOfStrategy(apiID, strategyID, target)
E
eoLinker API Management 已提交
22 23 24 25 26 27 28 29 30
	if flag {
		dao.UpdateTable(name)
	}
	return flag, result, err
}

// BatchSetTarget 批量重置目标地址
func BatchSetTarget(apiIds []int, strategyID string, target string) (bool, string, error) {
	name := "goku_conn_strategy_api"
Y
Your Name 已提交
31
	flag, result, err := console_mysql.BatchSetAPITargetOfStrategy(apiIds, strategyID, target)
E
eoLinker API Management 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
	if flag {
		dao.UpdateTable(name)
	}
	return flag, result, err
}

// GetAPIIDListFromStrategy 获取策略组接口ID列表
func GetAPIIDListFromStrategy(strategyID, keyword string, condition int, ids []int, balanceNames []string) (bool, []int, error) {
	return console_mysql.GetAPIIDListFromStrategy(strategyID, keyword, condition, ids, balanceNames)
}

// GetAPIListFromStrategy 获取策略组接口列表
func GetAPIListFromStrategy(strategyID, keyword string, condition, page, pageSize int, ids []int, balanceNames []string) (bool, []map[string]interface{}, int, error) {
	return console_mysql.GetAPIListFromStrategy(strategyID, keyword, condition, page, pageSize, ids, balanceNames)
}

Y
Your Name 已提交
48 49 50
//CheckIsExistAPIInStrategy 检查插件是否添加进策略组
func CheckIsExistAPIInStrategy(apiID int, strategyID string) (bool, string, error) {
	return console_mysql.CheckIsExistAPIInStrategy(apiID, strategyID)
E
eoLinker API Management 已提交
51 52
}

Y
Your Name 已提交
53
// GetAPIIDListNotInStrategy 获取未被该策略组绑定的接口ID列表(通过项目)
E
eoLinker API Management 已提交
54 55 56 57 58 59 60 61 62
func GetAPIIDListNotInStrategy(strategyID string, projectID, groupID int, keyword string) (bool, []int, error) {
	return console_mysql.GetAPIIDListNotInStrategy(strategyID, projectID, groupID, keyword)
}

// GetAPIListNotInStrategy 获取未被该策略组绑定的接口列表(通过项目)
func GetAPIListNotInStrategy(strategyID string, projectID, groupID, page, pageSize int, keyword string) (bool, []map[string]interface{}, int, error) {
	return console_mysql.GetAPIListNotInStrategy(strategyID, projectID, groupID, page, pageSize, keyword)
}

Y
Your Name 已提交
63 64
//BatchDeleteAPIInStrategy 批量删除策略组接口
func BatchDeleteAPIInStrategy(apiIDList, strategyID string) (bool, string, error) {
E
eoLinker API Management 已提交
65
	name := "goku_conn_strategy_api"
Y
Your Name 已提交
66
	flag, result, err := console_mysql.BatchDeleteAPIInStrategy(apiIDList, strategyID)
E
eoLinker API Management 已提交
67 68 69 70 71
	if flag {
		dao.UpdateTable(name)
	}
	return flag, result, err
}