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

import (
Y
Your Name 已提交
4 5
	"github.com/eolinker/goku-api-gateway/common/pdao"
	"github.com/eolinker/goku-api-gateway/server/dao"
黄孟柱 已提交
6
	entity "github.com/eolinker/goku-api-gateway/server/entity/console-entity"
E
eoLinker API Management 已提交
7
)
Y
Your Name 已提交
8 9 10
var (
	pluginDao dao.PluginDao
)
E
eoLinker API Management 已提交
11

Y
Your Name 已提交
12 13 14
func init() {
	pdao.Need(&pluginDao)
}
Y
Your Name 已提交
15
//GetPluginInfo 获取插件配置信息
E
eoLinker API Management 已提交
16
func GetPluginInfo(pluginName string) (bool, *entity.Plugin, error) {
Y
Your Name 已提交
17
	return pluginDao.GetPluginInfo(pluginName)
E
eoLinker API Management 已提交
18 19
}

Y
Your Name 已提交
20
//GetPluginList 获取插件列表
E
eoLinker API Management 已提交
21
func GetPluginList(keyword string, condition int) (bool, []*entity.Plugin, error) {
Y
Your Name 已提交
22
	return pluginDao.GetPluginList(keyword, condition)
E
eoLinker API Management 已提交
23 24
}

Y
Your Name 已提交
25
//AddPlugin 新增插件信息
E
eoLinker API Management 已提交
26
func AddPlugin(pluginName, pluginConfig, pluginDesc, version string, pluginPriority, isStop, pluginType int) (bool, string, error) {
Y
Your Name 已提交
27
	return pluginDao.AddPlugin(pluginName, pluginConfig, pluginDesc, version, pluginPriority, isStop, pluginType)
E
eoLinker API Management 已提交
28 29
}

Y
Your Name 已提交
30
//EditPlugin 修改插件信息
E
eoLinker API Management 已提交
31
func EditPlugin(pluginName, pluginConfig, pluginDesc, version string, pluginPriority, isStop, pluginType int) (bool, string, error) {
Y
Your Name 已提交
32
	return pluginDao.EditPlugin(pluginName, pluginConfig, pluginDesc, version, pluginPriority, isStop, pluginType)
E
eoLinker API Management 已提交
33 34
}

Y
Your Name 已提交
35
//DeletePlugin 删除插件信息
E
eoLinker API Management 已提交
36
func DeletePlugin(pluginName string) (bool, string, error) {
Y
Your Name 已提交
37
	return pluginDao.DeletePlugin(pluginName)
E
eoLinker API Management 已提交
38 39
}

Y
Your Name 已提交
40
//CheckIndexIsExist 判断插件ID是否存在
E
eoLinker API Management 已提交
41
func CheckIndexIsExist(pluginName string, pluginPriority int) (bool, error) {
Y
Your Name 已提交
42
	return pluginDao.CheckIndexIsExist(pluginName, pluginPriority)
E
eoLinker API Management 已提交
43 44
}

Y
Your Name 已提交
45
//GetPluginConfig 获取插件配置及插件信息
E
eoLinker API Management 已提交
46
func GetPluginConfig(pluginName string) (bool, string, error) {
Y
Your Name 已提交
47
	return pluginDao.GetPluginConfig(pluginName)
E
eoLinker API Management 已提交
48 49
}

Y
Your Name 已提交
50
//CheckNameIsExist 检查插件名称是否存在
E
eoLinker API Management 已提交
51
func CheckNameIsExist(pluginName string) (bool, error) {
Y
Your Name 已提交
52
	return pluginDao.CheckNameIsExist(pluginName)
E
eoLinker API Management 已提交
53 54
}

Y
Your Name 已提交
55
//EditPluginStatus 修改插件开启状态
E
eoLinker API Management 已提交
56
func EditPluginStatus(pluginName string, pluginStatus int) (bool, error) {
Y
Your Name 已提交
57
	flag, err := pluginDao.EditPluginStatus(pluginName, pluginStatus)
Y
Your Name 已提交
58

E
eoLinker API Management 已提交
59 60 61
	return flag, err
}

Y
Your Name 已提交
62
//GetPluginListByPluginType 获取不同类型的插件列表
E
eoLinker API Management 已提交
63
func GetPluginListByPluginType(pluginType int) (bool, []map[string]interface{}, error) {
Y
Your Name 已提交
64
	return pluginDao.GetPluginListByPluginType(pluginType)
E
eoLinker API Management 已提交
65 66
}

Y
Your Name 已提交
67
//BatchStopPlugin 批量关闭插件
E
eoLinker API Management 已提交
68
func BatchStopPlugin(pluginNameList string) (bool, string, error) {
Y
Your Name 已提交
69
	flag, result, err := pluginDao.BatchStopPlugin(pluginNameList)
Y
Your Name 已提交
70

E
eoLinker API Management 已提交
71 72 73
	return flag, result, err
}

Y
Your Name 已提交
74
//BatchStartPlugin 批量关闭插件
E
eoLinker API Management 已提交
75
func BatchStartPlugin(pluginNameList string) (bool, string, error) {
Y
Your Name 已提交
76
	flag, result, err := pluginDao.BatchStartPlugin(pluginNameList)
Y
Your Name 已提交
77

E
eoLinker API Management 已提交
78 79 80
	return flag, result, err
}

Y
Your Name 已提交
81
//EditPluginCheckStatus 更新插件检测状态
E
eoLinker API Management 已提交
82
func EditPluginCheckStatus(pluginName string, isCheck int) (bool, string, error) {
Y
Your Name 已提交
83
	return pluginDao.EditPluginCheckStatus(pluginName, isCheck)
E
eoLinker API Management 已提交
84
}