strategy-plugin.go 1.1 KB
Newer Older
Y
Your Name 已提交
1
package daostrategy
E
eoLinker API Management 已提交
2 3

import (
黄孟柱 已提交
4 5
	"github.com/eolinker/goku-api-gateway/common/database"
	entity "github.com/eolinker/goku-api-gateway/server/entity/node-entity"
E
eoLinker API Management 已提交
6 7
)

Y
Your Name 已提交
8
// GetAllStrategyPluginList 获取策略组插件列表
E
eoLinker API Management 已提交
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
func GetAllStrategyPluginList() ([]*entity.StrategyPluginItem, error) {

	sql := "SELECT  A.`strategyID`,A.`pluginName`,A.`pluginConfig`,IFNULL(A.`updateTag`,'') FROM `goku_conn_plugin_strategy` A INNER JOIN `goku_gateway_strategy` S ON  A.`strategyID` = S.`strategyID` INNER JOIN `goku_plugin` P ON P.`isCheck` = TRUE AND P.`pluginStatus` = 1 AND A.`pluginName` = P.`pluginName` WHERE A.`pluginStatus` = 1;"

	stmt, e := database.GetConnection().Prepare(sql)
	if e != nil {
		return nil, e
	}
	defer stmt.Close()
	rows, e := stmt.Query()
	if e != nil {
		return nil, e
	}
	defer rows.Close()

	strategyList := make([]*entity.StrategyPluginItem, 0, 100)
	for rows.Next() {
		s := new(entity.StrategyPluginItem)
		err := rows.Scan(
			&s.StrategyID,
			&s.PluginName,
			&s.PluginConfig,
			&s.UpdateTag,
		)
		if err != nil {
			continue
		}
		strategyList = append(strategyList, s)
	}
	return strategyList, nil

}