strategy-api.go 872 字节
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 9
//GetAllStrategyAPI 获取所有策略接口列表
func GetAllStrategyAPI() ([]*entity.StrategyAPI, error) {
E
eoLinker API Management 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23

	const sql = "SELECT A.`strategyID`,A.`apiID`,IFNULL(A.`target`,'') FROM `goku_conn_strategy_api` A  JOIN `goku_gateway_strategy` B ON A.`strategyID` = B.`strategyID` ;"

	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()

Y
Your Name 已提交
24
	apis := make([]*entity.StrategyAPI, 0, 1000)
E
eoLinker API Management 已提交
25 26

	for rows.Next() {
Y
Your Name 已提交
27 28
		api := new(entity.StrategyAPI)
		err := rows.Scan(&api.StrategyID, &api.APIID, &api.Target)
E
eoLinker API Management 已提交
29 30 31 32 33 34 35 36
		if err != nil {
			continue
		}
		apis = append(apis, api)
	}
	return apis, nil

}