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

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

Y
Your Name 已提交
9
//GetPluginInfo 获取插件配置信息
E
eoLinker API Management 已提交
10
func GetPluginInfo(pluginName string) (bool, *entity.Plugin, error) {
Y
Your Name 已提交
11
	return consolemysql.GetPluginInfo(pluginName)
E
eoLinker API Management 已提交
12 13
}

Y
Your Name 已提交
14
//GetPluginList 获取插件列表
E
eoLinker API Management 已提交
15
func GetPluginList(keyword string, condition int) (bool, []*entity.Plugin, error) {
Y
Your Name 已提交
16
	return consolemysql.GetPluginList(keyword, condition)
E
eoLinker API Management 已提交
17 18
}

Y
Your Name 已提交
19
//AddPlugin 新增插件信息
E
eoLinker API Management 已提交
20
func AddPlugin(pluginName, pluginConfig, pluginDesc, version string, pluginPriority, isStop, pluginType int) (bool, string, error) {
Y
Your Name 已提交
21
	return consolemysql.AddPlugin(pluginName, pluginConfig, pluginDesc, version, pluginPriority, isStop, pluginType)
E
eoLinker API Management 已提交
22 23
}

Y
Your Name 已提交
24
//EditPlugin 修改插件信息
E
eoLinker API Management 已提交
25
func EditPlugin(pluginName, pluginConfig, pluginDesc, version string, pluginPriority, isStop, pluginType int) (bool, string, error) {
Y
Your Name 已提交
26
	return consolemysql.EditPlugin(pluginName, pluginConfig, pluginDesc, version, pluginPriority, isStop, pluginType)
E
eoLinker API Management 已提交
27 28
}

Y
Your Name 已提交
29
//DeletePlugin 删除插件信息
E
eoLinker API Management 已提交
30
func DeletePlugin(pluginName string) (bool, string, error) {
Y
Your Name 已提交
31
	return consolemysql.DeletePlugin(pluginName)
E
eoLinker API Management 已提交
32 33
}

Y
Your Name 已提交
34
//CheckIndexIsExist 判断插件ID是否存在
E
eoLinker API Management 已提交
35
func CheckIndexIsExist(pluginName string, pluginPriority int) (bool, error) {
Y
Your Name 已提交
36
	return consolemysql.CheckIndexIsExist(pluginName, pluginPriority)
E
eoLinker API Management 已提交
37 38
}

Y
Your Name 已提交
39
//GetPluginConfig 获取插件配置及插件信息
E
eoLinker API Management 已提交
40
func GetPluginConfig(pluginName string) (bool, string, error) {
Y
Your Name 已提交
41
	return consolemysql.GetPluginConfig(pluginName)
E
eoLinker API Management 已提交
42 43
}

Y
Your Name 已提交
44
//CheckNameIsExist 检查插件名称是否存在
E
eoLinker API Management 已提交
45
func CheckNameIsExist(pluginName string) (bool, error) {
Y
Your Name 已提交
46
	return consolemysql.CheckNameIsExist(pluginName)
E
eoLinker API Management 已提交
47 48
}

Y
Your Name 已提交
49
//EditPluginStatus 修改插件开启状态
E
eoLinker API Management 已提交
50 51
func EditPluginStatus(pluginName string, pluginStatus int) (bool, error) {
	tableName := "goku_plugin"
Y
Your Name 已提交
52
	flag, err := consolemysql.EditPluginStatus(pluginName, pluginStatus)
E
eoLinker API Management 已提交
53 54
	if flag {
		dao.UpdateTable(tableName)
Y
Your Name 已提交
55
		consolemysql.UpdatePluginTagByPluginName(pluginName)
E
eoLinker API Management 已提交
56 57 58 59
	}
	return flag, err
}

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

Y
Your Name 已提交
65
//BatchStopPlugin 批量关闭插件
E
eoLinker API Management 已提交
66 67
func BatchStopPlugin(pluginNameList string) (bool, string, error) {
	tableName := "goku_plugin"
Y
Your Name 已提交
68
	flag, result, err := consolemysql.BatchStopPlugin(pluginNameList)
E
eoLinker API Management 已提交
69 70 71 72 73 74
	if flag {
		dao.UpdateTable(tableName)
	}
	return flag, result, err
}

Y
Your Name 已提交
75
//BatchStartPlugin 批量关闭插件
E
eoLinker API Management 已提交
76 77
func BatchStartPlugin(pluginNameList string) (bool, string, error) {
	tableName := "goku_plugin"
Y
Your Name 已提交
78
	flag, result, err := consolemysql.BatchStartPlugin(pluginNameList)
E
eoLinker API Management 已提交
79 80
	if flag {
		dao.UpdateTable(tableName)
Y
Your Name 已提交
81
		consolemysql.UpdatePluginTagByPluginName(pluginNameList)
E
eoLinker API Management 已提交
82 83 84 85
	}
	return flag, result, err
}

Y
Your Name 已提交
86
//EditPluginCheckStatus 更新插件检测状态
E
eoLinker API Management 已提交
87
func EditPluginCheckStatus(pluginName string, isCheck int) (bool, string, error) {
Y
Your Name 已提交
88
	return consolemysql.EditPluginCheckStatus(pluginName, isCheck)
E
eoLinker API Management 已提交
89
}