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

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

Y
Your Name 已提交
7
//AddAPI 新增接口
Y
Your Name 已提交
8
func AddAPI(apiName, alias, requestURL, targetURL, requestMethod, targetMethod, isFollow, linkApis, staticResponse, responseDataType, balanceName, protocol string, projectID, groupID, timeout, retryCount, alertValve, managerID, userID, apiType int) (bool, int, error) {
Y
Your Name 已提交
9

Y
Your Name 已提交
10
	flag, result, err := apiDao.AddAPI(apiName, alias, requestURL, targetURL, requestMethod, targetMethod, isFollow, linkApis, staticResponse, responseDataType, balanceName, protocol, projectID, groupID, timeout, retryCount, alertValve, managerID, userID, apiType)
E
eoLinker API Management 已提交
11 12 13 14

	return flag, result, err
}

Y
Your Name 已提交
15
//EditAPI 新增接口
Y
Your Name 已提交
16 17
func EditAPI(apiName, alias, requestURL, targetURL, requestMethod, targetMethod, isFollow, linkApis, staticResponse, responseDataType, balanceName, protocol string, projectID, groupID, timeout, retryCount, alertValve, apiID, managerID, userID int) (bool, error) {
	flag, err := apiDao.EditAPI(apiName, alias, requestURL, targetURL, requestMethod, targetMethod, isFollow, linkApis, staticResponse, responseDataType, balanceName, protocol, projectID, groupID, timeout, retryCount, alertValve, apiID, managerID, userID)
Y
Your Name 已提交
18

E
eoLinker API Management 已提交
19 20 21
	return flag, err
}

Y
Your Name 已提交
22 23
//GetAPIInfo 获取接口信息
func GetAPIInfo(apiID int) (bool, *entity.API, error) {
Y
Your Name 已提交
24
	return apiDao.GetAPIInfo(apiID)
E
eoLinker API Management 已提交
25 26 27 28
}

// GetAPIIDList 获取接口ID列表
func GetAPIIDList(projectID int, groupID int, keyword string, condition int, ids []int) (bool, []int, error) {
Y
Your Name 已提交
29
	return apiDao.GetAPIIDList(projectID, groupID, keyword, condition, ids)
E
eoLinker API Management 已提交
30 31 32 33
}

// GetAPIList 获取接口列表
func GetAPIList(projectID int, groupID int, keyword string, condition, page, pageSize int, ids []int) (bool, []map[string]interface{}, int, error) {
Y
Your Name 已提交
34
	return apiDao.GetAPIList(projectID, groupID, keyword, condition, page, pageSize, ids)
E
eoLinker API Management 已提交
35 36
}

Y
Your Name 已提交
37
//CheckURLIsExist 接口路径是否存在
E
eoLinker API Management 已提交
38
func CheckURLIsExist(requestURL, requestMethod string, projectID, apiID int) bool {
Y
Your Name 已提交
39
	return apiDao.CheckURLIsExist(requestURL, requestMethod, projectID, apiID)
E
eoLinker API Management 已提交
40 41
}

Y
Your Name 已提交
42 43
//CheckAPIIsExist 检查接口是否存在
func CheckAPIIsExist(apiID int) (bool, error) {
Y
Your Name 已提交
44 45 46 47 48 49
	return apiDao.CheckAPIIsExist(apiID)
}

//CheckAliasIsExist 检查接口是否存在
func CheckAliasIsExist(apiID int, alias string) bool {
	return apiDao.CheckAliasIsExist(apiID, alias)
E
eoLinker API Management 已提交
50 51
}

Y
Your Name 已提交
52 53
//BatchEditAPIGroup 批量修改接口分组
func BatchEditAPIGroup(apiIDList []string, groupID int) (bool, string, error) {
Y
Your Name 已提交
54
	r, e := apiDao.BatchEditAPIGroup(apiIDList, groupID)
E
eoLinker API Management 已提交
55 56 57 58

	return e == nil, r, e
}

Y
Your Name 已提交
59 60
//BatchEditAPIBalance 批量修改接口负载
func BatchEditAPIBalance(apiIDList []string, balance string) (string, error) {
E
eoLinker API Management 已提交
61

Y
Your Name 已提交
62
	r, err := apiDao.BatchEditAPIBalance(apiIDList, balance)
Y
Your Name 已提交
63

E
eoLinker API Management 已提交
64 65 66
	return r, err
}

Y
Your Name 已提交
67 68
//BatchDeleteAPI 批量删除接口
func BatchDeleteAPI(apiIDList string) (bool, string, error) {
E
eoLinker API Management 已提交
69

Y
Your Name 已提交
70
	flag, result, err := apiDao.BatchDeleteAPI(apiIDList)
Y
Your Name 已提交
71

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