plugin.go 862 字节
Newer Older
Y
Your Name 已提交
1
package daoplugin
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
//GetAll 获取所有插件
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
func GetAll() (map[string]*entity.PluginInfo, error) {

	const sql = "SELECT P.`pluginName`,P.`pluginPriority`,IFNULL(P.`pluginConfig`,''),P.`isStop`,P.`pluginType` FROM `goku_plugin` P WHERE P.`isCheck` = TRUE AND P.`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()

	plugins := make(map[string]*entity.PluginInfo)
	for rows.Next() {
		p := new(entity.PluginInfo)
		err := rows.Scan(&p.Name, &p.Priority, &p.Config, &p.IsStop, &p.Type)
		if err != nil {
			continue
		}
		plugins[p.Name] = p
	}
	return plugins, nil

}