add.go 904 字节
Newer Older
E
eoLinker API Management 已提交
1 2 3 4
package dao_service

import (
	"time"
Y
Your Name 已提交
5 6

	"github.com/eolinker/goku-api-gateway/common/database"
E
eoLinker API Management 已提交
7 8
)

Y
Your Name 已提交
9
const sqlAdd = "INSERT INTO `goku_service_config`(`name`,`driver`,`default`,`desc`,`config`,`clusterConfig`,`healthCheck`,`healthCheckPath`,`healthCheckPeriod`,`healthCheckCode`,`healthCheckTimeOut`,`createTime`,`updateTime`)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?);"
E
eoLinker API Management 已提交
10

Y
Your Name 已提交
11
//Add 新增服务
Y
Your Name 已提交
12 13
func Add(name, driver, desc, config, clusterConfig string, isDefault, healthCheck bool, healthCheckPath string, healthCheckCode string, healthCheckPeriod, healthCheckTimeOut int) error {

Y
Your Name 已提交
14
	now := time.Now().Format("2006-01-02 15:04:05")
E
eoLinker API Management 已提交
15 16

	stmt, e := database.GetConnection().Prepare(sqlAdd)
Y
Your Name 已提交
17
	if e != nil {
E
eoLinker API Management 已提交
18 19
		return e
	}
20
	defer stmt.Close()
Y
Your Name 已提交
21
	_, err := stmt.Exec(name, driver, isDefault, desc, config, clusterConfig, healthCheck, healthCheckPath, healthCheckPeriod, healthCheckCode, healthCheckTimeOut, now, now)
E
eoLinker API Management 已提交
22 23
	return err
}